File tree Expand file tree Collapse file tree 2 files changed +25
-4
lines changed
Expand file tree Collapse file tree 2 files changed +25
-4
lines changed Original file line number Diff line number Diff line change 1+ Stty = {}
2+
3+ function Stty .enableRawMode ()
4+ os.execute (" /bin/stty raw" )
5+ end
6+
7+ function Stty .disableRawMode ()
8+ os.execute (" /bin/stty sane" )
9+ end
10+
11+ function Stty .disableEcho ()
12+ os.execute (" /bin/stty -echo" )
13+ end
14+
15+ function Stty .enableEcho ()
16+ os.execute (" /bin/stty echo" )
17+ end
18+
19+ return Stty
Original file line number Diff line number Diff line change 1+ local stty = require (" lib/stty" )
2+
13Term = {}
24Term .internalInputBuffer = " "
35Term .internalOutputBuffer = " "
145147--- This will disable echo and line buffering
146148--- It will also switch to the alternate screen buffer
147149function Term .enterRawMode ()
148- os.execute ( " /bin/stty raw " )
149- os.execute ( " /bin/stty -echo " )
150+ stty . enableRawMode ( )
151+ stty . disableEcho ( )
150152 io.write (" \27 [?1049h" )
151153 io.flush ()
152154end
157159function Term .leaveRawMode ()
158160 io.write (" \27 [?1049l" )
159161 io.flush ()
160- os.execute ( " /bin/stty echo " )
161- os.execute ( " /bin/stty sane " )
162+ stty . enableEcho ( )
163+ stty . disableRawMode ( )
162164end
163165
164166--- Requests the cursor position from the terminal.
You can’t perform that action at this time.
0 commit comments