Skip to content

Commit

Permalink
Merge pull request #32 from Joe7M/master
Browse files Browse the repository at this point in the history
Syntax highlight for nano and tutorial for sbasicw
  • Loading branch information
chrisws authored Jun 29, 2024
2 parents 385533f + 6f1ef4c commit 80d88d3
Show file tree
Hide file tree
Showing 8 changed files with 113 additions and 8 deletions.
1 change: 1 addition & 0 deletions _build/pages/articles.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
- [FLTK](/pages/fltk.html)
- [Setup external editors](/pages/language_support.html)
- [Distribute your program](/pages/distributiontool.html)
- [SmallBASIC web server](/pages/sbasicw.html)

## Plugins

Expand Down
8 changes: 5 additions & 3 deletions _build/pages/language_support.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ The SDL and FLTK versions of SmallBASIC come with an integrated editor. If you a
Contents
:::

#. [Visual Studio Code](/pages/language_support_vscode.html)

#. [Atom](/pages/language_support_atom.html)
#. [Geany](/pages/language_support_geany.html)
#. [Sublime Text](/pages/language_support_sublimetext.html)
#. [KDE Kate](/pages/language_support_kdekate.html)
#. [jEdit](/pages/language_support_jedit.html)
#. [KDE Kate](/pages/language_support_kdekate.html)
#. [Micro](/pages/language_support_micro.html)
#. [nano](/pages/language_support_nano.html)
#. [Sublime Text](/pages/language_support_sublimetext.html)
#. [Visual Studio Code](/pages/language_support_vscode.html)
:::
38 changes: 38 additions & 0 deletions _build/pages/language_support_nano.markdown
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# SmallBASIC in nano

