-
Notifications
You must be signed in to change notification settings - Fork 53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make REPLPanel not blink when it is not selected #801
Conversation
xsebek
commented
Oct 29, 2022
•
edited
Loading
edited
- closes REPL cursor should stop blinking when focus is elsewhere #776
@byorgey and @kostmo, feel free to have a look. 🙂 I would in particular be interested in better naming and further refactoring. I might have introduced some bugs while porting the code from EDIT1: EDIT2: |
I mean, this was just awful.
-- computed values. (Note that `it{n}` variables are set in the | ||
-- base robot context; we only set `it` here because it's so transient) | ||
topContext :: AppState -> RobotContext | ||
topContext s = ctxPossiblyWithIt |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just moved this from controller to model, where it belongs. 😉
I have no idea if it is right, but at least I can fix it in one place.
Co-authored-by: Restyled.io <commits@restyled.io>
Everything seems to work, except that #750 introduced the ability to click in the middle of the REPL input to move the cursor there (#470) and that no longer seems to do anything. I'm still going to go through the code carefully but just wanted to note that regression first. EDIT: I think the reason clicking on the REPL input no longer works is that we had |
Completion also seems to be broken. Once you complete something, the completion queue persists even when you erase what you were typing and type something else. For example, try typing |
Thanks, @byorgey! I was not even aware that clicking worked in REPL, I guess that is the only reason we need I wish we had some mock tests for this, that would make finding that bug faster. 😩 |
@byorgey should be fixed now 😉 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is looking great. I still think clicking in the REPL is not perfect, and I hope it is easy to fix, but I haven't tried yet. If you're sick of this and just want to merge I can play with it in a separate PR. 😄
src/Swarm/TUI/Controller.hs
Outdated
@@ -282,7 +282,7 @@ handleMainEvent ev = do | |||
WorldPanel -> do | |||
mouseCoordsM <- Brick.zoom gameState (mouseLocToWorldCoords mouseLoc) | |||
uiState . uiWorldCursor .= mouseCoordsM | |||
REPLInput -> handleREPLEvent ev | |||
REPLPanel -> handleREPLEvent ev |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So this still isn't a perfect solution: now, clicking anywhere on the entire REPL panel can cause the cursor to jump around inside the input. To see this, type some long input, click on a different panel, and then click somewhere inside the REPL panel on the left side, but not on the line of input. The cursor will jump to somewhere in the middle of the input --- and the position where it jumps doesn't even correspond exactly with the x-coordinate of where you click.
I was thinking of keeping REPLInput
and simply wrapping the REPL editor widget in clickable REPLInput
--- does that not work?
src/Swarm/TUI/View.hs
Outdated
replEditor = repl ^. replPromptEditor | ||
color = if repl ^. replValid then id else withAttr redAttr | ||
ps1 = replPromptAsWidget (T.concat $ getEditContents replEditor) prompt | ||
replE = withFocusRing focus (renderEditor (color . vBox . map txt)) replEditor |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
replE = withFocusRing focus (renderEditor (color . vBox . map txt)) replEditor | |
replE = clickable REPLInput (withFocusRing focus (renderEditor (color . vBox . map txt)) replEditor) |
Like this, maybe?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems to work with my fix, so this may be unnecessary. 🙂
@byorgey I am indeed quite tired of this but it all seems to work now. 🤞 If you find the clicking does not work as expected, then feel free to improve it in another PR. 🙂 |
Ensure that focus changes to the REPL panel also when clicking on the REPL input itself. Cleaning up a small leftover issue from #801.