14 Commits
Author SHA1 Message Date
obligaron 22ec684671 Fix some MSVC warnings 2023-12-02 12:57:34 +01:00
Gleb Mazovetskiy a2b94cc03c Lua: Migrate and organize the rest of debug cmds
Fully migrates debug commands to Lua and organizes them into logical
groups.

The CLI `+` syntax now runs Lua, e.g.:

```bash
build/devilutionx '+dev.player.trn.plr("infra")'
```

Chat hotkeys run Lua code if they start with `/lua`, e.g.:

```ini
[NetMsg]
QuickMessage1=/lua message(dev.player.info())
```
2023-11-07 22:27:48 +00:00
Gleb Mazovetskiy b265bbdbb4 Skip console autocomplete when navigating history 2023-11-06 22:25:52 +00:00
Gleb Mazovetskiy e02dc1f9dd Console input: Word-wrap-related cursor fixes
1. Handle word breaks in the prompt, e.g. `"> " -> "\n"`.
2. Handle word breaks in the original newline for all whitespace, not just `"\n"`.
2023-11-06 21:42:58 +00:00
Gleb Mazovetskiy 4f23762308 Console: Fix crash when there is too much input
It doesn't make the field scrollable but at least it doesn't crash.
2023-11-04 21:47:56 +00:00
Gleb Mazovetskiy 8bffbedcb4 Migrate some debug.cpp commands to Lua
Introduces a new `devilutionx.dev` Lua module, automatically loaded in
the console prelude.

Arguments and basic help are shown in autocompletion.
2023-11-04 20:28:27 +00:00
Gleb Mazovetskiy b30b712cbb Lua: Add basic autocomplete in the console 2023-11-03 19:19:45 +00:00
Gleb Mazovetskiy 4a7fa5d13e Lua console: Add a prelude file
Runs lua/repl_prelude.lua at console initialization.

The default prelude contains global assignments for all devilutionx
modules. This should save us on typing.
2023-11-03 09:48:05 +00:00
Gleb Mazovetskiy dbfa204944 Lua: Set warn function
Previously, warnings went nowhere.
2023-11-02 15:16:31 +01:00
Gleb Mazovetskiy 17d5f05ada Fix some compilation warnings 2023-11-02 00:42:44 +00:00
Gleb Mazovetskiy a9c0f5764c Console: Use a REPL environment to run code
In the REPL environment, we set `print` to print to the UI console
instead of stdout.
2023-11-01 20:05:02 +00:00
Gleb Mazovetskiy d8c328ad68 Console: Add Ctrl+L binding to clear the console 2023-11-01 20:05:02 +00:00
Gleb Mazovetskiy 63da74300b Console: Scrolling and history navigation
Scrolling: PageUp/Down and mouse wheel.

History navigation:

* Up/Down navigates the input history.
* Shift+Up/Down navigates the output history (allowing us to copy/paste the
outputs, I imagine this will be very handy).
* Duplicates are skipped.
2023-11-01 20:05:02 +00:00
Gleb Mazovetskiy 3ea4996367 Add a basic Quake-style console
Enabled only in Debug mode.

Runs Lua similar to the `lua` CLI.
Supports multiline input with Shift+Enter.

Missing features:
1. Scrollback.
2. Input history on up/down.

Open with backtick, close with Esc.
2023-10-31 23:19:56 +00:00