Handle backword kill word event in REPL (#1861)

Closes #897
This commit is contained in:
Nitin Prakash 2024-05-22 17:31:01 +05:30 committed by GitHub
parent 82e8ac95ad
commit 92d3e74d40
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 7 additions and 1 deletions

View File

@ -40,7 +40,7 @@ module Swarm.TUI.Controller (
import Brick hiding (Direction, Location)
import Brick.Focus
import Brick.Widgets.Dialog
import Brick.Widgets.Edit (handleEditorEvent)
import Brick.Widgets.Edit (applyEdit, handleEditorEvent)
import Brick.Widgets.List (handleListEvent)
import Brick.Widgets.List qualified as BL
import Control.Applicative (liftA2, pure)
@ -66,6 +66,7 @@ import Data.String (fromString)
import Data.Text (Text)
import Data.Text qualified as T
import Data.Text.IO qualified as T
import Data.Text.Zipper.Generic.Words qualified as TZ
import Data.Time (getZonedTime)
import Data.Vector qualified as V
import Graphics.Vty qualified as V
@ -1198,6 +1199,8 @@ handleREPLEventTyping = \case
if text == T.empty
then toggleModal QuitModal
else continueWithoutRedraw
MetaKey V.KBS ->
uiState . uiGameplay . uiREPL . replPromptEditor %= applyEdit TZ.deletePrevWord
-- finally if none match pass the event to the editor
ev -> do
Brick.zoom (uiState . uiGameplay . uiREPL . replPromptEditor) (handleEditorEvent ev)

View File

@ -37,6 +37,9 @@ pattern MetaChar c = VtyEvent (V.EvKey (V.KChar c) [V.MMeta])
pattern ShiftKey :: V.Key -> BrickEvent n e
pattern ShiftKey k = VtyEvent (V.EvKey k [V.MShift])
pattern MetaKey :: V.Key -> BrickEvent n e
pattern MetaKey k = VtyEvent (V.EvKey k [V.MMeta])
pattern EscapeKey :: BrickEvent n e
pattern EscapeKey = VtyEvent (V.EvKey V.KEsc [])