dislpay the current key sequence
Ignore-this: 603951c76e406e726eaf6e00bfadba27 darcs-hash:20110804073522-c41ad-2420851c7dbcbb13b4952113ebec3a31565e6ead
This commit is contained in:
parent
37f984d15e
commit
05b2b2cf30
45
src/uTop.ml
45
src/uTop.ml
|
@ -42,9 +42,11 @@ let profile, set_profile = S.create Dark
|
||||||
|
|
||||||
let size = UTop_private.size
|
let size = UTop_private.size
|
||||||
|
|
||||||
|
let key_sequence = UTop_private.key_sequence
|
||||||
|
|
||||||
let count = UTop_private.count
|
let count = UTop_private.count
|
||||||
|
|
||||||
let make_prompt profile count size recording macro_count macro_counter =
|
let make_prompt profile count size key_sequence (recording, macro_count, macro_counter) =
|
||||||
let tm = Unix.localtime (Unix.time ()) in
|
let tm = Unix.localtime (Unix.time ()) in
|
||||||
let color dark light =
|
let color dark light =
|
||||||
match profile with
|
match profile with
|
||||||
|
@ -53,15 +55,28 @@ let make_prompt profile count size recording macro_count macro_counter =
|
||||||
in
|
in
|
||||||
let bold = profile = Dark in
|
let bold = profile = Dark in
|
||||||
let txta =
|
let txta =
|
||||||
eval [
|
if key_sequence = [] then
|
||||||
B_bold bold;
|
eval [
|
||||||
B_fg (color lcyan blue);
|
B_bold bold;
|
||||||
S "─( ";
|
B_fg (color lcyan blue);
|
||||||
B_fg (color lmagenta magenta); S (Printf.sprintf "%02d:%02d:%02d" tm.Unix.tm_hour tm.Unix.tm_min tm.Unix.tm_sec); E_fg;
|
S "─( ";
|
||||||
S " )─< ";
|
B_fg (color lmagenta magenta); S (Printf.sprintf "%02d:%02d:%02d" tm.Unix.tm_hour tm.Unix.tm_min tm.Unix.tm_sec); E_fg;
|
||||||
B_fg (color lyellow yellow); S (Printf.sprintf "command %d" count); E_fg;
|
S " )─< ";
|
||||||
S " >─";
|
B_fg (color lyellow yellow); S (Printf.sprintf "command %d" count); E_fg;
|
||||||
]
|
S " >─";
|
||||||
|
]
|
||||||
|
else
|
||||||
|
eval [
|
||||||
|
B_bold bold;
|
||||||
|
B_fg (color lcyan blue);
|
||||||
|
S "─( ";
|
||||||
|
B_fg (color lmagenta magenta); S (Printf.sprintf "%02d:%02d:%02d" tm.Unix.tm_hour tm.Unix.tm_min tm.Unix.tm_sec); E_fg;
|
||||||
|
S " )─< ";
|
||||||
|
B_fg (color lyellow yellow); S (Printf.sprintf "command %d" count); E_fg;
|
||||||
|
S " >─[ ";
|
||||||
|
B_fg (color lgreen green); S (String.concat " " (List.map LTerm_key.to_string_compact key_sequence)); E_fg;
|
||||||
|
S " ]─";
|
||||||
|
]
|
||||||
in
|
in
|
||||||
let txtb =
|
let txtb =
|
||||||
if recording then
|
if recording then
|
||||||
|
@ -97,13 +112,15 @@ let make_prompt profile count size recording macro_count macro_counter =
|
||||||
) [|(UChar.of_char '#', { none with foreground = Some (color lgreen green) }); (UChar.of_char ' ', none)|]
|
) [|(UChar.of_char '#', { none with foreground = Some (color lgreen green) }); (UChar.of_char ' ', none)|]
|
||||||
|
|
||||||
let prompt = ref (
|
let prompt = ref (
|
||||||
S.l6 make_prompt
|
S.l5 make_prompt
|
||||||
profile
|
profile
|
||||||
count
|
count
|
||||||
size
|
size
|
||||||
(Zed_macro.recording LTerm_read_line.macro)
|
key_sequence
|
||||||
(Zed_macro.count LTerm_read_line.macro)
|
(S.l3 (fun x y z -> (x, y, z))
|
||||||
(Zed_macro.counter LTerm_read_line.macro)
|
(Zed_macro.recording LTerm_read_line.macro)
|
||||||
|
(Zed_macro.count LTerm_read_line.macro)
|
||||||
|
(Zed_macro.counter LTerm_read_line.macro))
|
||||||
)
|
)
|
||||||
|
|
||||||
let prompt_continue = ref (S.map (fun profile -> [|(UChar.of_char '>', { none with foreground = Some (if profile = Dark then lgreen else green) }); (UChar.of_char ' ', LTerm_style.none)|]) profile)
|
let prompt_continue = ref (S.map (fun profile -> [|(UChar.of_char '>', { none with foreground = Some (if profile = Dark then lgreen else green) }); (UChar.of_char ' ', LTerm_style.none)|]) profile)
|
||||||
|
|
|
@ -33,6 +33,9 @@ val set_profile : profile -> unit
|
||||||
val size : LTerm_geom.size React.signal
|
val size : LTerm_geom.size React.signal
|
||||||
(** The current size of the terminal. *)
|
(** The current size of the terminal. *)
|
||||||
|
|
||||||
|
val key_sequence : LTerm_key.t list React.signal
|
||||||
|
(** The current key sequence entered by the user. *)
|
||||||
|
|
||||||
val prompt : LTerm_text.t React.signal ref
|
val prompt : LTerm_text.t React.signal ref
|
||||||
(** The current prompt.
|
(** The current prompt.
|
||||||
|
|
||||||
|
|
|
@ -435,6 +435,8 @@ object(self)
|
||||||
initializer
|
initializer
|
||||||
(* Set the source signal for the size of the terminal. *)
|
(* Set the source signal for the size of the terminal. *)
|
||||||
UTop_private.set_size self#size;
|
UTop_private.set_size self#size;
|
||||||
|
(* Set the source signal for the key sequence. *)
|
||||||
|
UTop_private.set_key_sequence self#key_sequence;
|
||||||
(* Set the prompt. *)
|
(* Set the prompt. *)
|
||||||
self#set_prompt prompt
|
self#set_prompt prompt
|
||||||
end
|
end
|
||||||
|
|
|
@ -13,4 +13,8 @@ let size, set_size =
|
||||||
let ev, set_size = E.create () in
|
let ev, set_size = E.create () in
|
||||||
(S.switch (S.const { LTerm_geom.rows = 0; LTerm_geom.cols = 0 }) ev, set_size)
|
(S.switch (S.const { LTerm_geom.rows = 0; LTerm_geom.cols = 0 }) ev, set_size)
|
||||||
|
|
||||||
|
let key_sequence, set_key_sequence =
|
||||||
|
let ev, set_key_sequence = E.create () in
|
||||||
|
(S.switch (S.const ([] : LTerm_key.t list)) ev, set_key_sequence)
|
||||||
|
|
||||||
let count, set_count = S.create(-1)
|
let count, set_count = S.create(-1)
|
||||||
|
|
Loading…
Reference in New Issue