diff options
| author | dam <dam@gudinoff> | 2023-01-27 01:56:40 +0000 |
|---|---|---|
| committer | dam <dam@gudinoff> | 2023-01-27 01:56:40 +0000 |
| commit | 43d2bf3d44ebdd50c535649f609b458d1b487abc (patch) | |
| tree | 1a8e53ec68a9211ba3c62f6d76b85864c71f2f07 | |
| parent | e7cdf6fe804e1c01179afc3e40b761144cd0b057 (diff) | |
| download | task-time-tracker-43d2bf3d44ebdd50c535649f609b458d1b487abc.tar.zst task-time-tracker-43d2bf3d44ebdd50c535649f609b458d1b487abc.zip | |
First attempt to use ncurses.
| -rw-r--r-- | ttt.jai | 97 |
1 files changed, 97 insertions, 0 deletions
@@ -1823,4 +1823,101 @@ main :: () { print("Task Time Tracker version %\n", VERSION); print("Copyright 2022 Daniel Martins\n"); print("License GPL-3.0-or-later\n"); + +// TODO More binding examples here https://github.com/vrcamillo/jai-tracy +/* + short : s16 + int : s32 + long : s64 (int) + single : float32 (float) + double : float64 +*/ + +ldat :: struct { + text :*void; /* text of the line */ + firstchar :s16; /* first changed character in the line */ + lastchar :s16; /* last changed character in the line */ + oldindex :s16; /* index of the line at last update */ +}; + + +WINDOW :: struct { + _cury, _curx : s16; /* current cursor position */ + + /* window location and size */ + _maxy, _maxx : s16; /* maximums of x and y, NOT window size */ + _begy, _begx : s16; /* screen coords of upper-left-hand corner */ + + _flags :s16; /* window state flags */ + + /* attribute tracking */ + _attrs :u8; /* current attribute for non-space character */ + _bkgd :u8; /* current background char/attribute pair */ + + /* option values set by user */ + _notimeout :bool; /* no time out on function-key entry? */ + _clear :bool; /* consider all data in the window invalid? */ + _leaveok :bool; /* OK to not reset cursor on exit? */ + _scroll :bool; /* OK to scroll this window? */ + _idlok :bool; /* OK to use insert/delete line? */ + _idcok :bool; /* OK to use insert/delete char? */ + _immed :bool; /* window in immed mode? (not yet used) */ + _sync :bool; /* window in sync mode? */ + _use_keypad :bool; /* process function keys into KEY_ symbols? */ + _delay :s32; /* 0 = nodelay, <0 = blocking, >0 = delay */ + + _line :*ldat; /* the actual line data */ + + /* global screen state */ + _regtop :s16; /* top line of scrolling region */ + _regbottom :s16; /* bottom line of scrolling region */ + + /* these are used only if this is a sub-window */ + _parx :s32; /* x coordinate of this window in parent */ + _pary :s32; /* y coordinate of this window in parent */ + _parent :*WINDOW; /* pointer to parent if a sub-window */ + + /* these are used only if this is a pad */ + pdat :: struct + { + _pad_y, _pad_x :s16 ; + _pad_top, _pad_left :s16; + _pad_bottom, _pad_right :s16; + }; + _pad :pdat; + + _yoffset :s16; /* real begy is _begy + _yoffset */ + +/* +#if NCURSES_WIDECHAR + cchar_t _bkgrnd; +#if 1 + int _color; +#endif +#endif +*/ +}; + + tinfo :: #system_library "libtinfo"; // Required by some of ncurses functions. + ncurses :: #library "libncurses"; + initscr :: () -> *WINDOW #foreign ncurses; + getch :: () -> s8 #foreign ncurses; + endwin :: () -> void #foreign ncurses; + + curs_set :: (visibility: s32) -> s32 #foreign ncurses; + mvaddstr :: (y: s32, x: s32, str: *u8) -> s32 #foreign ncurses; + noecho :: () -> s32 #foreign ncurses; + box :: (win :*WINDOW, verch :u8, horch :u8) -> s32 #foreign ncurses; + + stdscr := initscr(); + curs_set(0); + noecho(); + box(stdscr, 0, 0); + while true { + key := getch(); + if key == #char "q" break; + mvaddstr(1, 1, "> wow alçapão <"); + } + endwin(); + } |
