From 3de29be96d6c5fac7b176bc313308501fba9a0e1 Mon Sep 17 00:00:00 2001 From: spy Date: Thu, 17 Mar 2022 21:47:19 +0000 Subject: [PATCH] basic visual buffer support --- core/__pycache__/buffer.cpython-310.pyc | Bin 454 -> 513 bytes core/__pycache__/cursor.cpython-310.pyc | Bin 934 -> 1139 bytes core/__pycache__/files.cpython-310.pyc | Bin 311 -> 318 bytes core/__pycache__/mode.cpython-310.pyc | Bin 497 -> 497 bytes core/__pycache__/statusbar.cpython-310.pyc | Bin 1024 -> 1024 bytes core/__pycache__/utils.cpython-310.pyc | Bin 929 -> 1280 bytes core/__pycache__/welcome.cpython-310.pyc | Bin 768 -> 768 bytes core/buffer.py | 12 +++--- core/cursor.py | 15 ++++++-- core/files.py | 6 +-- core/mode.py | 8 ++-- core/statusbar.py | 12 +++--- core/utils.py | 42 ++++++++++++++------- core/welcome.py | 8 ++-- lambda | 2 +- lambda.py | 22 +++++++---- modes/__pycache__/command.cpython-310.pyc | Bin 1335 -> 1335 bytes modes/__pycache__/insert.cpython-310.pyc | Bin 640 -> 640 bytes modes/__pycache__/normal.cpython-310.pyc | Bin 864 -> 882 bytes modes/command.py | 29 +++++++------- modes/insert.py | 10 ++--- modes/normal.py | 9 +++-- 22 files changed, 105 insertions(+), 70 deletions(-) diff --git a/core/__pycache__/buffer.cpython-310.pyc b/core/__pycache__/buffer.cpython-310.pyc index 5e606aabdfc50d0b957724ca56594b8af8ff06fd..db3cfc69c01a5a6a1af546abacde865e1efea723 100644 GIT binary patch delta 316 zcmYLDyGq1B6uoyciAgkK5p~yUD`7<}6l}NA*2Y2*B_z(o9gJC=%!)#SkHrsI_6L$m z1i!q#OvY(?$Yqp?LTT?-6e7uZbg!Ku7negdC+0N`+7)>^ijr7LG{!gf z<}LRf?eTnk&1J0k^lN+bLUNvK%3>93TjY%2X_|?gpSp!=Z{++9WH=k(V5f&G=;JOS YkMu{bwabWHHuR@u*s6b6oxS76FQeL0CjbBd delta 280 zcmZoPG(+e6i0ChNOxZ9N`@kV$yJQ@9xRMJj9iRH uK+N*DNC;#EQxV8-V0MuJh=m{of!tdhHo5sJr8%i~APb9GfCL8v4>JHiqCklN diff --git a/core/__pycache__/cursor.cpython-310.pyc b/core/__pycache__/cursor.cpython-310.pyc index 751bcf6fe19647918f1ec676ae82ccd171b7808b..d8c2dc1ff9e287e5b162953a62f98dba5ff7c6a2 100644 GIT binary patch literal 1139 zcmZ`&O>Yx15cS9IX44N;BB0r{LXkMol`4XYpglx@#66exlpdmF?Xs)vZc=*_+A5sF z4}l}%ANdNG`~@yB<4u}K2umK@Z)QC9^YdtTcZ)!4|9Ca{-wqV!0;7~h)ha@xa0V3_C{7@zJ?pRK#|N8vmC zLyileCFcyNLUIDMEFk-&u*3vpj)XlypGyLu=!|gEUdOtCd36FYr~l8_=woI6sm;%q z(E=&G054xvwj-=WB_Km?eap#%_3KD1hyb@t3b~YpToV?ZMNOlI*34E*7Xo@y58H5>dnp4z7?Jp32j!CcA{8D!(Le&A6_@W z9MV1dlGW%D^g~vsHP)at+Mo_ob#O;mebsP&uYx8lfI&K^pXrQzr88<3K~WLk@I&Hl zc}HzSoO%c*EO$iNP9^+BPe)41Tp fp43Kc>|=Md7x&ws_em<>B8eLDJ>ql!!Or8q@}S>T delta 549 zcmY+9%}&BV5XWbB`z0VG2nH&8@M3!KWK4`9-n?@0=7m7F2;rkL6{)DV%?i1OqKfmK!p8-ju0DtZ*bEO6HbN0V?OdGF&}qk z6b2IqV@-6zj?}4}1w)w%Zr^iQCackkU(PLM&r@)S zr~%s8zw;ax8$l=nSIUYK{9ht>i5<`%XcR0~<0)x5T$)O)=A`70FP)Iy&}xo-F&%jq O>izjZF$=6>q4W)f^Kq>J diff --git a/core/__pycache__/files.cpython-310.pyc b/core/__pycache__/files.cpython-310.pyc index b7fd14a5079bfb53d8a1ee5b6b82817117add6ac..0657b9d363a3edb53d95536a4f7ab02303f065a3 100644 GIT binary patch delta 115 zcmdnaw2z55pO=@50SHVN87E~-L19D0jY8aXs`*~{_YZw3TH@RU;)Br zW=4h@reFp`hGLO&Mn(n@j0EBuril}zIXTlZb5i5;5_2c6cN5?N8pOp2g#THX1pcuw JO=e^?0{~Rn7i0hc delta 108 zcmdnTw4I4JpO=@50SGJ;jgpck@_JfX068TLH4M#+{d~2IHH-@w7c$f`)i8xKFfpVs zumE8*Gb2MVgCRq)XgMPz0|-U}aSFr4K4}(~w9K4|o7{LffTnOUaxgM6s{EVG!Dt2m Datag# diff --git a/core/__pycache__/mode.cpython-310.pyc b/core/__pycache__/mode.cpython-310.pyc index 27c7be4845fc1ce938b56b1f3cd64d4540665aa4..389673589c6f5db7b0e767b85411f41062fda8d5 100644 GIT binary patch delta 30 kcmey!{E?YEpO=@50SKl|Gv3H;%gCBsl$x41*_Uw%0DNc&cK`qY delta 30 kcmey!{E?YEpO=@50SKO#>2Kt=Wn?W$DNZh$?8~?W0DvF}w*UYD diff --git a/core/__pycache__/statusbar.cpython-310.pyc b/core/__pycache__/statusbar.cpython-310.pyc index d9486d46233002776a010127a8905fc07a0e0ce9..259e5ab5fec3945660458eac20d3957502014e81 100644 GIT binary patch delta 40 ucmZqRXyD+@=jG*M0D}JujFZea@`f_ACKsiq=1op#wq|A$VxGK|IT`@QXbLO< delta 40 ucmZqRXyD+@=jG*M0D^hH43cCv@`f_AmZTIX7fnuQwq|A&Vw${^IT`@NxC$5m diff --git a/core/__pycache__/utils.cpython-310.pyc b/core/__pycache__/utils.cpython-310.pyc index 7a80db1771dcabee49520aca641198b4a0512825..060765b49cf3542f0fe75f613c16e400fee7cea9 100644 GIT binary patch literal 1280 zcma)*&2G~`5Xbk!cHA_fK#Q6pR9PIV`a%xePz6Yc3x^09RU)YZ>%H11rKKjD&XVn!WL9<_Fx-oI9EV?U}60dqp*+{j+!L4 z6;t$^L2Cz}H~5$ani;!b3-(dWIPepOR*=OgvQ>C}mGt_yaL*F3eGKULlpREqd=iSn zGqF}`SU3>b=oiyI2D^IN>}LbjG^4x;>T5HN2B#1;<4mjO*e0oYHp+`#tv+dG`rWf+ z2-#WJBvXY@m?2$z!jYO_#S+cUpf$xWRUhGkRL=yUT2w3#7&r~K$1J}P;4JvUA##|5 z+tM7puXvy-_$6&ZS$GkEvAXc$u{O#S)i_Ht-5o`V4yE?cNmtMmPMQo=nb^{7(aUO_ zsz`U~sE&I>M301ifYX0yM#`vGG#JR4Sk;Re$;Gv1N>|s&kl@R0G@+yEZ~7jY9W;fD zwTS!cdaat+O}*YoXM>S_h~Jci4}~xFBiya^1^tqWP!fKJ3yX}YC+6}Tb<&!81GUQr zn@f)LEwY~T&q5zqIcFT{|Lb*Kh3S4=xstoZI_)L6fKg78xd+Ihv zaIWj)F8gWy)MEAK*m?U5yt0b&*2`HC3-=BdmDaTKw%vZ;Ud?@3W}pwVS;Fw z2bgOZgx+T1WvYgH7oAH`t9UwFN^5N7f$42Ra?6ttzbX+`#UVf9zC=V%@LlK^(&VP( uy=*b!SjJzLggBO-D{<*U>henXCxZ;esd`E6YN$nP%*W`y@4LQV+xZJ=Chdg) literal 929 zcmZ{iUuzRV5Wx4}T`n=zqNP=Ya`+%U9~yk{rHFqJUn|77yvX%tNkT8Vbaqp{Z~>wH z5P}HJqkg1)^(kM$Cuc8dEQ$j=H*+&PyF0%rwzgV~wzV(>pgskn@U`IUofL zc+N(=$GNvfE_wnas7uz95I{&@1>!wR8cWJ%33p0=8rtK`SGksejEL47TILHW;Bx_D zE-QA$Dh~1i19hMIdgL`$-VU?;N`PAMh2re*%u3eLXcLtSHdmFh3Yr)ERNylkT(E!l z{r?1D^orK;Z1;7Z$Jrnq_qB;r)Uip=H5|_Nx;oACGCrFQ?aTO}j0=p%$x-aWfgbh; zcFE~s=+!SCyWryx>|l9|T*u2KbYTi$EV?k8qS3~+vLY|=!z3M|3;Nn-11Adv^nFVL z7a9vDL#H6MX)mbn;KB(OqltC$RF~fw-t}ia>I{mJ?wCp00e#-d)6of}ovc9Jnc87) z4kx8+^os&cO6@tAZBj}o{zUG}NVY{N4khl;&rFiK7H@BmU6KR55?|RjF&AqTf-p&f zrYcdR2sS7@(sk6zN?Z`&JqBT&B{x}W@dwYQ7BpyYw5q%wfc1_VPxE-zc-!s1>mJ4E zZ-_L%tDY~tJKH{(pf-eUT*lO+Bu4*a3`r#cHofgipckVl4fwdnb%fN8E@ P_=z#T)om70x%TdF8I!~Z diff --git a/core/__pycache__/welcome.cpython-310.pyc b/core/__pycache__/welcome.cpython-310.pyc index 600f4df1a573b05102684e90c5cd3acd348c4715..019a5b9ae25460e1603174301f109459e7457451 100644 GIT binary patch delta 30 kcmZo*YhdHf=jG*M0D@`Lj5l(NFtH{VrKaXhR$;mW0AW-Ig8%>k delta 30 kcmZo*YhdHf=jG*M00M<1qmA4mOspj-#mPmJRhaGo09L{V>i_@% diff --git a/core/buffer.py b/core/buffer.py index 8646d9c..20cc9c0 100644 --- a/core/buffer.py +++ b/core/buffer.py @@ -1,9 +1,9 @@ import curses -def write_buffer(stdscr, data): - count = 0 - for line in data["buffer_list"]: - str_line = "".join(line) - stdscr.addstr(count, len(data["info_bar"][0]), str_line + (" " * (len(line) - 1)), curses.color_pair(1)) - count += 1 +def write_buffer(screen, data): + for index, line in enumerate(data["buffer_list"][data["visible_y"]:]): + if index < data["height"] - 2: + str_line = "".join(line) + # [data["visible_x"]:1:data["width"] - data["visible_x"]] + screen.addstr(index, len(data["info_bar"][0]), str_line + (" " * (len(line) - 1)), curses.color_pair(1)) diff --git a/core/cursor.py b/core/cursor.py index 09dc967..e9cadeb 100644 --- a/core/cursor.py +++ b/core/cursor.py @@ -1,3 +1,6 @@ +from core import utils, buffer + + def cursor_mode(mode): if mode == "block": print("\033[2 q") @@ -13,9 +16,15 @@ def cursor_mode(mode): def check_cursor(data): - if data["cursor_y"] == len(data["buffer_list"]): + if data["cursor_y"] + data["visible_y"] == len(data["buffer_list"]): data["cursor_y"] -= 1 + if data["cursor_y"] == data["height"] - 2 and not data["cursor_y"] + data["visible_y"] == len(data["buffer_list"]): + data["visible_y"] += 1 + + elif data["cursor_y"] == 0 and data["buffer_list"][data["visible_y"]] != data["buffer_list"][0]: + data["visible_y"] -= 1 + elif data["cursor_x"] > len(data["buffer_list"][data["cursor_y"]]): data["cursor_x"] = len(data["buffer_list"][data["cursor_y"]]) @@ -27,9 +36,9 @@ def check_cursor(data): return data -def move(stdscr, data): +def move(screen, data): # Calculate a valid cursor position from data data = check_cursor(data) # Move the cursor - stdscr.move(data["cursor_y"], data["cursor_x"]) + screen.move(data["cursor_y"], data["cursor_x"]) diff --git a/core/files.py b/core/files.py index 599a755..d9b60f1 100644 --- a/core/files.py +++ b/core/files.py @@ -1,4 +1,4 @@ -def open_file(file): - with open(file) as f: +def open_file(file_name): + with open(file_name) as f: lines = f.readlines() - return lines + return lines diff --git a/core/mode.py b/core/mode.py index 918464a..55456c1 100644 --- a/core/mode.py +++ b/core/mode.py @@ -1,17 +1,17 @@ from modes import normal, insert, command -def activate(stdscr, data): +def activate(screen, data): if data["mode"] == "normal": data["mode_color"] = 6 - data = normal.activate(stdscr, data) + data = normal.activate(screen, data) elif data["mode"] == "insert": data["mode_color"] = 12 - data = insert.activate(stdscr, data) + data = insert.activate(screen, data) elif data["mode"] == "command": data["mode_color"] = 6 - data = command.activate(stdscr, data) + data = command.activate(screen, data) return data diff --git a/core/statusbar.py b/core/statusbar.py index 53e1da1..6c9ae46 100644 --- a/core/statusbar.py +++ b/core/statusbar.py @@ -23,21 +23,23 @@ def themes(data): return colors, icon, mode, file -def refresh(stdscr, data): +def refresh(screen, data): + # Calculate the theme colors, icon, mode, file = themes(data) + # Render icon - stdscr.addstr(data["height"] - 2, 0, icon, + screen.addstr(data["height"] - 2, 0, icon, curses.color_pair(colors[0]) | curses.A_BOLD) # Render mode - stdscr.addstr(data["height"] - 2, len(icon), mode, + screen.addstr(data["height"] - 2, len(icon), mode, curses.color_pair(colors[1]) | curses.A_BOLD) # Render file name - stdscr.addstr(data["height"] - 2, len(icon) + len(mode), file, + screen.addstr(data["height"] - 2, len(icon) + len(mode), file, curses.color_pair(colors[2]) | curses.A_BOLD) # Rest of the bar - stdscr.addstr(data["height"] - 2, len(icon) + len(mode) + len(file), + screen.addstr(data["height"] - 2, len(icon) + len(mode) + len(file), " " * (data["width"] - (len(icon) + len(mode) + len(file))), curses.color_pair(colors[3])) diff --git a/core/utils.py b/core/utils.py index 5470687..00367e1 100644 --- a/core/utils.py +++ b/core/utils.py @@ -2,36 +2,50 @@ from sys import exit import curses -def goodbye(stdscr, data): - # The prompt message - saved = "All changes are saved." - prompt = "Really quit? (y or n): " +def refresh_window_size(screen, data): + # Get the height and width of the screen + data["height"], data["width"] = screen.getmaxyx() - # Clear the bottom line - stdscr.addstr(data["height"] - 1, 0, " " * (data["width"] - 1), curses.color_pair(1)) + # Return the data as changes may have been made + return data + +def clear_line(screen, data, line): + # Clear the specified line + screen.addstr(line, 0, " " * (data["width"] - 1), curses.color_pair(1)) + + +def prompt(screen, data, text): # Print the prompt - stdscr.addstr(data["height"] - 1, 0, prompt, curses.color_pair(11)) + screen.addstr(data["height"] - 1, 0, text, curses.color_pair(11)) # Wait for and capture a key press from the user - key = stdscr.getch() + return screen.getch() + + +def goodbye(screen, data): + # Create a goodbye prompt + key = prompt(screen, data, "Really quit? (y or n): ") + + # Clear the bottom line + clear_line(screen, data, data["height"] - 1) if key == ord("y"): # Only exit if the key was "y", a confirmation exit() # Clear the bottom line again - stdscr.addstr(data["height"] - 1, 0, " " * (data["width"] - 1), curses.color_pair(1)) + clear_line(screen, data, data["height"] - 1) -def error(stdscr, data, error_msg): +def error(screen, data, error_msg): # Print the error message to the bottom line error_msg = f"ERROR: {error_msg}" - stdscr.addstr(data["height"] - 1, 0, error_msg, curses.color_pair(3)) - stdscr.addstr(data["height"] - 1, len(error_msg) + 1, "(press any key) ", curses.color_pair(1)) + screen.addstr(data["height"] - 1, 0, error_msg, curses.color_pair(3)) + screen.addstr(data["height"] - 1, len(error_msg) + 1, "(press any key) ", curses.color_pair(1)) # Wait for a key to be pressed - stdscr.getch() + screen.getch() # Clear the bottom line - stdscr.addstr(data["height"] - 1, 0, " " * (data["width"] - 1), curses.color_pair(1)) + clear_line(screen, data, data["height"] - 1) diff --git a/core/welcome.py b/core/welcome.py index e12ae98..3bc814f 100644 --- a/core/welcome.py +++ b/core/welcome.py @@ -1,9 +1,9 @@ import curses -def start_screen(stdscr): +def start_screen(screen): # Get window height and width - height, width = stdscr.getmaxyx() + height, width = screen.getmaxyx() # Startup text title = "λ Lambda" @@ -20,10 +20,10 @@ def start_screen(stdscr): start_y = int((height // 2) - 2) # Rendering title - stdscr.addstr(start_y, start_x_title, title, curses.color_pair(7) | curses.A_BOLD) + screen.addstr(start_y, start_x_title, title, curses.color_pair(7) | curses.A_BOLD) # Print the subtext for text in subtext: start_y += 1 start_x = int((width // 2) - (len(text) // 2) - len(text) % 2) - stdscr.addstr(start_y, start_x, text) + screen.addstr(start_y, start_x, text) diff --git a/lambda b/lambda index 6f03d04..8494e3f 100755 --- a/lambda +++ b/lambda @@ -1,3 +1,3 @@ #!/bin/sh -python3 ./lambda.py $@ +python3 ./lambda.py "$@" diff --git a/lambda.py b/lambda.py index 3e1f1ed..233e95c 100755 --- a/lambda.py +++ b/lambda.py @@ -4,7 +4,7 @@ import curses import argparse -def start(stdscr, buffer_name, buffer_list): +def start(screen, buffer_name, buffer_list): # Initialise data before starting data = { "cursor_y": 0, @@ -16,6 +16,8 @@ def start(stdscr, buffer_name, buffer_list): "info_bar": [" "], "buffer_name": buffer_name, "buffer_list": buffer_list, + "visible_y": 0, + "visible_x": 0, "statusbar_theme": "filled" } @@ -27,22 +29,28 @@ def start(stdscr, buffer_name, buffer_list): # Start the screen if data["buffer_name"] == "[No Name]": - welcome.start_screen(stdscr) + welcome.start_screen(screen) # Main loop while True: # Get the height and width of the screen - data["height"], data["width"] = stdscr.getmaxyx() + data["height"], data["width"] = screen.getmaxyx() # Write the buffer to the screen - buffer.write_buffer(stdscr, data) + buffer.write_buffer(screen, data) # Activate the next mode - data = mode.activate(stdscr, data) + data = mode.activate(screen, data) + + # Write the buffer to the screen + buffer.write_buffer(screen, data) # Refresh and clear the screen - stdscr.refresh() - stdscr.clear() + screen.refresh() + screen.clear() + + # Write the buffer to the screen + buffer.write_buffer(screen, data) def main(): diff --git a/modes/__pycache__/command.cpython-310.pyc b/modes/__pycache__/command.cpython-310.pyc index 474b6b80d223968703cec63fa380beeefc433f2e..365f3f38934f43ae0def6acbff81139fe52b3112 100644 GIT binary patch delta 52 zcmdnawVjJMpO=@50SKl|Gfvtuk+++vhH>JoORUL7si}FB3mLN*nKs{HJkG?ZIC%-n HBt{tkoK_Gj delta 52 zcmdnawVjJMpO=@50SK-h)=!!?k++*Eg<;~XOROa+#mPmJ3mLN*88_cyJkG?ZFnI~f HBt~ffrVtQk diff --git a/modes/__pycache__/insert.cpython-310.pyc b/modes/__pycache__/insert.cpython-310.pyc index 80f41fa63f17d18bbfa781d076295f05fcd195d7..8e3c4c6a190265f02f866d74cf3f3465ac177bf8 100644 GIT binary patch delta 30 kcmZo*ZD8fj=jG*M0D@`Lj5l)MXJkz-N=?n1{GM?l0BorU$^ZZW delta 30 kcmZo*ZD8fj=jG*M0D|M)`Ww0LGqRSX6ekx=e$O}&0B?~9{{R30 diff --git a/modes/__pycache__/normal.cpython-310.pyc b/modes/__pycache__/normal.cpython-310.pyc index 2b0aad60754756021360352d50a0faef0ecce98c..cc97c67cfeda6051a8a24e8ba040373bd53366c2 100644 GIT binary patch delta 143 zcmaFB_KA%*pO=@50SJz-HcnbRkylnv2gpfbNMX!j$YqRT%w>vVVg&J-a+sr-QifHZ3g)5HKdM!$`DlNlLVCo?f!VofeeP0gEplS!FTZSr3xNhwXXTP(@> mMX5zhKx2!Tfy6Dg;4n_`U9z_6!X&}!4 delta 144 zcmeyw_JEBypO=@50SGF143nl#av7r-bD5%;7#UKSQkYv9qL@=y zQdogBOA6b>2)T{rlNlLVCUY}gVl7E2PA;1Kh)G#j6{x$I2T1TR@i22Sa{w_5Q;{4{ jz)zF)7E5w|QECwrkXOVEBqm!j>vFLH83GI(%sh$!X*3$A diff --git a/modes/command.py b/modes/command.py index 0dd0c51..a85f827 100644 --- a/modes/command.py +++ b/modes/command.py @@ -2,10 +2,10 @@ from core import statusbar, utils import curses -def execute(stdscr, data, commands): +def execute(screen, data, commands): if not commands: # Quit if there are no commands, don't check anything - return + return data for command in commands: if command == "w": @@ -14,9 +14,10 @@ def execute(stdscr, data, commands): elif command == "q": # Goodbye prompt - utils.goodbye(stdscr, data) + utils.goodbye(screen, data) elif command == "t": + # Theme switcher if data["statusbar_theme"] == "filled": data["statusbar_theme"] = "bare" @@ -24,29 +25,29 @@ def execute(stdscr, data, commands): data["statusbar_theme"] = "filled" else: - utils.error(stdscr, data, f"Not an editor command: '{command}'") + utils.error(screen, data, f"Not an editor command: '{command}'") return data -def activate(stdscr, data): +def activate(screen, data): # Initialise variables commands = [] # Visibly switch to command mode - statusbar.refresh(stdscr, data) - stdscr.addstr(data["height"]-1, 0, ":") - stdscr.move(data["height"]-1, 1) + statusbar.refresh(screen, data) + screen.addstr(data["height"]-1, 0, ":") + screen.move(data["height"]-1, 1) # Main loop while True: # Get a key inputted by the user - key = stdscr.getch() + key = screen.getch() # Handle subtracting a key (backspace) if key == curses.KEY_BACKSPACE: # Write whitespace over characters to refresh it - stdscr.addstr(data["height"]-1, 1, " " * len(commands)) + screen.addstr(data["height"]-1, 1, " " * len(commands)) if commands: # Subtract a character @@ -63,10 +64,10 @@ def activate(stdscr, data): elif key in (curses.KEY_ENTER, ord('\n'), ord('\r'), ord(":"), ord(";")): # Execute commands - data = execute(stdscr, data, commands) + data = execute(screen, data, commands) # Clear the bottom bar - stdscr.addstr(data["height"] - 1, 0, " " * (data["width"] - 1)) + screen.addstr(data["height"] - 1, 0, " " * (data["width"] - 1)) # Return to normal mode after executing a command data["mode"] = "normal" @@ -83,7 +84,7 @@ def activate(stdscr, data): friendly_command = "".join(commands) # Write the commands to the screen - stdscr.addstr(data["height"]-1, 1, friendly_command) + screen.addstr(data["height"]-1, 1, friendly_command) # Move the cursor the end of the commands - stdscr.move(data["height"]-1, len(commands)+1) + screen.move(data["height"]-1, len(commands)+1) diff --git a/modes/insert.py b/modes/insert.py index 41e2458..71f4252 100644 --- a/modes/insert.py +++ b/modes/insert.py @@ -5,22 +5,22 @@ def execute(data, key): return data -def activate(stdscr, data): +def activate(screen, data): # Refresh the status bar with a different colour for insert data["statusbar_colors"] = [8, 12, 14, 2] - statusbar.refresh(stdscr, data) + statusbar.refresh(screen, data) # Refresh the status bar - statusbar.refresh(stdscr, data) + statusbar.refresh(screen, data) # Move the cursor - cursor.move(stdscr, data) + cursor.move(screen, data) # Switch to a line cursor cursor.cursor_mode("line") # Wait for and capture a key press from the user - key = stdscr.getch() + key = screen.getch() # Exit insert mode if key == 27: diff --git a/modes/normal.py b/modes/normal.py index 0bfedbc..b727a59 100644 --- a/modes/normal.py +++ b/modes/normal.py @@ -1,4 +1,5 @@ from core import statusbar, cursor +import curses def execute(data, key): @@ -34,18 +35,18 @@ def execute(data, key): return data -def activate(stdscr, data): +def activate(screen, data): # Refresh the status bar - statusbar.refresh(stdscr, data) + statusbar.refresh(screen, data) # Move the cursor - cursor.move(stdscr, data) + cursor.move(screen, data) # Switch the cursor to a block cursor.cursor_mode("block") # Wait for and capture a key press from the user - key = stdscr.getch() + key = screen.getch() # Check against the keybindings data = execute(data, key)