About Monkey 2 › Forums › Monkey 2 Projects › ncurses
This topic contains 1 reply, has 1 voice, and was last updated by
Simon Armstrong 1 year, 9 months ago.
Viewing 2 posts - 1 through 2 (of 2 total)
-
AuthorPosts
-
July 1, 2017 at 4:46 am #9068
ncurses allows you to draw all over a terminal window and build interactive menus and apps on Mac and Linux
[edit] now with mouse events
July 2, 2017 at 1:38 am #9078Monkey123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145' ncurses.monkey2' linux console control for monkey2' sudo apt-get install ncurses-dev#Import "<libc>"#Import "<libncurses.a>"#Import "<ncurses.h>"Externstruct MEVENTfield id:shortfield x:intfield y:intfield z:intfield bstate:intendstruct mmask_tendclass WINDOWendconst ALL_MOUSE_EVENTS:mmask_tconst OK:intconst A_STANDOUT:intconst A_UNDERLINE:intconst A_REVERSE:intconst A_PROTECT:intconst A_INVIS:intconst A_DIM:intconst A_BOLD:intconst A_BLINK:intconst A_ALTCHARSET:intconst A_ATTRIBUTES:intconst A_CHARTEXT:intconst A_COLOR:intglobal COLS:intglobal LINES:intconst KEY_MOUSE:intconst KEY_DOWN:intconst KEY_UP:intconst KEY_LEFT:intconst KEY_RIGHT:intconst KEY_HOME:intconst KEY_BACKSPACE:intconst KEY_DC:intconst KEY_IC:intconst KEY_ENTER:intconst KEY_F1:intconst KEY_F2:intconst KEY_F3:intconst COLOR_BLACK:intconst COLOR_BLUE:intconst COLOR_GREEN:intconst COLOR_CYAN:intconst COLOR_RED:intconst COLOR_MAGENTA:intconst COLOR_YELLOW:intconst COLOR_WHITE:intFunction initscr()Function noecho()Function echo()Function raw()Function noraw()Function printw:Int(text:CString)Function refresh:Int()function clear:int()Function getch:Int()function curs_set(cursor:int)function newwin:WINDOW(w:int,h:int,x:int,y:int)function wclear(window:WINDOW)function wrefresh(window:WINDOW)function box(window:WINDOW,a:int,b:int)function wprintw(window:WINDOW,text:CString)function mvwprintw(window:WINDOW,x:int,y:int,text:CString)function delwin(window:WINDOW)Function wgetch:Int(window:WINDOW)Function endwin:Int()function wattron(window:WINDOW,attribute:int)function wattroff(window:WINDOW,attribute:int)function keypad(window:WINDOW,enable:bool)function getmouse:int(event:MEVENT ptr)function mousemask:mmask_t(events:mmask_t, oldmask:mmask_t ptr)PublicFunction Main()initscr()noecho()curs_set(0)local w:=newwin(10,32,4,(COLS-32)/2)local oldmask:mmask_tlocal newmask:=mousemask(ALL_MOUSE_EVENTS, varptr oldmask)box(w,0,0)mvwprintw(w,3,2,"HELLO")wattron(w,A_BOLD)mvwprintw(w,4,2,"("+LINES+","+COLS+")")wattroff(w,A_BOLD)mvwprintw(w,8,2,"Escape To Quit")wrefresh(w)keypad(w,true)local e:MEVENTwhile truelocal key:=wgetch(w)mvwprintw(w,6,2,"key="+key)if key=27 exitif key=113 exitif key=KEY_MOUSElocal r:=getmouse(varptr e)if r=OKmvwprintw(w,6,2,"mouse="+e.id+","+e.x+","+e.y+","+e.z+","+e.bstate+" ")endifendifwendwclear(w)wrefresh(w)delwin(w)endwin()End -
AuthorPosts
Viewing 2 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic.