aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordam <dam@gudinoff>2023-09-21 22:52:04 +0100
committerdam <dam@gudinoff>2023-09-21 22:52:04 +0100
commit1b76de83f52f7199a51e8e5d563b4ddfa8e2f289 (patch)
tree276de0ae44e3831bd1926958666c668be5914c37
parent1b6fbda3a7f9fa95e2dbbafea56388900167639c (diff)
downloadtask-time-tracker-1b76de83f52f7199a51e8e5d563b4ddfa8e2f289.tar.zst
task-time-tracker-1b76de83f52f7199a51e8e5d563b4ddfa8e2f289.zip
Fixed one bug on read_input... more remaining (sad).
-rw-r--r--TUI/module.jai101
1 files changed, 71 insertions, 30 deletions
diff --git a/TUI/module.jai b/TUI/module.jai
index 27a871b..fae022f 100644
--- a/TUI/module.jai
+++ b/TUI/module.jai
@@ -215,7 +215,7 @@ else #if OS == .LINUX || OS == .MACOS {
tcgetattr(STDIN_FILENO, *term);
// Input modes.
- Input_Modes :: enum u32 {
+ Input_Modes :: enum_flags u32 {
IGNBRK; // Ignore break condition.
BRKINT; // Signal interrupt on break.
IGNPAR; // Ignore characters with parity errors.
@@ -232,44 +232,77 @@ else #if OS == .LINUX || OS == .MACOS {
IMAXBEL; // Ring bell when input queue is full.
IUCLC; // Translate upper case input to lower case.
}
+
+ // Local modes.
+ Local_Modes :: enum_flags u32 {
+ ECHOKE; // Visual erase for KILL.
+ ECHOE; // Visual erase for ERASE.
+ ECHOK; // Echo NL after KILL.
+ ECHO; // Enable echo.
+ ECHONL; // Echo NL even if ECHO is off.
+ ECHOPRT; // Hardcopy visual erase.
+ ECHOCTL; // Echo control characters as ^X.
+ ISIG; // Enable signals.
+ ICANON; // Do erase and kill processing.
+ ALTWERASE; // Alternate WERASE algorithm.
+ IEXTEN; // Enable DISCARD and LNEXT.
+ EXTPROC; // External processing.
+ TOSTOP; // Send SIGTTOU for background output.
+ FLUSHO; // Output being flushed (state).
+ XCASE; // Canonical upper/lower case.
+ NOKERNINFO; // Disable VSTATUS.
+ PENDIN; // Retype pending input (state).
+ NOFLSH; // Disable flush after interrupt.
- // IGNBRK :u32: (1 << 0); // Ignore break condition.
- // BRKINT :u32: (1 << 1); // Signal interrupt on break.
- // IGNPAR :u32: (1 << 2); // Ignore characters with parity errors.
- // PARMRK :u32: (1 << 3); // Mark parity and framing errors.
- // INPCK :u32: (1 << 4); // Enable input parity check.
- // ISTRIP :u32: (1 << 5); // Strip 8th bit off characters.
- // INLCR :u32: (1 << 6); // Map NL to CR on input.
- // IGNCR :u32: (1 << 7); // Ignore CR.
- // ICRNL :u32: (1 << 8); // Map CR to NL on input.
- // IXON :u32: (1 << 9); // Enable start/stop output control.
- // IXOFF :u32: (1 << 10); // Enable start/stop input control.
- // IXANY :u32: (1 << 11); // Any character will restart after stop.
- // IMAXBEL :u32: (1 << 13); // Ring bell when input queue is full.
- // IUCLC :u32: (1 << 14); // Translate upper case input to lower case.
-
- // IGNBRK :u32: 0x0001;
- // BRKINT :u32: 0x0002;
- // IGNCR :u32: 0x0040;
-
- ECHO :u32: 0x0004;
- ECHONL :u32: 0x0010;
- ICANON :u32: 0x0080;
- IEXTEN :u32: 0x0400;
+ }
backup: My_Termios;
tcgetattr(STDIN_FILENO, *backup);
if blocking {
- term = __term;
- // iflags: Input_Modes = (.IGNBRK | .BRKINT | .PARMRK | .ISTRIP | .INLCR | .IGNCR | .ICRNL | .IXON);
- // term.c_iflag |= xx iflags;
- // term.c_lflag |= (ECHO | ECHONL | ICANON | IEXTEN);
+ // write_number(term.c_iflag, 2);
+ // write_string(":");
+ // write_number(term.c_lflag, 2);
+ // write_string(":");
+ // write_number(__term.c_iflag, 2);
+ // write_string(":");
+ // write_number(__term.c_lflag, 2);
+
+ // c_iflag
+ // 10
+ // 8
+ // 0101 0101 0000 0000 : __term
+ // 1111 1010 0001 0100 : &MASK
+ // 0101 0000 0000 0000 :
+
+ // 0101 0101 0000 0000 : NOW
+
+
+ // c_lflag
+ // 15
+ // 3
+ // 1
+ // 0
+ // 1000 1010 0011 1011 : __term
+ // 0111 1111 1011 0100 : &MASK
+ // 0000 1010 0011 0000 :
+
+ // 1000 1010 0011 1011 : NOW
+
+
+ // print("%\n", term.c_iflag, to_standard_error = true);
+ // print("%\n", term.c_lflag, to_standard_error = true);
+ // print("%\n", term, to_standard_error = true);
+
+ // term = __term;
+ term.c_iflag |= xx cast(Input_Modes)(.IXOFF | .ICRNL);
+ term.c_lflag |= xx cast(Local_Modes)(.NOKERNINFO | .ECHO | .ECHOE | .ECHOKE);
}
else {
iflags: Input_Modes = (.IGNBRK | .BRKINT | .PARMRK | .ISTRIP | .INLCR | .IGNCR | .ICRNL | .IXON);
term.c_iflag &= xx ~(iflags);
- term.c_lflag &= ~(ECHO | ECHONL | ICANON | IEXTEN);
+ lflags: Local_Modes = (.ECHO | .ECHONL | .ICANON | .IEXTEN);
+ term.c_lflag &= xx ~lflags;
}
// term.c_iflag &= 0xFFFFFA14;// ~(IGNBRK | BRKINT | PARMRK | ISTRIP | INLCR | IGNCR | ICRNL | IXON);
@@ -287,7 +320,15 @@ else #if OS == .LINUX || OS == .MACOS {
write_string(Commands.HideCursor);
// TODO WIP WIP WIP
- result = to_string(buffer.data, bytes_read); // TODO WIP WIP WIP This is still using the stack allocated buffer and WILL FAIL!
+ result.data = alloc(bytes_read, temp);
+ memcpy(result.data, buffer.data, bytes_read);
+ result.count = bytes_read;
+ // result = "jat";
+ // result.count = bytes_read;
+ // result.data = buffer.data;
+ // result = copy_temporary_string(buffer);
+ // result = tprint("%", xx buffer.data);
+ // result = to_string(buffer.data, bytes_read); // TODO WIP WIP WIP This is still using the stack allocated buffer and WILL FAIL!
tcsetattr(STDIN_FILENO, 0, *backup);