aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--TUI/module.jai16
-rw-r--r--ttt.jai39
2 files changed, 32 insertions, 23 deletions
diff --git a/TUI/module.jai b/TUI/module.jai
index bb5b800..9014be7 100644
--- a/TUI/module.jai
+++ b/TUI/module.jai
@@ -43,11 +43,11 @@ Drawings :: struct {
}
Commands :: struct {
- EnterAlternateBuffer :: "\e[?1049h";
- EnterMainBuffer :: "\e[?1049l";
+ StartAlternateBuffer :: "\e[?1049h";
+ StartMainBuffer :: "\e[?1049l";
- EnterDrawingMode :: "\e(0";
- EnterNormalMode :: "\e(B";
+ StartDrawingMode :: "\e(0";
+ StartNormalMode :: "\e(B";
ClearScreen :: "\e[2J";
ClearLine :: "\e[2K";
@@ -371,7 +371,7 @@ start :: () {
input_string.count = 0;
input_override = xx Keys.None;
- write_strings(Commands.HideCursor, Commands.SaveCursorPosition, Commands.EnterAlternateBuffer, Commands.SetUTF8);
+ write_strings(Commands.HideCursor, Commands.SaveCursorPosition, Commands.StartAlternateBuffer, Commands.SetUTF8);
OS_prepare_terminal();
initialized = true;
@@ -382,7 +382,7 @@ stop :: () {
initialized = false;
OS_reset_terminal();
- write_strings(Commands.EnterMainBuffer, Commands.RestoreCursorPosition, Commands.ShowCursor);
+ write_strings(Commands.StartMainBuffer, Commands.RestoreCursorPosition, Commands.ShowCursor);
}
flush_input :: () {
@@ -402,7 +402,7 @@ draw_box :: (x: int, y: int, width: int, height: int) {
tmp_string = tprint(Commands.SetCursorPosition, y, x);
write_strings(
- Commands.EnterDrawingMode,
+ Commands.StartDrawingMode,
tmp_string,
Drawings.CornerTL
);
@@ -431,7 +431,7 @@ draw_box :: (x: int, y: int, width: int, height: int) {
}
write_string(Drawings.CornerBR);
- write_string(Commands.EnterNormalMode);
+ write_string(Commands.StartNormalMode);
}
// TODO Maybe rename to "clear()"
diff --git a/ttt.jai b/ttt.jai
index c411d81..58a025b 100644
--- a/ttt.jai
+++ b/ttt.jai
@@ -21,13 +21,9 @@
#import "System";
#import "Sort";
#import "Math";
-// #import "POSIX";
#import "File";
#import "File_Utilities";
#import "String";
-// #import "curses";
-// #import "kscurses";
-TIO :: #import "tio"; // TODO Move things into TUI.
TUI :: #import "TUI";
#load "Integer_Saturating_Arithmetic.jai";
@@ -991,17 +987,22 @@ draw_tui :: (db: *Database, layout: *Layout) {
// Draw table grids.
// TODO Maybe this could be simplified?
- y = 0;
- x = 0;
+ y = 1;
+ x = 1;
+ write_string(TUI.Commands.StartDrawingMode);
for 0..layout.columns.count-2 {
column := layout.columns[it];
x += 1 + column.width;
- //mvaddch(xx y, xx x, ACS_TTEE); TODO DAM
- for row: 1..size_y-1 {
- //mvaddch(xx row, xx x, ACS_VLINE); TODO DAM
+ TUI.set_cursor_position(y, x);
+ write_string(TUI.Drawings.TeeT);
+ for row: 2..size_y {
+ TUI.set_cursor_position(row, x);
+ write_string(TUI.Drawings.LineV);
}
- //mvaddch(size_y-1, xx x, ACS_BTEE); TODO DAM
+ TUI.set_cursor_position(size_y, x);
+ write_string(TUI.Drawings.TeeB);
}
+ write_string(TUI.Commands.StartNormalMode);
///////////////////////////////////////////////////////////////////////////
@@ -1081,7 +1082,15 @@ draw_tui :: (db: *Database, layout: *Layout) {
column_width = layout.columns[L_TITLE_IDX].width;
// mvprintw(xx y, xx x, "%-*.*s", column_width, column_width, temp_c_string(xx task.name)); //task.name); TODO Fix required for LLVM/Cncurses. TODO DAM
TUI.set_cursor_position(y, x);
- print("%", cast(string)task.name); // TODO Needs adjustment to fit column width.
+ // TODO FIXME OH MY GOD SUCH BAD CODEZ
+ task_name: string = cast(string)task.name;
+ task_name.count = ifx task_name.count > column_width then column_width else task_name.count;
+ print("%", task_name);
+ diff := column_width - task_name.count;
+ while diff > 0 {
+ diff -= 1;
+ print_character(#char " ");
+ }
x += column_width;
// Task times.
@@ -1120,7 +1129,7 @@ draw_tui :: (db: *Database, layout: *Layout) {
///////////////////////////////////////////////////////////////////////////
// Draw daily totals.
y = size_y;
- x = 0 + 1 + layout.columns[L_TITLE_IDX].width;
+ x = 1 + 1 + layout.columns[L_TITLE_IDX].width;
total_time = 0;
for 0..NUM_WEEK_DAYS-1 {
idx := adjust_first_day_of_week[it];
@@ -1526,7 +1535,8 @@ main :: () {
if (is_terminal_too_small) {
INVALID_WINDOW_MESSAGE :: "Terminal is too small: minimum 60x3.";
- //mvaddstr(size_y / 2, (size_x - xx INVALID_WINDOW_MESSAGE.count) / 2, INVALID_WINDOW_MESSAGE); TODO DAM
+ TUI.set_cursor_position(size_y / 2, (size_x - INVALID_WINDOW_MESSAGE.count) / 2);
+ write_strings(INVALID_WINDOW_MESSAGE);
}
else {
draw_tui(db, layout);
@@ -1574,11 +1584,10 @@ main :: () {
// When terminal is resized.
case TUI.Keys.Resize;
TUI.clear_terminal();
- //getmaxyx(stdscr, *size_y, *size_x);
_y, _x := TUI.get_terminal_size();
+ // TODO FIX ME
size_y = xx _y;
size_x = xx _x;
- print("resize:%x%", size_x, size_y);
is_terminal_too_small = size_x < 60 || size_y < 3;
update_layout();
layout = *layouts[ifx size_x > 100 then Layouts.NORMAL else Layouts.COMPACT];