Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/hop/blob/main/Linux/main.om # hop Hop: a small native macOS launcher. Clipboard history, find, on-device dictation and your coding agent behind one key. Brought by drakestapleton Sign in to star 1 stars 1 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `hop / Linux / main.om` 205 lines ยท 4448 bytes Raw Blame History 1 note Hop's Linux entrypoint and shared UI and command actions. 2 text hm_help "Hop for Linux\n\nOpen Hop to find and launch your applications. Type find followed by words from a filename to search your file list. Type ask followed by a question to use a model you configured.\n\nCommands:\n hop Open the launcher\n hop --search TEXT Print matching application names\n hop --open TEXT Open the first matching application\n hop --find TEXT Print matching file paths as JSON\n hop --reindex [ROOT] Rebuild the file list\n hop --selftest Check the search helper\n hop --version Show the Linux edition\n hop --help Show this help\n\nAsk settings: HOP_MODEL_URL and HOP_MODEL; HOP_API_KEY is optional.\nThis edition needs a local X11 desktop or XWayland. Clipboard history, saved accounts and voice are not available yet.\n" 3 text hm_ver "Hop Linux development edition\n" 4 text hm_search "--search" 5 text hm_open "--open" 6 text hm_test "--selftest" 7 text hm_version "--version" 8 text hm_dashhelp "--help" 9 text hm_plainhelp "help" 10 text hm_reindex "--reindex" 11 text hm_find "--find" 12 text hm_badarg "Hop could not understand that command. Run hop --help.\n" 13 text hm_ok "PASS Linux search helper\n" 14 text hm_no "FAIL Linux search helper\n" 15 global hm_wrap uchar * 16 global hm_mode ulong 1 17 18 fn hop_query to void 19 if ne ff_query 0 20 put hm_mode 0 2 21 ret 22 end 23 if ne hc_query 0 24 put hm_mode 0 1 25 ret 26 end 27 put hm_mode 0 0 28 ha_query 29 end 30 31 fn hop_activate to int 32 if eq get hm_mode 0 2 33 ret ff_activate 34 end 35 if eq get hm_mode 0 1 36 resultv = hc_activate 37 hm_wrapanswer 38 ret resultv 39 end 40 ret ha_activate 41 end 42 43 fn hm_wrapanswer to void 44 note The X11 fixed font uses six pixels per character; wrap to the row's actual drawable width. 45 cols = div sub get lx_s 11 64 6 46 if eq cols 0 47 ret 48 end 49 n = get lx_rn 0 50 r = enlarge hm_wrap add mul n 2 1 51 if lt r 0 52 ret 53 end 54 p = ulong 0 55 column = ulong 0 56 for i ulong n bound `9223372036854775807` 57 c = get lx_rows i 58 if eq c 10 59 column = 0 60 else 61 if ne and c 192 128 62 if ge column cols 63 put hm_wrap p 10 64 p = add p 1 65 column = 0 66 end 67 column = add column 1 68 end 69 end 70 put hm_wrap p c 71 p = add p 1 72 end 73 r = enlarge lx_rows p 74 if lt r 0 75 ret 76 end 77 for i ulong p bound `9223372036854775807` 78 put lx_rows i get hm_wrap i 79 end 80 put lx_rn 0 p 81 end 82 83 fn hm_equal a view uchar * b view uchar * to bool 84 if ne len a len b 85 ret false 86 end 87 for i ulong len a 88 if ne get a i get b i 89 ret false 90 end 91 end 92 ret true 93 end 94 95 fn hm_selftest to int 96 inp = new ulong 256 0 97 put inp 0 `1212568922` 98 put inp 1 1 99 put inp 2 2 100 put inp 3 5 101 put inp 8 or ulong 102 shl ulong 1 32 102 put inp 9 or ulong 105 shl ulong 1 32 103 put inp 72 or ulong 102 shl ulong 1 32 104 put inp 73 or ulong 105 shl ulong 1 32 105 put inp 74 or ulong 108 shl ulong 1 32 106 put inp 75 or ulong 101 shl ulong 1 32 107 put inp 76 or ulong 115 shl ulong 1 32 108 score = hp_fuzz inp 109 put inp 8 or ulong 122 shl ulong 1 32 110 put inp 9 or ulong 122 shl ulong 1 32 111 wrong = hp_fuzz inp 112 note Prefix score 160-(5-2)=157, calc:`ba69e77a30c85acf63f8374eceeb39df95c290c8b55d0f26a64e0d5b4b5ba9da`. 113 if and eq score 157 eq wrong 0 114 k = write 1 hm_ok 0 len hm_ok 115 ret 0 116 end 117 k = write 2 hm_no 0 len hm_no 118 ret 1 119 end 120 121 fn main to int 122 a = new uchar 4096 0 123 if gt argcnt 1 124 n = argread 1 a 0 len a 125 if or lt n 0 eq n long len a 126 k = write 2 hm_badarg 0 len hm_badarg 127 ret 2 128 end 129 if or hm_equal part a 0 ulong n hm_dashhelp hm_equal part a 0 ulong n hm_plainhelp 130 k = write 1 hm_help 0 len hm_help 131 ret 0 132 end 133 if hm_equal part a 0 ulong n hm_version 134 k = write 1 hm_ver 0 len hm_ver 135 ret 0 136 end 137 if hm_equal part a 0 ulong n hm_reindex 138 ret ff_cli 0 139 end 140 if hm_equal part a 0 ulong n hm_find 141 ret ff_cli 1 142 end 143 end 144 if ne hp_start 0 145 ret 1 146 end 147 if gt argcnt 1 148 n = argread 1 a 0 len a 149 if hm_equal part a 0 ulong n hm_test 150 resultv = hm_selftest 151 hp_stop 152 ret resultv 153 end 154 searchv = hm_equal part a 0 ulong n hm_search 155 openv = hm_equal part a 0 ulong n hm_open 156 if or not or searchv openv ne argcnt 3 157 k = write 2 hm_badarg 0 len hm_badarg 158 hp_stop 159 ret 2 160 end 161 n = argread 2 a 0 len a 162 if lt n 0 163 k = write 2 hm_badarg 0 len hm_badarg 164 hp_stop 165 ret 2 166 end 167 k = enlarge lx_query ulong n 168 if lt k 0 169 hp_stop 170 ret 1 171 end 172 for i ulong ulong n 173 put lx_query i get a i 174 end 175 put lx_qn 0 ulong n 176 if ne ha_init 0 177 hp_stop 178 ret 1 179 end 180 ha_query 181 if eq get lx_rn 0 0 182 hp_stop 183 ret 1 184 end 185 if searchv 186 k = write 1 lx_rows 0 get lx_rn 0 187 hp_stop 188 ret 0 189 end 190 put lx_pick 0 0 191 opened = ha_activate 192 hp_stop 193 if eq opened 1 194 ret 0 195 end 196 ret 1 197 end 198 if ne ha_init 0 199 hp_stop 200 ret 1 201 end 202 resultv = lx_main 203 hp_stop 204 ret resultv 205 end