-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ New NCurses funcs and mouse support (#17)
- Loading branch information
Showing
4 changed files
with
177 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
## Description ################################################################# | ||
# | ||
# This file contains the definition of keys in libncurses. | ||
# | ||
################################################################################ | ||
|
||
KEY_CTRL(c::Char)=UInt8(c-'A'+1) | ||
const KEY_DOWN=0o402 | ||
const KEY_LEFT=0o404 | ||
const KEY_UP=0o403 | ||
const KEY_RIGHT=0o405 | ||
const KEY_HOME=0o406 | ||
const KEY_BACKSPACE=0o407 | ||
KEY_F(i)=0o410+i | ||
const KEY_DC=0o512 | ||
const KEY_IC=0o513 | ||
const KEY_SF=0o520 | ||
const KEY_SR=0o521 | ||
const KEY_NPAGE=0o522 | ||
const KEY_PPAGE=0o523 | ||
const KEY_ENTER=0o527 | ||
const KEY_BTAB=0o541 | ||
const KEY_BEG=0o542 | ||
const KEY_END=0o550 | ||
const KEY_SDELETE=0o577 | ||
const KEY_SEND=0o602 | ||
const KEY_SHOME=0o607 | ||
const KEY_SIC=0o610 | ||
const KEY_SLEFT=0o611 | ||
const KEY_SNEXT=0o614 | ||
const KEY_SPREVIOUS=0o616 | ||
const KEY_SRIGHT=0o622 | ||
const KEY_MOUSE=0o631 | ||
KEY_ALT(c::Char)=0o641+c-'A' | ||
const KEY_CTRL_DC=0o1020 | ||
const KEY_CTRL_DOWN=0o1026 | ||
const KEY_CTRL_END=0o1033 | ||
const KEY_CTRL_LEFT=0o1052 | ||
const KEY_CTRL_HOME=0o1040 | ||
const KEY_CTRL_NPAGE=0o1057 | ||
const KEY_CTRL_PPAGE=0o1064 | ||
const KEY_CTRL_RIGHT=0o1071 | ||
const KEY_CTRL_UP=0o1077 | ||
const KEY_PAD_PLUS=0o1107 | ||
const KEY_PAD_DIV=0o1111 | ||
const KEY_PAD_TIMES=0o1113 | ||
const KEY_PAD_MINUS=0o1114 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
## Description ################################################################# | ||
# | ||
# This file contains the definition of mouse events in libncurses. | ||
# | ||
################################################################################ | ||
|
||
""" | ||
struct MEVENT | ||
represents a mouse event | ||
""" | ||
mutable struct MEVENT | ||
id::Cshort | ||
x::Cint | ||
y::Cint | ||
z::Cint | ||
bstate::Culong | ||
end | ||
|
||
NCURSES_MOUSE_MASK(b,m)=m<<((b-1)*6) | ||
const NCURSES_BUTTON_RELEASED=1 | ||
const NCURSES_BUTTON_PRESSED=2 | ||
const NCURSES_BUTTON_CLICKED=4 | ||
const NCURSES_DOUBLE_CLICKED=8 | ||
|
||
const BUTTON1_RELEASED= NCURSES_MOUSE_MASK(1, NCURSES_BUTTON_RELEASED) | ||
const BUTTON1_PRESSED= NCURSES_MOUSE_MASK(1, NCURSES_BUTTON_PRESSED) | ||
const BUTTON1_CLICKED= NCURSES_MOUSE_MASK(1, NCURSES_BUTTON_CLICKED) | ||
const BUTTON1_DOUBLE_CLICKED= NCURSES_MOUSE_MASK(1, NCURSES_DOUBLE_CLICKED) | ||
const BUTTON2_RELEASED= NCURSES_MOUSE_MASK(2, NCURSES_BUTTON_RELEASED) | ||
const BUTTON2_PRESSED= NCURSES_MOUSE_MASK(2, NCURSES_BUTTON_PRESSED) | ||
const BUTTON2_CLICKED= NCURSES_MOUSE_MASK(2, NCURSES_BUTTON_CLICKED) | ||
const BUTTON2_DOUBLE_CLICKED= NCURSES_MOUSE_MASK(2, NCURSES_DOUBLE_CLICKED) | ||
const BUTTON3_RELEASED= NCURSES_MOUSE_MASK(3, NCURSES_BUTTON_RELEASED) | ||
const BUTTON3_PRESSED= NCURSES_MOUSE_MASK(3, NCURSES_BUTTON_PRESSED) | ||
const BUTTON3_CLICKED= NCURSES_MOUSE_MASK(3, NCURSES_BUTTON_CLICKED) | ||
const BUTTON3_DOUBLE_CLICKED= NCURSES_MOUSE_MASK(3, NCURSES_DOUBLE_CLICKED) | ||
const REPORT_MOUSE_POSITION= NCURSES_MOUSE_MASK(6, 10) | ||
const ALL_MOUSE_EVENTS= REPORT_MOUSE_POSITION-1 | ||
|
||
# two useful methods which also show the proper use of | ||
# getmouse and mousemask | ||
|
||
function getmouse() | ||
me=MEVENT(1,0,0,0,0) | ||
getmouse(Ptr{MEVENT}(pointer_from_objref(me))) | ||
me | ||
end | ||
|
||
mousemask(x::Integer)=mousemask(UInt(x),Ptr{UInt}(C_NULL)) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters