diff options
Diffstat (limited to 'curses.jai')
| -rw-r--r-- | curses.jai | 316 |
1 files changed, 0 insertions, 316 deletions
diff --git a/curses.jai b/curses.jai deleted file mode 100644 index 7ec39c0..0000000 --- a/curses.jai +++ /dev/null @@ -1,316 +0,0 @@ - -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 */ -}; - - -tinfo :: #system_library "libtinfo"; // Required by some of ncurses functions. -// NOTE -// Must use local lib while having package libncurses-dev installed because it introduces -// an override file: -// > cat /lib/x86_64-linux-gnu/libncurses.so -// INPUT(libncursesw.so.6 -ltinfo) -// I suspect this is an attempt to help the compilers to include libtinfo automatically. -// ncurses :: #system_library "libncurses"; -ncurses :: #library "libncurses"; - -stdscr : *WINDOW; - -initscr :: () -> *WINDOW #foreign ncurses; -getch :: () -> s32 #foreign ncurses; -endwin :: () -> void #foreign ncurses; -cbreak :: () -> void #foreign ncurses; -start_color :: () -> void #foreign ncurses; -use_default_colors :: () -> void #foreign ncurses; -flushinp :: () -> s32 #foreign ncurses; -echo :: () -> s32 #foreign ncurses; - -keypad :: (win: *WINDOW, bf: bool) -> s32 #foreign ncurses; -ungetch :: (ch: s32) -> s32 #foreign ncurses; - -attrset :: (attrs: s32) -> s32 #foreign ncurses; -attron :: (attrs: s32) -> s32 #foreign ncurses; -erase :: () -> s32 #foreign ncurses; -curs_set :: (visibility: s32) -> s32 #foreign ncurses; -addstr :: (str: *u8) -> s32 #foreign ncurses; -mvaddstr :: (y: s32, x: s32, str: *u8) -> s32 #foreign ncurses; -mvprintw :: (y: s32, x: s32, fmt: *u8, - args: ..Any) -> s32 #foreign ncurses; -mvgetnstr :: (y: s32, x: s32, str: *u8, - n: s32) -> s32 #foreign ncurses; -noecho :: () -> s32 #foreign ncurses; -box :: (win: *WINDOW, verch: u8, - horch: u8) -> s32 #foreign ncurses; -init_pair :: (pair: s16, f: s16, b: s16) -> s32 #foreign ncurses; -timeout :: (delay: s32) -> void #foreign ncurses; -addch :: (ch: u32) -> s32 #foreign ncurses; -mvaddch :: (y: s32, x: s32, ch: u32) -> s32 #foreign ncurses; -clear :: () -> s32 #foreign ncurses; -refresh :: () -> s32 #foreign ncurses; -move :: (y: s32, x: s32) -> s32 #foreign ncurses; -isendwin :: () -> bool #foreign ncurses; -delwin :: (win: *WINDOW) -> s32 #foreign ncurses; -newwin :: (nlines: s32, ncols: s32, begin_y: s32, - begin_x: s32) -> *WINDOW #foreign ncurses; -wattron :: (win: *WINDOW, attrs: s32) -> s32 #foreign ncurses; -wborder :: (win: *WINDOW, ls: u32, rs: u32, - ts: u32, bs: u32, tl: u32, - tr: u32, bl: u32, br: u32) -> s32 #foreign ncurses; -mvwin :: (win: *WINDOW, y: s32, x: s32) -> s32 #foreign ncurses; -touchwin :: (win: *WINDOW) -> s32 #foreign ncurses; -wrefresh :: (win: *WINDOW) -> s32 #foreign ncurses; -mvwprintw :: (win: *WINDOW, y: s32, x: s32, - fmt: *u8, args: ..Any) -> s32 #foreign ncurses; -wmove :: (win: *WINDOW, y: s32, x: s32) -> s32 #foreign ncurses; -waddch :: (win: *WINDOW, ch: u32) -> s32 #foreign ncurses; -wprintw :: (win: *WINDOW, fmt: *u8, - args: ..Any) -> s32 #foreign ncurses; - - -getmaxyx :: inline (win: *WINDOW, y: *s32, x: *s32) { <<y = getmaxy(win); <<x = getmaxx(win); } -getmaxx :: inline (win: *WINDOW) -> s32 { return ifx win == null then ERR else win._maxx + 1; } -getmaxy :: inline (win: *WINDOW) -> s32 { return ifx win == null then ERR else win._maxy + 1; } -getcurx :: inline (win: *WINDOW) -> s32 { return ifx win == null then ERR else win._curx; } -getcury :: inline (win: *WINDOW) -> s32 { return ifx win == null then ERR else win._cury; } - -//#if CPU == .X64 { -//typedef unsigned chtype; // Used for mask and shift vars. -//typedef unsigned mmask_t; -//} else { -//typedef uint32_t chtype; -//typedef uint32_t mmask_t; -//} -NCURSES_ATTR_SHIFT :: 8; -NCURSES_BITS :: inline (mask: u32, shift: u32) -> u32 { return mask << (shift + NCURSES_ATTR_SHIFT); } - -A_NORMAL :: 0; -A_ATTRIBUTES :: #run NCURSES_BITS(~(cast(u32)(1 - 1)),0); -A_CHARTEXT :: #run (NCURSES_BITS(1,0) - 1); -A_COLOR :: #run NCURSES_BITS(((1) << 8) - 1,0); -A_STANDOUT :: #run NCURSES_BITS(1,8); -A_UNDERLINE :: #run NCURSES_BITS(1,9); -A_REVERSE :: #run NCURSES_BITS(1,10); -A_BLINK :: #run NCURSES_BITS(1,11); -A_DIM :: #run NCURSES_BITS(1,12); -A_BOLD :: #run NCURSES_BITS(1,13); -A_ALTCHARSET :: #run NCURSES_BITS(1,14); -A_INVIS :: #run NCURSES_BITS(1,15); -A_PROTECT :: #run NCURSES_BITS(1,16); -A_HORIZONTAL :: #run NCURSES_BITS(1,17); -A_LEFT :: #run NCURSES_BITS(1,18); -A_LOW :: #run NCURSES_BITS(1,19); -A_RIGHT :: #run NCURSES_BITS(1,20); -A_TOP :: #run NCURSES_BITS(1,21); -A_VERTICAL :: #run NCURSES_BITS(1,22); -A_ITALIC :: #run NCURSES_BITS(1,23); // ncurses extension - -// VT100 symbols begin here. -ACS_ULCORNER :: #run A_ALTCHARSET | #char "l"; /* upper left corner */ -ACS_LLCORNER :: #run A_ALTCHARSET | #char "m"; /* lower left corner */ -ACS_URCORNER :: #run A_ALTCHARSET | #char "k"; /* upper right corner */ -ACS_LRCORNER :: #run A_ALTCHARSET | #char "j"; /* lower right corner */ -ACS_LTEE :: #run A_ALTCHARSET | #char "t"; /* tee pointing right */ -ACS_RTEE :: #run A_ALTCHARSET | #char "u"; /* tee pointing left */ -ACS_BTEE :: #run A_ALTCHARSET | #char "v"; /* tee pointing up */ -ACS_TTEE :: #run A_ALTCHARSET | #char "w"; /* tee pointing down */ -ACS_HLINE :: #run A_ALTCHARSET | #char "q"; /* horizontal line */ -ACS_VLINE :: #run A_ALTCHARSET | #char "x"; /* vertical line */ -ACS_PLUS :: #run A_ALTCHARSET | #char "n"; /* large plus or crossover */ -ACS_S1 :: #run A_ALTCHARSET | #char "o"; /* scan line 1 */ -ACS_S9 :: #run A_ALTCHARSET | #char "s"; /* scan line 9 */ -ACS_DIAMOND :: #run A_ALTCHARSET | #char "`"; /* diamond */ -ACS_CKBOARD :: #run A_ALTCHARSET | #char "a"; /* checker board (stipple) */ -ACS_DEGREE :: #run A_ALTCHARSET | #char "f"; /* degree symbol */ -ACS_PLMINUS :: #run A_ALTCHARSET | #char "g"; /* plus/minus */ -ACS_BULLET :: #run A_ALTCHARSET | #char "~"; /* bullet */ -// Teletype 5410v1 symbols begin here. -ACS_LARROW :: #run A_ALTCHARSET | #char ","; /* arrow pointing left */ -ACS_RARROW :: #run A_ALTCHARSET | #char "+"; /* arrow pointing right */ -ACS_DARROW :: #run A_ALTCHARSET | #char "."; /* arrow pointing down */ -ACS_UARROW :: #run A_ALTCHARSET | #char "-"; /* arrow pointing up */ -ACS_BOARD :: #run A_ALTCHARSET | #char "h"; /* board of squares */ -ACS_LANTERN :: #run A_ALTCHARSET | #char "i"; /* lantern symbol */ -ACS_BLOCK :: #run A_ALTCHARSET | #char "0"; /* solid square block */ -// These aren't documented, but a lot of System Vs have them anyway -// (you can spot pprryyzz{{||}} in a lot of AT&T terminfo strings). -// The ACS_names may not match AT&T's, our source didn't know them. -ACS_S3 :: #run A_ALTCHARSET | #char "p"; /* scan line 3 */ -ACS_S7 :: #run A_ALTCHARSET | #char "r"; /* scan line 7 */ -ACS_LEQUAL :: #run A_ALTCHARSET | #char "y"; /* less/equal */ -ACS_GEQUAL :: #run A_ALTCHARSET | #char "z"; /* greater/equal */ -ACS_PI :: #run A_ALTCHARSET | #char "{"; /* Pi */ -ACS_NEQUAL :: #run A_ALTCHARSET | #char "|"; /* not equal */ -ACS_STERLING :: #run A_ALTCHARSET | #char "}"; /* UK pound sign */ - -COLOR_PAIR :: (n: s32) -> s32 #foreign ncurses; - -COLOR_BLACK :: 0; -COLOR_RED :: 1; -COLOR_GREEN :: 2; -COLOR_YELLOW :: 3; -COLOR_BLUE :: 4; -COLOR_MAGENTA :: 5; -COLOR_CYAN :: 6; -COLOR_WHITE :: 7; - -ERR :: -1; -OK :: 0; - -KEY_CODE_YES :: 256; -KEY_MIN :: 257; -KEY_BREAK :: 257; -KEY_SRESET :: 344; -KEY_RESET :: 345; -KEY_DOWN :: 258; -KEY_UP :: 259; -KEY_LEFT :: 260; -KEY_RIGHT :: 261; -KEY_HOME :: 262; -KEY_BACKSPACE :: 263; -KEY_F0 :: 264; -KEY_F :: inline (n: s32) -> s32 { return KEY_F0+n; }; -KEY_F1 :: KEY_F0 + 1; -KEY_F2 :: KEY_F0 + 2; -KEY_F3 :: KEY_F0 + 3; -KEY_F4 :: KEY_F0 + 4; -KEY_F5 :: KEY_F0 + 5; -KEY_F6 :: KEY_F0 + 6; -KEY_F7 :: KEY_F0 + 7; -KEY_F8 :: KEY_F0 + 8; -KEY_F9 :: KEY_F0 + 9; -KEY_F10 :: KEY_F0 + 10; -KEY_F11 :: KEY_F0 + 11; -KEY_F12 :: KEY_F0 + 12; -KEY_DL :: 328; -KEY_IL :: 329; -KEY_DC :: 330; -KEY_IC :: 331; -KEY_EIC :: 332; -KEY_CLEAR :: 333; -KEY_EOS :: 334; -KEY_EOL :: 335; -KEY_SF :: 336; -KEY_SR :: 337; -KEY_NPAGE :: 338; -KEY_PPAGE :: 339; -KEY_STAB :: 340; -KEY_CTAB :: 341; -KEY_CATAB :: 342; -KEY_ENTER :: 343; -KEY_PRINT :: 346; -KEY_LL :: 347; -KEY_A1 :: 348; -KEY_A3 :: 349; -KEY_B2 :: 350; -KEY_C1 :: 351; -KEY_C3 :: 352; -KEY_BTAB :: 353; -KEY_BEG :: 354; -KEY_CANCEL :: 355; -KEY_CLOSE :: 356; -KEY_COMMAND :: 357; -KEY_COPY :: 358; -KEY_CREATE :: 359; -KEY_END :: 360; -KEY_EXIT :: 361; -KEY_FIND :: 362; -KEY_HELP :: 363; -KEY_MARK :: 364; -KEY_MESSAGE :: 365; -KEY_MOVE :: 366; -KEY_NEXT :: 367; -KEY_OPEN :: 368; -KEY_OPTIONS :: 369; -KEY_PREVIOUS :: 370; -KEY_REDO :: 371; -KEY_REFERENCE :: 372; -KEY_REFRESH :: 373; -KEY_REPLACE :: 374; -KEY_RESTART :: 375; -KEY_RESUME :: 376; -KEY_SAVE :: 377; -KEY_SBEG :: 378; -KEY_SCANCEL :: 379; -KEY_SCOMMAND :: 380; -KEY_SCOPY :: 381; -KEY_SCREATE :: 382; -KEY_SDC :: 383; -KEY_SDL :: 384; -KEY_SELECT :: 385; -KEY_SEND :: 386; -KEY_SEOL :: 387; -KEY_SEXIT :: 388; -KEY_SFIND :: 389; -KEY_SHELP :: 390; -KEY_SHOME :: 391; -KEY_SIC :: 392; -KEY_SLEFT :: 393; -KEY_SMESSAGE :: 394; -KEY_SMOVE :: 395; -KEY_SNEXT :: 396; -KEY_SOPTIONS :: 397; -KEY_SPREVIOUS :: 398; -KEY_SPRINT :: 399; -KEY_SREDO :: 400; -KEY_SREPLACE :: 401; -KEY_SRIGHT :: 402; -KEY_SRSUME :: 403; -KEY_SSAVE :: 404; -KEY_SSUSPEND :: 405; -KEY_SUNDO :: 406; -KEY_SUSPEND :: 407; -KEY_UNDO :: 408; -KEY_MOUSE :: 409; -KEY_RESIZE :: 410; -KEY_MAX :: 511; |
