#Weirdness with Termion

4 messages · Page 1 of 1 (latest)

lean maple
#

I'm not fully sure how to describe the issue but I'll try my best.

I'm trying to make a small modal text editor but I'm running into an issue where the functions are not correctly running.

main.rs: https://pastebin.com/KbhcSrbs
display.rs: https://pastebin.com/SgcNhibe
footer.rs: https://pastebin.com/FRQ7pVFz
run.rs: https://pastebin.com/S4Nb26rb

In the DisplayableFile there seems to be a disconnect of file.mode. Whenever you change the mode from Insert to Normal, the footer updates accordingly. However, it still seems to run the code that runs when you're in Insert mode despite visually being in Normal mode.

Does anyone have any ideas on what's going on / how to fix this?

fickle crest
#

all your mode run functions do for c in stdin.keys() { and there is nothing that tells them to exit that loop when the mode changes

#

I would suggest that you have one main loop which reads keys, and dispatches them individually to the current mode