History

Barbaric method to make arrowless keyboards usable

Or non QWERTY layouts. I tried to think of a way to make that neat and configurable, i really did, but...

malc committed 5 years ago

Commit 33ca8001 parent 8634d204 files · +23 −2Browse files

Unified · Split

4 files
  1. main.ml +15 −0
  2. wsi.mli +2 −0
  3. wsi/cocoa/wsi.ml +1 −0
  4. wsi/x11/wsi.ml +5 −2
main.ml+15−0
@@ -616,6 +616,20 @@ let layoutready layout = · 615 unmodified lines
616616 alltilesvisible;
617617 ;;
618618
619+let mapc code =
620+ let viewmapcode = function
621+ (* remap some key codes to arrows in view mode *)
622+ | 44 -> 113
623+ | 45 -> 116
624+ | 46 -> 111
625+ | 47 -> 114
626+ | n -> n
627+ in
628+ match state.mode with
629+ | View -> viewmapcode code
630+ | LinkNav _ | Textentry _ | Birdseye _ -> code
631+;;
632+
619633 let gotoxy x y =
620634 let y = bound y 0 state.maxy in
621635 let y, layout =
@@ -5052,6 +5066,7 @@ let () = · 4430 unmodified lines
50525066 display ();
50535067 Wsi.mapwin ();
50545068 Wsi.setcursor Wsi.CURSOR_INHERIT;
5069+ Wsi.setmapc mapc;
50555070 Sys.set_signal Sys.sighup (Sys.Signal_handle (fun _ -> reload ()));
50565071
50575072 let rec reap () =
wsi.mli+2−0
@@ -38,8 +38,10 @@ class type t = · 37 unmodified lines
3838 method opendoc : string -> unit
3939 end;;
4040
41+type keycode = int;;
4142 val setcursor : cursor -> unit;;
4243 val settitle : string -> unit;;
44+val setmapc : (keycode -> keycode) -> unit;;
4345 val swapb : unit -> unit;;
4446 val readresp : Unix.file_descr -> unit;;
4547 val init : t -> int -> int -> Unix.file_descr * int * int;;
wsi/cocoa/wsi.ml+1−0
@@ -312,3 +312,4 @@ let ks2kt = · 311 unmodified lines
312312 | code when code land 0xff00 = 0xff00 -> Ctrl code
313313 | code -> Code code
314314
315+let setmapc = ignore
wsi/x11/wsi.ml+5−2
@@ -101,11 +101,12 @@ type state = · 100 unmodified lines
101101 ; mutable levl5mask : int
102102 ; mutable xkb : bool
103103 ; mutable fscale : float
104+ ; mutable mapc : keycode -> keycode
104105 }
105106 and fs =
106107 | NoFs
107108 | Fs of (int * int * int * int)
108−;;
109+and keycode = int;;
109110
110111 let state =
111112 { mink = max_int
@@ -140,6 +141,7 @@ let state = · 28 unmodified lines
140141 ; levl5mask = 0
141142 ; xkb = false
142143 ; fscale = 1.0
144+ ; mapc = Fun.id
143145 }
144146 ;;
145147
@@ -484,7 +486,7 @@ let readresp sock = · 338 unmodified lines
484486 | 2 -> (* key press *)
485487 if Array.length state.keymap > 0
486488 then
487− let code = r8 resp 1 in
489+ let code = r8 resp 1 |> state.mapc in
488490 let mask = r16 resp 28 in
489491 let keysym = getkeysym code mask in
490492 vlog "keysym = %x %c mask %#x code %d"
@@ -1289,3 +1291,4 @@ let ks2kt = · 798 unmodified lines
12891291 ;;
12901292
12911293 let fontsizescale n = float n *. state.fscale |> truncate;;
1294+let setmapc f = state.mapc <- f;;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t