-
Notifications
You must be signed in to change notification settings - Fork 4
OS Limitations
tl;dr: windows = fast & good input, posix = sometimes slow & limited input.
scone is cross-platform, meaning it will work on both Windows and POSIX (Linux-based, such as Ubuntu and macOS). However there are some differences between the platforms. As a developer it is good practice to know what differs the OS versions. Let's take a look at the differences!
Windows
Uses the Windows Console API, resulting in fast output performance.
POSIX
Uses setCursor(x,y)
and writeln(...)
combined with ANSI escape sequences, resulting in varied performance.
print();
works by looking looking at each line of the window, and determining what lines have been modified. For each modified line, setCursor(x,y);
is called (where y
is the line which is modified, and x
is at the first modified cell), and then all characters gets written to the terminal.
Unfortunately there are no real advice to speed up draw time, other than limiting the amount of times print();
is called.
...and struct InputEvent {...}
Windows
Uses the Windows Console API, resulting in proper key press/release and support for multiple control-keys in each press.
POSIX
A whole crap-ton of hokus pokus, magic, and prayer.
- Only key-presses are registered via the terminal (not key-releases).
-
InputEvent
s only store one control-key (last control-key pressed) per input. - If multiple keys are pressed at the same time, sometimes none get registered.
- Not all keys are available everywhere, as the inputs differ from machine to machine.
Due to how inputs work in the terminal, an input is sent as a sequence of bytes. These sequences are different on different distributions.
Is is possible to manually bind an input sequence to an input. This is done by entering a specifically formatted line into a file input_sequences.scone
in the same directory as the executable. The lines must follow this syntax:
# in file 'input_sequences.scone' at binary directory
SK-key<tab>control-key<tab>ascii-code-sequence
# examples
key_2 none 50
a shift 65
down none 27,91,66
Windows
The console has a minimum buffer size, so if setting the window size so something too small will have no effect. The minimum size is dependent on the system.
POSIX
Resizing the terminal might be disabled or unavailable for your terminal emulator.
On macOS, the following terminals are tested and not resizable:
- iTerm2 - Preferences → Profiles → → Terminal → untick "Disable session-initiated window resizing"
- Hyper - See bug https://github.com/zeit/hyper/issues/1788
- Visual Studio Code Integrated Terminal - Not possible to resize