> Using nano
_"GNU nano is a text editor for Unix-like computing systems or operating environments using a command line interface. " ([Wikipedia](https://en.wikipedia.org/wiki/GNU_nano))_


![Example](https://raw.githubusercontent.com/Joe7M/smallbasic.nano.syntaxcoloring/main/screenshot.png)

## Installation

- Download the file `smallbasic.nanorc` from [github](https://github.com/Joe7M/smallbasic.nano.syntaxcoloring)
- Create the folder `~/.config/nano/syntax`
- Copy the file "smallbasic.nanorc" into that folder
- Edit the nano configuration file -> `nano ~/.config/nano/nanorc`
- In the section `## === Syntax coloring ===` add `include "~/.config/nano/syntax/*.nanorc"`

## Tweaking nano

Depending on your Linux distribution the default nano settings are a little bit disappointing.
But fortunately you can tweak nano quite a bit by activating some settings in `nanorc`.
Just remove the comments for:

1. `set autoindent`
2. `set indicator`
3. `set linenumbers`
4. `set minibar`
5. `set mouse`
6. Remove the comments in the section `### Paint the interface elements of nano` to make nano colorful.
7. `include "/usr/share/nano/*.nanorc"`
8. To get more common keyboard shortcuts like CTRL+C for copy uncomment all the commands in the section
`## If you would like nano to have keybindings that are more "usual"`

## A useful hint

If you use nano in a console you can suspend it by pressing `CTRL-Z`. After pressing `CTRL-Z` you are on the
console and you can i.e. start the console version of SmallBASIC to test your program. After testing
you can switch back to the suspended nano by executing the command `fg` in the console.
2 changes: 1 addition & 1 deletion _build/pages/plugins_raylib.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ A simple SmallBASIC version is available at [Github](https://github.com/smallbas
The raylib plugin is included in the release version of SmallBASIC. SmallBASIC should find the plugin automatically.
If you have problems loading the plugin, you can copy the library (libraylib.dll or libraylib.so) to the folder of your BASIC file.
Additionally you need the file [raylibc.bas](https://github.com/smallbasic/smallbasic.plugins/blob/master/raylib/samples/raylibc.bas).
If it is not found automatically, please copy it the folder of your BASIC file, too.
If it is not found automatically, please copy it to the folder of your BASIC file, too.
You have also the option to give the full path to the plugin or to raylibc.bas with the `ìmport` command.

Since raylib uses its own window management, you cannot use it together with the SDL version of SmallBASIC (sbasicg.exe or sbasicg).
Expand Down
64 changes: 64 additions & 0 deletions _build/pages/sbasicw.markdown
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
SBASICW
=======

> `sbasicw` is a web server which can display the output of a SmallBASIC program in a browser.
> It can also be used to dynamically generate websites using SmallBASIC commands.
## Getting started

### Render to canvas

Launch `sbasicw` (Linux) or `sbasicw.exe` (Windows) in a folder containing the files of your website.
It is quite helpful, if `sbasicw` is in the search path. After you started the web server you can open in
your browser the URL `http://127.0.0.1:8080`. This will display the file `index.html`. You can also load
`http://127.0.0.1:8080/myprogram.bas`. This will execute the SmallBASIC file `myprogram.bas`. The output
(graphics and text) will be rendered to an HTML5 canvas and displayed as a bitmap in your browser. Only a
snapshot of the output is displayed i.e., you would only see one frame of an animation in your web browser.

### HTML text output

Launch the web server in a folder containing the files of your website with the following command:

```
sbasicw --graphic-text="0"
```

If you call a SmallBASIC file, graphics output will still be rendered to an HTML5 canvas. But output of
the `print` command is interpreted as text by the browser. You can print HTML and even Java script commands.

## Transfer data

`sbasicw` supports sending data using the get method. To send variables to a SmallBASIC program add `?var1=value1&var2=value2...&varN=valueN` to the URL of the website. You can then read the values of the
variables using the `env()` function, for example `v = env("var1")`.

## Tutorial

[sbasicw_tutorial.zip](/assets/sbasicw_tutorial.zip) contains several HTML and SmallBASIC files. To start the
tutorial extract the files to a folder of your choice and launch the web sever in this folder with:

```
Linux: sbasicw --graphic-text="0"
Windows: sbasicw.exe --graphic-text="0"
```

Open a browser and start the tutorial with `http://127.0.0.1:8080`. You will learn how to link between HTML
files, dynamically generate HTML files using SmallBASIC, create forms, process the input of the forms and
draw graphics to an HTML canvas.

![Page 7 of the tutorial](/images/sbasicw_screenshot.png)

## Run the web server in the background

If you want to start the web server in the background, use the following command:

```
sbasicw &
sbasicw --graphic-text="0" &
```

If an error message like `[1] + suspended (tty input) sbasicw` is displayed, then start the server with:

```
sbasicw < /dev/null &
sbasicw --graphic-text="0" < /dev/null &
```
8 changes: 4 additions & 4 deletions _build/reference/621-graphics-pset.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
> PSET [STEP] x,y [, color| COLOR color]
Draws a pixel at coordinate `x`,`y` with color `color`. If `color` is not defined, the current foreground color will be used.
If STEP is used, the graphics cursor will be moved by `x` pixels in x-direction and `y` pixel in y-direction and then the pixel
If `STEP` is used, the graphics cursor will be moved by `x` pixels in x-direction and `y` pixel in y-direction and then the pixel
will be drawn.

### Example:

```
color 10 ' Set foreground color 10
PSET 50,50 ' Point at 50,50 with foreground color
PSET 60,60, 11 ' Point at 60,60 with color 5
PSET 70,70 COLOR 12 ' Point at 70,70 with color 6
PSET 60,60, 11 ' Point at 60,60 with color 11
PSET 70,70 COLOR 12 ' Point at 70,70 with color 12
PSET 80,80, rgb(255,255,0) ' Point at 80,80 with color yellow
PSET STEP 10,10 COLOR 13 ' Point at 90,90 with color 7
PSET STEP 10,10 COLOR 13 ' Point at 90,90 with color 13
```
Binary file added assets/sbasicw_tutorial.zip
Binary file not shown.
Binary file added images/sbasicw_screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 80d88d3

Please sign in to comment.