Skip to content

Commit

Permalink
Merge pull request nagydani#48 from aldum/sprint_13
Browse files Browse the repository at this point in the history
Sprint 13 accepted.
  • Loading branch information
nagydani authored Oct 16, 2024
2 parents 0402ed1 + b8a8d76 commit adfc76b
Show file tree
Hide file tree
Showing 100 changed files with 7,098 additions and 1,649 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
- uses: jkl1337/gh-actions-lua@v11
with:
# luaVersion: "5.3"
luaVersion: "luajit-2.1.0-beta3"
luaVersion: "luajit-git"
- uses: jkl1337/gh-actions-luarocks@v5
with:
luarocksVersion: "3.9.2"
Expand Down Expand Up @@ -143,7 +143,7 @@ jobs:
VER: ${{ github.ref_name }}
run: echo VER_CODE="$(echo $VERSION | sed -e 's/^v//' -e 's/\.//g')" >> $GITHUB_ENV
- name: Package for android
uses: aldum/[email protected]
uses: compy-toys/[email protected]
with:
love-ref: "loveputer"
no-soft-keyboard: "enabled"
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
/.luarocks
.history
dist/*
doc/*.md
.debug/*
doc/scratch/
doc/parse
*.lua_
*.odg#
Expand Down
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[submodule "src/lib/metalua"]
path = src/lib/metalua
url = https://github.com/aldum/metalua.git
url = https://github.com/compy-toys/metalua.git
5 changes: 4 additions & 1 deletion .luarc.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,12 @@
// project env
"input_text",
"input_code",
"validated_input",
"stop",
"continue",
"font1",
// luautils
"prequire",
// end of array
""
],
"workspace.library": [
Expand Down
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@
"color": "#555",
}
],
"reflowMarkdown.preferredLineLength" : 64,
}
91 changes: 72 additions & 19 deletions DEVELOPMENT.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
## Development
## Installing

To run the code, [LÖVE2D] is required. It's been tested and developed on version 11.4 (Mysterious Mysteries).
To run the code, [LÖVE2D] is required. It's been tested and
developed on version 11.4 (Mysterious Mysteries).

For unit tests, we are using the [busted] framework.
Also, we need to supplement a utf-8 library, which comes with LOVE, but
is not available for Lua 5.1 by default.
For unit tests, we are using the [busted] framework. Also, we
need to supply a [utf-8][luautf8] library, one of which comes
with LOVE, but is not available for Lua 5.1 / Luajit by default.

The recommended way of installing these is with [LuaRocks]:

Expand All @@ -13,44 +14,96 @@ luarocks --local --lua-version 5.1 install busted
luarocks --local --lua-version 5.1 install luautf8
```

For information about installing [LÖVE2D] and [LuaRocks], visit their respective webpages.
For information about installing [LÖVE2D] and [LuaRocks], visit
their respective webpages.

## Development

### Running unit tests
### [OOP](doc/development/OOP.md)

```sh
busted tests
### `util/lua.lua` (luautils)

The contents of this module will be put into the global
namespace (`_G`). However, the language server does not pick up
on this (yet), so usages will be littered with warnings unless
silenced.

#### `prequire()`

Analogous to `pcall()`, require a lua file that may or may not
exist. Example:

```lua
--- @diagnostic disable-next-line undefined-global
local autotest = prequire('tests/autotest')
if autotest then
autotest(self)
end
```

### Test mode
## Testing

### Test modes

The game can be run with the `--test` flag, which causes it to launch in test mode.
#### normal

The game can be run with the `--test` flag, which causes it to launch in test
mode.

```sh
love src --test
```

This is currently used for testing the canvas terminal, therefore it causes the terminal to be smaller (so overflows are clearly visible), and pre-fills it with characters.
This is currently used for testing the canvas terminal, therefore it causes the
terminal to be smaller (so overflows are clearly visible), and pre-fills it with
characters.

#### autotest

```sh
love src --autotest
```

#### drawtest

```sh
love src --drawtest
```

### Running unit tests

In project root:

```sh
busted tests
```

## Environment variables

### Debug mode

Certain diagnostic key combinations are only available in debug mode,
to access this, run the project with the `DEBUG` environment variable set
(it's value doesn't matter, just that it's set):
Certain diagnostic key combinations are only available in debug
mode, to access this, run the project with the `DEBUG`
environment variable set (it's value doesn't matter, just that
it's set):

```sh
DEBUG=1 love src
```

In this mode, a VT-100 terminal test can be activated with ^T (C-t, or Ctrl+t).
In this mode, a VT-100 terminal test can be activated with ^T
(C-t, or Ctrl+t).

### HiDPI

Similarly, to set double scaling, set the `HIDPI` variable to `true`
Similarly, to set double scaling, set the `HIDPI` variable to
`true`:

```sh
HIDPI=true love src
```


[löve2d]: https://love2d.org
[busted]: https://lunarmodules.github.io/busted/
[LuaRocks]: https://luarocks.org/
[luautf8]: https://github.com/starwing/luautf8
[luarocks]: https://luarocks.org/
142 changes: 77 additions & 65 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
# loveputer

A console-based Lua-programmable computer for children based on [LÖVE2D] framework.

## Principles
* Command-line based UI
* Full control over each pixel of the display
* Ability to easily reset to initial state
* Impossible to damage with non-violent interaction
* Syntactic mistakes caught early, not accepted on input
* Possibility to test/try parts of program separately
* Share software in source package form
* Minimize frustration

- Command-line based UI
- Full control over each pixel of the display
- Ability to easily reset to initial state
- Impossible to damage with non-violent interaction
- Syntactic mistakes caught early, not accepted on input
- Possibility to test/try parts of program separately
- Share software in source package form
- Minimize frustration

# Usage

Rather than the default LÖVE storage locations (save directory, cache, etc), the
application uses a folder under *Documents* to store projects. Ideally, this is
application uses a folder under _Documents_ to store projects. Ideally, this is
located on removable storage to enable sharing programs the user writes.

For simplicity and security reasons, the user is only allowed to access files
Expand All @@ -23,92 +25,102 @@ first.

## Keys

| Command | Keymap |
| :--------------------------------- | :-------------------------------------------- |
| Clear terminal | <kbd>Ctrl</kbd>+<kbd>L</kbd> |
| Quit project | <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>Q</kbd> |
| Reset application to initial state | <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>R</kbd> |
| Exit application | <kbd>Ctrl</kbd>+<kbd>Esc</kbd> |
| **Input** |
| Move cursor | <kbd>⇦</kbd><kbd>⇧</kbd><kbd>⇨</kbd><kbd>⇩</kbd> |
| Go back in command history | <kbd>PageUp</kbd> |
| Go forward in command history | <kbd>PageDown</kbd> |
| Move in history (if in first/last line) | <kbd>⇧</kbd><kbd>⇩</kbd> |
| Jump to start | <kbd>Home</kbd> |
| Jump to end | <kbd>End</kbd> |
| Insert newline | <kbd>Shift</kbd>+<kbd>Enter</kbd> |
| Evaluate input | <kbd>Enter</kbd> |
| **Editor** |
| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; _same as Input, except for:_ |
| Scroll up | <kbd>PageUp</kbd> |
| Scroll down | <kbd>PageDown</kbd> |
| Move selection (if in first/last line) | <kbd>⇧</kbd><kbd>⇩</kbd> |
| Replace selection with input | <kbd>Enter</kbd> |
| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; _additionally_ |
| Delete selected (line) | <kbd>Ctrl</kbd>+<kbd>Delete</kbd> |
| | <kbd>Ctrl</kbd>+<kbd>Y</kbd> |
| Replace input with selected content | <kbd>Esc</kbd> |
| Insert selected content into input | <kbd>Shift</kbd>+<kbd>Esc</kbd> |
| Scroll to start | <kbd>Ctrl</kbd>+<kbd>PageUp</kbd> |
| Scroll to end | <kbd>Ctrl</kbd>+<kbd>PageDown</kbd> |
| Move selection to start | <kbd>Ctrl</kbd>+<kbd>Home</kbd> |
| Move selecion to end | <kbd>Ctrl</kbd>+<kbd>End</kbd> |
| Quit editor (save work) | <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>Q</kbd> |
| Command | Keymap |
| :---------------------------------------------------------------- | :-------------------------------------------- |
| Clear terminal | <kbd>Ctrl</kbd>+<kbd>L</kbd> |
| Quit project | <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>Q</kbd> |
| Reset application to initial state | <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>R</kbd> |
| Exit application | <kbd>Ctrl</kbd>+<kbd>Esc</kbd> |
| Pause application | <kbd>Ctrl</kbd>+<kbd>Pause</kbd> |
| **Input** |
| Move cursor horizontally | <kbd>⇦</kbd><kbd>⇨</kbd> |
| Move cursor vertically | <kbd>⇧</kbd><kbd>⇩</kbd> |
| Go back in command history | <kbd>PageUp</kbd> |
| Go forward in command history | <kbd>PageDown</kbd> |
| Move in history (if in first/last line) | <kbd>⇧</kbd><kbd>⇩</kbd> |
| Jump to start | <kbd>Home</kbd> |
| Jump to end | <kbd>End</kbd> |
| Jump to line start | <kbd>Alt</kbd>+<kbd>Home</kbd> |
| Jump to line end | <kbd>Alt</kbd>+<kbd>End</kbd> |
| Insert newline | <kbd>Shift</kbd>+<kbd>Enter</kbd> |
| Evaluate input | <kbd>Enter</kbd> |
| **Editor** |
| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; _same as Input, except for:_ |
| Scroll up | <kbd>PageUp</kbd> |
| Scroll down | <kbd>PageDown</kbd> |
| Move selection (if in first/last line) | <kbd>⇧</kbd><kbd>⇩</kbd> |
| Replace selection with input | <kbd>Enter</kbd> |
| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; _additionally_ |
| Delete selected (line) | <kbd>Ctrl</kbd>+<kbd>Delete</kbd> |
| | <kbd>Ctrl</kbd>+<kbd>Y</kbd> |
| Replace input with selected content | <kbd>Esc</kbd> |
| Insert selected content into input | <kbd>Shift</kbd>+<kbd>Esc</kbd> |
| Scroll to start | <kbd>Ctrl</kbd>+<kbd>PageUp</kbd> |
| Scroll to end | <kbd>Ctrl</kbd>+<kbd>PageDown</kbd> |
| Scroll up by one line | <kbd>Ctrl</kbd>+<kbd>PageUp</kbd> |
| Scroll down by one line | <kbd>Ctrl</kbd>+<kbd>PageDown</kbd> |
| Move selection to start | <kbd>Ctrl</kbd>+<kbd>Home</kbd> |
| Move selecion to end | <kbd>Ctrl</kbd>+<kbd>End</kbd> |
| Quit editor (save work) | <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>Q</kbd> |

### Projects

A *project* is a folder in the application's storage which contains at least a
A _project_ is a folder in the application's storage which contains at least a
`main.lua` file.
Projects can be loaded and ran. At any time, pressing <kbd>Ctrl-Shift-Q</kbd>
quits and returns to the console

* `list_projects()`
- `list_projects()`

List available projects.

List available projects.
- `project(proj)`

* `project(proj)`
Open project _proj_ or create a new one if it doesn't exist.
New projects are supplied with example code to demonstrate the structure.

Open project *proj* or create a new one if it doesn't exist.
New projects are supplied with example code to demonstrate the structure.
- `current_project()`

* `current_project()`
Print the currently open project's name (if any).

Print the currently open project's name (if any).
- `run_project(proj?)`

* `run_project(proj?)`
Run either _proj_ or the currently open project if no arguments are passed.

Run either *proj* or the currently open project if no arguments are passed.
- `example_projects()`

* `example_projects()`
Copy the included example projects to the projects folder.

Copy the included example projects to the projects folder.
- `close_project()`

* `close_project()`
Close currently opened project.

Close currently opened project.
- `edit(file)`

* `edit(file)`
Open file in editor. If it does not exist yet, a new file will be created.
See [Editor mode](#editor)

Open file in editor. If it does not exist yet, a new file will be created.
### Files

Once a project is open, file operations are available on it's contents.

* `list_contents()`
- `list_contents()`

List files in the project.
List files in the project.

* `readfile(file)`
- `readfile(file)`

Open *file* and display it's contents.
Open _file_ and display it's contents.

* `writefile(file, content)`
- `writefile(file, content)`

Write to *file* the text supplied as the *content* parameter. This can be
either a string, or an array of strings.
Write to _file_ the text supplied as the _content_ parameter. This can be
either a string, or an array of strings.

* `runfile(file)`
- `runfile(file)`

Run *file* if it's a lua script.
Run _file_ if it's a lua script.

### Editor

![editor_1](./doc/interface/editor_1.png)
Loading

0 comments on commit adfc76b

Please sign in to comment.