-
-
Notifications
You must be signed in to change notification settings - Fork 629
Allows to run TIC-80 commands from the system console #2939
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
imsys
wants to merge
25
commits into
nesbox:main
Choose a base branch
from
imsys:console-console
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
5c1f2f9
Allows to run TIC-80 commands from the system console
imsys 63b28b8
makes the console works in async
imsys 0a2d77c
Fix NSwitch and Android, due to conflicting fn map2ram()
imsys 32bdfbe
Fix builds using console_minimal.c
imsys 4f5963e
Fix system console under wine, fixes newline, adds comments
imsys b1dab1c
wine fix attempt
imsys 89da39d
fix wine freeze
imsys 84b1d9a
Better bidirectional console sync
imsys 869416d
Windows -> Do not open the system console automatically
imsys e2a0283
Windows/Wine fix/attempt
imsys 658ad34
Wine fix
imsys d59047c
Revert to test wine fix
imsys 1b9c405
Windows - Attempt to hide system console
imsys ff78585
Wine fix
imsys beb325a
Try to improve wine app
imsys 00f65d2
Another wine fix attempt
imsys 18a877a
Another wine fix try
imsys 18fce7c
wine debug
imsys a837b85
enhanced debug
imsys e2725da
debug
imsys a10664c
further debug
imsys a8ee968
missing declaration
imsys 3a6082b
another debug
imsys 240d0a1
Removed debugging test, fixed up Wine
imsys cb14d7e
fix minor duplicated > at startup
imsys File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4003,7 +4003,9 @@ static void processConsoleCommand(Console* console) | |
|
|
||
| if(commandSize) | ||
| { | ||
| #ifdef BAREMETALPI | ||
| printf("%s", console->input.text); | ||
| #endif | ||
| appendHistory(console, console->input.text); | ||
| processCommand(console, console->input.text); | ||
| } | ||
|
|
@@ -4271,6 +4273,26 @@ static void backspaceWord(Console* console) | |
| console->input.pos = pos; | ||
| } | ||
|
|
||
| static void refreshTerminal(Console* console) | ||
| { | ||
| #ifndef BAREMETALPI | ||
| if (!console->args.cli) | ||
| { | ||
| char dir[TICNAME_MAX]; | ||
| tic_fs_dir(console->fs, dir); | ||
| printf("\r\033[K"); | ||
| if(strlen(dir)) | ||
| printf("%s", dir); | ||
| printf(">%s", console->input.text); | ||
|
|
||
| s32 tailLen = (s32)strlen(console->input.text) - (s32)console->input.pos; | ||
| if (tailLen > 0) | ||
| printf("\033[%dD", tailLen); | ||
| fflush(stdout); | ||
| } | ||
| #endif | ||
| } | ||
|
|
||
| static void processKeyboard(Console* console) | ||
| { | ||
| tic_mem* tic = console->tic; | ||
|
|
@@ -4356,6 +4378,7 @@ static void processKeyboard(Console* console) | |
| console->cursor.delay = CONSOLE_CURSOR_DELAY; | ||
| } | ||
|
|
||
| refreshTerminal(console); | ||
| } | ||
|
|
||
| static void processGamepad(Console* console) | ||
|
|
@@ -4376,7 +4399,6 @@ static void tick(Console* console) | |
| tic_mem* tic = console->tic; | ||
|
|
||
| processMouse(console); | ||
| processKeyboard(console); | ||
| processGamepad(console); | ||
|
|
||
| Start* start = getStartScreen(console->studio); | ||
|
|
@@ -4402,6 +4424,8 @@ static void tick(Console* console) | |
| else printBack(console, "\n loading cart..."); | ||
| } | ||
|
|
||
| processKeyboard(console); | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I had to move it down here because it was causing an extra |
||
|
|
||
| tic_api_cls(tic, TIC_COLOR_BG); | ||
| drawConsoleText(console); | ||
|
|
||
|
|
@@ -4541,6 +4565,32 @@ static int apicmp(const void* a, const void* b) | |
| return strcmp(((const ApiItem*)a)->name, ((const ApiItem*)b)->name); | ||
| } | ||
|
|
||
| // Handle terminal input events directly, bypassing the regular SDL event loop for some keys. | ||
| // This allows commands to be entered and executed even when the console is in the background. | ||
| void console_terminal_input(Console* console, tic_key key, char text) | ||
| { | ||
| if(key == tic_key_return) | ||
| { | ||
| processConsoleCommand(console); | ||
| while(console->commands.current < console->commands.count) | ||
| { | ||
| const char* command = console->commands.items[console->commands.current]; | ||
| processCommand(console, command); | ||
| console->commands.current++; | ||
| } | ||
| } | ||
| else if(key == tic_key_backspace) processConsoleBackspace(console); | ||
| else if(key == tic_key_tab) processConsoleTab(console); | ||
| else if(key == tic_key_delete) processConsoleDel(console); | ||
| else if(key == tic_key_up) onHistoryUp(console); | ||
| else if(key == tic_key_down) onHistoryDown(console); | ||
| else if(key == tic_key_left) { if(console->input.pos > 0) console->input.pos--; } | ||
| else if(key == tic_key_right) { console->input.pos++; s32 len = (s32)strlen(console->input.text); if(console->input.pos > len) console->input.pos = (size_t)len; } | ||
| else if(text) insertInputText(console, (char[]){text, '\0'}); | ||
|
|
||
| refreshTerminal(console); | ||
| } | ||
|
|
||
| void initConsole(Console* console, Studio* studio, tic_fs* fs, tic_net* net, Config* config, StartArgs args) | ||
| { | ||
| if(!console->text) console->text = malloc(CONSOLE_BUFFER_SIZE); | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As this proposed request makes a sync between tic80 console and the system console, we have to remove the output here, otherwise we get a duplicated command output.