diff options
author | Marc Coquand <marc@mccd.space> | 2024-05-18 11:18:52 -0500 |
---|---|---|
committer | Marc Coquand <marc@mccd.space> | 2024-05-18 11:18:52 -0500 |
commit | 12ba5ed258b3a1ff30c3ece030e8eeed0dc417e9 (patch) | |
tree | bd5ec1905891dd947e329c1205978f0cc1161ec0 /lib | |
parent | b2c2fda8005b3e20669e7f87f5ee7d1372de4c7b (diff) | |
download | stitch-12ba5ed258b3a1ff30c3ece030e8eeed0dc417e9.tar.gz stitch-12ba5ed258b3a1ff30c3ece030e8eeed0dc417e9.tar.bz2 stitch-12ba5ed258b3a1ff30c3ece030e8eeed0dc417e9.zip |
Prompt: Fix visual
Diffstat (limited to 'lib')
-rw-r--r-- | lib/done.ml | 2 | ||||
-rw-r--r-- | lib/headlines.ml | 2 | ||||
-rw-r--r-- | lib/input_prompt.ml | 16 | ||||
-rw-r--r-- | lib/stitched_article.ml | 2 | ||||
-rw-r--r-- | lib/todos.ml | 2 |
5 files changed, 15 insertions, 9 deletions
diff --git a/lib/done.ml b/lib/done.ml index a7bfd61..acec094 100644 --- a/lib/done.ml +++ b/lib/done.ml @@ -80,7 +80,7 @@ let rec render let (input_state : Input_prompt.state) = { screen = img ; user_input = "" - ; prompt = "REGEXP: " + ; prompt = "REGEXP" ; on_enter = (fun tag -> let content = Grep.get_tagged_done tag () |> Grep.parse_todo_string in diff --git a/lib/headlines.ml b/lib/headlines.ml index ea6664f..4f905fd 100644 --- a/lib/headlines.ml +++ b/lib/headlines.ml @@ -104,7 +104,7 @@ let rec render let (input_state : Input_prompt.state) = { screen = img ; user_input = "" - ; prompt = "REGEXP: " + ; prompt = "REGEXP" ; on_enter = (fun tag -> let content = Grep.get_tagged_headlines tag () |> Grep.parse_headlines in diff --git a/lib/input_prompt.ml b/lib/input_prompt.ml index 45979aa..aec6021 100644 --- a/lib/input_prompt.ml +++ b/lib/input_prompt.ml @@ -10,16 +10,22 @@ type state = ; screen : I.t } -let rec render t ({ user_input; on_enter; on_cancel; screen; prompt } as state) = - let _, size_y = Common.Term.size t in - Common.Term.cursor t (Some (String.length user_input + String.length prompt, size_y)); +let rec render t ({ user_input; on_enter; on_cancel; prompt; screen } as state) = + let size_x, size_y = Common.Term.size t in + Common.Term.cursor + t + (Some (String.length user_input + String.length prompt + 3, size_y)); let img = let open I in - I.strf "%s%s" prompt user_input |> I.pad ~l:0 ~t:(size_y - 1) </> screen + I.strf " %s " ~attr:(A.st A.reverse) prompt + <|> I.strf " %s%s" user_input (String.make size_x ' ') + |> I.pad ~l:0 ~t:(size_y - 1) + </> screen in Common.Term.image t img; match Common.Term.event t with - | `End | `Key (`ASCII 'G', [ `Ctrl ]) | `Key (`ASCII 'C', [ `Ctrl ]) -> on_cancel () + | `End | `Key (`Escape, []) | `Key (`ASCII 'G', [ `Ctrl ]) | `Key (`ASCII 'C', [ `Ctrl ]) + -> on_cancel () | `Key (`Enter, []) -> on_enter user_input | `Key (`Backspace, []) -> if String.equal "" user_input diff --git a/lib/stitched_article.ml b/lib/stitched_article.ml index d512b39..e6c8f0f 100644 --- a/lib/stitched_article.ml +++ b/lib/stitched_article.ml @@ -61,7 +61,7 @@ let rec render let (input_state : Input_prompt.state) = { screen = img ; user_input = "" - ; prompt = "REGEXP: " + ; prompt = "REGEXP" ; on_enter = (fun tag -> try diff --git a/lib/todos.ml b/lib/todos.ml index e5b0084..51b878f 100644 --- a/lib/todos.ml +++ b/lib/todos.ml @@ -92,7 +92,7 @@ let rec render let (input_state : Input_prompt.state) = { screen = img ; user_input = "" - ; prompt = "REGEXP: " + ; prompt = "REGEXP" ; on_enter = (fun tag -> let content = Grep.get_tagged_todo tag () |> Grep.parse_todo_string in |