@@ -35,6 +35,40 @@ import {
3535import { useInput } from "./use-input.ts" ;
3636import { useStdin } from "./use-stdin.ts" ;
3737
38+ const active = rgba ( 60 , 120 , 220 ) ;
39+ const inactive = rgba ( 50 , 50 , 60 ) ;
40+ const on = rgba ( 40 , 180 , 80 ) ;
41+ const label = rgba ( 220 , 220 , 220 ) ;
42+ const dim = rgba ( 100 , 100 , 120 ) ;
43+ const highlight = rgba ( 255 , 220 , 80 ) ;
44+
45+ const KEY_W = 5 ;
46+ const GAP = 1 ;
47+ const hovered = rgba ( 80 , 80 , 100 ) ;
48+
49+ const flagNames :
50+ ( keyof Omit < AppContext , "mode" | "event" | "logged" | "log" | "entered" > ) [ ] = [
51+ "Disambiguate escape codes" ,
52+ "Report event types" ,
53+ "Report alternate keys" ,
54+ "Report all keys as escapes" ,
55+ "Report associated text" ,
56+ ] ;
57+
58+ const logEntries : { key : string ; name : keyof EventFilter } [ ] = [
59+ { key : "a" , name : "keydown" } ,
60+ { key : "b" , name : "keyup" } ,
61+ { key : "c" , name : "keyrepeat" } ,
62+ { key : "d" , name : "mousedown" } ,
63+ { key : "e" , name : "mouseup" } ,
64+ { key : "f" , name : "mousemove" } ,
65+ { key : "g" , name : "wheel" } ,
66+ { key : "h" , name : "resize" } ,
67+ { key : "i" , name : "pointerenter" } ,
68+ { key : "j" , name : "pointerleave" } ,
69+ { key : "k" , name : "pointerclick" } ,
70+ ] ;
71+
3872await main ( function * ( ) {
3973 let { columns, rows } = terminalSize ( ) ;
4074
@@ -164,16 +198,6 @@ function updateFlagsIfChanged(current: Setting, next: Setting): Setting {
164198 return next ;
165199}
166200
167- const active = rgba ( 60 , 120 , 220 ) ;
168- const inactive = rgba ( 50 , 50 , 60 ) ;
169- const on = rgba ( 40 , 180 , 80 ) ;
170- const label = rgba ( 220 , 220 , 220 ) ;
171- const dim = rgba ( 100 , 100 , 120 ) ;
172- const highlight = rgba ( 255 , 220 , 80 ) ;
173-
174- const KEY_W = 5 ;
175- const GAP = 1 ;
176-
177201interface KeyDef {
178202 label : string ;
179203 code : string ;
@@ -189,8 +213,6 @@ function matches(k: KeyDef, event: InputEvent | PointerEvent): boolean {
189213 event . code . toUpperCase ( ) === k . code . toUpperCase ( ) ;
190214}
191215
192- const hovered = rgba ( 80 , 80 , 100 ) ;
193-
194216function key ( ops : Op [ ] , k : KeyDef , ctx : AppContext ) : void {
195217 let pressed = ctx . event && matches ( k , ctx . event ) ;
196218 let hover = ctx . entered . has ( `key:${ k . code } ` ) ;
@@ -459,30 +481,6 @@ function toggle(ops: Op[], enabled: boolean, name: string): void {
459481 ) ;
460482}
461483
462- const flagNames :
463- ( keyof Omit < AppContext , "mode" | "event" | "logged" | "log" | "entered" > ) [ ] =
464- [
465- "Disambiguate escape codes" ,
466- "Report event types" ,
467- "Report alternate keys" ,
468- "Report all keys as escapes" ,
469- "Report associated text" ,
470- ] ;
471-
472- const logEntries : { key : string ; name : keyof EventFilter } [ ] = [
473- { key : "a" , name : "keydown" } ,
474- { key : "b" , name : "keyup" } ,
475- { key : "c" , name : "keyrepeat" } ,
476- { key : "d" , name : "mousedown" } ,
477- { key : "e" , name : "mouseup" } ,
478- { key : "f" , name : "mousemove" } ,
479- { key : "g" , name : "wheel" } ,
480- { key : "h" , name : "resize" } ,
481- { key : "i" , name : "pointerenter" } ,
482- { key : "j" , name : "pointerleave" } ,
483- { key : "k" , name : "pointerclick" } ,
484- ] ;
485-
486484function logToggle (
487485 ops : Op [ ] ,
488486 entries : typeof logEntries ,
0 commit comments