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/omega-mv/blob/main/apps/hop/Omega/ui/hoppanel.om # omega-mv Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance. Brought by drakestapleton Sign in to star 1 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-mv / apps / hop / Omega / ui / hoppanel.om` 8126 lines ยท 211350 bytes Raw Blame History 1 target macos 2 om2 3 note hoppanel: the first cut of Hop's launcher panel as one Omega program, with no Swift. A window with a search 4 note field and a list. Before anything is typed the list offers up to six apps by Hop's own rule (fn swsuggest): the 5 note ones you usually open from the app in front or around this hour (habits.json, through fn swlifts), the ones 6 note you use most (recents.json), the ones that are running and the one you were just in, each with the reason. What is opened is remembered in those two files as Hop remembers it (fn urecordapp, fn urecent). 7 note The apps are the names in /Applications and /System/Applications. Typing narrows the 8 note list by Hop's own rules: the matcher (hopfuzz), the test for a web address (weba) and the order of the rows 9 note (swrank) are the functions of Omega/hopcore.om, which Omega/gen-ui.sh puts between the two marker notes, so 10 note the panel and the one box cannot drift apart. Typed text shows the eight best apps, a row that opens the text when 11 note it is a web address, and up to twelve files and folders from Hop's file index (file-index.bin in Hop's folder, 12 note which Hop builds: the panel reads it, lower-cases a copy and searches it by the rule of Hop's file search). 13 note The Ask row sends the typed text to a model and shows the answer as it arrives, in place of the list: the 14 note model is the default one of Hop's settings (config.json) when it is an HTTP one, else the 15 note first such; the request is Hop's (POST base/chat/completions, the model, one user message, stream true) and 16 note the answer's pieces are read from the server's "data:" lines. The session's delegate methods are Omega code 17 note (callback entries 7 and 8), called on the main queue. A model whose key is a saved account is asked with that key. The first row is selected; the down and up arrows move the selection, Enter 18 note opens the selected row. Like Hop it then stays: Enter and Escape hide the panel and give the app before it the 19 note keyboard back, and a global key (Option Space; Hop itself has Command Space), a click on its Dock icon or opening it again brings it 20 note back. It has a small menu (Quit, and Edit with cut, copy, paste, select all) and runs in AppKit's own event 21 note loop. The global key is a Carbon hot key whose handler is callback entry 5. 22 note The field's two delegate methods, the list's two data-source methods and the field's action are Omega code, reached 23 note through the callback entries (libback; omega-mv seed/ng/a64/DESIGN.md s14). 24 note With HOPCHECK set in the environment it checks itself instead: it stays in the background and, after half a 25 note second, puts "sa" into its field through the field's own editor (so AppKit, not the program, tells the 26 note delegate that the text changed), sends that editor arrow down, Enter and Escape as commands, prints 27 note "hoppanel apps N shown H first NAME selected R enter APP" and ends after six seconds. Enter reaches the field's 28 note action with the field as sender, as a real Enter does, but opens nothing. Status then: 1 when apps were found, 29 note the typed text narrowed them, the first one was read back from the list's own data source, the arrow moved the 30 note list's selection, Enter chose the selected app, Escape hid the panel, a hot key could be registered (a spare 31 note one: Control Option Shift Command F19) and its handler showed the panel again; 2 to 9 name a failed step. 32 note The line then ends " key K hid H back B" (K 0 when the key was registered). 33 note With HOPCHECK=type:TEXT it types TEXT instead and sends Enter (no arrow), still opening nothing: status 1 when 34 note Enter chose a row. With HOPCHECK=open:TEXT it does the same and does open the row: the line ends " opened 1" 35 note when the workspace took it, and the status is 1 then. With HOPCHECK=ask:TEXT it types TEXT, sends Enter on the 36 note Ask row (first for a question) and does ask the model: the line ends " answer TEXT" and the status is 1 when an 37 note answer came. With HOPCHECK=idle it types nothing and sends Enter on the first offer; HOPFRONT=ID then stands for 38 note the app in front. With HOPRECORD set as well, a check that opens nothing still remembers what Enter chose, 39 note and puts a chosen copied thing on a board of its own (the line then ends " pasted " and what is on it). 40 note A check reaches no other machine but through HOPSSH and HOPSCP, its stand-ins for ssh and scp (HOPSSH is 41 note also what a check starts in place of ssh for a forwarded port), and HOPLATE sends Enter late, when 42 note they have answered. With HOPCHECK=agent:TEXT a check sends TEXT to the agent of the settings and waits for it to end; with 43 note HOPAGENTS it first says each agent's command as it would be run. 44 note HOPASK2 is a second question a check asks in the same conversation once the first is answered; with 45 note HOPASKNEW it starts a new chat first. 46 note HOPSCREEN (clipboard or accounts) starts a check in that screen, and HOPCLIPDO (pin or delete) does that to 47 note the selected copied thing before Enter. With HOPCLIPREC a check first records what is on its own board into the history, as the program that stays 48 note does for the real clipboard. HOPCLIPKEY is the clipboard key for a check, in base64, or "tool:" and the name of a Keychain item of the 49 note security tool to read it from (the repository's checks use an item of their own, made and deleted there). HOPROW is the row Enter is sent on. 50 note Without HOPCHECK it runs until it is quit. 51 text s_appkit "/System/Library/Frameworks/AppKit.framework/AppKit" 52 text s_gc "objc_getClass" 53 text s_sr "sel_registerName" 54 text s_ms "objc_msgSend" 55 text s_wr "write" 56 text s_acp "objc_allocateClassPair" 57 text s_cam "class_addMethod" 58 text s_rcp "objc_registerClassPair" 59 text s_strlen "strlen" 60 text s_memcpy "memcpy" 61 text s_getenv "getenv" 62 text c_pool "NSAutoreleasePool" 63 text c_app "NSApplication" 64 text c_win "NSWindow" 65 text c_str "NSString" 66 text c_field "NSTextField" 67 text c_scroll "NSScrollView" 68 text c_table "NSTableView" 69 text c_col "NSTableColumn" 70 text c_fm "NSFileManager" 71 text c_obj "NSObject" 72 text c_date "NSDate" 73 text c_mine "OmegaHopPanel" 74 text c_url "NSURL" 75 text c_ws "NSWorkspace" 76 text m_alloc "alloc" 77 text m_init "init" 78 text m_shared "sharedApplication" 79 text m_policy "setActivationPolicy:" 80 text m_initwi "initWithContentRect:styleMask:backing:defer:" 81 text m_utf "stringWithUTF8String:" 82 text m_cstr "UTF8String" 83 text m_title "setTitle:" 84 text m_conten "contentView" 85 text m_addsub "addSubview:" 86 text m_initfr "initWithFrame:" 87 text m_label "labelWithString:" 88 text m_setfra "setFrame:" 89 text m_placeh "setPlaceholderString:" 90 text m_setdel "setDelegate:" 91 text m_settar "setTarget:" 92 text m_setact "setAction:" 93 text m_initid "initWithIdentifier:" 94 text m_setwid "setWidth:" 95 text m_addcol "addTableColumn:" 96 text m_header "setHeaderView:" 97 text m_dataso "setDataSource:" 98 text m_docvie "setDocumentView:" 99 text m_scroll "setHasVerticalScroller:" 100 text m_reload "reloadData" 101 text m_strval "stringValue" 102 text m_setstr "setStringValue:" 103 text m_defaul "defaultManager" 104 text m_conte1 "contentsOfDirectoryAtPath:error:" 105 text m_count "count" 106 text m_at "objectAtIndex:" 107 text m_finish "finishLaunching" 108 text m_front "orderFrontRegardless" 109 text m_visibl "isVisible" 110 text m_close "close" 111 text m_since "dateWithTimeIntervalSinceNow:" 112 text m_next "nextEventMatchingMask:untilDate:inMode:dequeue:" 113 text m_send "sendEvent:" 114 text m_change "controlTextDidChange:" 115 text m_rows "numberOfRowsInTableView:" 116 text m_value "tableView:objectValueForTableColumn:row:" 117 text m_go "go:" 118 text m_furl "fileURLWithPath:" 119 text m_shws "sharedWorkspace" 120 text m_open "openURL:" 121 text m_activ "activateIgnoringOtherApps:" 122 text m_key "makeKeyAndOrderFront:" 123 text m_firstr "makeFirstResponder:" 124 text m_down "moveDown:" 125 text m_up "moveUp:" 126 text m_cancel "cancelOperation:" 127 text m_selrow "selectRowIndexes:byExtendingSelection:" 128 text m_ixwith "indexSetWithIndex:" 129 text m_scrrow "scrollRowToVisible:" 130 text m_cmd "control:textView:doCommandBySelector:" 131 text m_selrd "selectedRow" 132 text c_ixset "NSIndexSet" 133 text t_b "B@:@@:" 134 text m_curred "currentEditor" 135 text m_instxt "insertText:" 136 text m_docmd "doCommandBySelector:" 137 text m_newln "insertNewline:" 138 text t_v "v@:@" 139 text t_q "q@:@" 140 text t_o "@@:@@q" 141 text x_title "Hop (Omega)" 142 text x_hint "Type to find an app" 143 text x_dir1 "/Applications" 144 text x_dir2 "/System/Applications" 145 text x_mode "kCFRunLoopDefaultMode" 146 text x_name "name" 147 text x_typed "sa" 148 text x_out1 "hoppanel apps " 149 text x_out2 " shown " 150 text x_out3 " first " 151 text x_out4 " selected " 152 text x_out5 " enter " 153 text x_out6 " opened " 154 text x_https "https://" 155 text x_open "Open " 156 text m_urlstr "URLWithString:" 157 text m_host "host" 158 text s_carbon "/System/Library/Frameworks/Carbon.framework/Carbon" 159 text s_event_target "GetApplicationEventTarget" 160 text s_install_handler "InstallEventHandler" 161 text s_register_key "RegisterEventHotKey" 162 text m_order_out "orderOut:" 163 text m_hide_app "hide:" 164 text m_released "setReleasedWhenClosed:" 165 text m_set_app_delegate "setDelegate:" 166 text m_reopen "applicationShouldHandleReopen:hasVisibleWindows:" 167 text m_run "run" 168 text m_terminate "terminate:" 169 text m_set_menu "setMainMenu:" 170 text m_add_item "addItem:" 171 text m_set_submenu "setSubmenu:" 172 text m_init_title "initWithTitle:" 173 text m_init_item "initWithTitle:action:keyEquivalent:" 174 text m_cut "cut:" 175 text m_copy "copy:" 176 text m_paste "paste:" 177 text m_select_all "selectAll:" 178 text c_menu "NSMenu" 179 text c_menu_item "NSMenuItem" 180 text t_reopen "B@:@B" 181 text t_handler "i^v^v^v" 182 text x_quit "Quit Hop Omega" 183 text x_edit "Edit" 184 text x_cut "Cut" 185 text x_copy "Copy" 186 text x_paste "Paste" 187 text x_select_all "Select All" 188 text x_key_q "q" 189 text x_key_x "x" 190 text x_key_c "c" 191 text x_key_v "v" 192 text x_key_a "a" 193 text x_app "Hop Omega" 194 text x_out7 " key " 195 text x_out8 " hid " 196 text x_out9 " back " 197 text s_malloc "malloc" 198 text s_memmem "memmem" 199 text s_memchr "memchr" 200 text s_memrchr "memrchr" 201 text c_data "NSData" 202 text m_data_file "dataWithContentsOfFile:" 203 text m_retain "retain" 204 text m_bytes "bytes" 205 text m_length "length" 206 text x_env_dir "HOP_CONFIG_DIR" 207 text x_env_home "HOME" 208 text x_support "/Library/Application Support/Hop" 209 text x_index "/file-index.bin" 210 text x_gap " - " 211 text x_dotapp_low ".app" 212 text x_dir1_low "/applications/" 213 text x_dir2_low "/system/applications/" 214 text x_config "/config.json" 215 text c_json "NSJSONSerialization" 216 text c_dict "NSDictionary" 217 text c_array "NSArray" 218 text c_number "NSNumber" 219 text c_mutable_dict "NSMutableDictionary" 220 text c_mutable_string "NSMutableString" 221 text c_request "NSMutableURLRequest" 222 text c_session "NSURLSession" 223 text c_session_config "NSURLSessionConfiguration" 224 text c_queue "NSOperationQueue" 225 text c_text_view "NSTextView" 226 text m_json_object "JSONObjectWithData:options:error:" 227 text m_json_data "dataWithJSONObject:options:error:" 228 text m_object_for_key "objectForKey:" 229 text m_is_kind "isKindOfClass:" 230 text m_equal_string "isEqualToString:" 231 text m_has_suffix "hasSuffix:" 232 text m_substring_to "substringToIndex:" 233 text m_append_string "stringByAppendingString:" 234 text m_append "appendString:" 235 text m_set_string "setString:" 236 text m_string "string" 237 text m_dictionary "dictionary" 238 text m_set_object "setObject:forKey:" 239 text m_array_with "arrayWithObject:" 240 text m_number_bool "numberWithBool:" 241 text m_request_url "requestWithURL:" 242 text m_set_method "setHTTPMethod:" 243 text m_set_header "setValue:forHTTPHeaderField:" 244 text m_set_body "setHTTPBody:" 245 text m_set_timeout "setTimeoutInterval:" 246 text m_ephemeral "ephemeralSessionConfiguration" 247 text m_main_queue "mainQueue" 248 text m_session_with "sessionWithConfiguration:delegate:delegateQueue:" 249 text m_data_task "dataTaskWithRequest:" 250 text m_resume "resume" 251 text m_cancel_task "cancel" 252 text m_data_bytes "dataWithBytes:length:" 253 text m_set_editable "setEditable:" 254 text m_set_hidden "setHidden:" 255 text m_description "localizedDescription" 256 text m_response "response" 257 text m_status_code "statusCode" 258 text m_did_data "URLSession:dataTask:didReceiveData:" 259 text m_did_complete "URLSession:task:didCompleteWithError:" 260 text t_session "v@:@@@" 261 text k_models "models" 262 text k_default "defaultModel" 263 text k_name "name" 264 text k_base "baseURL" 265 text k_model "model" 266 text k_kind "kind" 267 text k_key "keychainKey" 268 text k_messages "messages" 269 text k_stream "stream" 270 text k_role "role" 271 text k_content "content" 272 text k_choices "choices" 273 text k_delta "delta" 274 text k_message "message" 275 text x_openai "openai" 276 text x_user "user" 277 text x_post "POST" 278 text x_json_type "application/json" 279 text x_content_type "Content-Type" 280 text x_slash_text "/" 281 text x_completions "/chat/completions" 282 text x_ask "Ask " 283 text x_colon ": " 284 text x_ask_none "Ask: no model in Hop's settings that can be asked from here" 285 text x_asking "Asking ..." 286 text x_no_answer "[no answer]" 287 text x_http "[HTTP " 288 text x_busy "The model is busy right now. Try again in a moment. " 289 text x_bracket "]" 290 text x_out10 " answer " 291 text s_pow "pow" 292 text s_log2 "log2" 293 text c_calendar "NSCalendar" 294 text c_running_app "NSRunningApplication" 295 text m_current_calendar "currentCalendar" 296 text m_component "component:fromDate:" 297 text m_date_now "date" 298 text m_current_app "currentApplication" 299 text m_frontmost "frontmostApplication" 300 text m_running_apps "runningApplications" 301 text m_policy_of "activationPolicy" 302 text m_bundle_id "bundleIdentifier" 303 text m_bundle_url "bundleURL" 304 text m_path "path" 305 text m_localized_name "localizedName" 306 text m_integer_value "integerValue" 307 text m_double_value "doubleValue" 308 text m_number_integer "numberWithInteger:" 309 text m_reference_now "timeIntervalSinceReferenceDate" 310 text x_habits "/habits.json" 311 text x_recents "/recents.json" 312 text x_mac_key "Mac:" 313 text x_env_front "HOPFRONT" 314 text k_app "app" 315 text k_from "from" 316 text k_hour "hour" 317 text k_count "count" 318 text k_last "last" 319 text x_why4 "You often open this from " 320 text x_here "here" 321 text x_why5 "You were just here" 322 text x_why6 "You often open this around now" 323 text x_why7 "One of your most used" 324 text x_why8 "Running now" 325 text s_chmod "chmod" 326 text c_mutable_array "NSMutableArray" 327 text m_array "array" 328 text m_add_object "addObject:" 329 text m_remove_range "removeObjectsInRange:" 330 text m_remove_key "removeObjectForKey:" 331 text m_all_keys "allKeys" 332 text m_number_double "numberWithDouble:" 333 text m_write_file "writeToFile:atomically:" 334 text k_at_key "at" 335 text k_path "path" 336 text x_env_record "HOPRECORD" 337 text s_memset "memset" 338 text s_trusted "AXIsProcessTrusted" 339 text s_key_event "CGEventCreateKeyboardEvent" 340 text s_event_flags "CGEventSetFlags" 341 text s_event_post "CGEventPost" 342 text s_cf_release "CFRelease" 343 text x_security "/usr/bin/security" 344 text x_find "find-generic-password" 345 text x_dash_s "-s" 346 text x_clip_service "com.aienos.hop.clipboard" 347 text x_dash_a "-a" 348 text x_clip_account "storage-key-v2" 349 text x_dash_w "-w" 350 text x_clipboard_file "/clipboard.bin" 351 text x_clip_images "/clip-images/" 352 text x_env_clipkey "HOPCLIPKEY" 353 text x_env_row "HOPROW" 354 text x_env_vault "HOPVAULT" 355 text x_env_cliprec "HOPCLIPREC" 356 text x_real_ssh "/usr/bin/ssh" 357 text x_nc "/usr/bin/nc" 358 text x_nc_args "-z|-G|2|127.0.0.1" 359 text m_probe_done "probeDone:" 360 text m_all_keys_for "allKeysForObject:" 361 text m_remove_for_key "removeObjectForKey:" 362 text m_note_object "object" 363 text m_is_equal_number "isEqualToNumber:" 364 text s_cf_true "kCFBooleanTrue" 365 text s_cf_false "kCFBooleanFalse" 366 text x_out16 " links " 367 text x_tunnel_args "-N|-o|ControlMaster=no|-o|ControlPath=none|-o|BatchMode=yes|-o|ExitOnForwardFailure=yes|-o|ServerAliveInterval=15|-o|ServerAliveCountMax=3|-o|ConnectTimeout=8|-L" 368 text x_loopback "127.0.0.1:" 369 text k_tunnels "tunnels" 370 text k_local_port "localPort" 371 text k_remote_port "remotePort" 372 text k_ssh_host "sshHost" 373 text k_cortex "cortex" 374 text k_enabled "enabled" 375 text k_url "url" 376 text k_host "host" 377 text m_url_port "port" 378 text m_is_executable "isExecutableFileAtPath:" 379 text m_all_values "allValues" 380 text s_will_terminate "NSApplicationWillTerminateNotification" 381 text m_app_quit "appQuit:" 382 text x_env_menu "HOPMENU" 383 text x_status_symbol "bolt.horizontal.circle" 384 text x_status_open "Open Hop Omega (Option Space)" 385 text x_status_index "Rebuild file index" 386 text x_status_paste "Allow paste into apps ..." 387 text x_status_login "Open at login" 388 text x_status_settings "Settings (edit config file) ..." 389 text x_status_clear "Clear clipboard history" 390 text x_key_comma "," 391 text x_menu_word "menu " 392 text c_status_bar "NSStatusBar" 393 text m_system_status_bar "systemStatusBar" 394 text m_status_item_length "statusItemWithLength:" 395 text m_button "button" 396 text m_set_image "setImage:" 397 text m_symbol_image "imageWithSystemSymbolName:accessibilityDescription:" 398 text m_set_target "setTarget:" 399 text m_set_state "setState:" 400 text m_separator "separatorItem" 401 text m_set_item_menu "setMenu:" 402 text m_item_array "itemArray" 403 text m_item_title "title" 404 text m_menu_open "menuOpen:" 405 text m_menu_index "menuIndex:" 406 text m_menu_paste "menuPaste:" 407 text m_menu_login "menuLogin:" 408 text m_menu_settings "menuSettings:" 409 text m_menu_clear "menuClear:" 410 text s_trusted_options "AXIsProcessTrustedWithOptions" 411 text s_trusted_prompt "kAXTrustedCheckOptionPrompt" 412 text x_sm_path "/System/Library/Frameworks/ServiceManagement.framework/ServiceManagement" 413 text c_sm_service "SMAppService" 414 text m_main_app "mainAppService" 415 text m_status "status" 416 text m_register "registerAndReturnError:" 417 text m_unregister "unregisterAndReturnError:" 418 text x_login_failed "Couldn't change Open at login" 419 text x_textedit "/System/Applications/TextEdit.app" 420 text c_open_config "NSWorkspaceOpenConfiguration" 421 text m_configuration "configuration" 422 text m_open_urls_with "openURLs:withApplicationAtURL:configuration:completionHandler:" 423 text x_empty_settings "{}" 424 text x_env_ssh "HOPSSH" 425 text x_env_scp "HOPSCP" 426 text x_env_late "HOPLATE" 427 text x_ssh_word "ssh" 428 text x_scp_word "scp" 429 text x_ssh_options " -o BatchMode=yes -o ConnectTimeout=8 " 430 text x_scp_options " -q -o BatchMode=yes " 431 text x_remote_a "d=~/.cache/hop/shards; [ -f $d/s00 ] || { echo HOP-NO-INDEX; exit 0; }; t=$(mktemp -d /dev/shm/hop.XXXXXX 2>/dev/null || mktemp -d); for s in $d/s*; do ( " 432 text x_remote_grep "LC_ALL=C grep -F -i -- " 433 text x_remote_shard " %%$s%%" 434 text x_remote_pipe " | " 435 text x_remote_b " | head -300 > %%$t/${s##*/}%% ) & done; wait; cat %%$t%%/*; rm -rf %%$t%%" 436 text x_local_a "( " 437 text x_local_b "; [ $? = 255 ] && echo HOP-UNREACHABLE ) 2>/dev/null | sed 's/^/" 438 text x_local_c ":/' &" 439 text x_wait_word "wait" 440 text x_build_a "cd ~/.cache/hop && find " 441 text x_build_b " -xdev ^^( -path '*/.*' -o " 442 text x_build_c " ^^) -prune -o -type d -printf '%p/^^n' -o -printf '%p^^n' > index.tmp 2>/dev/null && rm -rf shards.new && mkdir shards.new && split -n l/20 -d -a 2 index.tmp shards.new/s && rm -f index.tmp index.txt && rm -rf shards.old && { [ ! -d shards ] || mv shards shards.old; } && mv shards.new shards && rm -rf shards.old; rm -f index.tmp; rmdir ~/.cache/hop/building" 443 text x_name_flag "-name " 444 text x_or_flag " -o " 445 text x_fresh_a "mkdir -p ~/.cache/hop; f=~/.cache/hop/shards/s00" 446 text x_fresh_b "if [ -d ~/.cache/hop/building ] && [ -n %%$(find ~/.cache/hop/building -maxdepth 0 -mmin +180 2>/dev/null)%% ]; then rmdir ~/.cache/hop/building; fi" 447 text x_fresh_c "if [ ! -f $f ] || [ -n %%$(find $f -mmin +30 2>/dev/null)%% ]; then if mkdir ~/.cache/hop/building 2>/dev/null; then nohup nice -n 19 ionice -c3 sh -c " 448 text x_fresh_d " >/dev/null 2>&1 & fi; fi" 449 text x_fresh_e "echo ok" 450 text x_percents "%%" 451 text x_carets "^^" 452 text x_fetch_a "sz=$(" 453 text x_fetch_stat "stat -c %s -- " 454 text x_fetch_b ") && [ %%$sz%% -le `2000000000` ] && mkdir -p " 455 text x_fetch_c " && " 456 text x_fetch_d " && echo HOP-FETCHED" 457 text x_fetched "HOP-FETCHED" 458 text x_no_index "HOP-NO-INDEX" 459 text x_unreachable "HOP-UNREACHABLE" 460 text x_remote_cache "/Library/Caches/Hop/remote/" 461 text x_check_cache "/remote/" 462 text x_on " on " 463 text x_note_unreachable " is unreachable right now" 464 text x_note_building " is building its file list ..." 465 text x_note_bringing "Bringing it over from " 466 text x_note_copied "Copied the path on the clipboard: " 467 text x_note_failed "Could not bring it over; its path is on the clipboard: " 468 text x_out13 " fetched " 469 text x_out14 " machine " 470 text x_out15 " says " 471 text k_roots_m "roots" 472 text k_skip_m "skip" 473 text m_remote_go "remoteGo:" 474 text m_remote_done "remoteDone:" 475 text m_fetch_done "fetchDone:" 476 text m_read_to_end "readToEndOfFileInBackgroundAndNotify" 477 text s_read_to_end_done "NSFileHandleReadToEndOfFileCompletionNotification" 478 text m_cancel_previous "cancelPreviousPerformRequestsWithTarget:selector:object:" 479 text m_dir_of "stringByDeletingLastPathComponent" 480 text x_mskip0 ".git" 481 text x_mskip1 "node_modules" 482 text x_mskip2 "target" 483 text x_mskip3 "__pycache__" 484 text x_mskip4 "venv" 485 text x_mskip5 ".venv" 486 text x_mskip6 "site-packages" 487 text x_mskip7 "build" 488 text x_mskip8 "dist" 489 text x_mskip9 "proc" 490 text x_engine0 "Claude Code" 491 text x_engine0_command "claude|-p|{prompt}|--output-format|stream-json|--verbose" 492 text x_engine1 "Codex" 493 text x_engine1_command "codex|exec|--skip-git-repo-check|{prompt}" 494 text x_engine2 "Grok" 495 text x_engine2_command "grok|-p|{prompt}" 496 text x_engine3 "Gemini" 497 text x_engine3_command "gemini|-p|{prompt}" 498 text x_engine4 "OpenCode" 499 text x_engine4_command "opencode|run|{prompt}" 500 text x_engine5 "Cursor" 501 text x_engine5_command "cursor-agent|-p|--output-format|text|{prompt}" 502 text x_engine6 "Hermes" 503 text x_engine6_command "hermes|-z|{prompt}" 504 text x_old0_command "codex|exec|--skip-git-repo-check|--dangerously-bypass-approvals-and-sandbox|{prompt}" 505 text x_old1_command "grok|--always-approve|-p|{prompt}" 506 text x_old2_command "gemini|-y|-p|{prompt}" 507 text x_old3_command "cursor-agent|-p|-f|--output-format|text|{prompt}" 508 text x_old4_command "hermes|--yolo|-z|{prompt}" 509 text x_path0 ".local/bin" 510 text x_path1 ".claude/local" 511 text x_path2 "/opt/homebrew/bin" 512 text x_path3 "/usr/local/bin" 513 text x_path4 ".bun/bin" 514 text x_path5 ".npm-global/bin" 515 text x_path6 ".cargo/bin" 516 text x_path7 ".opencode/bin" 517 text x_path8 ".volta/bin" 518 text x_path9 ".asdf/shims" 519 text x_path10 ".local/share/mise/shims" 520 text x_path11 "bin" 521 text x_custom_command "Custom command" 522 text x_legacy_mark "HOP-LEGACY-COMMAND" 523 text x_zsh "/bin/zsh" 524 text x_dash_lc "-lc" 525 text x_wrapper "[ -n ~$HOP_EXTRA_PATH~ ] && PATH=~$PATH:$HOP_EXTRA_PATH~; unset HOP_EXTRA_PATH; exec ~$@~" 526 text x_tilde "~" 527 text x_hop_word "hop" 528 text x_sh "sh" 529 text x_dash_c "-c" 530 text x_probe_a "command -v " 531 text x_probe_b " >/dev/null 2>&1 && echo " 532 text x_true_word "true" 533 text x_term "TERM" 534 text x_dumb "dumb" 535 text x_no_color "NO_COLOR" 536 text x_one "1" 537 text x_extra_path "HOP_EXTRA_PATH" 538 text x_colon_only ":" 539 text x_nvm "/.nvm/versions/node" 540 text x_herd "/Library/Application Support/Herd/config/nvm/versions/node" 541 text x_slash_bin "/bin" 542 text x_prompt_mark "{prompt}" 543 text x_claude "claude" 544 text x_append_system "--append-system-prompt" 545 text x_resume "--resume" 546 text x_request "Request: " 547 text x_the_user "the user" 548 text x_brief_a "'s agent." 549 text x_brief_b " All machines = one box; never ask which. Mac = here. " 550 text x_brief_c " (auto-routed). Find files anywhere: hop find ." 551 text x_brief_d " Factory: " 552 text x_brief_e " Never delete agent files. Back up before destructive changes. Reply short, plain words." 553 text x_ssh_a ": ssh " 554 text x_ssh_b " ''" 555 text x_semi_space "; " 556 text x_period "." 557 text x_agent_row "Agent fixes it: " 558 text x_brace "{" 559 text x_bang "! " 560 text x_tool_word "tool" 561 text x_tool_mark "> " 562 text x_agent_error "agent error" 563 text x_agent_none_a "No coding agent was found on this Mac. Install one of these, sign in to it, then open Hop Omega again: " 564 text x_agent_none_b "No coding agent was found on this Mac. Add an agent command to Hop's settings." 565 text x_agent_missing_a " is set as your agent but is not installed on this Mac. Installed here: " 566 text x_agent_missing_b ". Name one of them as agentEngine in Hop's settings. Nothing was run." 567 text x_agent_stopped_a "Agent stopped (exit " 568 text x_agent_stopped_b ")." 569 text x_agent_working "The agent is working ..." 570 text x_agent_busy "The agent is still working on the last request. Nothing new was run." 571 text x_agent_ask "Let the agent work on this Mac?" 572 text x_agent_ask_more "It can read and change files on this Mac, with the command of Hop's settings. Hop Omega asks this once each time it is started, until Hop itself has been told yes." 573 text x_agent_yes "Run the agent" 574 text x_agent_no "Cancel" 575 text x_comma_space ", " 576 text x_paren_a " (" 577 text x_paren_b ")" 578 text x_screen2 "Agent" 579 text x_screen2_about "what the agent said" 580 text x_word_agent "agent" 581 text x_stop_item "Stop the Agent" 582 text x_key_period "." 583 text x_agent_menu "Agent" 584 text c_alert "NSAlert" 585 text m_set_message "setMessageText:" 586 text m_set_informative "setInformativeText:" 587 text m_add_button "addButtonWithTitle:" 588 text m_run_modal "runModal" 589 text c_center "NSNotificationCenter" 590 text m_default_center "defaultCenter" 591 text m_add_observer "addObserver:selector:name:object:" 592 text m_remove_all_observer "removeObserver:name:object:" 593 text s_read_done "NSFileHandleReadCompletionNotification" 594 text s_data_item "NSFileHandleNotificationDataItem" 595 text s_task_ended "NSTaskDidTerminateNotification" 596 text m_read_background "readInBackgroundAndNotify" 597 text m_user_info "userInfo" 598 text m_set_cwd "setCurrentDirectoryPath:" 599 text m_set_environment "setEnvironment:" 600 text m_set_input "setStandardInput:" 601 text m_environment "environment" 602 text m_mutable_copy "mutableCopy" 603 text m_terminate_task "terminate" 604 text m_is_equal_array "isEqualToArray:" 605 text m_range_of_data "rangeOfData:options:range:" 606 text m_subdata "subdataWithRange:" 607 text m_replace_bytes "replaceBytesInRange:withBytes:length:" 608 text m_append_data "appendData:" 609 text m_joined "componentsJoinedByString:" 610 text m_uppercase "uppercaseString" 611 text m_substring_from "substringFromIndex:" 612 text m_contents_of_dir "contentsOfDirectoryAtPath:error:" 613 text m_standard_compare "localizedStandardCompare:" 614 text m_newline_set "newlineCharacterSet" 615 text m_agent_out "agentOut:" 616 text m_agent_err "agentErr:" 617 text m_agent_end "agentEnd:" 618 text m_agent_stop "stopAgent:" 619 text k_engines "agentEngines" 620 text k_engine "agentEngine" 621 text k_agent_command "agentCommand" 622 text k_agent_folder "agentWorkingDirectory" 623 text k_enter_agent "enterSendsToAgent" 624 text k_agent_confirmed "agentConfirmed" 625 text k_keep_flags "keepAgentFlags" 626 text k_command "command" 627 text k_owner "ownerName" 628 text k_machines "machines" 629 text k_ssh "ssh" 630 text k_factory_url "factoryURL" 631 text k_type "type" 632 text k_parts_text "text" 633 text k_tool_use "tool_use" 634 text k_result "result" 635 text k_is_error "is_error" 636 text k_session_id "session_id" 637 text x_env_ask2 "HOPASK2" 638 text x_env_agents "HOPAGENTS" 639 text x_engine_word "engine " 640 text x_env_asknew "HOPASKNEW" 641 text m_array_adding "arrayByAddingObject:" 642 text m_remove_last "removeLastObject" 643 text x_assistant "assistant" 644 text x_you "You: " 645 text x_command3 "New chat" 646 text x_word_new_chat "new chat" 647 text x_word_clear_chat "clear chat" 648 text s_free "free" 649 text s_iopolicy "setiopolicy_np" 650 text s_home_directory "NSHomeDirectory" 651 text s_key_directory "NSURLIsDirectoryKey" 652 text s_key_package "NSURLIsPackageKey" 653 text s_key_link "NSURLIsSymbolicLinkKey" 654 text s_modified "NSFileModificationDate" 655 text c_process_info "NSProcessInfo" 656 text m_process_info "processInfo" 657 text m_arguments "arguments" 658 text c_bundle "NSBundle" 659 text m_main_bundle "mainBundle" 660 text m_executable_path "executablePath" 661 text m_drain "drain" 662 text c_set "NSSet" 663 text m_set_with_array "setWithArray:" 664 text m_enumerator "enumeratorAtURL:includingPropertiesForKeys:options:errorHandler:" 665 text m_next_object "nextObject" 666 text m_get_resource "getResourceValue:forKey:error:" 667 text m_last_component "lastPathComponent" 668 text m_skip_descendants "skipDescendants" 669 text m_is_running "isRunning" 670 text m_attributes_of "attributesOfItemAtPath:error:" 671 text m_since_now "timeIntervalSinceNow" 672 text k_roots "indexRoots" 673 text k_skip_names "indexSkipNames" 674 text x_index_word "index" 675 text x_applications "/Applications" 676 text x_system_applications "/System/Applications" 677 text x_indexed "indexed " 678 text x_items " items" 679 text x_indexing " (indexing files ...)" 680 text x_command2 "Rebuild file index" 681 text x_word_rebuild "rebuild file index" 682 text x_word_reindex "reindex" 683 text x_word_index_files "index files" 684 text x_skipname0 "Library" 685 text x_skipname1 "node_modules" 686 text x_skipname2 ".git" 687 text x_skipname3 "target" 688 text x_skipname4 "build" 689 text x_skipname5 "dist" 690 text x_skipname6 "DerivedData" 691 text x_skipname7 "__pycache__" 692 text x_skipname8 "venv" 693 text x_skipname9 ".venv" 694 text x_skipname10 ".cache" 695 text x_skipname11 "Caches" 696 text x_skipname12 ".Trash" 697 text x_skipname13 "site-packages" 698 text x_skipname14 ".build" 699 text x_skipname15 "Pods" 700 text x_word0 "clipboard" 701 text x_word1 "copied" 702 text x_word2 "clipboard history" 703 text x_word3 "accounts" 704 text x_word4 "keys" 705 text x_word5 "api keys" 706 text x_word6 "passwords" 707 text x_word7 "logins" 708 text x_word8 "settings" 709 text x_word9 "preferences" 710 text x_word10 "config" 711 text x_word11 "hop settings" 712 text x_word12 "quit hop" 713 text x_screen0 "Clipboard" 714 text x_screen0_about "your copied things" 715 text x_screen1 "Accounts" 716 text x_screen1_about "your saved keys and logins" 717 text x_command0 "Settings" 718 text x_command0_about "opens Hop's settings file" 719 text x_command1 "Quit Hop Omega" 720 text x_copied_things " copied things" 721 text x_accounts_word " accounts" 722 text x_pinned "pinned" 723 text x_env_screen "HOPSCREEN" 724 text x_env_clipdo "HOPCLIPDO" 725 text x_clip_menu "Clipboard" 726 text x_pin_item "Pin or Unpin" 727 text x_delete_item "Delete from History" 728 text x_key_p "p" 729 text x_key_d "d" 730 text m_pin_clip "pinClip:" 731 text m_delete_clip "deleteClip:" 732 text x_out12 " screen " 733 text s_random "arc4random_buf" 734 text c_uuid "NSUUID" 735 text m_uuid "UUID" 736 text m_uuid_string "UUIDString" 737 text c_timer "NSTimer" 738 text m_timer "scheduledTimerWithTimeInterval:target:selector:userInfo:repeats:" 739 text m_clip_tick "clipTick:" 740 text m_change_count "changeCount" 741 text m_types "types" 742 text m_contains_object "containsObject:" 743 text c_image "NSImage" 744 text m_init_pasteboard "initWithPasteboard:" 745 text m_tiff "TIFFRepresentation" 746 text c_bitmap "NSBitmapImageRep" 747 text m_rep_with_data "imageRepWithData:" 748 text m_rep_using "representationUsingType:properties:" 749 text m_running_with "runningApplicationsWithBundleIdentifier:" 750 text x_hop_id "com.aienos.hop" 751 text k_id "id" 752 text k_source "sourceApp" 753 text k_limit "clipboardLimit" 754 text m_insert_at "insertObject:atIndex:" 755 text m_remove_at "removeObjectAtIndex:" 756 text m_byte_length "lengthOfBytesUsingEncoding:" 757 text c_mutable_data "NSMutableData" 758 text m_data "data" 759 text m_append_bytes "appendBytes:length:" 760 text c_file_manager "NSFileManager" 761 text m_default_manager "defaultManager" 762 text m_file_exists "fileExistsAtPath:" 763 text m_remove_item "removeItemAtPath:error:" 764 text m_create_dir "createDirectoryAtPath:withIntermediateDirectories:attributes:error:" 765 text x_clip_backup "/clipboard.before-hop-omega.bin" 766 text x_dot_bin ".bin" 767 text x_skip0 "org.nspasteboard.ConcealedType" 768 text x_skip1 "org.nspasteboard.TransientType" 769 text x_skip2 "org.nspasteboard.AutoGeneratedType" 770 text x_skip3 "com.agilebits.onepassword" 771 text x_skip4 "com.typeit4me.clipping" 772 text x_skip5 "de.petermaurer.TransientPasteboardType" 773 text x_env_vault_add "HOPVAULTADD" 774 text s_item_add "SecItemAdd" 775 text s_item_delete "SecItemDelete" 776 text s_interaction "SecKeychainSetUserInteractionAllowed" 777 text s_value_data "kSecValueData" 778 text s_accessible "kSecAttrAccessible" 779 text s_accessible_unlocked "kSecAttrAccessibleWhenUnlockedThisDeviceOnly" 780 text m_data_using "dataUsingEncoding:" 781 text x_semicolon ";" 782 text x_bar "|" 783 text x_vault_service "com.aienos.hop.vault" 784 text s_item_copy "SecItemCopyMatching" 785 text s_class "kSecClass" 786 text s_class_generic "kSecClassGenericPassword" 787 text s_attr_service "kSecAttrService" 788 text s_attr_account "kSecAttrAccount" 789 text s_attr_description "kSecAttrDescription" 790 text s_attr_comment "kSecAttrComment" 791 text s_match_limit "kSecMatchLimit" 792 text s_limit_all "kSecMatchLimitAll" 793 text s_limit_one "kSecMatchLimitOne" 794 text s_return_attributes "kSecReturnAttributes" 795 text s_return_data "kSecReturnData" 796 text s_true "kCFBooleanTrue" 797 text m_sorted "sortedArrayUsingSelector:" 798 text m_compare "compare:" 799 text m_has_prefix "hasPrefix:" 800 text m_declare_types "declareTypes:owner:" 801 text x_type_concealed "org.nspasteboard.ConcealedType" 802 text x_bearer "Bearer " 803 text x_authorization "Authorization" 804 text x_no_key "[The key of this model could not be read from the Keychain]" 805 text x_check_board "com.aienos.hop.omega.check" 806 text c_task "NSTask" 807 text c_pipe "NSPipe" 808 text c_file_handle "NSFileHandle" 809 text c_pasteboard "NSPasteboard" 810 text c_charset "NSCharacterSet" 811 text m_set_launch "setLaunchPath:" 812 text m_set_arguments "setArguments:" 813 text m_pipe "pipe" 814 text m_set_output "setStandardOutput:" 815 text m_set_error "setStandardError:" 816 text m_null_device "fileHandleWithNullDevice" 817 text m_launch "launch" 818 text m_reading "fileHandleForReading" 819 text m_read_end "readDataToEndOfFile" 820 text m_wait "waitUntilExit" 821 text m_termination "terminationStatus" 822 text m_init_data_encoding "initWithData:encoding:" 823 text m_trim "stringByTrimmingCharactersInSet:" 824 text m_whitespace "whitespaceAndNewlineCharacterSet" 825 text m_init_base64 "initWithBase64EncodedString:options:" 826 text m_general_pasteboard "generalPasteboard" 827 text m_board_named "pasteboardWithName:" 828 text m_clear "clearContents" 829 text m_set_string_type "setString:forType:" 830 text m_set_data_type "setData:forType:" 831 text m_string_for_type "stringForType:" 832 text m_data_for_type "dataForType:" 833 text m_lowercase "lowercaseString" 834 text m_contains "containsString:" 835 text m_components "componentsSeparatedByString:" 836 text m_replace "stringByReplacingOccurrencesOfString:withString:" 837 text m_composed_at "rangeOfComposedCharacterSequenceAtIndex:" 838 text m_bool_value "boolValue" 839 text m_release "release" 840 text m_perform_after "performSelector:withObject:afterDelay:" 841 text m_paste_now "pasteNow:" 842 text x_type_string "public.utf8-plain-text" 843 text x_type_png "public.png" 844 text k_text "text" 845 text k_image "imageFile" 846 text k_pinned "pinned" 847 text k_date "date" 848 text x_image "Image" 849 text x_image_low "image" 850 text x_space " " 851 text x_paste_row "Paste: " 852 text x_why1 "You just copied this" 853 text x_why2 "The last thing you copied" 854 text x_why3 "You copied a web address" 855 text x_out11 " pasted " 856 text x_png_word "png " 857 text x_browser0 "com.apple.Safari" 858 text x_browser1 "com.google.Chrome" 859 text x_browser2 "com.brave.Browser" 860 text x_browser3 "org.mozilla.firefox" 861 text x_browser4 "company.thebrowser.Browser" 862 text x_browser5 "com.microsoft.edgemac" 863 text x_browser6 "com.operasoftware.Opera" 864 text x_browser7 "com.vivaldi.Vivaldi" 865 text x_browser8 "app.zen-browser.zen" 866 text x_of " of " 867 text x_apps " apps" 868 text x_slash "/" 869 text x_dotapp ".app" 870 text x_env "HOPCHECK" 871 872 note g_f: library functions. 0 objc_getClass 1 sel_registerName 2 objc_msgSend 3 write 4 objc_allocateClassPair 873 note 5 class_addMethod 6 objc_registerClassPair 7 strlen 8 memcpy 9 getenv 10 malloc 11 memmem 12 memchr 13 memrchr 874 note 14 pow 15 log2 16 chmod 17 memset 18 AXIsProcessTrusted 19 CGEventCreateKeyboardEvent 20 CGEventSetFlags 875 note 21 CGEventPost 22 CFRelease 23 SecItemCopyMatching 24 SecItemAdd 25 SecItemDelete 876 note 26 SecKeychainSetUserInteractionAllowed 27 arc4random_buf 28 free 29 setiopolicy_np 30 NSHomeDirectory 877 global g_f ulong 32 878 note g_o: objects and selectors the callbacks need. 0 field 1 table 2 status line 3 NSString 4 stringWithUTF8String: 879 note 5 UTF8String 6 stringValue 7 reloadData 8 setStringValue: 9 moveDown: 10 moveUp: 11 cancelOperation: 880 note 12 selectRowIndexes:byExtendingSelection: 13 NSIndexSet 14 indexSetWithIndex: 15 scrollRowToVisible: 881 note 16 NSURL 17 URLWithString: 18 host 19 the window 20 orderOut: 21 the application 22 hide: 882 note 23 activateIgnoringOtherApps: 24 makeKeyAndOrderFront: 25 makeFirstResponder: 26 orderFrontRegardless 883 note 27 the object whose methods are the callbacks 28 the list's scroll view 29 the answer's scroll view 884 note 30 the answer's text view 885 global g_o ulong 32 886 note g_n: 0 apps 1 shown 2 bytes of names 3 times the action ran 4 length of the typed text 5 1 to end the program 887 note 6 the selected row 7 1 when Enter may open the row 8 the row Enter chose, plus 1 9 what the workspace answered 888 note 10 the typed text as a web address (0 it is none, 1 written with its scheme, 2 a bare address) 12 where the 889 note typed text starts once blanks are trimmed 13 its length then 14 1 when the program stays (no HOPCHECK) 890 note 15 what registering the hot key gave (0 it is registered) 16 the words of the typed text 17 the files found 891 note 18 1 when a file has exactly the typed text as its name 19 bytes of the answer waiting in g_net 892 note 20 1 when an answer is on show 21 1 when the model's answer has ended 22 1 when a piece of it came 893 note 23 1 when the check asks for what is chosen to be remembered without being opened 24 the count of copied 894 note things 25 the bytes of the newest one's text when it may be a web address 26 its address kind 27 the count 895 note of other copied things offered 28 the count of copied things that match the typed text 29 what the check 896 note pasted (1 text, 2 a picture) 30 the row the check chooses before Enter (0: the first) 31 the count of 897 note saved accounts 32 the place plus 1 of the app that was in front before the one in front now 898 note 33 1 once the history was set aside before this run's first change to it 34 how many unpinned copied 899 note things are kept 35 the clipboard's change count last seen 36 the screen the list shows (0 everything, 900 note 1 the copied things, 2 the saved accounts) 37 what a check does to the selected copied thing (1 pin or 901 note unpin, 2 delete) 38 half seconds since the file index was last looked at 902 note 39 1 when the answer on show belongs to a turn that has ended 40 1 when that turn failed 41 1 when the 903 note typed text reads as a question 42 1 when Hop's settings send a sentence to the agent on Enter 43 1 while 904 note the agent runs 44 1 once the person said yes to the agent 45 1 once the agents on this Mac were looked 905 note for 46 1 when a check sends what it types to the agent 47 what of the agent's run has ended (1 its 906 note output, 2 the program) 48 the turn at which a check sends Enter 49 the count of files found on other 907 note machines 50 the bytes of what the machines answered 51 what to say about a machine (1 unreachable, 2 building 908 note its list, 3 a file is on its way, 4 a path was copied, 5 a file could not be brought) 52 which machine 909 note 53 the bytes of the text the machines were asked for 54 the count of machines 55 1 when a check's file 910 note arrived 56 the machine and 57 the found file that is on its way 58 1 when a file found on a machine has exactly the typed name 911 note 59 1 when other machines may be reached 60 half seconds since the forwarded ports were last looked at 912 note 61 how many links this program has started 62 how many forwarded ports the settings name 913 global g_n ulong 64 914 note g_t: the text HOPCHECK=open:TEXT asks to type 915 global g_t uchar 64 916 global g_rg uchar 128 917 global g_nm uchar 1024 918 global g_pool uchar 65536 919 global g_off ulong 2048 920 global g_ln ulong 2048 921 global g_hit ulong 2048 922 note g_hit: the app of each row; g_rk: the kind of each row (1 an app, 2 the web address); g_dir: the folder each 923 note app is in (0 /Applications, 1 /System/Applications); g_mk and g_ms: the apps hopfuzz matched and their scores 924 global g_rk uchar 2048 925 global g_dir uchar 2048 926 global g_mk ulong 2048 927 global g_ms ulong 2048 928 global g_q uchar 256 929 note g_x: the first row's text, kept for the check's line 930 global g_x uchar 256 931 note g_ev: the hot key's event type (class 'keyb', kind 5 pressed) and, from byte 8, the reference Carbon gives back 932 global g_ev uchar 16 933 note The file index. g_fb: 0 where its bytes are (paths, a line each), 1 where the lower-case copy is, 2 how many 934 note bytes, 3 1 when it is loaded, 4 the object that holds the bytes. g_chunk: a piece of it on its way to lower case. g_line: one path, lower case. 935 note g_lq: the typed text, lower case; g_to and g_tl: where each of its words starts and how long it is. 936 note g_fs, g_fo, g_fl: the best 40 files, best first: score plus 100000, where the path starts, how long it is 937 global g_fb ulong 8 938 note The model. g_m: 0 its id, 1 the address to post to, 2 its name (three NSStrings), 3 1 when there is one, 939 note 4 the answer so far (an NSMutableString), 5 the session, 6 the running task, 7 NSDictionary, 8 NSArray, 940 note 9 NSString (the classes, to tell what a JSON value is), 10 each app's path and its place (a dictionary), 941 note 11 the id of the app in front when the panel was last shown, 12 its name, 13 its place among the apps plus 1, 942 note 14 the copied things (an array, newest first), 15 the text each one is shown by, 16 objectAtIndex:, 943 note 18 the names of the saved accounts in order, 19 what each is (its kind and note), 20 the Keychain service 944 note they are under, 21 the name of the account that holds the model's key (nothing: it needs none), 22 the 945 note accounts a check made for itself (an array of their names), to be deleted when it ends, 23 the program 946 note that is building the file index now (nothing: none), 24 the conversation with the model (an array of 947 note messages, each a role and a content), 25 what was said before the answer on show (a text), 26 the agent's 948 note program while it runs, 27 where its output is read, 28 the agents of Hop's settings (each a name and a 949 note command), 29 the name of the one to use, 30 the folder it works in, 31 the older single command, 32 its 950 note output not yet a whole line, 33 the id of its last run (to carry on from), 34 the settings (for the 951 note agent's standing instructions), 35 the agents found on this Mac, 36 when the agent last worked (a number 952 note object), 37 where its errors are read, 38 to 41 the selectors agentOut: agentErr: agentEnd: stopAgent:, 953 note 42 the ssh names of the machines (an array), 43 the program asking the machines, 44 where its answer is 954 note read, 45 the program bringing a file over, 46 to 48 the selectors remoteGo: remoteDone: fetchDone:, 955 note 49 where the fetch's answer is read, 50 where the file that is on its way lands (a path), 51 its 956 note machine's ssh name and path, for the clipboard, 52 the icon in the menu bar, 53 its Open at login item, 957 note 54 to 59 the selectors menuOpen: menuIndex: menuPaste: menuLogin: menuSettings: menuClear:, 958 note 60 the forwarded ports to keep open (each: this Mac's port, the far port, the ssh name), 61 the programs 959 note that hold them open (by this Mac's port), 62 the selector appQuit:, 63 the programs asking whether a port 960 note is served (by the port), 64 the selector probeDone:. 961 note g_net: bytes from the server not yet read as lines 962 global g_m ulong 80 963 global g_net uchar 262144 964 note What is offered before anything is typed. g_so: the apps in the order of their paths; g_lf, g_lh: each app's 965 note lift from the app in front and from the hour; g_us: how much it is used; g_rn: 1 when it is running; 966 note g_fr: the apps that were in front when the panel was shown, newest first (place plus 1); g_why: why each 967 note row is offered 968 global g_so ulong 2048 969 global g_lf ulong 2048 970 global g_lh ulong 2048 971 global g_us ulong 2048 972 global g_rn uchar 2048 973 global g_fr ulong 12 974 global g_why uchar 2048 975 note Copied things. g_ci: all of them in the order they are searched (the pinned ones first); g_cp: 1 for a 976 note pinned one; g_cr: the others offered before anything is typed; g_cm: the ones that match the typed text; 977 note g_ca: the newest one's text, kept while it may be a web address 978 global g_ci ulong 1024 979 global g_cp uchar 1024 980 global g_cr ulong 20 981 global g_cm ulong 1024 982 global g_ca uchar 256 983 note eight bytes a library function writes a pointer into 984 global g_t8 uchar 8 985 note Files on other machines. g_rb: what the machines answered (lines "K:path", K the machine's number); g_rq: 986 note the text they were asked for; g_ro, g_rl, g_rs, g_rw: the best 64 found, best first (where the path starts in 987 note g_rb, its length, its score plus 100000, its machine); g_mn and g_ml: the machines' names 988 global g_rb uchar `1048576` 989 global g_rq uchar 256 990 global g_ro ulong 64 991 global g_rl ulong 64 992 global g_rs ulong 64 993 global g_rw uchar 64 994 global g_mn uchar 640 995 global g_ml uchar 10 996 note the byte that ends a line of the file index 997 global g_nl uchar 1 998 global g_chunk uchar 524288 999 global g_line uchar 4096 1000 global g_lq uchar 256 1001 global g_to ulong 16 1002 global g_tl ulong 16 1003 global g_fs ulong 64 1004 global g_fo ulong 64 1005 global g_fl ulong 64 1006 1007 note @hopcore 1008 1009 fn upr o ulong v ulong to void 1010 for i ulong 8 1011 put g_rg add o i uchar and shr v mul i 8 255 1012 end 1013 end 1014 1015 fn ugr o ulong to ulong 1016 v = ulong 0 1017 for i ulong 8 1018 v = or v shl ulong get g_rg add o i mul i 8 1019 end 1020 ret v 1021 end 1022 1023 note the text into g_nm with a zero byte after it; its length 1024 fn ucs t view uchar * to ulong 1025 n = len t 1026 for i ulong n 1027 put g_nm i get t i 1028 end 1029 put g_nm n 0 1030 ret n 1031 end 1032 1033 note library function k of g_f on the register file; x0 as it came back (an object may have its top bit set) 1034 fn ucall k ulong to ulong 1035 lr = libcall get g_f k g_rg 0 128 1036 ret ugr 0 1037 end 1038 1039 fn usym t view uchar * to ulong 1040 n = ucs t 1041 upr 0 `18446744073709551614` 1042 upr 8 ulong libptr g_nm 0 1024 1043 lr = libcall ulong libfn 1 g_rg 0 128 1044 ret ugr 0 1045 end 1046 1047 fn ucl t view uchar * to ulong 1048 n = ucs t 1049 upr 0 ulong libptr g_nm 0 1024 1050 ret ucall 0 1051 end 1052 1053 fn usl t view uchar * to ulong 1054 n = ucs t 1055 upr 0 ulong libptr g_nm 0 1024 1056 ret ucall 1 1057 end 1058 1059 note [obj s a b c] 1060 fn umsg obj ulong s ulong a ulong b ulong c ulong to ulong 1061 upr 0 obj 1062 upr 8 s 1063 upr 16 a 1064 upr 24 b 1065 upr 32 c 1066 ret ucall 2 1067 end 1068 1069 note an NSString of the zero-ended bytes in g_nm 1070 fn unsb to ulong 1071 ret umsg get g_o 3 get g_o 4 ulong libptr g_nm 0 1024 0 0 1072 end 1073 1074 fn uns t view uchar * to ulong 1075 n = ucs t 1076 ret unsb 1077 end 1078 1079 note a rectangle for the next message, in d0..d3 1080 fn urect x f64 y f64 w f64 h f64 to void 1081 upr 64 bitcast ulong x 1082 upr 72 bitcast ulong y 1083 upr 80 bitcast ulong w 1084 upr 88 bitcast ulong h 1085 end 1086 1087 fn ulower c ulong to ulong 1088 if and ge c 65 le c 90 1089 ret add c 32 1090 end 1091 ret c 1092 end 1093 1094 note the zero-ended bytes at address p into g_nm (at most 1000); their count 1095 fn ufetch p ulong to ulong 1096 upr 0 p 1097 n = ucall 7 1098 if gt n 1000 1099 n = 1000 1100 end 1101 upr 0 ulong libptr g_nm 0 1024 1102 upr 8 p 1103 upr 16 n 1104 x = ucall 8 1105 put g_nm n 0 1106 ret n 1107 end 1108 1109 note the names in one folder that end in ".app", without that ending, into the pool 1110 fn ufolder t view uchar * dn ulong to void 1111 c = ucl c_fm 1112 s = usl m_defaul 1113 mgr = umsg c s 0 0 0 1114 s = usl m_conte1 1115 path = uns t 1116 arr = umsg mgr s path 0 0 1117 if eq arr 0 1118 ret 1119 end 1120 s = usl m_count 1121 cnt = umsg arr s 0 0 0 1122 sat = usl m_at 1123 for i ulong cnt bound 4096 1124 item = umsg arr sat i 0 0 1125 p = umsg item get g_o 5 0 0 0 1126 n = ufetch p 1127 k = get g_n 0 1128 used = get g_n 2 1129 if and and gt n 4 lt k 2048 lt add used n 65536 1130 if and and eq get g_nm sub n 4 46 eq get g_nm sub n 3 97 and eq get g_nm sub n 2 112 eq get g_nm sub n 1 112 1131 m = sub n 4 1132 for j ulong m bound 1000 1133 put g_pool add used j get g_nm j 1134 end 1135 put g_off k used 1136 put g_ln k m 1137 put g_dir k uchar dn 1138 put g_n 0 add k 1 1139 put g_n 2 add used m 1140 end 1141 end 1142 end 1143 end 1144 1145 note the word hopfuzz reads for one byte: its lower-case value, bit 32 for a letter or digit (and for every byte of 1146 note a longer character), bit 33 for a space or tab 1147 fn ufword c ulong to ulong 1148 l = ulower c 1149 w = l 1150 if or or and ge l 97 le l 122 and ge l 48 le l 57 ge l 128 1151 w = or w `4294967296` 1152 end 1153 if or eq l 32 eq l 9 1154 w = or w `8589934592` 1155 end 1156 ret w 1157 end 1158 1159 note how well app k matches the typed text: hopfuzz's score plus 1, or 0 for no match (and for a text over 64 bytes 1160 note or a name over 184, which hopfuzz refuses) 1161 fn uscore k ulong to ulong 1162 inp = new ulong 256 0 1163 res = new ulong 256 0 1164 ql = get g_n 4 1165 nl = get g_ln k 1166 o = get g_off k 1167 if or gt ql 64 or gt nl 184 eq nl 0 1168 ret 0 1169 end 1170 put inp 0 `1212568922` 1171 put inp 1 1 1172 put inp 2 ql 1173 put inp 3 nl 1174 for i ulong ql bound 64 1175 put inp add 8 i ufword ulong get g_q i 1176 end 1177 for i ulong nl bound 184 1178 put inp add 72 i ufword ulong get g_pool add o i 1179 end 1180 v = hopfuzz inp res 1181 if ne v 1 1182 ret 0 1183 end 1184 ret add get res 3 1 1185 end 1186 1187 note a number in decimal into g_nm from byte p; the byte after it 1188 fn upnum p ulong v ulong to ulong 1189 d = ulong 1 1190 while ge div v d 10 bound 24 1191 d = mul d 10 1192 end 1193 q = p 1194 while gt d 0 bound 24 1195 put g_nm q uchar add 48 rem div v d 10 1196 q = add q 1 1197 d = div d 10 1198 end 1199 ret q 1200 end 1201 1202 note the text into g_nm from byte p; the byte after it 1203 fn uptxt p ulong t view uchar * to ulong 1204 for i ulong len t 1205 put g_nm add p i get t i 1206 end 1207 ret add p len t 1208 end 1209 1210 note name k into g_nm from byte p; the byte after it 1211 fn upname p ulong k ulong to ulong 1212 o = get g_off k 1213 n = get g_ln k 1214 for i ulong n bound 1000 1215 put g_nm add p i get g_pool add o i 1216 end 1217 ret add p n 1218 end 1219 1220 note four bytes and eight bytes into a request for the core, and eight bytes out of its answer; numbers travel with 1221 note 2^40 added (k_b), as in Omega/README.md kind 7 1222 fn uw32 b edit uchar `1048576` o ulong v ulong to void 1223 for i ulong 4 1224 put b add o i uchar and shr v mul i 8 255 1225 end 1226 end 1227 1228 fn upb b edit uchar `1048576` k ulong x ulong to void 1229 o = add 8 mul k 8 1230 for i ulong 8 1231 put b add o i uchar and shr x mul i 8 255 1232 end 1233 end 1234 1235 fn upn b edit uchar `1048576` k ulong v ulong to void 1236 upb b k add v k_b 1237 end 1238 1239 fn uog ob view uchar 65544 k ulong to ulong 1240 v = ulong 0 1241 o = add 8 mul k 8 1242 for i ulong 8 1243 v = or v shl ulong get ob add o i mul i 8 1244 end 1245 ret v 1246 end 1247 1248 note the address the typed text stands for into g_nm from byte p (with "https://" before a bare one); the byte after 1249 fn upaddr p ulong to ulong 1250 q = p 1251 if eq get g_n 10 2 1252 q = uptxt p x_https 1253 end 1254 a = get g_n 12 1255 n = get g_n 13 1256 for i ulong n bound 256 1257 put g_nm add q i get g_q add a i 1258 end 1259 ret add q n 1260 end 1261 1262 note is the typed text a web address? The shape is the core's decision (fn weba, text decisions op 3); that macOS 1263 note can read it is asked of NSURL, as Hop does. The answer goes to g_n 10 1264 fn udecide to void 1265 tb = new uchar `1048576` 0 1266 a = get g_n 12 1267 n = get g_n 13 1268 put g_n 10 0 1269 put g_n 41 0 1270 if or eq n 0 gt n 255 1271 ret 1272 end 1273 uw32 tb 0 3 1274 uw32 tb 4 n 1275 uw32 tb 8 n 1276 for i ulong n bound 256 1277 l = ulower ulong get g_q add a i 1278 o = add 16 mul i 8 1279 put tb o uchar l 1280 f = ulong 0 1281 if or or and ge l 97 le l 122 and ge l 48 le l 57 ge l 128 1282 f = 1 1283 end 1284 if or eq l 32 eq l 9 1285 f = 14 1286 end 1287 put tb add o 4 uchar f 1288 end 1289 put g_n 41 qlike tb n 1290 k = weba tb n n 1291 if eq k 0 1292 ret 1293 end 1294 put g_n 10 k 1295 p = upaddr 0 1296 put g_nm p 0 1297 str = unsb 1298 u = umsg get g_o 16 get g_o 17 str 0 0 1299 if eq u 0 1300 put g_n 10 0 1301 ret 1302 end 1303 if eq k 1 1304 if eq umsg u get g_o 18 0 0 0 0 1305 put g_n 10 0 1306 end 1307 end 1308 end 1309 1310 note ---- files: Hop's file index, searched by the rule of Hop's own file search (Sources/FileIndex.swift) ---- 1311 note read file-index.bin from Hop's folder (HOP_CONFIG_DIR, else the user's Application Support/Hop) and make the 1312 note lower-case copy the search runs on. Without the file there are no file rows 1313 fn uloadindex to void 1314 if eq get g_fb 3 1 1315 upr 0 get g_fb 1 1316 x = ucall 28 1317 x = umsg get g_fb 4 usl m_release 0 0 0 1318 end 1319 put g_fb 3 0 1320 n = ucs x_env_dir 1321 upr 0 ulong libptr g_nm 0 1024 1322 dir_text = ucall 9 1323 p = ulong 0 1324 if ne dir_text 0 1325 p = ufetch dir_text 1326 end 1327 if eq p 0 1328 n = ucs x_env_home 1329 upr 0 ulong libptr g_nm 0 1024 1330 home_text = ucall 9 1331 if eq home_text 0 1332 ret 1333 end 1334 p = ufetch home_text 1335 p = uptxt p x_support 1336 end 1337 p = uptxt p x_index 1338 put g_nm p 0 1339 path = unsb 1340 c = ucl c_data 1341 s = usl m_data_file 1342 d = umsg c s path 0 0 1343 if eq d 0 1344 ret 1345 end 1346 s = usl m_retain 1347 x = umsg d s 0 0 0 1348 s = usl m_bytes 1349 src = umsg d s 0 0 0 1350 s = usl m_length 1351 total = umsg d s 0 0 0 1352 if or or eq src 0 eq total 0 gt total `536870912` 1353 ret 1354 end 1355 upr 0 total 1356 dst = ucall 10 1357 if eq dst 0 1358 x = umsg d usl m_release 0 0 0 1359 ret 1360 end 1361 done = ulong 0 1362 while lt done total bound 2048 1363 m = sub total done 1364 if gt m 524288 1365 m = 524288 1366 end 1367 upr 0 ulong libptr g_chunk 0 524288 1368 upr 8 add src done 1369 upr 16 m 1370 x = ucall 8 1371 for i ulong m bound 524288 1372 cc = ulong get g_chunk i 1373 if and ge cc 65 le cc 90 1374 put g_chunk i uchar add cc 32 1375 end 1376 end 1377 upr 0 add dst done 1378 upr 8 ulong libptr g_chunk 0 524288 1379 upr 16 m 1380 x = ucall 8 1381 done = add done m 1382 end 1383 put g_fb 0 src 1384 put g_fb 1 dst 1385 put g_fb 2 total 1386 put g_fb 4 d 1387 put g_fb 3 1 1388 end 1389 1390 note does g_line[ho .. ho+hl) hold word t of the typed text; md 1: does it start with it 1391 fn uhas ho ulong hl ulong t ulong md ulong to bool 1392 wo = get g_to t 1393 wl = get g_tl t 1394 if gt wl hl 1395 ret false 1396 end 1397 last = sub hl wl 1398 if eq md 1 1399 last = 0 1400 end 1401 st = ulong 0 1402 while le st last bound 4097 1403 same_bytes = true 1404 j = ulong 0 1405 while and same_bytes lt j wl bound 257 1406 if ne get g_line add add ho st j get g_lq add wo j 1407 same_bytes = false 1408 end 1409 j = add j 1 1410 end 1411 if same_bytes 1412 ret true 1413 end 1414 st = add st 1 1415 end 1416 ret false 1417 end 1418 1419 note the score of the path in g_line (ln bytes, lower case) plus 100000, or 0 when a word is in it nowhere: a 1420 note word in the name counts 60 at its start and 30 elsewhere, a word only in the folders 5; a point less for 1421 note every 20 bytes of path; 40 more when the name is exactly as long as the words; 25 more for an app 1422 fn ufscore ln ulong to ulong 1423 nt = get g_n 16 1424 ns0 = ln 1425 while gt ns0 0 bound 4097 1426 if eq ulong get g_line sub ns0 1 47 1427 break 1428 end 1429 ns0 = sub ns0 1 1430 end 1431 nl = sub ln ns0 1432 sc = ulong 100000 1433 words_len = ulong 0 1434 for t ulong nt bound 16 1435 words_len = add words_len get g_tl t 1436 if uhas ns0 nl t 0 1437 if uhas ns0 nl t 1 1438 sc = add sc 60 1439 else 1440 sc = add sc 30 1441 end 1442 else 1443 if uhas 0 ln t 0 1444 sc = add sc 5 1445 else 1446 ret 0 1447 end 1448 end 1449 end 1450 sc = sub sc div ln 20 1451 if eq nl words_len 1452 sc = add sc 40 1453 end 1454 if ge ln 4 1455 if and and eq ulong get g_line sub ln 4 46 eq ulong get g_line sub ln 3 97 and eq ulong get g_line sub ln 2 112 eq ulong get g_line sub ln 1 112 1456 sc = add sc 25 1457 end 1458 end 1459 ret sc 1460 end 1461 1462 note keep a found path among the best 40, best first; equal scores stay in the order they were found 1463 fn ufkeep sc ulong o ulong ln ulong to void 1464 k = get g_n 17 1465 if and ge k 40 le sc get g_fs 39 1466 ret 1467 end 1468 pos = k 1469 if ge k 40 1470 pos = 39 1471 else 1472 put g_n 17 add k 1 1473 end 1474 while gt pos 0 bound 64 1475 if ge get g_fs sub pos 1 sc 1476 break 1477 end 1478 put g_fs pos get g_fs sub pos 1 1479 put g_fo pos get g_fo sub pos 1 1480 put g_fl pos get g_fl sub pos 1 1481 pos = sub pos 1 1482 end 1483 put g_fs pos sc 1484 put g_fo pos o 1485 put g_fl pos ln 1486 end 1487 1488 note path i of the best files into g_line, from the lower-case copy (lo 1) or as it is written (lo 0); its length 1489 fn ufpath i ulong lo ulong to ulong 1490 ln = get g_fl i 1491 upr 0 ulong libptr g_line 0 4096 1492 upr 8 add get g_fb lo get g_fo i 1493 upr 16 ln 1494 x = ucall 8 1495 ret ln 1496 end 1497 1498 note the files for the typed text: every line of the index that holds the longest word is scored (at most 1499 note 20000 lines, as Hop does), the best 40 are kept. Nothing under two characters 1500 fn usearch to void 1501 put g_n 17 0 1502 put g_n 18 0 1503 a = get g_n 12 1504 n = get g_n 13 1505 nt = ulong 0 1506 i = ulong 0 1507 while lt i n bound 257 1508 c = ulower ulong get g_q add a i 1509 put g_lq i uchar c 1510 if or eq c 32 eq c 9 1511 i = add i 1 1512 continue 1513 end 1514 st = i 1515 while lt i n bound 257 1516 c = ulower ulong get g_q add a i 1517 if or eq c 32 eq c 9 1518 break 1519 end 1520 put g_lq i uchar c 1521 i = add i 1 1522 end 1523 if lt nt 16 1524 put g_to nt st 1525 put g_tl nt sub i st 1526 nt = add nt 1 1527 end 1528 end 1529 put g_n 16 nt 1530 if or or eq get g_fb 3 0 lt n 2 eq nt 0 1531 ret 1532 end 1533 lead = ulong 0 1534 for t ulong nt bound 16 1535 if gt get g_tl t get g_tl lead 1536 lead = t 1537 end 1538 end 1539 low = get g_fb 1 1540 total = get g_fb 2 1541 pos = ulong 0 1542 scanned = ulong 0 1543 while and lt pos total lt scanned 20000 bound 20001 1544 upr 0 add low pos 1545 upr 8 sub total pos 1546 upr 16 ulong libptr g_lq get g_to lead get g_tl lead 1547 upr 24 get g_tl lead 1548 m = ucall 11 1549 if eq m 0 1550 break 1551 end 1552 hit_at = sub m low 1553 upr 0 low 1554 upr 8 10 1555 upr 16 hit_at 1556 r = ucall 13 1557 s = ulong 0 1558 if ne r 0 1559 s = add sub r low 1 1560 end 1561 upr 0 m 1562 upr 8 10 1563 upr 16 sub total hit_at 1564 r = ucall 12 1565 e = total 1566 if ne r 0 1567 e = sub r low 1568 end 1569 pos = add e 1 1570 scanned = add scanned 1 1571 ln = sub e s 1572 if and gt ln 0 le ln 4000 1573 upr 0 ulong libptr g_line 0 4096 1574 upr 8 add low s 1575 upr 16 ln 1576 x = ucall 8 1577 sc = ufscore ln 1578 if ne sc 0 1579 ufkeep sc s ln 1580 end 1581 end 1582 end 1583 note does one of them have exactly the typed text as its name (a folder's last "/" aside) 1584 for f ulong get g_n 17 bound 64 1585 ln = ufpath f 1 1586 if gt ln 0 1587 if eq ulong get g_line sub ln 1 47 1588 ln = sub ln 1 1589 end 1590 end 1591 ns0 = ln 1592 while gt ns0 0 bound 4097 1593 if eq ulong get g_line sub ns0 1 47 1594 break 1595 end 1596 ns0 = sub ns0 1 1597 end 1598 if eq sub ln ns0 n 1599 same_bytes = true 1600 for j ulong n bound 256 1601 if ne get g_line add ns0 j get g_lq j 1602 same_bytes = false 1603 end 1604 end 1605 if same_bytes 1606 put g_n 18 1 1607 end 1608 end 1609 end 1610 end 1611 1612 note is g_line[o .. o+n) the text t 1613 fn ulineis o ulong n ulong t view uchar * to bool 1614 if ne n len t 1615 ret false 1616 end 1617 for i ulong n bound 64 1618 if ne get g_line add o i get t i 1619 ret false 1620 end 1621 end 1622 ret true 1623 end 1624 1625 note is best file i one of the m matched apps (an app already listed is not shown again as a file) 1626 fn uisapp i ulong m ulong to ulong 1627 ln = ufpath i 1 1628 if lt ln 6 1629 ret 0 1630 end 1631 if not ulineis sub ln 4 4 x_dotapp_low 1632 ret 0 1633 end 1634 o = ulong 0 1635 if and ge ln 14 ulineis 0 14 x_dir1_low 1636 o = 14 1637 end 1638 if and ge ln 21 ulineis 0 21 x_dir2_low 1639 o = 21 1640 end 1641 if eq o 0 1642 ret 0 1643 end 1644 nl = sub sub ln o 4 1645 for j ulong m bound 2048 1646 k = get g_mk j 1647 if eq get g_ln k nl 1648 same_bytes = true 1649 for b ulong nl bound 1000 1650 if ne ulower ulong get g_pool add get g_off k b ulong get g_line add o b 1651 same_bytes = false 1652 end 1653 end 1654 if same_bytes 1655 ret 1 1656 end 1657 end 1658 end 1659 ret 0 1660 end 1661 1662 note the text of a file row into g_nm from byte p: its name, a gap, the folder it is in; the byte after it 1663 fn ufilerow p ulong i ulong to ulong 1664 ln = ufpath i 0 1665 if gt ln 0 1666 if eq ulong get g_line sub ln 1 47 1667 ln = sub ln 1 1668 end 1669 end 1670 ns0 = ln 1671 while gt ns0 0 bound 4097 1672 if eq ulong get g_line sub ns0 1 47 1673 break 1674 end 1675 ns0 = sub ns0 1 1676 end 1677 q = p 1678 nl = sub ln ns0 1679 if gt nl 300 1680 nl = 300 1681 end 1682 for j ulong nl bound 301 1683 put g_nm add q j get g_line add ns0 j 1684 end 1685 q = add q nl 1686 if and gt ns0 1 le ns0 600 1687 q = uptxt q x_gap 1688 for j ulong sub ns0 1 bound 601 1689 put g_nm add q j get g_line j 1690 end 1691 q = add q sub ns0 1 1692 end 1693 ret q 1694 end 1695 1696 note the whole path of best file i into g_nm from byte p (nothing when it is over 900 bytes); the byte after it 1697 fn ufilepath p ulong i ulong to ulong 1698 ln = ufpath i 0 1699 if gt ln 900 1700 ret p 1701 end 1702 for j ulong ln bound 901 1703 put g_nm add p j get g_line j 1704 end 1705 ret add p ln 1706 end 1707 1708 note open best file i with the app macOS has for it 1709 fn uopenfile i ulong to void 1710 p = ufilepath 0 i 1711 if eq p 0 1712 ret 1713 end 1714 put g_nm p 0 1715 str = unsb 1716 c = ucl c_url 1717 s = usl m_furl 1718 url = umsg c s str 0 0 1719 c = ucl c_ws 1720 s = usl m_shws 1721 ws = umsg c s 0 0 0 1722 s = usl m_open 1723 put g_n 9 and umsg ws s url 0 0 255 1724 end 1725 1726 note ---- Ask: the model of Hop's settings, asked over HTTP as Hop asks it (Sources/Runners.swift) ---- 1727 note [obj objectForKey: the key named by t] 1728 fn ukeyed obj ulong t view uchar * to ulong 1729 key = uns t 1730 ret umsg obj usl m_object_for_key key 0 0 1731 end 1732 1733 note is obj an object of class number w of g_m (7 a dictionary, 8 an array, 9 a string); nothing is not 1734 fn uiskind obj ulong w ulong to bool 1735 if eq obj 0 1736 ret false 1737 end 1738 ret eq and umsg obj usl m_is_kind get g_m w 0 0 255 1 1739 end 1740 1741 note the path of the file at Hop's folder plus the text t (an NSString, its bytes left in g_nm; 0 when the 1742 note folder is not known) 1743 fn uhoppath t view uchar * to ulong 1744 n = ucs x_env_dir 1745 upr 0 ulong libptr g_nm 0 1024 1746 dir_text = ucall 9 1747 p = ulong 0 1748 if ne dir_text 0 1749 p = ufetch dir_text 1750 end 1751 if eq p 0 1752 n = ucs x_env_home 1753 upr 0 ulong libptr g_nm 0 1024 1754 home_text = ucall 9 1755 if eq home_text 0 1756 ret 0 1757 end 1758 p = ufetch home_text 1759 p = uptxt p x_support 1760 end 1761 p = uptxt p t 1762 put g_nm p 0 1763 ret unsb 1764 end 1765 1766 note the file at Hop's folder plus the text t, as NSData (0 when it is not there) 1767 fn uhopfile t view uchar * to ulong 1768 path = uhoppath t 1769 if eq path 0 1770 ret 0 1771 end 1772 ret umsg ucl c_data usl m_data_file path 0 0 1773 end 1774 1775 note ---- saved accounts: Hop's keys and logins in the login Keychain (Sources/Vault.swift) ---- 1776 note Each is a generic password under Hop's service: the account is its name, the description its kind, the comment 1777 note its note. Listing them reads no secret. Enter on one reads its secret and puts it on the clipboard, marked 1778 note concealed so that clipboard histories pass it over, as Hop does; macOS asks the person the first time this 1779 note program reads an item Hop made. A check (HOPCHECK) reads only the service named by HOPVAULT, never Hop's, 1780 note and tells the Keychain to put no dialog up for it: what it may not read without one, it does not read. 1781 note It makes its accounts itself (HOPVAULTADD), since macOS lets a program read back what it saved, and 1782 note deletes them when it ends. 1783 note the eight bytes of g_t8 as a number 1784 fn uread8 to ulong 1785 v = ulong 0 1786 for i ulong 8 1787 v = or v shl ulong get g_t8 i mul i 8 1788 end 1789 ret v 1790 end 1791 1792 note the value of the library's constant named t (a pointer kept in a variable of that name); 0 when there is none 1793 fn uconst t view uchar * to ulong 1794 sym_at = usym t 1795 if eq sym_at 0 1796 ret 0 1797 end 1798 upr 0 ulong libptr g_t8 0 8 1799 upr 8 sym_at 1800 upr 16 8 1801 x = ucall 8 1802 ret uread8 1803 end 1804 1805 note ask the Keychain for what q describes; the answer (an object), or 0 1806 fn ukeychain q ulong to ulong 1807 for i ulong 8 1808 put g_t8 i 0 1809 end 1810 upr 0 q 1811 upr 8 ulong libptr g_t8 0 8 1812 if ne and ucall 23 `4294967295` 0 1813 ret 0 1814 end 1815 ret uread8 1816 end 1817 1818 note a question to the Keychain about Hop's items: the generic passwords under the service 1819 fn uvaultquery to ulong 1820 q = umsg ucl c_mutable_dict usl m_dictionary 0 0 0 1821 sset = usl m_set_object 1822 x = umsg q sset uconst s_class_generic uconst s_class 0 1823 x = umsg q sset get g_m 20 uconst s_attr_service 0 1824 ret q 1825 end 1826 1827 note the saved accounts: their names in order (lower case decides), and what each is 1828 fn uloadvault to void 1829 put g_n 31 0 1830 service = ulong 0 1831 if eq get g_n 14 0 1832 n = ucs x_env_vault 1833 upr 0 ulong libptr g_nm 0 1024 1834 vault_text = ucall 9 1835 if eq vault_text 0 1836 ret 1837 end 1838 n = ufetch vault_text 1839 service = unsb 1840 else 1841 service = uns x_vault_service 1842 end 1843 if eq service 0 1844 ret 1845 end 1846 sret = usl m_retain 1847 if eq get g_m 20 0 1848 put g_m 20 umsg service sret 0 0 0 1849 if eq get g_n 14 0 1850 uvaultcheckadd 1851 end 1852 end 1853 q = uvaultquery 1854 sset = usl m_set_object 1855 x = umsg q sset uconst s_limit_all uconst s_match_limit 0 1856 x = umsg q sset uconst s_true uconst s_return_attributes 0 1857 items = ukeychain q 1858 if not uiskind items 8 1859 ret 1860 end 1861 key_account = uconst s_attr_account 1862 key_kind = uconst s_attr_description 1863 key_note = uconst s_attr_comment 1864 sget = usl m_object_for_key 1865 sat = usl m_at 1866 slower = usl m_lowercase 1867 sappend = usl m_append_string 1868 slen = usl m_length 1869 by_low = umsg ucl c_mutable_dict usl m_dictionary 0 0 0 1870 cnt = umsg items usl m_count 0 0 0 1871 for i ulong cnt bound 4096 1872 item = umsg items sat i 0 0 1873 if uiskind item 7 1874 name = umsg item sget key_account 0 0 1875 if uiskind name 9 1876 x = umsg by_low sset item umsg name slower 0 0 0 0 1877 end 1878 end 1879 end 1880 lows = umsg umsg by_low usl m_all_keys 0 0 0 usl m_sorted usl m_compare 0 0 1881 acct_names = umsg ucl c_mutable_array usl m_array 0 0 0 1882 acct_details = umsg ucl c_mutable_array usl m_array 0 0 0 1883 sadd = usl m_add_object 1884 put g_nm 0 32 1885 put g_nm 1 194 1886 put g_nm 2 183 1887 put g_nm 3 32 1888 put g_nm 4 0 1889 dot = unsb 1890 put g_nm 0 0 1891 nothing = unsb 1892 total = umsg lows usl m_count 0 0 0 1893 if gt total 800 1894 total = 800 1895 end 1896 for i ulong total bound 800 1897 item = umsg by_low sget umsg lows sat i 0 0 0 0 1898 x = umsg acct_names sadd umsg item sget key_account 0 0 0 0 1899 detail = nothing 1900 kind = umsg item sget key_kind 0 0 1901 if uiskind kind 9 1902 detail = kind 1903 end 1904 remark = umsg item sget key_note 0 0 1905 if uiskind remark 9 1906 if gt umsg remark slen 0 0 0 0 1907 if gt umsg detail slen 0 0 0 0 1908 detail = umsg detail sappend dot 0 0 1909 end 1910 detail = umsg detail sappend remark 0 0 1911 end 1912 end 1913 x = umsg acct_details sadd detail 0 0 1914 end 1915 srel = usl m_release 1916 if ne get g_m 18 0 1917 x = umsg get g_m 18 srel 0 0 0 1918 x = umsg get g_m 19 srel 0 0 0 1919 end 1920 put g_m 18 umsg acct_names sret 0 0 0 1921 put g_m 19 umsg acct_details sret 0 0 0 1922 put g_n 31 total 1923 end 1924 1925 note the secret of the account named name (an NSString), as text; 0 when it cannot be read 1926 fn usecret name ulong to ulong 1927 if or eq get g_m 20 0 eq name 0 1928 ret 0 1929 end 1930 q = uvaultquery 1931 sset = usl m_set_object 1932 x = umsg q sset name uconst s_attr_account 0 1933 x = umsg q sset uconst s_true uconst s_return_data 0 1934 x = umsg q sset uconst s_limit_one uconst s_match_limit 0 1935 d = ukeychain q 1936 if eq d 0 1937 ret 0 1938 end 1939 whole = umsg ucl c_str usl m_alloc 0 0 0 1940 ret umsg whole usl m_init_data_encoding d 4 0 1941 end 1942 1943 note save an account as Hop does (Vault.save): any item of that name goes, then one is added with the secret as 1944 note its data, the kind as its description and the note as its comment; 1 when it was added 1945 fn uvaultsave name ulong secret_text ulong kind ulong remark ulong to ulong 1946 if or eq get g_m 20 0 or eq name 0 eq secret_text 0 1947 ret 0 1948 end 1949 q = uvaultquery 1950 sset = usl m_set_object 1951 x = umsg q sset name uconst s_attr_account 0 1952 upr 0 q 1953 x = ucall 25 1954 data = umsg secret_text usl m_data_using 4 0 0 1955 if eq data 0 1956 ret 0 1957 end 1958 x = umsg q sset data uconst s_value_data 0 1959 if ne kind 0 1960 x = umsg q sset kind uconst s_attr_description 0 1961 end 1962 if ne remark 0 1963 x = umsg q sset remark uconst s_attr_comment 0 1964 end 1965 x = umsg q sset uconst s_accessible_unlocked uconst s_accessible 0 1966 upr 0 q 1967 upr 8 0 1968 if ne and ucall 24 `4294967295` 0 1969 ret 0 1970 end 1971 ret 1 1972 end 1973 1974 note delete the account of that name (Vault.delete) 1975 fn uvaultdelete name ulong to void 1976 if or eq get g_m 20 0 eq name 0 1977 ret 1978 end 1979 q = uvaultquery 1980 x = umsg q usl m_set_object name uconst s_attr_account 0 1981 upr 0 q 1982 x = ucall 25 1983 end 1984 1985 note for a check: the accounts HOPVAULTADD describes ("name|kind|note|value", more after ";") are saved under the 1986 note check's service by this very program, so that it may read them back without the person being asked 1987 fn uvaultcheckadd to void 1988 if eq get g_m 20 0 1989 ret 1990 end 1991 n = ucs x_env_vault_add 1992 upr 0 ulong libptr g_nm 0 1024 1993 add_text = ucall 9 1994 if eq add_text 0 1995 ret 1996 end 1997 n = ufetch add_text 1998 whole = unsb 1999 if eq whole 0 2000 ret 2001 end 2002 ssplit = usl m_components 2003 sat = usl m_at 2004 slen = usl m_length 2005 made = umsg ucl c_mutable_array usl m_array 0 0 0 2006 put g_m 22 umsg made usl m_retain 0 0 0 2007 entries = umsg whole ssplit uns x_semicolon 0 0 2008 entry_count = umsg entries usl m_count 0 0 0 2009 for i ulong entry_count bound 16 2010 fields = umsg umsg entries sat i 0 0 ssplit uns x_bar 0 0 2011 if eq umsg fields usl m_count 0 0 0 4 2012 name = umsg fields sat 0 0 0 2013 kind = umsg fields sat 1 0 0 2014 remark = umsg fields sat 2 0 0 2015 value = umsg fields sat 3 0 0 2016 if eq umsg kind slen 0 0 0 0 2017 kind = 0 2018 end 2019 if eq umsg remark slen 0 0 0 0 2020 remark = 0 2021 end 2022 if eq uvaultsave name value kind remark 1 2023 x = umsg made usl m_add_object name 0 0 2024 end 2025 end 2026 end 2027 end 2028 2029 note for a check: delete the accounts it made 2030 fn uvaultcheckend to void 2031 made = get g_m 22 2032 if eq made 0 2033 ret 2034 end 2035 cnt = umsg made usl m_count 0 0 0 2036 for i ulong cnt bound 16 2037 uvaultdelete umsg made get g_m 16 i 0 0 2038 end 2039 put g_m 22 0 2040 end 2041 2042 note string i of the array into g_nm from byte p; the byte after it 2043 fn ustrat list_of ulong p ulong i ulong to ulong 2044 if or eq list_of 0 ge p 900 2045 ret p 2046 end 2047 entry_text = umsg list_of get g_m 16 i 0 0 2048 src = umsg entry_text get g_o 5 0 0 0 2049 if eq src 0 2050 ret p 2051 end 2052 upr 0 src 2053 n = ucall 7 2054 if gt add p n 900 2055 n = sub 900 p 2056 end 2057 if eq n 0 2058 ret p 2059 end 2060 upr 0 ulong libptr g_nm p n 2061 upr 8 src 2062 upr 16 n 2063 x = ucall 8 2064 ret add p n 2065 end 2066 2067 note put the secret of saved account i on the clipboard, marked concealed. A check uses a board of its own 2068 fn ucopysecret i ulong to void 2069 if ge i get g_n 31 2070 ret 2071 end 2072 name = umsg get g_m 18 get g_m 16 i 0 0 2073 secret_text = usecret name 2074 if eq secret_text 0 2075 ret 2076 end 2077 pboard = ulong 0 2078 if eq get g_n 14 1 2079 pboard = umsg ucl c_pasteboard usl m_general_pasteboard 0 0 0 2080 else 2081 pboard = umsg ucl c_pasteboard usl m_board_named uns x_check_board 0 0 2082 end 2083 x = umsg pboard usl m_clear 0 0 0 2084 plain_type = uns x_type_string 2085 concealed = uns x_type_concealed 2086 types = umsg ucl c_mutable_array usl m_array 0 0 0 2087 sadd = usl m_add_object 2088 x = umsg types sadd plain_type 0 0 2089 x = umsg types sadd concealed 0 0 2090 x = umsg pboard usl m_declare_types types 0 0 2091 sput = usl m_set_string_type 2092 x = umsg pboard sput secret_text plain_type 0 2093 put g_nm 0 0 2094 nothing = unsb 2095 x = umsg pboard sput nothing concealed 0 2096 put g_n 29 1 2097 end 2098 2099 note is entry e of the models an HTTP model the panel can ask (one whose key is a saved account needs the 2100 note accounts to be readable); when it is, keep it as the model to ask 2101 fn utakemodel e ulong to bool 2102 if not uiskind e 7 2103 ret false 2104 end 2105 kind = ukeyed e k_kind 2106 if uiskind kind 9 2107 want = uns x_openai 2108 if ne and umsg kind usl m_equal_string want 0 0 255 1 2109 ret false 2110 end 2111 end 2112 key_name = ukeyed e k_key 2113 if uiskind key_name 9 2114 if eq get g_m 20 0 2115 ret false 2116 end 2117 else 2118 key_name = 0 2119 end 2120 base = ukeyed e k_base 2121 model = ukeyed e k_model 2122 name = ukeyed e k_name 2123 if or or not uiskind base 9 not uiskind model 9 not uiskind name 9 2124 ret false 2125 end 2126 slash = uns x_slash_text 2127 for i ulong 8 2128 if eq and umsg base usl m_has_suffix slash 0 0 255 1 2129 base = umsg base usl m_substring_to sub umsg base usl m_length 0 0 0 1 0 0 2130 end 2131 end 2132 if eq umsg base usl m_length 0 0 0 0 2133 ret false 2134 end 2135 tail = uns x_completions 2136 address = umsg base usl m_append_string tail 0 0 2137 sret = usl m_retain 2138 put g_m 0 umsg model sret 0 0 0 2139 put g_m 1 umsg address sret 0 0 0 2140 put g_m 2 umsg name sret 0 0 0 2141 put g_m 21 0 2142 if ne key_name 0 2143 put g_m 21 umsg key_name sret 0 0 0 2144 end 2145 put g_m 3 1 2146 ret true 2147 end 2148 2149 note read Hop's settings and choose the model: the default one when it will do, else the first that will 2150 fn uloadconfig to void 2151 put g_m 3 0 2152 put g_m 7 ucl c_dict 2153 put g_m 8 ucl c_array 2154 put g_m 9 ucl c_str 2155 d = uhopfile x_config 2156 if eq d 0 2157 uagentconfig 0 2158 ret 2159 end 2160 config = umsg ucl c_json usl m_json_object d 0 0 2161 if not uiskind config 7 2162 uagentconfig 0 2163 ret 2164 end 2165 uagentconfig config 2166 umachines config 2167 utunnelsload config 2168 put g_n 34 500 2169 limit_number = ukeyed config k_limit 2170 if ne limit_number 0 2171 limit_value = ujsonint limit_number 2172 if and gt limit_value 0 lt limit_value `1000000` 2173 put g_n 34 limit_value 2174 end 2175 end 2176 models = ukeyed config k_models 2177 if not uiskind models 8 2178 ret 2179 end 2180 default_name = ukeyed config k_default 2181 count = umsg models usl m_count 0 0 0 2182 sat = usl m_at 2183 if uiskind default_name 9 2184 for i ulong count bound 256 2185 e = umsg models sat i 0 0 2186 if uiskind e 7 2187 name = ukeyed e k_name 2188 if uiskind name 9 2189 if eq and umsg name usl m_equal_string default_name 0 0 255 1 2190 if utakemodel e 2191 ret 2192 end 2193 end 2194 end 2195 end 2196 end 2197 end 2198 for i ulong count bound 256 2199 e = umsg models sat i 0 0 2200 if utakemodel e 2201 ret 2202 end 2203 end 2204 end 2205 2206 note show the answer in place of the list (on 1), or the list again (on 0) 2207 fn uanswerview on ulong to void 2208 s = usl m_set_hidden 2209 x = umsg get g_o 28 s on 0 0 2210 x = umsg get g_o 29 s sub 1 on 0 0 2211 put g_n 20 on 2212 end 2213 2214 note put the answer so far on show 2215 fn uanswershow to void 2216 whole_talk = get g_m 4 2217 if ne get g_m 25 0 2218 whole_talk = umsg get g_m 25 usl m_append_string get g_m 4 0 0 2219 end 2220 x = umsg get g_o 30 usl m_set_string whole_talk 0 0 2221 end 2222 2223 note stop asking: the running task is cancelled and the list is back 2224 fn uaskstop to void 2225 if ne get g_m 6 0 2226 x = umsg get g_m 6 usl m_cancel_task 0 0 0 2227 put g_m 6 0 2228 if ne get g_m 24 0 2229 x = umsg get g_m 24 usl m_remove_last 0 0 0 2230 end 2231 put g_n 39 1 2232 end 2233 if eq get g_n 20 1 2234 uanswerview 0 2235 end 2236 end 2237 2238 note ask the model the typed text. The body is made by Foundation, so the text is quoted as JSON wants it 2239 fn uask to void 2240 if eq get g_m 3 0 2241 ret 2242 end 2243 a = get g_n 12 2244 n = get g_n 13 2245 for i ulong n bound 256 2246 put g_nm i get g_q add a i 2247 end 2248 put g_nm n 0 2249 question = unsb 2250 sset = usl m_set_object 2251 message = umsg ucl c_mutable_dict usl m_dictionary 0 0 0 2252 x = umsg message sset uns x_user uns k_role 0 2253 x = umsg message sset question uns k_content 0 2254 if eq get g_m 24 0 2255 talk = umsg ucl c_mutable_array usl m_array 0 0 0 2256 put g_m 24 umsg talk usl m_retain 0 0 0 2257 told = umsg ucl c_mutable_string usl m_string 0 0 0 2258 put g_m 25 umsg told usl m_retain 0 0 0 2259 end 2260 note a question asked while another is on its way takes its place 2261 if ne get g_m 6 0 2262 x = umsg get g_m 6 usl m_cancel_task 0 0 0 2263 put g_m 6 0 2264 x = umsg get g_m 24 usl m_remove_last 0 0 0 2265 put g_n 39 1 2266 end 2267 messages = umsg get g_m 24 usl m_array_adding message 0 0 2268 body = umsg ucl c_mutable_dict usl m_dictionary 0 0 0 2269 x = umsg body sset get g_m 0 uns k_model 0 2270 x = umsg body sset messages uns k_messages 0 2271 yes = umsg ucl c_number usl m_number_bool 1 0 0 2272 x = umsg body sset yes uns k_stream 0 2273 data = umsg ucl c_json usl m_json_data body 0 0 2274 url = umsg get g_o 16 get g_o 17 get g_m 1 0 0 2275 if or eq data 0 eq url 0 2276 ret 2277 end 2278 req = umsg ucl c_request usl m_request_url url 0 0 2279 x = umsg req usl m_set_method uns x_post 0 0 2280 x = umsg req usl m_set_header uns x_json_type uns x_content_type 0 2281 if ne get g_m 21 0 2282 secret_text = usecret get g_m 21 2283 if eq secret_text 0 2284 if eq get g_m 4 0 2285 fresh_text = umsg ucl c_mutable_string usl m_string 0 0 0 2286 put g_m 4 umsg fresh_text usl m_retain 0 0 0 2287 end 2288 x = umsg get g_m 4 usl m_set_string uns x_no_key 0 0 2289 put g_n 21 1 2290 put g_n 22 1 2291 uanswershow 2292 uanswerview 1 2293 ret 2294 end 2295 bearer = umsg uns x_bearer usl m_append_string secret_text 0 0 2296 x = umsg req usl m_set_header bearer uns x_authorization 0 2297 end 2298 x = umsg req usl m_set_body data 0 0 2299 s_timeout = usl m_set_timeout 2300 upr 64 bitcast ulong 120.0f64 2301 x = umsg req s_timeout 0 0 0 2302 if eq get g_m 5 0 2303 cfg = umsg ucl c_session_config usl m_ephemeral 0 0 0 2304 queue = umsg ucl c_queue usl m_main_queue 0 0 0 2305 session = umsg ucl c_session usl m_session_with cfg get g_o 27 queue 2306 put g_m 5 umsg session usl m_retain 0 0 0 2307 end 2308 if eq get g_m 4 0 2309 fresh_text = umsg ucl c_mutable_string usl m_string 0 0 0 2310 put g_m 4 umsg fresh_text usl m_retain 0 0 0 2311 end 2312 note what was on show joins what was said before; then the question 2313 put g_nm 0 10 2314 put g_nm 1 10 2315 put g_nm 2 0 2316 blank_line = unsb 2317 sappend_text = usl m_append 2318 if eq get g_n 39 1 2319 x = umsg get g_m 25 sappend_text get g_m 4 0 0 2320 x = umsg get g_m 25 sappend_text blank_line 0 0 2321 end 2322 x = umsg get g_m 25 sappend_text uns x_you 0 0 2323 x = umsg get g_m 25 sappend_text question 0 0 2324 x = umsg get g_m 25 sappend_text blank_line 0 0 2325 x = umsg get g_m 24 usl m_add_object message 0 0 2326 x = umsg get g_m 4 usl m_set_string uns x_asking 0 0 2327 put g_n 19 0 2328 put g_n 21 0 2329 put g_n 22 0 2330 put g_n 39 0 2331 put g_n 40 0 2332 uanswershow 2333 uanswerview 1 2334 task = umsg get g_m 5 usl m_data_task req 0 0 2335 put g_m 6 umsg task usl m_retain 0 0 0 2336 x = umsg task usl m_resume 0 0 0 2337 end 2338 2339 note a turn has ended: an answer joins the conversation; without one the question leaves it again, so that the 2340 note model is not sent a question it never answered 2341 fn uturnend to void 2342 put g_n 39 1 2343 if eq get g_m 24 0 2344 ret 2345 end 2346 if or eq get g_n 40 1 eq get g_n 22 0 2347 x = umsg get g_m 24 usl m_remove_last 0 0 0 2348 ret 2349 end 2350 sset = usl m_set_object 2351 reply = umsg ucl c_mutable_dict usl m_dictionary 0 0 0 2352 x = umsg reply sset uns x_assistant uns k_role 0 2353 said = umsg ucl c_str usl m_utf umsg get g_m 4 get g_o 5 0 0 0 0 0 2354 if eq said 0 2355 x = umsg get g_m 24 usl m_remove_last 0 0 0 2356 ret 2357 end 2358 x = umsg reply sset said uns k_content 0 2359 x = umsg get g_m 24 usl m_add_object reply 0 0 2360 end 2361 2362 note New chat: the conversation is forgotten 2363 fn uchatnew to void 2364 if ne get g_m 33 0 2365 x = umsg get g_m 33 usl m_release 0 0 0 2366 put g_m 33 0 2367 end 2368 if ne get g_m 6 0 2369 x = umsg get g_m 6 usl m_cancel_task 0 0 0 2370 put g_m 6 0 2371 end 2372 srel = usl m_release 2373 if ne get g_m 24 0 2374 x = umsg get g_m 24 srel 0 0 0 2375 x = umsg get g_m 25 srel 0 0 0 2376 put g_m 24 0 2377 put g_m 25 0 2378 end 2379 put g_n 39 0 2380 if ne get g_m 4 0 2381 put g_nm 0 0 2382 no_text = unsb 2383 x = umsg get g_m 4 usl m_set_string no_text 0 0 2384 end 2385 if eq get g_n 20 1 2386 uanswerview 0 2387 end 2388 end 2389 2390 note for a check: when the first answer has come, ask the second question (HOPASK2) in the same conversation 2391 fn uasksecond to void 2392 n = ucs x_env_ask2 2393 upr 0 ulong libptr g_nm 0 1024 2394 second_text = ucall 9 2395 if or eq second_text 0 eq get g_n 21 0 2396 ret 2397 end 2398 n = ucs x_env_asknew 2399 upr 0 ulong libptr g_nm 0 1024 2400 if ne ucall 9 0 2401 uchatnew 2402 end 2403 n = ufetch second_text 2404 second = unsb 2405 x = umsg get g_o 0 get g_o 8 second 0 0 2406 utyped 2407 if and gt get g_n 1 0 eq ulong get g_rk 0 8 2408 uask 2409 end 2410 end 2411 2412 note a piece of the answer: the first one takes the place of "Asking ..." 2413 fn uanswerpiece piece ulong to void 2414 if eq get g_n 22 0 2415 put g_nm 0 0 2416 empty_text = unsb 2417 x = umsg get g_m 4 usl m_set_string empty_text 0 0 2418 put g_n 22 1 2419 end 2420 x = umsg get g_m 4 usl m_append piece 0 0 2421 uanswershow 2422 end 2423 2424 note the JSON in g_net[o .. o+n) as an object (0 when it is not JSON) 2425 fn unetjson o ulong n ulong to ulong 2426 if or eq n 0 gt add o n 262144 2427 ret 0 2428 end 2429 d = umsg ucl c_data usl m_data_bytes ulong libptr g_net o n n 0 2430 ret umsg ucl c_json usl m_json_object d 0 0 2431 end 2432 2433 note one line from the server: "data: {...}" carries a piece of the answer at choices[0].delta.content 2434 note (an empty line may stand first in what came: a server's packet may begin with the line break that ends an 2435 note event, so nothing before the line is looked at when it is empty; "and" looks at both its sides) 2436 fn unetline o ulong n ulong to void 2437 ln = n 2438 if gt ln 0 2439 if eq ulong get g_net sub add o ln 1 13 2440 ln = sub ln 1 2441 end 2442 end 2443 if lt ln 6 2444 ret 2445 end 2446 if or or ne ulong get g_net o 100 ne ulong get g_net add o 1 97 or ne ulong get g_net add o 2 116 or ne ulong get g_net add o 3 97 ne ulong get g_net add o 4 58 2447 ret 2448 end 2449 pay_o = add o 5 2450 pay_l = sub ln 5 2451 while and gt pay_l 0 eq ulong get g_net pay_o 32 bound 300000 2452 pay_o = add pay_o 1 2453 pay_l = sub pay_l 1 2454 end 2455 obj = unetjson pay_o pay_l 2456 if not uiskind obj 7 2457 ret 2458 end 2459 choices = ukeyed obj k_choices 2460 if not uiskind choices 8 2461 ret 2462 end 2463 if eq umsg choices usl m_count 0 0 0 0 2464 ret 2465 end 2466 choice = umsg choices usl m_at 0 0 0 2467 if not uiskind choice 7 2468 ret 2469 end 2470 delta = ukeyed choice k_delta 2471 if not uiskind delta 7 2472 ret 2473 end 2474 content = ukeyed delta k_content 2475 if uiskind content 9 2476 if gt umsg content usl m_length 0 0 0 0 2477 uanswerpiece content 2478 end 2479 end 2480 end 2481 2482 note bytes from the server: add them to g_net, read every whole line, keep the rest 2483 fn unetdata data ulong to void 2484 p = umsg data usl m_bytes 0 0 0 2485 n = umsg data usl m_length 0 0 0 2486 fill = get g_n 19 2487 if or eq p 0 gt add fill n 262144 2488 put g_n 19 0 2489 ret 2490 end 2491 if eq n 0 2492 ret 2493 end 2494 upr 0 ulong libptr g_net fill n 2495 upr 8 p 2496 upr 16 n 2497 x = ucall 8 2498 fill = add fill n 2499 line_start = ulong 0 2500 i = ulong 0 2501 while lt i fill bound 300000 2502 if eq ulong get g_net i 10 2503 unetline line_start sub i line_start 2504 line_start = add i 1 2505 end 2506 i = add i 1 2507 end 2508 rest = sub fill line_start 2509 for j ulong rest bound 300000 2510 put g_net j get g_net add line_start j 2511 end 2512 put g_n 19 rest 2513 end 2514 2515 note the answer has ended (problem: what went wrong, or nothing). A server that did not stream gave one JSON 2516 note object: its text is at choices[0].message.content 2517 fn unetdone task ulong problem ulong to void 2518 put g_n 21 1 2519 if ne task get g_m 6 2520 ret 2521 end 2522 put g_m 6 0 2523 if ne problem 0 2524 uanswerpiece umsg problem usl m_description 0 0 0 2525 put g_n 40 1 2526 uturnend 2527 ret 2528 end 2529 if eq get g_n 22 0 2530 obj = unetjson 0 get g_n 19 2531 if uiskind obj 7 2532 choices = ukeyed obj k_choices 2533 if uiskind choices 8 2534 if gt umsg choices usl m_count 0 0 0 0 2535 choice = umsg choices usl m_at 0 0 0 2536 if uiskind choice 7 2537 message = ukeyed choice k_message 2538 if uiskind message 7 2539 content = ukeyed message k_content 2540 if uiskind content 9 2541 uanswerpiece content 2542 end 2543 end 2544 end 2545 end 2546 end 2547 end 2548 end 2549 if eq get g_n 22 0 2550 code = umsg umsg task usl m_response 0 0 0 usl m_status_code 0 0 0 2551 if ge code 300 2552 p = ulong 0 2553 if or eq code 429 eq code 503 2554 p = uptxt 0 x_busy 2555 end 2556 p = uptxt p x_http 2557 p = upnum p code 2558 p = uptxt p x_bracket 2559 put g_nm p 0 2560 uanswerpiece unsb 2561 else 2562 uanswerpiece uns x_no_answer 2563 end 2564 put g_n 40 1 2565 end 2566 uturnend 2567 end 2568 2569 note the rows for typed text, by the one box's rules (fn swrank): the request is what Sources/SmartRank.swift 2570 note sends, with the m matched apps of g_mk, their hopfuzz scores, use and habits, the web address and the files found, and 2571 note the copied things that match, the saved accounts, the two screens and the two commands the panel has. The Ask row and the agent's row come back too. 2572 note one word of a screen or a command into the request: its length as number k, its bytes at bp; the byte after 2573 fn uwordput tb edit uchar `1048576` k ulong bp ulong t view uchar * to ulong 2574 n = ucs t 2575 upn tb k n 2576 for i ulong n bound 64 2577 put tb add bp i get g_nm i 2578 end 2579 ret add bp n 2580 end 2581 2582 fn urankrows m ulong to void 2583 tb = new uchar `1048576` 0 2584 ob = new uchar 65544 0 2585 a = get g_n 12 2586 n = get g_n 13 2587 nf = get g_n 17 2588 uclipmatch 8 2589 ncl = get g_n 28 2590 nacc = get g_n 31 2591 nr = get g_n 49 2592 nfa = add nf nr 2593 c = add add add add add 13 mul m 4 mul nfa 3 mul nacc 2 ncl 26 2594 upn tb 0 n 2595 upn tb 1 n 2596 upn tb 2 get g_n 10 2597 upn tb 3 1 2598 exact_name = get g_n 18 2599 if eq get g_n 58 1 2600 exact_name = 1 2601 end 2602 upn tb 4 exact_name 2603 upn tb 5 get g_n 41 2604 words_typed = ulong 0 2605 in_word = false 2606 for i ulong n bound 256 2607 cw = ulong get g_q add a i 2608 if or eq cw 32 eq cw 9 2609 in_word = false 2610 else 2611 if not in_word 2612 words_typed = add words_typed 1 2613 end 2614 in_word = true 2615 end 2616 end 2617 send_agent = ulong 0 2618 if and eq get g_n 42 1 ge words_typed 3 2619 send_agent = 1 2620 end 2621 upn tb 6 send_agent 2622 upn tb 7 m 2623 upn tb 8 nfa 2624 for i ulong nr bound 64 2625 o = add add 13 mul m 4 mul add nf i 3 2626 upb tb o sub add k_b get g_rs i 100000 2627 upn tb add o 1 0 2628 upn tb add o 2 0 2629 end 2630 for i ulong 4 2631 upn tb add 9 i 0 2632 end 2633 upn tb 12 ncl 2634 upn tb 11 nacc 2635 pacc = add add 13 mul m 4 mul nfa 3 2636 note the screens the panel has (the copied things, the accounts) and what it can do (settings, quit), each with 2637 note the words that name it (and Rebuild file index): a count, then the length of each word; the words themselves follow the typed text 2638 q = add add pacc mul nacc 2 ncl 2639 word_start = add add 8 mul c 8 n 2640 bp = word_start 2641 upn tb add q 0 3 2642 bp = uwordput tb add q 1 bp x_word0 2643 bp = uwordput tb add q 2 bp x_word1 2644 bp = uwordput tb add q 3 bp x_word2 2645 upn tb add q 4 5 2646 bp = uwordput tb add q 5 bp x_word3 2647 bp = uwordput tb add q 6 bp x_word4 2648 bp = uwordput tb add q 7 bp x_word5 2649 bp = uwordput tb add q 8 bp x_word6 2650 bp = uwordput tb add q 9 bp x_word7 2651 upn tb add q 10 1 2652 bp = uwordput tb add q 11 bp x_word_agent 2653 upn tb add q 12 4 2654 bp = uwordput tb add q 13 bp x_word8 2655 bp = uwordput tb add q 14 bp x_word9 2656 bp = uwordput tb add q 15 bp x_word10 2657 bp = uwordput tb add q 16 bp x_word11 2658 upn tb add q 17 1 2659 bp = uwordput tb add q 18 bp x_word12 2660 upn tb add q 19 3 2661 bp = uwordput tb add q 20 bp x_word_rebuild 2662 bp = uwordput tb add q 21 bp x_word_reindex 2663 bp = uwordput tb add q 22 bp x_word_index_files 2664 upn tb add q 23 2 2665 bp = uwordput tb add q 24 bp x_word_new_chat 2666 bp = uwordput tb add q 25 bp x_word_clear_chat 2667 word_bytes = sub bp word_start 2668 upn tb 9 3 2669 upn tb 10 4 2670 for i ulong ncl bound 8 2671 upn tb add add pacc mul nacc 2 i ulong get g_cp get g_cm i 2672 end 2673 if gt nacc 0 2674 for i ulong n bound 256 2675 put g_nm i get g_q add a i 2676 end 2677 put g_nm n 0 2678 typed = unsb 2679 typed_low = ulong 0 2680 if ne typed 0 2681 typed_low = umsg typed usl m_lowercase 0 0 0 2682 end 2683 slower = usl m_lowercase 2684 scontains = usl m_contains 2685 sprefix = usl m_has_prefix 2686 for i ulong nacc bound 800 2687 has = ulong 0 2688 starts = ulong 0 2689 if ne typed_low 0 2690 name_low = umsg umsg get g_m 18 get g_m 16 i 0 0 slower 0 0 0 2691 has = and umsg name_low scontains typed_low 0 0 255 2692 starts = and umsg name_low sprefix typed_low 0 0 255 2693 end 2694 upn tb add pacc mul i 2 has 2695 upn tb add add pacc mul i 2 1 starts 2696 end 2697 end 2698 note an app's own use and habits count as in Hop: how much it is used, its lifts from the app in front and the 2699 note hour, and whether it is the app that was in front before (all as they were when the panel was last shown) 2700 for i ulong m bound 2048 2701 o = add 13 mul i 4 2702 k = get g_mk i 2703 upn tb o get g_ms i 2704 upn tb add o 1 get g_us k 2705 upn tb add o 2 add get g_lf k get g_lh k 2706 was_before = ulong 0 2707 if eq add k 1 get g_n 32 2708 was_before = 1 2709 end 2710 upn tb add o 3 was_before 2711 end 2712 note a file's score may be below zero: it goes in as 2^40 plus the score, written as it is 2713 for i ulong nf bound 64 2714 o = add add 13 mul m 4 mul i 3 2715 upb tb o sub add k_b get g_fs i 100000 2716 upn tb add o 1 0 2717 upn tb add o 2 uisapp i m 2718 end 2719 lo = add 8 mul c 8 2720 for i ulong n bound 256 2721 put tb add lo i uchar ulower ulong get g_q add a i 2722 end 2723 k = swrank tb c add n word_bytes ob 2724 h = ulong 0 2725 if ne k 0 2726 rws = sub uog ob 0 k_b 2727 for i ulong rws bound 1024 2728 knd = sub uog ob add 1 mul i 4 k_b 2729 ix = sub uog ob add 2 mul i 4 k_b 2730 if and eq knd 1 lt ix m 2731 put g_rk h 1 2732 put g_hit h get g_mk ix 2733 h = add h 1 2734 end 2735 if eq knd 2 2736 put g_rk h 2 2737 put g_hit h 0 2738 h = add h 1 2739 end 2740 if and eq knd 7 lt ix nf 2741 put g_rk h 7 2742 put g_hit h ix 2743 h = add h 1 2744 end 2745 if and and eq knd 7 ge ix nf lt ix nfa 2746 put g_rk h 10 2747 put g_hit h sub ix nf 2748 h = add h 1 2749 end 2750 if eq knd 8 2751 put g_rk h 8 2752 put g_hit h 0 2753 h = add h 1 2754 end 2755 if eq knd 9 2756 put g_rk h 9 2757 put g_hit h 0 2758 h = add h 1 2759 end 2760 if and eq knd 6 lt ix ncl 2761 put g_rk h 6 2762 put g_hit h get g_cm ix 2763 h = add h 1 2764 end 2765 if and eq knd 5 lt ix nacc 2766 put g_rk h 5 2767 put g_hit h ix 2768 h = add h 1 2769 end 2770 if and eq knd 3 lt ix 3 2771 put g_rk h 3 2772 put g_hit h ix 2773 h = add h 1 2774 end 2775 if and eq knd 4 lt ix 4 2776 put g_rk h 4 2777 put g_hit h ix 2778 h = add h 1 2779 end 2780 end 2781 end 2782 put g_n 1 h 2783 end 2784 2785 note ---- before anything is typed: what to offer, by Hop's rule (fn swsuggest, fn swlifts) ---- 2786 note the path of app k into g_nm from byte p (its folder, "/", its name, ".app"); the byte after it 2787 fn uapppath p ulong k ulong to ulong 2788 q = p 2789 if eq ulong get g_dir k 0 2790 q = uptxt p x_dir1 2791 else 2792 q = uptxt p x_dir2 2793 end 2794 q = uptxt q x_slash 2795 q = upname q k 2796 ret uptxt q x_dotapp 2797 end 2798 2799 note byte j of app k's name with ".app" after it (0 past the end): what its path is ordered by within a folder 2800 fn ukeybyte k ulong j ulong to ulong 2801 n = get g_ln k 2802 if lt j n 2803 ret ulong get g_pool add get g_off k j 2804 end 2805 if lt j add n 4 2806 ret ulong get x_dotapp sub j n 2807 end 2808 ret 0 2809 end 2810 2811 note does app a come before app b in the order of their paths 2812 fn uappless a ulong b ulong to bool 2813 da = ulong get g_dir a 2814 db = ulong get g_dir b 2815 if ne da db 2816 ret lt da db 2817 end 2818 for j ulong 1100 2819 ca = ukeybyte a j 2820 cb = ukeybyte b j 2821 if ne ca cb 2822 ret lt ca cb 2823 end 2824 if eq ca 0 2825 ret false 2826 end 2827 end 2828 ret false 2829 end 2830 2831 note each app's path and place into a dictionary, and the apps into the order of their paths 2832 fn ubuildmap to void 2833 map = umsg ucl c_mutable_dict usl m_dictionary 0 0 0 2834 put g_m 10 umsg map usl m_retain 0 0 0 2835 sset = usl m_set_object 2836 snum = usl m_number_integer 2837 cnum = ucl c_number 2838 for k ulong get g_n 0 bound 2048 2839 p = uapppath 0 k 2840 put g_nm p 0 2841 path = unsb 2842 num = umsg cnum snum k 0 0 2843 x = umsg map sset num path 0 2844 pos = k 2845 while gt pos 0 bound 4096 2846 if not uappless k get g_so sub pos 1 2847 break 2848 end 2849 put g_so pos get g_so sub pos 1 2850 pos = sub pos 1 2851 end 2852 put g_so pos k 2853 end 2854 end 2855 2856 note the place of the app at this path (an NSString), or the count of apps when it is not one of them 2857 fn uplaceof path ulong to ulong 2858 if or eq path 0 eq get g_m 10 0 2859 ret get g_n 0 2860 end 2861 num = umsg get g_m 10 usl m_object_for_key path 0 0 2862 if eq num 0 2863 ret get g_n 0 2864 end 2865 ret umsg num usl m_integer_value 0 0 0 2866 end 2867 2868 note how much the user's own use lifts a path: 25 times the base-2 logarithm of 1 plus the count of openings, the 2869 note count halved for every three days since the last, plus 10; 80 at most (Sources/Recents.swift) 2870 fn uboost cnt ulong last_bits ulong now_bits ulong to ulong 2871 age = sub bitcast f64 now_bits bitcast f64 last_bits 2872 upr 64 bitcast ulong 0.5f64 2873 upr 72 bitcast ulong div age 259200.0f64 2874 x = ucall 14 2875 weighed = mul f64 cnt bitcast f64 ugr 64 2876 upr 64 bitcast ulong add 1.0f64 weighed 2877 x = ucall 15 2878 v = add mul 25.0f64 bitcast f64 ugr 64 10.0f64 2879 if gt v 80.0f64 2880 ret 80 2881 end 2882 if lt v 0.0f64 2883 ret 0 2884 end 2885 ret ulong v 2886 end 2887 2888 note remember the app in front (not this program) before the panel takes its place 2889 fn ufront to void 2890 ws = umsg ucl c_ws usl m_shws 0 0 0 2891 app_front = umsg ws usl m_frontmost 0 0 0 2892 this_app = umsg ucl c_running_app usl m_current_app 0 0 0 2893 if or eq app_front 0 eq app_front this_app 2894 ret 2895 end 2896 sret = usl m_retain 2897 id = umsg app_front usl m_bundle_id 0 0 0 2898 put g_m 11 0 2899 if ne id 0 2900 put g_m 11 umsg id sret 0 0 0 2901 end 2902 name = umsg app_front usl m_localized_name 0 0 0 2903 put g_m 12 0 2904 if ne name 0 2905 put g_m 12 umsg name sret 0 0 0 2906 end 2907 put g_m 13 0 2908 url = umsg app_front usl m_bundle_url 0 0 0 2909 if eq url 0 2910 ret 2911 end 2912 k = uplaceof umsg url usl m_path 0 0 0 2913 if ge k get g_n 0 2914 ret 2915 end 2916 put g_m 13 add k 1 2917 note newest first, each app once 2918 found = ulong 11 2919 for i ulong 12 2920 if and eq get g_fr i add k 1 eq found 11 2921 found = i 2922 end 2923 end 2924 pos = found 2925 while gt pos 0 bound 16 2926 put g_fr pos get g_fr sub pos 1 2927 pos = sub pos 1 2928 end 2929 put g_fr 0 add k 1 2930 end 2931 2932 note is the JSON value a number (a file a person may have edited can hold anything where a number belongs, and 2933 note only a number can be asked for its value: a null, a list or a group asked so would stop the program) 2934 fn uisnumber obj ulong to bool 2935 if eq obj 0 2936 ret false 2937 end 2938 ret eq and umsg obj usl m_is_kind ucl c_number 0 0 255 1 2939 end 2940 2941 note a whole number from a JSON value (0 when it is none); below zero comes back as a number of 2^63 and up 2942 fn ujsonint obj ulong to ulong 2943 if not uisnumber obj 2944 ret 0 2945 end 2946 ret umsg obj usl m_integer_value 0 0 0 2947 end 2948 2949 note the rows before anything is typed: the lifts from habit, the use, what is running and what was in front go 2950 note to the rule as numbers, in the order of the apps' paths; the app in front is never offered 2951 fn usuggest to void 2952 tb = new uchar `1048576` 0 2953 ob = new uchar 65544 0 2954 na = get g_n 0 2955 put g_n 1 0 2956 if eq get g_m 10 0 2957 ret 2958 end 2959 note the lifts from habit 2960 for k ulong na bound 2048 2961 put g_lf k 0 2962 put g_lh k 0 2963 put g_us k 0 2964 put g_rn k 0 2965 end 2966 cal = umsg ucl c_calendar usl m_current_calendar 0 0 0 2967 now_date = umsg ucl c_date usl m_date_now 0 0 0 2968 hour = umsg cal usl m_component 32 now_date 0 2969 front_id = get g_m 11 2970 nl = ulong 0 2971 habits = ulong 0 2972 d = uhopfile x_habits 2973 if ne d 0 2974 habits = umsg ucl c_json usl m_json_object d 0 0 2975 end 2976 if uiskind habits 8 2977 nl = umsg habits usl m_count 0 0 0 2978 if gt nl 4096 2979 nl = 4096 2980 end 2981 end 2982 upn tb 0 hour 2983 front_number = ulong 0 2984 if ne front_id 0 2985 front_number = 1 2986 end 2987 upn tb 1 front_number 2988 upn tb 2 na 2989 upn tb 3 nl 2990 sat = usl m_at 2991 for j ulong nl bound 4096 2992 o = add 4 mul j 3 2993 launch = umsg habits sat j 0 0 2994 here = ulong 0 2995 hr = ulong 0 2996 place = na 2997 if uiskind launch 7 2998 from = ukeyed launch k_from 2999 if and ne front_id 0 uiskind from 9 3000 if eq and umsg from usl m_equal_string front_id 0 0 255 1 3001 here = 1 3002 end 3003 end 3004 hr = ujsonint ukeyed launch k_hour 3005 opened = ukeyed launch k_app 3006 if uiskind opened 9 3007 place = uplaceof opened 3008 end 3009 end 3010 upn tb o here 3011 if ge hr `9223372036854775808` 3012 upb tb add o 1 sub k_b add xor hr `18446744073709551615` 1 3013 else 3014 if gt hr `1000000` 3015 hr = `1000000` 3016 end 3017 upn tb add o 1 hr 3018 end 3019 if lt place na 3020 upn tb add o 2 place 3021 else 3022 upb tb add o 2 sub k_b 1 3023 end 3024 end 3025 k1 = swlifts tb add 4 mul nl 3 ob 3026 if ne k1 0 3027 for k ulong na bound 2048 3028 put g_lf k sub uog ob add 1 mul k 2 k_b 3029 put g_lh k sub uog ob add 2 mul k 2 k_b 3030 end 3031 end 3032 note how much each app is used 3033 recents = ulong 0 3034 d = uhopfile x_recents 3035 if ne d 0 3036 recents = umsg ucl c_json usl m_json_object d 0 0 3037 end 3038 if uiskind recents 7 3039 x = umsg ucl c_date usl m_reference_now 0 0 0 3040 now_bits = ugr 64 3041 for k ulong na bound 2048 3042 p = uptxt 0 x_mac_key 3043 p = uapppath p k 3044 put g_nm p 0 3045 key = unsb 3046 e = umsg recents usl m_object_for_key key 0 0 3047 if uiskind e 7 3048 cnt = ujsonint ukeyed e k_count 3049 last = ukeyed e k_last 3050 if and uisnumber last lt cnt `1000000000` 3051 x = umsg last usl m_double_value 0 0 0 3052 put g_us k uboost cnt ugr 64 now_bits 3053 end 3054 end 3055 end 3056 end 3057 note what is running (apps a person sees: the regular ones) 3058 ws = umsg ucl c_ws usl m_shws 0 0 0 3059 running = umsg ws usl m_running_apps 0 0 0 3060 if ne running 0 3061 nr = umsg running usl m_count 0 0 0 3062 for j ulong nr bound 4096 3063 r = umsg running sat j 0 0 3064 if eq umsg r usl m_policy_of 0 0 0 0 3065 url = umsg r usl m_bundle_url 0 0 0 3066 if ne url 0 3067 k = uplaceof umsg url usl m_path 0 0 0 3068 if lt k na 3069 put g_rn k 1 3070 end 3071 end 3072 end 3073 end 3074 end 3075 note the app in front before: the newest remembered one that is not in front now 3076 front_place = get g_m 13 3077 previous = ulong 0 3078 for i ulong 12 3079 if and and eq previous 0 ne get g_fr i 0 ne get g_fr i front_place 3080 previous = get g_fr i 3081 end 3082 end 3083 put g_n 32 previous 3084 note the request of fn swsuggest: what was copied, then six numbers an app 3085 for i ulong 6 3086 upn tb i 0 3087 end 3088 ncl = get g_n 24 3089 nrest = ulong 0 3090 put g_n 25 0 3091 put g_n 26 0 3092 if gt ncl 0 3093 upn tb 0 1 3094 newest = umsg get g_m 14 get g_m 16 0 0 0 3095 age = ulong 0 3096 if uiskind newest 7 3097 moment = ukeyed newest k_date 3098 if uisnumber moment 3099 x = umsg moment usl m_double_value 0 0 0 3100 then_bits = ugr 64 3101 x = umsg ucl c_date usl m_reference_now 0 0 0 3102 gap = sub bitcast f64 ugr 64 bitcast f64 then_bits 3103 if gt gap 0.0f64 3104 age = `1000000000` 3105 if lt gap `1000000000`.0f64 3106 age = ulong gap 3107 end 3108 end 3109 end 3110 words = ukeyed newest k_text 3111 if uiskind words 9 3112 wb = umsg words get g_o 5 0 0 0 3113 if ne wb 0 3114 upr 0 wb 3115 wn = ucall 7 3116 if and ge wn 4 le wn 255 3117 upr 0 ulong libptr g_ca 0 wn 3118 upr 8 wb 3119 upr 16 wn 3120 x = ucall 8 3121 if and and eq ulower ulong get g_ca 0 104 eq ulower ulong get g_ca 1 116 and eq ulower ulong get g_ca 2 116 eq ulower ulong get g_ca 3 112 3122 put g_n 25 wn 3123 uclipaddr 1 3124 udecide 3125 put g_n 26 get g_n 10 3126 uclipaddr 0 3127 end 3128 end 3129 end 3130 end 3131 end 3132 upn tb 1 age 3133 if ne get g_n 26 0 3134 upn tb 2 1 3135 end 3136 upn tb 3 ufrontbrowser 3137 for pos ulong ncl bound 1024 3138 i = get g_ci pos 3139 if and ne i 0 lt nrest 20 3140 put g_cr nrest i 3141 nrest = add nrest 1 3142 end 3143 end 3144 upn tb 4 nrest 3145 end 3146 put g_n 27 nrest 3147 upn tb 6 na 3148 for pos ulong na bound 2048 3149 k = get g_so pos 3150 o = add 7 mul pos 6 3151 if eq add k 1 front_place 3152 for i ulong 6 3153 upn tb add o i 0 3154 end 3155 else 3156 upn tb o get g_lf k 3157 upn tb add o 1 get g_lh k 3158 upn tb add o 2 get g_us k 3159 upn tb add o 3 ulong get g_rn k 3160 was_before = ulong 0 3161 if eq add k 1 previous 3162 was_before = 1 3163 end 3164 upn tb add o 4 was_before 3165 lately = ulong 0 3166 for i ulong 5 3167 if eq get g_fr i add k 1 3168 lately = sub 10 mul 2 i 3169 end 3170 end 3171 upn tb add o 5 lately 3172 end 3173 end 3174 k2 = swsuggest tb add 7 mul na 6 ob 3175 h = ulong 0 3176 if ne k2 0 3177 rws = sub uog ob 0 k_b 3178 for i ulong rws bound 64 3179 knd = sub uog ob add 1 mul i 4 k_b 3180 ix = sub uog ob add 2 mul i 4 k_b 3181 if and eq knd 1 lt ix na 3182 put g_rk h 1 3183 put g_hit h get g_so ix 3184 put g_why h uchar sub uog ob add 4 mul i 4 k_b 3185 h = add h 1 3186 end 3187 if and eq knd 6 le ix nrest 3188 put g_rk h 6 3189 if eq ix 0 3190 put g_hit h 0 3191 else 3192 put g_hit h get g_cr sub ix 1 3193 end 3194 put g_why h uchar sub uog ob add 4 mul i 4 k_b 3195 h = add h 1 3196 end 3197 if and eq knd 2 ne get g_n 26 0 3198 put g_rk h 2 3199 put g_hit h 0 3200 put g_why h 3 3201 h = add h 1 3202 end 3203 end 3204 end 3205 put g_n 1 h 3206 end 3207 3208 note ---- remembering what was opened, as Hop does (Habits.record in Sources/Smart.swift, Sources/Recents.swift) ---- 3209 note Both files are read again at that moment and written whole, all at once. A file that is there but is not 3210 note what Hop writes is left alone. While Hop itself runs it keeps its own copy and writes that over the file the 3211 note next time it remembers something, so what the panel added then is lost. 3212 note write the JSON object obj as Hop's file named t; private: only the owner may read it; 1 when it was written 3213 fn uhopwrite obj ulong t view uchar * private ulong to ulong 3214 data = umsg ucl c_json usl m_json_data obj 0 0 3215 if eq data 0 3216 ret 0 3217 end 3218 s_write = usl m_write_file 3219 path = uhoppath t 3220 if eq path 0 3221 ret 0 3222 end 3223 ok = and umsg data s_write path 1 0 255 3224 if and eq ok 1 eq private 1 3225 path = uhoppath t 3226 upr 0 ulong libptr g_nm 0 1024 3227 upr 8 384 3228 x = ucall 16 3229 end 3230 ret ok 3231 end 3232 3233 note the weight of an entry of recents.json: its count of openings, halved for every three days since the last 3234 fn urecentweight e ulong now_bits ulong to ulong 3235 if not uiskind e 7 3236 ret bitcast ulong 0.0f64 3237 end 3238 cnt = ujsonint ukeyed e k_count 3239 if ge cnt `1000000000` 3240 cnt = 0 3241 end 3242 last = ukeyed e k_last 3243 if not uisnumber last 3244 ret bitcast ulong 0.0f64 3245 end 3246 x = umsg last usl m_double_value 0 0 0 3247 last_bits = ugr 64 3248 age = sub bitcast f64 now_bits bitcast f64 last_bits 3249 upr 64 bitcast ulong 0.5f64 3250 upr 72 bitcast ulong div age 259200.0f64 3251 x = ucall 14 3252 ret bitcast ulong mul f64 cnt bitcast f64 ugr 64 3253 end 3254 3255 note one more opening of path (an NSString) into recents.json: its count up by one, now as the last time; over 500 3256 note entries the one that weighs least goes 3257 fn urecent path ulong to void 3258 recents = ulong 0 3259 d = uhopfile x_recents 3260 if ne d 0 3261 recents = umsg ucl c_json usl m_json_object d 1 0 3262 if not uiskind recents 7 3263 ret 3264 end 3265 else 3266 recents = umsg ucl c_mutable_dict usl m_dictionary 0 0 0 3267 end 3268 prefix = uns x_mac_key 3269 key = umsg prefix usl m_append_string path 0 0 3270 sset = usl m_set_object 3271 cnum = ucl c_number 3272 e = umsg recents usl m_object_for_key key 0 0 3273 cnt = ulong 0 3274 if uiskind e 7 3275 cnt = ujsonint ukeyed e k_count 3276 if ge cnt `1000000000` 3277 cnt = 0 3278 end 3279 else 3280 e = umsg ucl c_mutable_dict usl m_dictionary 0 0 0 3281 key_path = uns k_path 3282 x = umsg e sset path key_path 0 3283 x = umsg recents sset e key 0 3284 end 3285 num = umsg cnum usl m_number_integer add cnt 1 0 0 3286 key_count = uns k_count 3287 x = umsg e sset num key_count 0 3288 x = umsg ucl c_date usl m_reference_now 0 0 0 3289 now_bits = ugr 64 3290 s_double = usl m_number_double 3291 upr 64 now_bits 3292 last = umsg cnum s_double 0 0 0 3293 key_last = uns k_last 3294 x = umsg e sset last key_last 0 3295 n = umsg recents usl m_count 0 0 0 3296 if gt n 500 3297 keys = umsg recents usl m_all_keys 0 0 0 3298 sat = usl m_at 3299 least = ulong 0 3300 least_bits = ulong 0 3301 for i ulong n bound 4096 3302 k = umsg keys sat i 0 0 3303 w = urecentweight umsg recents usl m_object_for_key k 0 0 now_bits 3304 if or eq least 0 lt bitcast f64 w bitcast f64 least_bits 3305 least = k 3306 least_bits = w 3307 end 3308 end 3309 if ne least 0 3310 x = umsg recents usl m_remove_key least 0 0 3311 end 3312 end 3313 x = uhopwrite recents x_recents 0 3314 end 3315 3316 note app k was opened: into recents.json, and into habits.json with the app that was in front and the hour (the 3317 note newest 400 are kept) 3318 fn urecordapp k ulong to void 3319 p = uapppath 0 k 3320 put g_nm p 0 3321 path = unsb 3322 urecent path 3323 habits = ulong 0 3324 d = uhopfile x_habits 3325 if ne d 0 3326 habits = umsg ucl c_json usl m_json_object d 1 0 3327 if not uiskind habits 8 3328 ret 3329 end 3330 else 3331 habits = umsg ucl c_mutable_array usl m_array 0 0 0 3332 end 3333 cal = umsg ucl c_calendar usl m_current_calendar 0 0 0 3334 now_date = umsg ucl c_date usl m_date_now 0 0 0 3335 hour = umsg cal usl m_component 32 now_date 0 3336 x = umsg ucl c_date usl m_reference_now 0 0 0 3337 now_bits = ugr 64 3338 cnum = ucl c_number 3339 sset = usl m_set_object 3340 launch = umsg ucl c_mutable_dict usl m_dictionary 0 0 0 3341 key_app = uns k_app 3342 x = umsg launch sset path key_app 0 3343 from_id = get g_m 11 3344 if eq from_id 0 3345 put g_nm 0 0 3346 from_id = unsb 3347 end 3348 key_from = uns k_from 3349 x = umsg launch sset from_id key_from 0 3350 num = umsg cnum usl m_number_integer hour 0 0 3351 key_hour = uns k_hour 3352 x = umsg launch sset num key_hour 0 3353 s_double = usl m_number_double 3354 upr 64 now_bits 3355 moment = umsg cnum s_double 0 0 0 3356 key_moment = uns k_at_key 3357 x = umsg launch sset moment key_moment 0 3358 x = umsg habits usl m_add_object launch 0 0 3359 n = umsg habits usl m_count 0 0 0 3360 if gt n 400 3361 x = umsg habits usl m_remove_range 0 sub n 400 0 3362 end 3363 x = uhopwrite habits x_habits 1 3364 end 3365 3366 note best file i was opened: into recents.json under its whole path 3367 fn urecordfile i ulong to void 3368 p = ufilepath 0 i 3369 if eq p 0 3370 ret 3371 end 3372 put g_nm p 0 3373 path = unsb 3374 urecent path 3375 end 3376 3377 note why an offered app is offered into g_nm from byte p (nothing for a typed row); the byte after it 3378 fn uwhy p ulong r ulong to ulong 3379 w = ulong get g_why r 3380 if or ne get g_n 13 0 eq w 0 3381 ret p 3382 end 3383 q = uptxt p x_gap 3384 if eq w 1 3385 ret uptxt q x_why1 3386 end 3387 if eq w 2 3388 ret uptxt q x_why2 3389 end 3390 if eq w 3 3391 ret uptxt q x_why3 3392 end 3393 if eq w 4 3394 q = uptxt q x_why4 3395 name = get g_m 12 3396 if eq name 0 3397 ret uptxt q x_here 3398 end 3399 name_bytes = umsg name get g_o 5 0 0 0 3400 upr 0 name_bytes 3401 n = ucall 7 3402 if gt n 200 3403 n = 200 3404 end 3405 upr 0 ulong libptr g_nm q n 3406 upr 8 name_bytes 3407 upr 16 n 3408 x = ucall 8 3409 ret add q n 3410 end 3411 if eq w 5 3412 ret uptxt q x_why5 3413 end 3414 if eq w 6 3415 ret uptxt q x_why6 3416 end 3417 if eq w 7 3418 ret uptxt q x_why7 3419 end 3420 ret uptxt q x_why8 3421 end 3422 3423 note ---- building the file index, as Hop builds it (Sources/FileIndex.swift, rebuild) ---- 3424 note The program run with the one argument "index" walks the folders of Hop's settings (indexRoots; without 3425 note settings the home folder, /Applications and /System/Applications) at throttled disk priority with the walker 3426 note Hop uses (NSFileManager's, hidden things left out), and writes every path, a line each, as Hop's 3427 note file-index.bin, all at once, for the owner only. A folder with one of the names to skip, or one that is a 3428 note link, is left out with all in it; a package (an app, a document that is a folder) is one line. Three million 3429 note lines at most. It is a program of its own run beside the panel, because the panel does one thing at a time. 3430 note is the resource named key of the URL u set (a yes among its values) 3431 fn uresource u ulong sget ulong key ulong to bool 3432 for i ulong 8 3433 put g_t8 i 0 3434 end 3435 x = umsg u sget ulong libptr g_t8 0 8 key 0 3436 v = uread8 3437 if eq v 0 3438 ret false 3439 end 3440 ret eq and umsg v usl m_bool_value 0 0 0 255 1 3441 end 3442 3443 fn uindexbuild to ulong 3444 upr 0 0 3445 upr 8 0 3446 upr 16 3 3447 x = ucall 29 3448 folder_roots = ulong 0 3449 skip_names = ulong 0 3450 d = uhopfile x_config 3451 if ne d 0 3452 config = umsg ucl c_json usl m_json_object d 0 0 3453 if uiskind config 7 3454 folder_roots = ukeyed config k_roots 3455 if not uiskind folder_roots 8 3456 folder_roots = 0 3457 end 3458 skip_names = ukeyed config k_skip_names 3459 if not uiskind skip_names 8 3460 skip_names = 0 3461 end 3462 end 3463 end 3464 sadd = usl m_add_object 3465 if eq folder_roots 0 3466 folder_roots = umsg ucl c_mutable_array usl m_array 0 0 0 3467 x = ucall 30 3468 home_folder = ugr 0 3469 if ne home_folder 0 3470 x = umsg folder_roots sadd home_folder 0 0 3471 end 3472 x = umsg folder_roots sadd uns x_applications 0 0 3473 x = umsg folder_roots sadd uns x_system_applications 0 0 3474 end 3475 if eq skip_names 0 3476 skip_names = umsg ucl c_mutable_array usl m_array 0 0 0 3477 x = umsg skip_names sadd uns x_skipname0 0 0 3478 x = umsg skip_names sadd uns x_skipname1 0 0 3479 x = umsg skip_names sadd uns x_skipname2 0 0 3480 x = umsg skip_names sadd uns x_skipname3 0 0 3481 x = umsg skip_names sadd uns x_skipname4 0 0 3482 x = umsg skip_names sadd uns x_skipname5 0 0 3483 x = umsg skip_names sadd uns x_skipname6 0 0 3484 x = umsg skip_names sadd uns x_skipname7 0 0 3485 x = umsg skip_names sadd uns x_skipname8 0 0 3486 x = umsg skip_names sadd uns x_skipname9 0 0 3487 x = umsg skip_names sadd uns x_skipname10 0 0 3488 x = umsg skip_names sadd uns x_skipname11 0 0 3489 x = umsg skip_names sadd uns x_skipname12 0 0 3490 x = umsg skip_names sadd uns x_skipname13 0 0 3491 x = umsg skip_names sadd uns x_skipname14 0 0 3492 x = umsg skip_names sadd uns x_skipname15 0 0 3493 end 3494 skip_set = umsg ucl c_set usl m_set_with_array skip_names 0 0 3495 key_dir = uconst s_key_directory 3496 key_pkg = uconst s_key_package 3497 key_link = uconst s_key_link 3498 wanted_keys = umsg ucl c_mutable_array usl m_array 0 0 0 3499 x = umsg wanted_keys sadd key_dir 0 0 3500 x = umsg wanted_keys sadd key_pkg 0 0 3501 x = umsg wanted_keys sadd key_link 0 0 3502 manager = umsg ucl c_file_manager usl m_default_manager 0 0 0 3503 index_lines = umsg ucl c_mutable_data usl m_data 0 0 0 3504 sappend = usl m_append_bytes 3505 snext = usl m_next_object 3506 sget = usl m_get_resource 3507 spath = usl m_path 3508 slast = usl m_last_component 3509 sskip = usl m_skip_descendants 3510 shas = usl m_contains_object 3511 s_enum = usl m_enumerator 3512 sat = usl m_at 3513 c_p = ucl c_pool 3514 salloc = usl m_alloc 3515 sinit = usl m_init 3516 sdrain = usl m_drain 3517 sfurl = usl m_furl 3518 c_u = ucl c_url 3519 put g_nl 0 10 3520 listed = ulong 0 3521 nroots = umsg folder_roots usl m_count 0 0 0 3522 for ri ulong nroots bound 64 3523 folder_root = umsg folder_roots sat ri 0 0 3524 if uiskind folder_root 9 3525 folder_url = umsg c_u sfurl folder_root 0 0 3526 upr 40 0 3527 en = umsg manager s_enum folder_url wanted_keys 4 3528 if ne en 0 3529 walking = true 3530 for portion ulong 3001 bound 3001 3531 if walking 3532 walk_pool = umsg umsg c_p salloc 0 0 0 sinit 0 0 0 3533 for turn ulong 1000 bound 1000 3534 if and walking lt listed `3000000` 3535 u = umsg en snext 0 0 0 3536 if eq u 0 3537 walking = false 3538 else 3539 list_it = true 3540 if uresource u sget key_dir 3541 item_name = umsg u slast 0 0 0 3542 skip_it = eq and umsg skip_set shas item_name 0 0 255 1 3543 if not skip_it 3544 skip_it = uresource u sget key_link 3545 end 3546 if skip_it 3547 x = umsg en sskip 0 0 0 3548 list_it = false 3549 else 3550 if uresource u sget key_pkg 3551 x = umsg en sskip 0 0 0 3552 end 3553 end 3554 end 3555 if list_it 3556 path_bytes = umsg umsg u spath 0 0 0 get g_o 5 0 0 0 3557 if ne path_bytes 0 3558 upr 0 path_bytes 3559 pn = ucall 7 3560 x = umsg index_lines sappend path_bytes pn 0 3561 x = umsg index_lines sappend ulong libptr g_nl 0 1 1 0 3562 listed = add listed 1 3563 end 3564 end 3565 end 3566 end 3567 end 3568 x = umsg walk_pool sdrain 0 0 0 3569 if ge listed `3000000` 3570 walking = false 3571 end 3572 end 3573 end 3574 end 3575 end 3576 end 3577 s_write = usl m_write_file 3578 path = uhoppath x_index 3579 if eq path 0 3580 ret 1 3581 end 3582 ok = and umsg index_lines s_write path 1 0 255 3583 path = uhoppath x_index 3584 upr 0 ulong libptr g_nm 0 1024 3585 upr 8 384 3586 x = ucall 16 3587 p = uptxt 0 x_indexed 3588 p = upnum p listed 3589 p = uptxt p x_items 3590 put g_nm p 10 3591 upr 0 1 3592 upr 8 ulong libptr g_nm 0 1024 3593 upr 16 add p 1 3594 x = ucall 3 3595 if eq ok 1 3596 ret 0 3597 end 3598 ret 1 3599 end 3600 3601 note when the program was run with the one argument "index": build the index (0 done, 1 not written); else 2 3602 fn uindexmode to ulong 3603 run_arguments = umsg umsg ucl c_process_info usl m_process_info 0 0 0 usl m_arguments 0 0 0 3604 if eq run_arguments 0 3605 ret 2 3606 end 3607 if le umsg run_arguments usl m_count 0 0 0 1 3608 ret 2 3609 end 3610 first_argument = umsg run_arguments get g_m 16 1 0 0 3611 if ne and umsg first_argument usl m_equal_string uns x_index_word 0 0 255 1 3612 ret 2 3613 end 3614 ret uindexbuild 3615 end 3616 3617 note start building the file index in a program of its own (this one, run with "index"); one at a time 3618 fn uindexstart to void 3619 if ne get g_m 23 0 3620 ret 3621 end 3622 exe = umsg umsg ucl c_bundle usl m_main_bundle 0 0 0 usl m_executable_path 0 0 0 3623 if eq exe 0 3624 ret 3625 end 3626 task = umsg ucl c_task usl m_alloc 0 0 0 3627 task = umsg task usl m_init 0 0 0 3628 x = umsg task usl m_set_launch exe 0 0 3629 arguments = umsg ucl c_mutable_array usl m_array 0 0 0 3630 x = umsg arguments usl m_add_object uns x_index_word 0 0 3631 x = umsg task usl m_set_arguments arguments 0 0 3632 quiet = umsg ucl c_file_handle usl m_null_device 0 0 0 3633 x = umsg task usl m_set_output quiet 0 0 3634 x = umsg task usl m_launch 0 0 0 3635 put g_m 23 umsg task usl m_retain 0 0 0 3636 ushowst 3637 end 3638 3639 note is the file index missing, or older than half an hour (Hop builds it anew that often) 3640 fn uindexstale to bool 3641 path = uhoppath x_index 3642 if eq path 0 3643 ret false 3644 end 3645 manager = umsg ucl c_file_manager usl m_default_manager 0 0 0 3646 attributes = umsg manager usl m_attributes_of path 0 0 3647 if eq attributes 0 3648 ret true 3649 end 3650 changed = umsg attributes usl m_object_for_key uconst s_modified 0 0 3651 if eq changed 0 3652 ret true 3653 end 3654 x = umsg changed usl m_since_now 0 0 0 3655 age = sub 0.0f64 bitcast f64 ugr 64 3656 ret gt age 1800.0f64 3657 end 3658 3659 note twice a second: when the program building the index has ended, read the new index and show the list anew; 3660 note every half hour, and when the panel starts, build it anew when it is old and Hop is not there to do it 3661 fn uindextick to void 3662 if ne get g_m 23 0 3663 if eq and umsg get g_m 23 usl m_is_running 0 0 0 255 0 3664 x = umsg get g_m 23 usl m_release 0 0 0 3665 put g_m 23 0 3666 uloadindex 3667 if ne get g_n 13 0 3668 unarrow 3669 x = umsg get g_o 1 get g_o 7 0 0 0 3670 end 3671 ushowst 3672 end 3673 ret 3674 end 3675 put g_n 38 add get g_n 38 1 3676 if ge get g_n 38 3600 3677 put g_n 38 0 3678 if and not uhoprunning uindexstale 3679 uindexstart 3680 end 3681 if not uhoprunning 3682 uremoterefreshall 3683 end 3684 end 3685 end 3686 3687 note ---- the agent: the person's coding agent, run on this Mac for the typed text (Sources/Model.swift, runAgent) ---- 3688 note Hop's settings name the agents (each a name and a command, "{prompt}" standing for the request) and the one 3689 note to use. Only that one is ever run, and only when it is installed: the look goes through the login shell 3690 note with the usual tool folders added, as Hop's does. The command runs through the same wrapper as in Hop, in 3691 note the folder of the settings; what it prints is shown as it comes (the lines of Claude Code's stream are read 3692 note for their text and the tools they name). Hop's standing instructions ride along. Not here yet: what the 3693 note knowledge base knows, and the count of tokens. 3694 note an NSString of text t with every "~" turned into a double quote 3695 fn uquoted t view uchar * to ulong 3696 put g_nm 0 34 3697 put g_nm 1 0 3698 quote_mark = unsb 3699 plain = uns t 3700 ret umsg plain usl m_replace uns x_tilde quote_mark 0 3701 end 3702 3703 note the words of text t (separated by "|") as an array 3704 fn uwords t view uchar * to ulong 3705 whole = uns t 3706 ret umsg whole usl m_components uns x_bar 0 0 3707 end 3708 3709 note an agent: a name and a command 3710 fn uengine name ulong command ulong to ulong 3711 e = umsg ucl c_mutable_dict usl m_dictionary 0 0 0 3712 sset = usl m_set_object 3713 x = umsg e sset name uns k_name 0 3714 x = umsg e sset command uns k_command 0 3715 ret e 3716 end 3717 3718 note is the JSON value v a yes: JSON's own true and nothing else, as Hop reads its settings (a null, a number, 3719 note a text, a list or a group is not) 3720 fn uyes v ulong to bool 3721 if eq v 0 3722 ret false 3723 end 3724 ret eq v uconst s_cf_true 3725 end 3726 3727 note the agents Hop has out of the box (none of them switches a tool's own approval prompts or sandbox off) 3728 fn uenginedefaults to ulong 3729 all_engines = umsg ucl c_mutable_array usl m_array 0 0 0 3730 sadd = usl m_add_object 3731 x = umsg all_engines sadd uengine uns x_engine0 uwords x_engine0_command 0 0 3732 x = umsg all_engines sadd uengine uns x_engine1 uwords x_engine1_command 0 0 3733 x = umsg all_engines sadd uengine uns x_engine2 uwords x_engine2_command 0 0 3734 x = umsg all_engines sadd uengine uns x_engine3 uwords x_engine3_command 0 0 3735 x = umsg all_engines sadd uengine uns x_engine4 uwords x_engine4_command 0 0 3736 x = umsg all_engines sadd uengine uns x_engine5 uwords x_engine5_command 0 0 3737 x = umsg all_engines sadd uengine uns x_engine6 uwords x_engine6_command 0 0 3738 ret all_engines 3739 end 3740 3741 note the zero-ended bytes at src into g_nm from byte p (900 bytes at most in all); the byte after them 3742 fn ufetchat p ulong src ulong to ulong 3743 if or eq src 0 ge p 900 3744 ret p 3745 end 3746 upr 0 src 3747 n = ucall 7 3748 if gt add p n 900 3749 n = sub 900 p 3750 end 3751 if eq n 0 3752 ret p 3753 end 3754 upr 0 ulong libptr g_nm p n 3755 upr 8 src 3756 upr 16 n 3757 x = ucall 8 3758 ret add p n 3759 end 3760 3761 note what Hop's settings say about the agent (config: the settings, or 0 without any). A saved command that is 3762 note exactly one of the old built-in ones that switched approval prompts or the sandbox off is brought to 3763 note today's built-in one, unless keepAgentFlags says the commands are wanted as written (as Hop does on reading) 3764 fn uagentconfig config ulong to void 3765 engines = ulong 0 3766 chosen = ulong 0 3767 legacy = ulong 0 3768 folder = ulong 0 3769 keep_flags = false 3770 put g_n 42 0 3771 put g_n 44 0 3772 put g_n 45 0 3773 if ne config 0 3774 engines = ukeyed config k_engines 3775 chosen = ukeyed config k_engine 3776 legacy = ukeyed config k_agent_command 3777 folder = ukeyed config k_agent_folder 3778 keep_flags = uyes ukeyed config k_keep_flags 3779 if uyes ukeyed config k_enter_agent 3780 put g_n 42 1 3781 end 3782 if uyes ukeyed config k_agent_confirmed 3783 put g_n 44 1 3784 end 3785 end 3786 defaults = uenginedefaults 3787 sat = usl m_at 3788 if not uiskind engines 8 3789 engines = defaults 3790 else 3791 if not keep_flags 3792 moved = umsg ucl c_mutable_array usl m_array 0 0 0 3793 sadd = usl m_add_object 3794 sequal = usl m_equal_string 3795 ssame = usl m_is_equal_array 3796 cnt = umsg engines usl m_count 0 0 0 3797 for i ulong cnt bound 256 3798 e = umsg engines sat i 0 0 3799 if uiskind e 7 3800 name = ukeyed e k_name 3801 command = ukeyed e k_command 3802 if and uiskind name 9 uiskind command 8 3803 if and eq and umsg name sequal uns x_engine1 0 0 255 1 eq and umsg command ssame uwords x_old0_command 0 0 255 1 3804 e = umsg defaults sat 1 0 0 3805 end 3806 if and eq and umsg name sequal uns x_engine2 0 0 255 1 eq and umsg command ssame uwords x_old1_command 0 0 255 1 3807 e = umsg defaults sat 2 0 0 3808 end 3809 if and eq and umsg name sequal uns x_engine3 0 0 255 1 eq and umsg command ssame uwords x_old2_command 0 0 255 1 3810 e = umsg defaults sat 3 0 0 3811 end 3812 if and eq and umsg name sequal uns x_engine5 0 0 255 1 eq and umsg command ssame uwords x_old3_command 0 0 255 1 3813 e = umsg defaults sat 5 0 0 3814 end 3815 if and eq and umsg name sequal uns x_engine6 0 0 255 1 eq and umsg command ssame uwords x_old4_command 0 0 255 1 3816 e = umsg defaults sat 6 0 0 3817 end 3818 end 3819 end 3820 x = umsg moved sadd e 0 0 3821 end 3822 engines = moved 3823 end 3824 end 3825 if not uiskind chosen 9 3826 chosen = uns x_engine0 3827 end 3828 if not uiskind legacy 8 3829 legacy = uwords x_engine0_command 3830 end 3831 if not uiskind folder 9 3832 x = ucall 30 3833 folder = ugr 0 3834 end 3835 sret = usl m_retain 3836 put g_m 28 umsg engines sret 0 0 0 3837 put g_m 29 umsg chosen sret 0 0 0 3838 put g_m 30 umsg folder sret 0 0 0 3839 put g_m 31 umsg legacy sret 0 0 0 3840 if ne config 0 3841 put g_m 34 umsg config sret 0 0 0 3842 end 3843 note for a check (HOPAGENTS): say each agent's command as it would be run 3844 if eq get g_n 14 0 3845 n = ucs x_env_agents 3846 upr 0 ulong libptr g_nm 0 1024 3847 if ne ucall 9 0 3848 cnt = umsg engines usl m_count 0 0 0 3849 sjoin = usl m_joined 3850 for i ulong cnt bound 256 3851 e = umsg engines sat i 0 0 3852 if uiskind e 7 3853 name = ukeyed e k_name 3854 command = ukeyed e k_command 3855 if and uiskind name 9 uiskind command 8 3856 said_words = umsg command sjoin uns x_space 0 0 3857 name_bytes = umsg name get g_o 5 0 0 0 3858 word_bytes = umsg said_words get g_o 5 0 0 0 3859 p = uptxt 0 x_engine_word 3860 p2 = ufetchat p name_bytes 3861 p2 = uptxt p2 x_colon 3862 p2 = ufetchat p2 word_bytes 3863 put g_nm p2 10 3864 upr 0 1 3865 upr 8 ulong libptr g_nm 0 1024 3866 upr 16 add p2 1 3867 x = ucall 3 3868 end 3869 end 3870 end 3871 end 3872 end 3873 end 3874 3875 note s between single quotes for a shell 3876 fn ushellquote s ulong to ulong 3877 put g_nm 0 39 3878 put g_nm 1 0 3879 tick = unsb 3880 put g_nm 0 39 3881 put g_nm 1 92 3882 put g_nm 2 39 3883 put g_nm 3 39 3884 put g_nm 4 0 3885 escaped = unsb 3886 inner = umsg s usl m_replace tick escaped 0 3887 sappend = usl m_append_string 3888 ret umsg umsg tick sappend inner 0 0 sappend tick 0 0 3889 end 3890 3891 note the folders tools are commonly installed in, joined by ":" (searched after the login shell's own PATH) 3892 fn uextrapath to ulong 3893 x = ucall 30 3894 home_folder = ugr 0 3895 if eq home_folder 0 3896 ret uns x_colon_only 3897 end 3898 dirs = umsg ucl c_mutable_array usl m_array 0 0 0 3899 sadd = usl m_add_object 3900 sappend = usl m_append_string 3901 slash = uns x_slash_text 3902 x = umsg dirs sadd umsg umsg home_folder sappend slash 0 0 sappend uns x_path0 0 0 0 0 3903 x = umsg dirs sadd umsg umsg home_folder sappend slash 0 0 sappend uns x_path1 0 0 0 0 3904 x = umsg dirs sadd uns x_path2 0 0 3905 x = umsg dirs sadd uns x_path3 0 0 3906 x = umsg dirs sadd umsg umsg home_folder sappend slash 0 0 sappend uns x_path4 0 0 0 0 3907 x = umsg dirs sadd umsg umsg home_folder sappend slash 0 0 sappend uns x_path5 0 0 0 0 3908 x = umsg dirs sadd umsg umsg home_folder sappend slash 0 0 sappend uns x_path6 0 0 0 0 3909 x = umsg dirs sadd umsg umsg home_folder sappend slash 0 0 sappend uns x_path7 0 0 0 0 3910 x = umsg dirs sadd umsg umsg home_folder sappend slash 0 0 sappend uns x_path8 0 0 0 0 3911 x = umsg dirs sadd umsg umsg home_folder sappend slash 0 0 sappend uns x_path9 0 0 0 0 3912 x = umsg dirs sadd umsg umsg home_folder sappend slash 0 0 sappend uns x_path10 0 0 0 0 3913 x = umsg dirs sadd umsg umsg home_folder sappend slash 0 0 sappend uns x_path11 0 0 0 0 3914 manager = umsg ucl c_file_manager usl m_default_manager 0 0 0 3915 sat = usl m_at 3916 for which ulong 2 3917 versions_root = umsg home_folder sappend uns x_nvm 0 0 3918 if eq which 1 3919 versions_root = umsg home_folder sappend uns x_herd 0 0 3920 end 3921 found_versions = umsg manager usl m_contents_of_dir versions_root 0 0 3922 if ne found_versions 0 3923 ordered = umsg found_versions usl m_sorted usl m_standard_compare 0 0 3924 cnt = umsg ordered usl m_count 0 0 0 3925 for back ulong cnt bound 512 3926 v = umsg ordered sat sub sub cnt 1 back 0 0 3927 one_dir = umsg umsg umsg versions_root sappend slash 0 0 sappend v 0 0 sappend uns x_slash_bin 0 0 3928 if eq and umsg one_dir usl m_contains uns x_colon_only 0 0 255 0 3929 x = umsg dirs sadd one_dir 0 0 3930 end 3931 end 3932 end 3933 end 3934 ret umsg dirs usl m_joined uns x_colon_only 0 0 3935 end 3936 3937 note a program run through the login shell, as Hop runs every command: zsh -lc with the wrapper that adds the 3938 note tool folders, then the words of argv; TERM is dumb and colours are off. Not started yet 3939 fn ushellrun argv ulong folder ulong to ulong 3940 task = umsg ucl c_task usl m_alloc 0 0 0 3941 task = umsg task usl m_init 0 0 0 3942 x = umsg task usl m_set_launch uns x_zsh 0 0 3943 arguments = umsg ucl c_mutable_array usl m_array 0 0 0 3944 sadd = usl m_add_object 3945 x = umsg arguments sadd uns x_dash_lc 0 0 3946 x = umsg arguments sadd uquoted x_wrapper 0 0 3947 x = umsg arguments sadd uns x_hop_word 0 0 3948 cnt = umsg argv usl m_count 0 0 0 3949 sat = usl m_at 3950 for i ulong cnt bound 256 3951 x = umsg arguments sadd umsg argv sat i 0 0 0 0 3952 end 3953 x = umsg task usl m_set_arguments arguments 0 0 3954 if ne folder 0 3955 x = umsg task usl m_set_cwd folder 0 0 3956 end 3957 around = umsg umsg umsg ucl c_process_info usl m_process_info 0 0 0 usl m_environment 0 0 0 usl m_mutable_copy 0 0 0 3958 sset = usl m_set_object 3959 x = umsg around sset uns x_dumb uns x_term 0 3960 x = umsg around sset uns x_one uns x_no_color 0 3961 x = umsg around sset uextrapath uns x_extra_path 0 3962 x = umsg task usl m_set_environment around 0 0 3963 ret task 3964 end 3965 3966 note the agents of the settings that are installed on this Mac, looked for once (the login shell is asked for 3967 note each tool); when none of them is and the older single command's tool is, that one, as "Custom command" 3968 fn uagentsfound to ulong 3969 if eq get g_n 45 1 3970 ret get g_m 35 3971 end 3972 engines = get g_m 28 3973 sat = usl m_at 3974 sappend = usl m_append_string 3975 put g_nm 0 10 3976 put g_nm 1 0 3977 line_end = unsb 3978 script = umsg ucl c_mutable_string usl m_string 0 0 0 3979 smore = usl m_append 3980 cnt = umsg engines usl m_count 0 0 0 3981 for i ulong cnt bound 256 3982 e = umsg engines sat i 0 0 3983 if uiskind e 7 3984 name = ukeyed e k_name 3985 command = ukeyed e k_command 3986 if and uiskind name 9 uiskind command 8 3987 if gt umsg command usl m_count 0 0 0 0 3988 tool = umsg command sat 0 0 0 3989 if uiskind tool 9 3990 x = umsg script smore uns x_probe_a 0 0 3991 x = umsg script smore ushellquote tool 0 0 3992 x = umsg script smore uns x_probe_b 0 0 3993 x = umsg script smore ushellquote name 0 0 3994 x = umsg script smore line_end 0 0 3995 end 3996 end 3997 end 3998 end 3999 end 4000 legacy = get g_m 31 4001 if gt umsg legacy usl m_count 0 0 0 0 4002 tool = umsg legacy sat 0 0 0 4003 if uiskind tool 9 4004 if gt umsg tool usl m_length 0 0 0 0 4005 x = umsg script smore uns x_probe_a 0 0 4006 x = umsg script smore ushellquote tool 0 0 4007 x = umsg script smore uns x_probe_b 0 0 4008 x = umsg script smore uns x_legacy_mark 0 0 4009 x = umsg script smore line_end 0 0 4010 end 4011 end 4012 end 4013 x = umsg script smore uns x_true_word 0 0 4014 argv = umsg ucl c_mutable_array usl m_array 0 0 0 4015 sadd = usl m_add_object 4016 x = umsg argv sadd uns x_sh 0 0 4017 x = umsg argv sadd uns x_dash_c 0 0 4018 x = umsg argv sadd script 0 0 4019 task = ushellrun argv 0 4020 tube = umsg ucl c_pipe usl m_pipe 0 0 0 4021 quiet = umsg ucl c_file_handle usl m_null_device 0 0 0 4022 x = umsg task usl m_set_output tube 0 0 4023 x = umsg task usl m_set_error quiet 0 0 4024 x = umsg task usl m_set_input quiet 0 0 4025 x = umsg task usl m_launch 0 0 0 4026 d = umsg umsg tube usl m_reading 0 0 0 usl m_read_end 0 0 0 4027 x = umsg task usl m_wait 0 0 0 4028 found = umsg ucl c_mutable_array usl m_array 0 0 0 4029 if ne d 0 4030 said = umsg ucl c_str usl m_alloc 0 0 0 4031 said = umsg said usl m_init_data_encoding d 4 0 4032 if ne said 0 4033 names_said = umsg said usl m_components line_end 0 0 4034 shas = usl m_contains_object 4035 for i ulong cnt bound 256 4036 e = umsg engines sat i 0 0 4037 if uiskind e 7 4038 name = ukeyed e k_name 4039 if uiskind name 9 4040 if eq and umsg names_said shas name 0 0 255 1 4041 x = umsg found sadd e 0 0 4042 end 4043 end 4044 end 4045 end 4046 if and eq umsg found usl m_count 0 0 0 0 eq and umsg names_said shas uns x_legacy_mark 0 0 255 1 4047 x = umsg found sadd uengine uns x_custom_command legacy 0 0 4048 end 4049 end 4050 end 4051 put g_m 35 umsg found usl m_retain 0 0 0 4052 put g_n 45 1 4053 ret found 4054 end 4055 4056 note the agent to run: the one the settings name, when it is installed; never another in its place 4057 fn uagentpicked to ulong 4058 found = uagentsfound 4059 cnt = umsg found usl m_count 0 0 0 4060 sat = usl m_at 4061 sequal = usl m_equal_string 4062 for pass_no ulong 2 4063 want = get g_m 29 4064 if eq pass_no 1 4065 want = uns x_custom_command 4066 end 4067 for i ulong cnt bound 256 4068 e = umsg found sat i 0 0 4069 if eq and umsg ukeyed e k_name sequal want 0 0 255 1 4070 ret e 4071 end 4072 end 4073 end 4074 ret 0 4075 end 4076 4077 note why nothing was run, in plain words 4078 fn uagentwhy to ulong 4079 found = uagentsfound 4080 sappend = usl m_append_string 4081 sat = usl m_at 4082 if eq umsg found usl m_count 0 0 0 0 4083 engines = get g_m 28 4084 cnt = umsg engines usl m_count 0 0 0 4085 if eq cnt 0 4086 ret uns x_agent_none_b 4087 end 4088 out_text = uns x_agent_none_a 4089 for i ulong cnt bound 256 4090 e = umsg engines sat i 0 0 4091 if uiskind e 7 4092 name = ukeyed e k_name 4093 command = ukeyed e k_command 4094 if and uiskind name 9 uiskind command 8 4095 if gt i 0 4096 out_text = umsg out_text sappend uns x_comma_space 0 0 4097 end 4098 out_text = umsg out_text sappend name 0 0 4099 if gt umsg command usl m_count 0 0 0 0 4100 out_text = umsg out_text sappend uns x_paren_a 0 0 4101 out_text = umsg out_text sappend umsg command sat 0 0 0 0 0 4102 out_text = umsg out_text sappend uns x_paren_b 0 0 4103 end 4104 end 4105 end 4106 end 4107 ret umsg out_text sappend uns x_period 0 0 4108 end 4109 out_text = umsg get g_m 29 sappend uns x_agent_missing_a 0 0 4110 cnt = umsg found usl m_count 0 0 0 4111 for i ulong cnt bound 256 4112 if gt i 0 4113 out_text = umsg out_text sappend uns x_comma_space 0 0 4114 end 4115 out_text = umsg out_text sappend ukeyed umsg found sat i 0 0 k_name 0 0 4116 end 4117 ret umsg out_text sappend uns x_agent_missing_b 0 0 4118 end 4119 4120 note Hop's standing instructions for the agent (Sources/Machines.swift, agentBriefing): kept tiny on purpose 4121 fn uagentbrief to ulong 4122 sappend = usl m_append_string 4123 config = get g_m 34 4124 owner = uns x_the_user 4125 if ne config 0 4126 given = ukeyed config k_owner 4127 if uiskind given 9 4128 blanks = umsg ucl c_charset usl m_whitespace 0 0 0 4129 given = umsg given usl m_trim blanks 0 0 4130 if gt umsg given usl m_length 0 0 0 0 4131 owner = given 4132 end 4133 end 4134 end 4135 head = umsg umsg owner usl m_substring_to 1 0 0 usl m_uppercase 0 0 0 4136 brief = umsg umsg head sappend umsg owner usl m_substring_from 1 0 0 0 0 sappend uns x_brief_a 0 0 4137 if ne config 0 4138 machines = ukeyed config k_machines 4139 if uiskind machines 8 4140 cnt = umsg machines usl m_count 0 0 0 4141 if gt cnt 0 4142 sat = usl m_at 4143 hosts = umsg ucl c_mutable_array usl m_array 0 0 0 4144 for i ulong cnt bound 256 4145 m = umsg machines sat i 0 0 4146 if uiskind m 7 4147 name = ukeyed m k_name 4148 via = ukeyed m k_ssh 4149 if and uiskind name 9 uiskind via 9 4150 one_host = umsg umsg umsg name sappend uns x_ssh_a 0 0 sappend via 0 0 sappend uns x_ssh_b 0 0 4151 x = umsg hosts usl m_add_object one_host 0 0 4152 end 4153 end 4154 end 4155 brief = umsg brief sappend uns x_brief_b 0 0 4156 brief = umsg brief sappend umsg hosts usl m_joined uns x_semi_space 0 0 0 0 4157 brief = umsg brief sappend uns x_brief_c 0 0 4158 end 4159 end 4160 factory = ukeyed config k_factory_url 4161 if uiskind factory 9 4162 blanks = umsg ucl c_charset usl m_whitespace 0 0 0 4163 if gt umsg umsg factory usl m_trim blanks 0 0 usl m_length 0 0 0 0 4164 brief = umsg brief sappend uns x_brief_d 0 0 4165 brief = umsg brief sappend factory 0 0 4166 brief = umsg brief sappend uns x_period 0 0 4167 end 4168 end 4169 end 4170 ret umsg brief sappend uns x_brief_e 0 0 4171 end 4172 4173 note add a line to what the agent said, and show it 4174 fn uagentsay line ulong to void 4175 if eq line 0 4176 ret 4177 end 4178 if eq get g_n 22 0 4179 put g_nm 0 0 4180 no_text = unsb 4181 x = umsg get g_m 4 usl m_set_string no_text 0 0 4182 put g_n 22 1 4183 end 4184 sappend_text = usl m_append 4185 x = umsg get g_m 4 sappend_text line 0 0 4186 put g_nm 0 10 4187 put g_nm 1 0 4188 x = umsg get g_m 4 sappend_text unsb 0 0 4189 if eq get g_n 20 1 4190 uanswershow 4191 end 4192 end 4193 4194 note one line the agent printed, as Hop shows it (Sources/Runners.swift, AgentEvents): a line of Claude Code's 4195 note stream gives its text and "> " and the name of each tool it uses, and its last line the id to carry on 4196 note from (an error there is said); any other line is shown as it is. 0: nothing to show 4197 fn uagentline line ulong to ulong 4198 if eq and umsg line usl m_has_prefix uns x_brace 0 0 255 0 4199 ret line 4200 end 4201 d = umsg line usl m_data_using 4 0 0 4202 if eq d 0 4203 ret line 4204 end 4205 obj = umsg ucl c_json usl m_json_object d 0 0 4206 if not uiskind obj 7 4207 ret line 4208 end 4209 kind = ukeyed obj k_type 4210 if not uiskind kind 9 4211 ret 0 4212 end 4213 sequal = usl m_equal_string 4214 sappend = usl m_append_string 4215 if eq and umsg kind sequal uns x_assistant 0 0 255 1 4216 message = ukeyed obj k_message 4217 if not uiskind message 7 4218 ret 0 4219 end 4220 parts = ukeyed message k_content 4221 if not uiskind parts 8 4222 ret 0 4223 end 4224 put g_nm 0 10 4225 put g_nm 1 0 4226 line_end = unsb 4227 put g_nm 0 0 4228 shown_text = unsb 4229 cnt = umsg parts usl m_count 0 0 0 4230 sat = usl m_at 4231 have = ulong 0 4232 for i ulong cnt bound 1024 4233 part_v = umsg parts sat i 0 0 4234 if uiskind part_v 7 4235 part_kind = ukeyed part_v k_type 4236 piece = ulong 0 4237 if uiskind part_kind 9 4238 if eq and umsg part_kind sequal uns k_parts_text 0 0 255 1 4239 piece = ukeyed part_v k_parts_text 4240 if not uiskind piece 9 4241 piece = 0 4242 end 4243 end 4244 if eq and umsg part_kind sequal uns k_tool_use 0 0 255 1 4245 tool_name = ukeyed part_v k_name 4246 if not uiskind tool_name 9 4247 tool_name = uns x_tool_word 4248 end 4249 piece = umsg uns x_tool_mark sappend tool_name 0 0 4250 end 4251 end 4252 if ne piece 0 4253 if eq have 1 4254 shown_text = umsg shown_text sappend line_end 0 0 4255 end 4256 shown_text = umsg shown_text sappend piece 0 0 4257 have = 1 4258 end 4259 end 4260 end 4261 if eq have 0 4262 ret 0 4263 end 4264 ret shown_text 4265 end 4266 if eq and umsg kind sequal uns k_result 0 0 255 1 4267 sid = ukeyed obj k_session_id 4268 if uiskind sid 9 4269 if ne get g_m 33 0 4270 x = umsg get g_m 33 usl m_release 0 0 0 4271 end 4272 put g_m 33 umsg sid usl m_retain 0 0 0 4273 end 4274 if uyes ukeyed obj k_is_error 4275 problem = ukeyed obj k_result 4276 if not uiskind problem 9 4277 problem = uns x_agent_error 4278 end 4279 ret umsg uns x_bang sappend problem 0 0 4280 end 4281 end 4282 ret 0 4283 end 4284 4285 note output of the agent arrived (d; nothing left when it is empty): every whole line is shown 4286 fn uagentout d ulong to void 4287 buffer = get g_m 32 4288 if eq buffer 0 4289 ret 4290 end 4291 n = umsg d usl m_length 0 0 0 4292 if gt n 0 4293 x = umsg buffer usl m_append_data d 0 0 4294 end 4295 put g_nl 0 10 4296 newline = umsg ucl c_data usl m_data_bytes ulong libptr g_nl 0 1 1 0 4297 srange = usl m_range_of_data 4298 ssub = usl m_subdata 4299 scut = usl m_replace_bytes 4300 slen = usl m_length 4301 c_s = ucl c_str 4302 salloc = usl m_alloc 4303 sinit_data = usl m_init_data_encoding 4304 more = true 4305 for turn ulong 4096 bound 4096 4306 if more 4307 total = umsg buffer slen 0 0 0 4308 if eq total 0 4309 more = false 4310 else 4311 upr 40 total 4312 found_at = umsg buffer srange newline 0 0 4313 take = total 4314 whole_line = false 4315 if lt found_at total 4316 take = found_at 4317 whole_line = true 4318 end 4319 if and not whole_line ne n 0 4320 more = false 4321 else 4322 piece = umsg buffer ssub 0 take 0 4323 line = umsg c_s salloc 0 0 0 4324 line = umsg line sinit_data piece 4 0 4325 drop = take 4326 if whole_line 4327 drop = add take 1 4328 end 4329 upr 40 0 4330 x = umsg buffer scut 0 drop 0 4331 if ne line 0 4332 uagentsay uagentline line 4333 end 4334 end 4335 end 4336 end 4337 end 4338 end 4339 4340 note the agent's run has ended in one more way (1 its output, 2 the program); when both have, the turn is over 4341 fn uagentended what ulong to void 4342 put g_n 47 or get g_n 47 what 4343 if eq get g_n 47 2 4344 s_after = usl m_perform_after 4345 upr 64 bitcast ulong 2.0f64 4346 x = umsg get g_o 27 s_after get g_m 38 0 0 4347 end 4348 if ne get g_n 47 3 4349 ret 4350 end 4351 task = get g_m 26 4352 if eq task 0 4353 ret 4354 end 4355 code = and umsg task usl m_termination 0 0 0 `4294967295` 4356 if ne code 0 4357 p = uptxt 0 x_agent_stopped_a 4358 p = upnum p code 4359 p = uptxt p x_agent_stopped_b 4360 put g_nm p 0 4361 uagentsay unsb 4362 end 4363 center = umsg ucl c_center usl m_default_center 0 0 0 4364 s_forget = usl m_remove_all_observer 4365 x = umsg center s_forget get g_o 27 0 get g_m 27 4366 x = umsg center s_forget get g_o 27 0 get g_m 37 4367 x = umsg center s_forget get g_o 27 0 task 4368 srel = usl m_release 4369 x = umsg task srel 0 0 0 4370 put g_m 26 0 4371 put g_n 43 0 4372 put g_n 21 1 4373 put g_n 39 1 4374 x = umsg ucl c_date usl m_reference_now 0 0 0 4375 now_bits = ugr 64 4376 if ne get g_m 36 0 4377 x = umsg get g_m 36 srel 0 0 0 4378 end 4379 s_double = usl m_number_double 4380 cnum = ucl c_number 4381 upr 64 now_bits 4382 put g_m 36 umsg umsg cnum s_double 0 0 0 usl m_retain 0 0 0 4383 end 4384 4385 note what the agent's program tells this one: output (agentOut:), errors (agentErr:), its end (agentEnd:), and the 4386 note menu's Stop the Agent (stopAgent:); which is the selector, about is what came with it 4387 fn uagentevent which ulong about ulong to void 4388 if ustatusevent which 4389 ret 4390 end 4391 if eq which get g_m 64 4392 uprobedone about 4393 ret 4394 end 4395 if eq which get g_m 46 4396 uremotestart 4397 ret 4398 end 4399 if eq which get g_m 47 4400 uremotedone about 4401 ret 4402 end 4403 if eq which get g_m 48 4404 ufetchdone about 4405 ret 4406 end 4407 if eq which get g_m 41 4408 if ne get g_m 26 0 4409 x = umsg get g_m 26 usl m_terminate_task 0 0 0 4410 end 4411 ret 4412 end 4413 if eq which get g_m 40 4414 uagentended 2 4415 ret 4416 end 4417 if eq get g_m 26 0 4418 ret 4419 end 4420 if eq about 0 4421 if and eq which get g_m 38 eq and get g_n 47 1 0 4422 uagentout umsg ucl c_data usl m_data 0 0 0 4423 uagentended 1 4424 end 4425 ret 4426 end 4427 info = umsg about usl m_user_info 0 0 0 4428 if eq info 0 4429 ret 4430 end 4431 d = umsg info usl m_object_for_key uconst s_data_item 0 0 4432 if eq d 0 4433 ret 4434 end 4435 n = umsg d usl m_length 0 0 0 4436 if eq which get g_m 38 4437 uagentout d 4438 if eq n 0 4439 uagentended 1 4440 else 4441 x = umsg get g_m 27 usl m_read_background 0 0 0 4442 end 4443 ret 4444 end 4445 if gt n 0 4446 said = umsg ucl c_str usl m_alloc 0 0 0 4447 said = umsg said usl m_init_data_encoding d 4 0 4448 if ne said 0 4449 edge = umsg ucl c_charset usl m_newline_set 0 0 0 4450 uagentsay umsg uns x_bang usl m_append_string umsg said usl m_trim edge 0 0 0 0 4451 end 4452 x = umsg get g_m 37 usl m_read_background 0 0 0 4453 end 4454 end 4455 4456 note send the typed text to the agent 4457 fn uagentrun to void 4458 a = get g_n 12 4459 n = get g_n 13 4460 if or eq n 0 gt n 255 4461 ret 4462 end 4463 for i ulong n bound 256 4464 put g_nm i get g_q add a i 4465 end 4466 put g_nm n 0 4467 request = unsb 4468 if eq request 0 4469 ret 4470 end 4471 note the talk on show: what was there joins what was said before, then the request 4472 if eq get g_m 25 0 4473 told = umsg ucl c_mutable_string usl m_string 0 0 0 4474 put g_m 25 umsg told usl m_retain 0 0 0 4475 end 4476 if eq get g_m 4 0 4477 fresh_text = umsg ucl c_mutable_string usl m_string 0 0 0 4478 put g_m 4 umsg fresh_text usl m_retain 0 0 0 4479 end 4480 if eq get g_n 43 1 4481 uanswershow 4482 uanswerview 1 4483 ret 4484 end 4485 put g_nm 0 10 4486 put g_nm 1 10 4487 put g_nm 2 0 4488 blank_line = unsb 4489 sappend_text = usl m_append 4490 if eq get g_n 39 1 4491 x = umsg get g_m 25 sappend_text get g_m 4 0 0 4492 x = umsg get g_m 25 sappend_text blank_line 0 0 4493 end 4494 x = umsg get g_m 25 sappend_text uns x_you 0 0 4495 x = umsg get g_m 25 sappend_text request 0 0 4496 x = umsg get g_m 25 sappend_text blank_line 0 0 4497 put g_n 39 0 4498 put g_n 21 0 4499 put g_n 22 0 4500 engine = uagentpicked 4501 if eq engine 0 4502 uagentsay uagentwhy 4503 put g_n 21 1 4504 put g_n 39 1 4505 uanswershow 4506 uanswerview 1 4507 ret 4508 end 4509 if eq get g_n 44 0 4510 if eq get g_n 14 0 4511 uagentsay uns x_agent_ask 4512 put g_n 21 1 4513 put g_n 39 1 4514 uanswershow 4515 uanswerview 1 4516 ret 4517 end 4518 alert = umsg umsg ucl c_alert usl m_alloc 0 0 0 usl m_init 0 0 0 4519 x = umsg alert usl m_set_message uns x_agent_ask 0 0 4520 x = umsg alert usl m_set_informative uns x_agent_ask_more 0 0 4521 x = umsg alert usl m_add_button uns x_agent_yes 0 0 4522 x = umsg alert usl m_add_button uns x_agent_no 0 0 4523 if ne umsg alert usl m_run_modal 0 0 0 1000 4524 ret 4525 end 4526 put g_n 44 1 4527 end 4528 x = umsg get g_m 4 usl m_set_string uns x_agent_working 0 0 4529 uanswershow 4530 uanswerview 1 4531 note the words to run: the request in place of "{prompt}", Hop's standing instructions before it, or for 4532 note Claude Code as its system prompt; a follow-up within 15 minutes carries on from Claude Code's last run 4533 brief = uagentbrief 4534 command = ukeyed engine k_command 4535 sat = usl m_at 4536 sappend = usl m_append_string 4537 sequal = usl m_equal_string 4538 tool = umsg command sat 0 0 0 4539 is_claude = eq and umsg tool sequal uns x_claude 0 0 255 1 4540 prompt = request 4541 if not is_claude 4542 prompt = umsg umsg umsg brief sappend blank_line 0 0 sappend uns x_request 0 0 sappend request 0 0 4543 end 4544 argv = umsg ucl c_mutable_array usl m_array 0 0 0 4545 sadd = usl m_add_object 4546 mark = uns x_prompt_mark 4547 cnt = umsg command usl m_count 0 0 0 4548 for i ulong cnt bound 256 4549 word = umsg command sat i 0 0 4550 if uiskind word 9 4551 x = umsg argv sadd umsg word usl m_replace mark prompt 0 0 0 4552 end 4553 end 4554 if is_claude 4555 shas = usl m_contains_object 4556 if eq and umsg argv shas uns x_append_system 0 0 255 0 4557 x = umsg argv sadd uns x_append_system 0 0 4558 x = umsg argv sadd brief 0 0 4559 end 4560 if and ne get g_m 33 0 ne get g_m 36 0 4561 if eq and umsg argv shas uns x_resume 0 0 255 0 4562 x = umsg get g_m 36 usl m_double_value 0 0 0 4563 last_bits = ugr 64 4564 x = umsg ucl c_date usl m_reference_now 0 0 0 4565 if lt sub bitcast f64 ugr 64 bitcast f64 last_bits 900.0f64 4566 x = umsg argv sadd uns x_resume 0 0 4567 x = umsg argv sadd get g_m 33 0 0 4568 end 4569 end 4570 end 4571 end 4572 task = ushellrun argv get g_m 30 4573 tube = umsg ucl c_pipe usl m_pipe 0 0 0 4574 error_tube = umsg ucl c_pipe usl m_pipe 0 0 0 4575 quiet = umsg ucl c_file_handle usl m_null_device 0 0 0 4576 x = umsg task usl m_set_output tube 0 0 4577 x = umsg task usl m_set_error error_tube 0 0 4578 x = umsg task usl m_set_input quiet 0 0 4579 sret = usl m_retain 4580 reader = umsg tube usl m_reading 0 0 0 4581 error_reader = umsg error_tube usl m_reading 0 0 0 4582 if ne get g_m 27 0 4583 x = umsg get g_m 27 usl m_release 0 0 0 4584 x = umsg get g_m 37 usl m_release 0 0 0 4585 x = umsg get g_m 32 usl m_release 0 0 0 4586 end 4587 put g_m 27 umsg reader sret 0 0 0 4588 put g_m 37 umsg error_reader sret 0 0 0 4589 put g_m 32 umsg umsg ucl c_mutable_data usl m_data 0 0 0 sret 0 0 0 4590 put g_m 26 umsg task sret 0 0 0 4591 put g_n 47 0 4592 center = umsg ucl c_center usl m_default_center 0 0 0 4593 s_observe = usl m_add_observer 4594 read_done = uconst s_read_done 4595 ended = uconst s_task_ended 4596 upr 40 reader 4597 x = umsg center s_observe get g_o 27 get g_m 38 read_done 4598 upr 40 error_reader 4599 x = umsg center s_observe get g_o 27 get g_m 39 read_done 4600 upr 40 task 4601 x = umsg center s_observe get g_o 27 get g_m 40 ended 4602 put g_n 43 1 4603 x = umsg task usl m_launch 0 0 0 4604 x = umsg reader usl m_read_background 0 0 0 4605 x = umsg error_reader usl m_read_background 0 0 0 4606 end 4607 4608 note ---- files on other machines, as Hop finds them (Sources/Machines.swift, Sources/Model.swift searchFiles) ---- 4609 note Each machine of Hop's settings keeps its own list of files (20 pieces, built there by a command Hop sends 4610 note when the list is missing or old); a search runs on the machine through ssh and the lines that hold every 4611 note typed word come back, to be scored here by the rule the local files are scored by. The machines are asked 4612 note a moment after typing pauses, all at once, by one program whose answer is read when it has ended. Enter on 4613 note such a file brings it over (scp, into the cache folder) and opens it; a folder's path goes to the clipboard. 4614 note an NSString of text t with every "%%" turned into a double quote and every "^^" into a backslash 4615 fn uquoted2 t view uchar * to ulong 4616 put g_nm 0 34 4617 put g_nm 1 0 4618 quote_mark = unsb 4619 put g_nm 0 92 4620 put g_nm 1 0 4621 back_mark = unsb 4622 plain = uns t 4623 srep = usl m_replace 4624 plain = umsg plain srep uns x_percents quote_mark 0 4625 ret umsg plain srep uns x_carets back_mark 0 4626 end 4627 4628 note the machines of the settings: their names into g_mn (63 bytes each at most), their ssh names kept; 10 at most 4629 fn umachines config ulong to void 4630 put g_n 54 0 4631 put g_n 59 0 4632 if eq get g_n 14 1 4633 put g_n 59 1 4634 else 4635 n = ucs x_env_ssh 4636 upr 0 ulong libptr g_nm 0 1024 4637 if ne ucall 9 0 4638 put g_n 59 1 4639 end 4640 end 4641 if eq config 0 4642 ret 4643 end 4644 machines = ukeyed config k_machines 4645 if not uiskind machines 8 4646 ret 4647 end 4648 sat = usl m_at 4649 aliases = umsg ucl c_mutable_array usl m_array 0 0 0 4650 cnt = umsg machines usl m_count 0 0 0 4651 have = ulong 0 4652 for i ulong cnt bound 64 4653 if lt have 10 4654 m = umsg machines sat i 0 0 4655 if uiskind m 7 4656 name = ukeyed m k_name 4657 via = ukeyed m k_ssh 4658 if and uiskind name 9 uiskind via 9 4659 src = umsg name get g_o 5 0 0 0 4660 if ne src 0 4661 upr 0 src 4662 n = ucall 7 4663 if gt n 63 4664 n = 63 4665 end 4666 if gt n 0 4667 upr 0 ulong libptr g_mn mul have 64 n 4668 upr 8 src 4669 upr 16 n 4670 x = ucall 8 4671 end 4672 put g_ml have uchar n 4673 x = umsg aliases usl m_add_object m 0 0 4674 have = add have 1 4675 end 4676 end 4677 end 4678 end 4679 end 4680 if ne get g_m 42 0 4681 x = umsg get g_m 42 usl m_release 0 0 0 4682 end 4683 put g_m 42 umsg aliases usl m_retain 0 0 0 4684 put g_n 54 have 4685 end 4686 4687 note may other machines be reached: always when resident; a check reaches none but through its stand-in (HOPSSH) 4688 note (looked up once, when the settings are read: 59 is 1 for yes) 4689 fn uremoteok to bool 4690 ret eq get g_n 59 1 4691 end 4692 4693 note the program to reach other machines with: ssh (scp when copy is 1), or for a check its stand-in 4694 fn uremotetool copy ulong to ulong 4695 if eq get g_n 14 0 4696 n = ucs x_env_ssh 4697 if eq copy 1 4698 n = ucs x_env_scp 4699 end 4700 upr 0 ulong libptr g_nm 0 1024 4701 given = ucall 9 4702 if ne given 0 4703 n = ufetch given 4704 ret ushellquote unsb 4705 end 4706 end 4707 if eq copy 1 4708 ret uns x_scp_word 4709 end 4710 ret uns x_ssh_word 4711 end 4712 4713 note run a script through the login shell and read all it says when it has ended: done is the selector told then. 4714 note The program (kept) and where its answer is read (kept) go to places prog and reader of g_m 4715 fn uscriptrun script ulong done ulong prog ulong reader_at ulong to void 4716 argv = umsg ucl c_mutable_array usl m_array 0 0 0 4717 sadd = usl m_add_object 4718 x = umsg argv sadd uns x_sh 0 0 4719 x = umsg argv sadd uns x_dash_c 0 0 4720 x = umsg argv sadd script 0 0 4721 task = ushellrun argv 0 4722 tube = umsg ucl c_pipe usl m_pipe 0 0 0 4723 quiet = umsg ucl c_file_handle usl m_null_device 0 0 0 4724 x = umsg task usl m_set_output tube 0 0 4725 x = umsg task usl m_set_error quiet 0 0 4726 x = umsg task usl m_set_input quiet 0 0 4727 reader = umsg tube usl m_reading 0 0 0 4728 sret = usl m_retain 4729 center = umsg ucl c_center usl m_default_center 0 0 0 4730 whole_read = uconst s_read_to_end_done 4731 if ne get g_m prog 0 4732 x = umsg get g_m prog usl m_terminate_task 0 0 0 4733 x = umsg center usl m_remove_all_observer get g_o 27 whole_read get g_m reader_at 4734 x = umsg get g_m prog usl m_release 0 0 0 4735 x = umsg get g_m reader_at usl m_release 0 0 0 4736 end 4737 put g_m prog umsg task sret 0 0 0 4738 put g_m reader_at umsg reader sret 0 0 0 4739 s_observe = usl m_add_observer 4740 upr 40 reader 4741 x = umsg center s_observe get g_o 27 done whole_read 4742 x = umsg task usl m_launch 0 0 0 4743 x = umsg reader usl m_read_to_end 0 0 0 4744 end 4745 4746 note the command that makes machine m (a settings entry) build its list of files when it has none or an old one 4747 fn urefreshscript m ulong to ulong 4748 sappend = usl m_append_string 4749 sat = usl m_at 4750 roots = ukeyed m k_roots_m 4751 skips = ukeyed m k_skip_m 4752 if not uiskind skips 8 4753 skips = umsg ucl c_mutable_array usl m_array 0 0 0 4754 sadd = usl m_add_object 4755 x = umsg skips sadd uns x_mskip0 0 0 4756 x = umsg skips sadd uns x_mskip1 0 0 4757 x = umsg skips sadd uns x_mskip2 0 0 4758 x = umsg skips sadd uns x_mskip3 0 0 4759 x = umsg skips sadd uns x_mskip4 0 0 4760 x = umsg skips sadd uns x_mskip5 0 0 4761 x = umsg skips sadd uns x_mskip6 0 0 4762 x = umsg skips sadd uns x_mskip7 0 0 4763 x = umsg skips sadd uns x_mskip8 0 0 4764 x = umsg skips sadd uns x_mskip9 0 0 4765 end 4766 prune = umsg ucl c_mutable_string usl m_string 0 0 0 4767 smore = usl m_append 4768 cnt = umsg skips usl m_count 0 0 0 4769 for i ulong cnt bound 256 4770 one_name = umsg skips sat i 0 0 4771 if uiskind one_name 9 4772 if gt umsg prune usl m_length 0 0 0 0 4773 x = umsg prune smore uns x_or_flag 0 0 4774 end 4775 x = umsg prune smore uns x_name_flag 0 0 4776 x = umsg prune smore ushellquote one_name 0 0 4777 end 4778 end 4779 places = umsg ucl c_mutable_string usl m_string 0 0 0 4780 if uiskind roots 8 4781 cnt = umsg roots usl m_count 0 0 0 4782 for i ulong cnt bound 256 4783 one_root = umsg roots sat i 0 0 4784 if uiskind one_root 9 4785 if gt umsg places usl m_length 0 0 0 0 4786 x = umsg places smore uns x_space 0 0 4787 end 4788 x = umsg places smore ushellquote one_root 0 0 4789 end 4790 end 4791 end 4792 build = umsg umsg umsg umsg uns x_build_a sappend places 0 0 sappend uquoted2 x_build_b 0 0 sappend prune 0 0 sappend uquoted2 x_build_c 0 0 4793 put g_nm 0 10 4794 put g_nm 1 0 4795 line_end = unsb 4796 script = umsg ucl c_mutable_string usl m_string 0 0 0 4797 x = umsg script smore uns x_fresh_a 0 0 4798 x = umsg script smore line_end 0 0 4799 x = umsg script smore uquoted2 x_fresh_b 0 0 4800 x = umsg script smore line_end 0 0 4801 x = umsg script smore uquoted2 x_fresh_c 0 0 4802 x = umsg script smore ushellquote build 0 0 4803 x = umsg script smore uns x_fresh_d 0 0 4804 x = umsg script smore line_end 0 0 4805 x = umsg script smore uns x_fresh_e 0 0 4806 ret script 4807 end 4808 4809 note ask machine k to build its list of files if it has none or an old one; nothing is waited for 4810 fn uremoterefresh k ulong to void 4811 if or or ge k get g_n 54 eq get g_m 42 0 not uremoteok 4812 ret 4813 end 4814 m = umsg get g_m 42 get g_m 16 k 0 0 4815 via = ukeyed m k_ssh 4816 sappend = usl m_append_string 4817 line = umsg umsg umsg uremotetool 0 sappend uns x_ssh_options 0 0 sappend ushellquote via 0 0 sappend uns x_space 0 0 4818 line = umsg line sappend ushellquote urefreshscript m 0 0 4819 argv = umsg ucl c_mutable_array usl m_array 0 0 0 4820 sadd = usl m_add_object 4821 x = umsg argv sadd uns x_sh 0 0 4822 x = umsg argv sadd uns x_dash_c 0 0 4823 x = umsg argv sadd line 0 0 4824 task = ushellrun argv 0 4825 quiet = umsg ucl c_file_handle usl m_null_device 0 0 0 4826 x = umsg task usl m_set_output quiet 0 0 4827 x = umsg task usl m_set_error quiet 0 0 4828 x = umsg task usl m_set_input quiet 0 0 4829 x = umsg task usl m_launch 0 0 0 4830 end 4831 4832 note a moment after typing pauses the machines are asked; until then nothing found there is shown 4833 fn uremotesoon to void 4834 put g_n 49 0 4835 put g_n 58 0 4836 if le get g_n 51 2 4837 put g_n 51 0 4838 end 4839 if eq get g_n 54 0 4840 ret 4841 end 4842 if not uremoteok 4843 ret 4844 end 4845 s_go = get g_m 46 4846 x = umsg ucl c_obj usl m_cancel_previous get g_o 27 s_go 0 4847 if or or lt get g_n 13 2 gt get g_n 13 255 ne get g_n 36 0 4848 ret 4849 end 4850 s_after = usl m_perform_after 4851 upr 64 bitcast ulong 0.22f64 4852 x = umsg get g_o 27 s_after s_go 0 0 4853 end 4854 4855 note ask every machine for the files that hold every typed word (the longest first, as on the machine's side 4856 note each further word narrows what the first found) 4857 fn uremotestart to void 4858 a = get g_n 12 4859 n = get g_n 13 4860 if or or lt n 2 gt n 255 eq get g_n 54 0 4861 ret 4862 end 4863 for i ulong n bound 256 4864 put g_rq i get g_q add a i 4865 put g_nm i get g_q add a i 4866 end 4867 put g_n 53 n 4868 put g_nm n 0 4869 typed = unsb 4870 if eq typed 0 4871 ret 4872 end 4873 parts = umsg umsg typed usl m_lowercase 0 0 0 usl m_components uns x_space 0 0 4874 sat = usl m_at 4875 slen = usl m_length 4876 cnt = umsg parts usl m_count 0 0 0 4877 longest = ulong 0 4878 longest_len = ulong 0 4879 for i ulong cnt bound 64 4880 one_word = umsg parts sat i 0 0 4881 wl = umsg one_word slen 0 0 0 4882 if ge wl longest_len 4883 if gt wl 0 4884 longest = one_word 4885 longest_len = wl 4886 end 4887 end 4888 end 4889 if eq longest 0 4890 ret 4891 end 4892 sappend = usl m_append_string 4893 filter = umsg umsg uns x_remote_grep sappend ushellquote longest 0 0 sappend uquoted2 x_remote_shard 0 0 4894 for i ulong cnt bound 64 4895 one_word = umsg parts sat i 0 0 4896 if and gt umsg one_word slen 0 0 0 0 eq and umsg one_word usl m_equal_string longest 0 0 255 0 4897 filter = umsg umsg umsg filter sappend uns x_remote_pipe 0 0 sappend uns x_remote_grep 0 0 sappend ushellquote one_word 0 0 4898 end 4899 end 4900 remote = umsg umsg uns x_remote_a sappend filter 0 0 sappend uquoted2 x_remote_b 0 0 4901 remote_quoted = ushellquote remote 4902 tool = uremotetool 0 4903 put g_nm 0 10 4904 put g_nm 1 0 4905 line_end = unsb 4906 script = umsg ucl c_mutable_string usl m_string 0 0 0 4907 smore = usl m_append 4908 for k ulong get g_n 54 bound 10 4909 m = umsg get g_m 42 sat k 0 0 4910 via = ukeyed m k_ssh 4911 x = umsg script smore uns x_local_a 0 0 4912 x = umsg script smore tool 0 0 4913 x = umsg script smore uns x_ssh_options 0 0 4914 x = umsg script smore ushellquote via 0 0 4915 x = umsg script smore uns x_space 0 0 4916 x = umsg script smore remote_quoted 0 0 4917 x = umsg script smore uns x_local_b 0 0 4918 put g_nm 0 uchar add 48 k 4919 put g_nm 1 0 4920 x = umsg script smore unsb 0 0 4921 x = umsg script smore uns x_local_c 0 0 4922 x = umsg script smore line_end 0 0 4923 end 4924 x = umsg script smore uns x_wait_word 0 0 4925 uscriptrun script get g_m 47 43 44 4926 end 4927 4928 note keep a file found on a machine among the best 64, best first 4929 fn uremotekeep sc ulong o ulong ln ulong k ulong to void 4930 have = get g_n 49 4931 if and ge have 64 le sc get g_rs 63 4932 ret 4933 end 4934 pos = have 4935 if ge have 64 4936 pos = 63 4937 else 4938 put g_n 49 add have 1 4939 end 4940 while gt pos 0 bound 80 4941 if ge get g_rs sub pos 1 sc 4942 break 4943 end 4944 put g_rs pos get g_rs sub pos 1 4945 put g_ro pos get g_ro sub pos 1 4946 put g_rl pos get g_rl sub pos 1 4947 put g_rw pos get g_rw sub pos 1 4948 pos = sub pos 1 4949 end 4950 put g_rs pos sc 4951 put g_ro pos o 4952 put g_rl pos ln 4953 put g_rw pos uchar k 4954 end 4955 4956 note does the line at o of g_rb (n bytes) read exactly as text t 4957 fn uremoteis o ulong n ulong t view uchar * to bool 4958 tl = len t 4959 if ne n tl 4960 ret false 4961 end 4962 for i ulong tl bound 64 4963 if ne ulong get g_rb add o i ulong get t i 4964 ret false 4965 end 4966 end 4967 ret true 4968 end 4969 4970 note the machines have answered (about: the notice that carries what they said). When the typed text is still 4971 note the one they were asked for, every line is scored and the list is made anew 4972 fn uremotedone about ulong to void 4973 if eq about 0 4974 ret 4975 end 4976 info = umsg about usl m_user_info 0 0 0 4977 if eq info 0 4978 ret 4979 end 4980 d = umsg info usl m_object_for_key uconst s_data_item 0 0 4981 if eq d 0 4982 ret 4983 end 4984 a = get g_n 12 4985 n = get g_n 13 4986 if ne n get g_n 53 4987 ret 4988 end 4989 for i ulong n bound 256 4990 if ne ulong get g_q add a i ulong get g_rq i 4991 ret 4992 end 4993 end 4994 total = umsg d usl m_length 0 0 0 4995 if gt total `1048575` 4996 total = `1048575` 4997 end 4998 put g_n 49 0 4999 put g_n 58 0 5000 put g_n 50 total 5001 if eq total 0 5002 ret 5003 end 5004 src = umsg d usl m_bytes 0 0 0 5005 base = ulong libptr g_rb 0 total 5006 upr 0 base 5007 upr 8 src 5008 upr 16 total 5009 x = ucall 8 5010 pos = ulong 0 5011 more = true 5012 for turn ulong 20000 bound 20000 5013 if more 5014 if ge pos total 5015 more = false 5016 else 5017 upr 0 add base pos 5018 upr 8 10 5019 upr 16 sub total pos 5020 x = ucall 12 5021 e = total 5022 hit_at = ugr 0 5023 if ne hit_at 0 5024 e = sub hit_at base 5025 end 5026 ln = sub e pos 5027 if and ge ln 3 eq ulong get g_rb add pos 1 58 5028 k = sub ulong get g_rb pos 48 5029 if lt k get g_n 54 5030 o = add pos 2 5031 bl = sub ln 2 5032 if uremoteis o bl x_no_index 5033 put g_n 51 2 5034 put g_n 52 k 5035 uremoterefresh k 5036 else 5037 if uremoteis o bl x_unreachable 5038 put g_n 51 1 5039 put g_n 52 k 5040 else 5041 pl = bl 5042 if eq ulong get g_rb sub add o bl 1 47 5043 pl = sub bl 1 5044 end 5045 if and gt pl 0 le pl 4000 5046 for j ulong pl bound 4096 5047 put g_line j uchar ulower ulong get g_rb add o j 5048 end 5049 sc = ufscore pl 5050 if ne sc 0 5051 uremotekeep sc o bl k 5052 name_at = pl 5053 while gt name_at 0 bound 4097 5054 if eq ulong get g_line sub name_at 1 47 5055 break 5056 end 5057 name_at = sub name_at 1 5058 end 5059 if eq sub pl name_at n 5060 same_name = true 5061 for j ulong n bound 256 5062 if ne ulong get g_line add name_at j ulower ulong get g_rq j 5063 same_name = false 5064 end 5065 end 5066 if same_name 5067 put g_n 58 1 5068 end 5069 end 5070 end 5071 end 5072 end 5073 end 5074 end 5075 end 5076 pos = add e 1 5077 end 5078 end 5079 end 5080 keep_row = get g_n 6 5081 unarrow 5082 x = umsg get g_o 1 get g_o 7 0 0 0 5083 if lt keep_row get g_n 1 5084 uchoose keep_row 5085 else 5086 if gt get g_n 1 0 5087 uchoose 0 5088 end 5089 end 5090 ushowst 5091 end 5092 5093 note the text of a row for a file on another machine into g_nm from byte p: its name, the folder it is in, 5094 note and the machine; the byte after it 5095 fn uremoterow p ulong r ulong to ulong 5096 if ge r get g_n 49 5097 ret p 5098 end 5099 o = get g_ro r 5100 ln = get g_rl r 5101 if gt ln 0 5102 if eq ulong get g_rb sub add o ln 1 47 5103 ln = sub ln 1 5104 end 5105 end 5106 ns0 = ln 5107 while gt ns0 0 bound 4097 5108 if eq ulong get g_rb sub add o ns0 1 47 5109 break 5110 end 5111 ns0 = sub ns0 1 5112 end 5113 q = p 5114 nl = sub ln ns0 5115 if gt nl 300 5116 nl = 300 5117 end 5118 for j ulong nl bound 301 5119 put g_nm add q j get g_rb add add o ns0 j 5120 end 5121 q = add q nl 5122 if and gt ns0 1 le ns0 400 5123 q = uptxt q x_gap 5124 for j ulong sub ns0 1 bound 401 5125 put g_nm add q j get g_rb add o j 5126 end 5127 q = add q sub ns0 1 5128 end 5129 k = ulong get g_rw r 5130 q = uptxt q x_on 5131 ml = ulong get g_ml k 5132 for j ulong ml bound 64 5133 put g_nm add q j get g_mn add mul k 64 j 5134 end 5135 ret add q ml 5136 end 5137 5138 note the path of found file r, as it is written on its machine, as an NSString (without a folder's last "/") 5139 fn uremotepath r ulong to ulong 5140 o = get g_ro r 5141 ln = get g_rl r 5142 if gt ln 0 5143 if eq ulong get g_rb sub add o ln 1 47 5144 ln = sub ln 1 5145 end 5146 end 5147 if or eq ln 0 gt ln 1000 5148 ret 0 5149 end 5150 for j ulong ln bound 1001 5151 put g_nm j get g_rb add o j 5152 end 5153 put g_nm ln 0 5154 ret unsb 5155 end 5156 5157 note put text on the clipboard (a check uses a board of its own) 5158 fn uclipput words ulong to void 5159 pboard = ulong 0 5160 if eq get g_n 14 1 5161 pboard = umsg ucl c_pasteboard usl m_general_pasteboard 0 0 0 5162 else 5163 pboard = umsg ucl c_pasteboard usl m_board_named uns x_check_board 0 0 5164 end 5165 x = umsg pboard usl m_clear 0 0 0 5166 x = umsg pboard usl m_set_string_type words uns x_type_string 0 5167 put g_n 29 1 5168 if eq get g_n 14 1 5169 uclipmine 0 5170 end 5171 end 5172 5173 note Enter on a file of another machine: a folder's "ssh name:path" goes to the clipboard; a file is brought over 5174 note (when it is under 2 GB) into the cache folder and opened when it has arrived 5175 fn uremoteopen r ulong to void 5176 if or or ge r get g_n 49 eq get g_m 42 0 not uremoteok 5177 ret 5178 end 5179 k = ulong get g_rw r 5180 o = get g_ro r 5181 ln = get g_rl r 5182 is_folder = false 5183 if gt ln 0 5184 is_folder = eq ulong get g_rb sub add o ln 1 47 5185 end 5186 path = uremotepath r 5187 if eq path 0 5188 ret 5189 end 5190 m = umsg get g_m 42 get g_m 16 k 0 0 5191 via = ukeyed m k_ssh 5192 name = ukeyed m k_name 5193 sappend = usl m_append_string 5194 there = umsg umsg via sappend uns x_colon_only 0 0 sappend path 0 0 5195 sret = usl m_retain 5196 if ne get g_m 51 0 5197 x = umsg get g_m 51 usl m_release 0 0 0 5198 end 5199 put g_m 51 umsg there sret 0 0 0 5200 put g_n 52 k 5201 if is_folder 5202 uclipput there 5203 put g_n 51 4 5204 ushowst 5205 ret 5206 end 5207 dest = ulong 0 5208 if eq get g_n 14 0 5209 dest = uhoppath x_check_cache 5210 else 5211 x = ucall 30 5212 dest = umsg ugr 0 sappend uns x_remote_cache 0 0 5213 end 5214 if eq dest 0 5215 ret 5216 end 5217 dest = umsg umsg dest sappend name 0 0 sappend path 0 0 5218 if ne get g_m 50 0 5219 x = umsg get g_m 50 usl m_release 0 0 0 5220 end 5221 put g_m 50 umsg dest sret 0 0 0 5222 folder = umsg dest usl m_dir_of 0 0 0 5223 tool = uremotetool 0 5224 script = umsg uns x_fetch_a sappend tool 0 0 5225 script = umsg script sappend uns x_ssh_options 0 0 5226 script = umsg script sappend ushellquote via 0 0 5227 script = umsg script sappend uns x_space 0 0 5228 script = umsg script sappend ushellquote umsg uns x_fetch_stat sappend ushellquote path 0 0 0 0 5229 script = umsg script sappend uquoted2 x_fetch_b 0 0 5230 script = umsg script sappend ushellquote folder 0 0 5231 script = umsg script sappend uns x_fetch_c 0 0 5232 script = umsg script sappend uremotetool 1 0 0 5233 script = umsg script sappend uns x_scp_options 0 0 5234 script = umsg script sappend ushellquote there 0 0 5235 script = umsg script sappend uns x_space 0 0 5236 script = umsg script sappend ushellquote dest 0 0 5237 script = umsg script sappend uns x_fetch_d 0 0 5238 put g_n 51 3 5239 ushowst 5240 uscriptrun script get g_m 48 45 49 5241 end 5242 5243 note the program bringing a file over has ended: when it says the file arrived it is opened, else the path goes 5244 note to the clipboard and that is said 5245 fn ufetchdone about ulong to void 5246 if eq about 0 5247 ret 5248 end 5249 info = umsg about usl m_user_info 0 0 0 5250 if eq info 0 5251 ret 5252 end 5253 d = umsg info usl m_object_for_key uconst s_data_item 0 0 5254 arrived = false 5255 if ne d 0 5256 said = umsg ucl c_str usl m_alloc 0 0 0 5257 said = umsg said usl m_init_data_encoding d 4 0 5258 if ne said 0 5259 arrived = eq and umsg said usl m_contains uns x_fetched 0 0 255 1 5260 end 5261 end 5262 if arrived 5263 put g_n 51 0 5264 put g_n 55 1 5265 if eq get g_n 7 1 5266 url = umsg ucl c_url usl m_furl get g_m 50 0 0 5267 ws = umsg ucl c_ws usl m_shws 0 0 0 5268 put g_n 9 and umsg ws usl m_open url 0 0 255 5269 end 5270 else 5271 if ne get g_m 51 0 5272 uclipput get g_m 51 5273 end 5274 put g_n 51 5 5275 end 5276 ushowst 5277 end 5278 5279 note every half hour, and when the panel starts, each machine is asked to build its list if it is old 5280 fn uremoterefreshall to void 5281 for k ulong get g_n 54 bound 10 5282 uremoterefresh k 5283 end 5284 end 5285 5286 note what to say about a machine into g_nm from byte p; the byte after it 5287 fn uremotenote p ulong to ulong 5288 w = get g_n 51 5289 k = get g_n 52 5290 if or eq w 0 ge k get g_n 54 5291 ret p 5292 end 5293 q = uptxt p x_gap 5294 if eq w 3 5295 q = uptxt q x_note_bringing 5296 end 5297 if eq w 4 5298 q = uptxt q x_note_copied 5299 end 5300 if eq w 5 5301 q = uptxt q x_note_failed 5302 end 5303 ml = ulong get g_ml k 5304 for j ulong ml bound 64 5305 put g_nm add q j get g_mn add mul k 64 j 5306 end 5307 q = add q ml 5308 if eq w 1 5309 q = uptxt q x_note_unreachable 5310 end 5311 if eq w 2 5312 q = uptxt q x_note_building 5313 end 5314 ret q 5315 end 5316 5317 note for a check: HOPLATE sends Enter late, when the machines have had time to answer 5318 fn uchecklate to void 5319 put g_n 48 20 5320 n = ucs x_env_late 5321 upr 0 ulong libptr g_nm 0 1024 5322 if ne ucall 9 0 5323 put g_n 48 80 5324 end 5325 end 5326 5327 note the three more things this program is told by selector (entry 13 hears them all) 5328 fn umoremethods mine ulong to bool 5329 ok = umethod mine m_remote_go 13 t_v 5330 ok = and ok umethod mine m_remote_done 13 t_v 5331 ok = and ok umethod mine m_fetch_done 13 t_v 5332 put g_m 46 usl m_remote_go 5333 put g_m 47 usl m_remote_done 5334 put g_m 48 usl m_fetch_done 5335 ret ok 5336 end 5337 5338 note ---- the icon in the menu bar and its menu, as Hop has them (Sources/main.swift) ---- 5339 note Open, Rebuild file index, Allow paste into apps, Open at login, Settings, Clear clipboard history, Quit. 5340 note one item of that menu: title, what it tells this program (action_sel), its key (an NSString); the item 5341 fn ustatusadd menu ulong title view uchar * action_sel ulong key_string ulong to ulong 5342 item = umsg ucl c_menu_item usl m_alloc 0 0 0 5343 title_string = uns title 5344 item = umsg item usl m_init_item title_string action_sel key_string 5345 x = umsg item usl m_set_target get g_o 27 0 0 5346 x = umsg menu usl m_add_item item 0 0 5347 ret item 5348 end 5349 5350 note macOS's keeper of what opens at login, for this app (0: there is none) 5351 fn uloginservice to ulong 5352 n = ucs x_sm_path 5353 upr 0 ulong libptr g_nm 0 1024 5354 upr 8 1 5355 x = ucall 0 5356 c = ucl c_sm_service 5357 if eq c 0 5358 ret 0 5359 end 5360 ret umsg c usl m_main_app 0 0 0 5361 end 5362 5363 note Open at login: on becomes off and off on; when macOS refuses, that is said 5364 fn ulogintoggle to void 5365 service = uloginservice 5366 if eq service 0 5367 ret 5368 end 5369 done = ulong 0 5370 if eq umsg service usl m_status 0 0 0 1 5371 done = and umsg service usl m_unregister 0 0 0 255 5372 if eq done 1 5373 x = umsg get g_m 53 usl m_set_state 0 0 0 5374 end 5375 else 5376 done = and umsg service usl m_register 0 0 0 255 5377 if eq done 1 5378 x = umsg get g_m 53 usl m_set_state 1 0 0 5379 end 5380 end 5381 if eq done 0 5382 alert = umsg umsg ucl c_alert usl m_alloc 0 0 0 usl m_init 0 0 0 5383 x = umsg alert usl m_set_message uns x_login_failed 0 0 5384 x = umsg alert usl m_run_modal 0 0 0 5385 end 5386 end 5387 5388 note Allow paste into apps: macOS is asked to show its own question about Accessibility for this app 5389 fn upasteask to void 5390 prompt_key = uconst s_trusted_prompt 5391 if eq prompt_key 0 5392 ret 5393 end 5394 yes_flag = umsg ucl c_number usl m_number_bool 1 0 0 5395 options = umsg ucl c_mutable_dict usl m_dictionary 0 0 0 5396 x = umsg options usl m_set_object yes_flag prompt_key 0 5397 f = usym s_trusted_options 5398 if eq f 0 5399 ret 5400 end 5401 upr 0 options 5402 x = ucallf f 5403 end 5404 5405 note Clear clipboard history: every copied thing that is not pinned goes, a picture's sealed file with it. Like 5406 note every change to the history it is this program's to do only while Hop is not running 5407 fn uclipclear to void 5408 if and eq get g_n 14 1 uhoprunning 5409 ret 5410 end 5411 items = uclipsmutable 5412 if eq items 0 5413 ret 5414 end 5415 sat = usl m_at 5416 sremove = usl m_remove_at 5417 cnt = umsg items usl m_count 0 0 0 5418 for back ulong cnt bound 100000 5419 j = sub sub cnt 1 back 5420 e = umsg items sat j 0 0 5421 if uiskind e 7 5422 if not uclippinned e 5423 image_name = ukeyed e k_image 5424 if uiskind image_name 9 5425 if ne and umsg image_name usl m_contains uns x_slash_text 0 0 255 1 5426 folder = uhoppath x_clip_images 5427 if ne folder 0 5428 gone = umsg folder usl m_append_string image_name 0 0 5429 manager = umsg ucl c_file_manager usl m_default_manager 0 0 0 5430 x = umsg manager usl m_remove_item gone 0 0 5431 end 5432 end 5433 end 5434 x = umsg items sremove j 0 0 5435 end 5436 end 5437 end 5438 if eq uclipswrite items 1 5439 uloadclips 5440 urefresh 5441 end 5442 end 5443 5444 note the menu of the icon in the menu bar 5445 fn ustatusmenu to ulong 5446 menu = umsg ucl c_menu usl m_alloc 0 0 0 5447 menu = umsg menu usl m_init_title uns x_app 0 0 5448 put g_nm 0 0 5449 no_key = unsb 5450 s_add = usl m_add_item 5451 c_item = ucl c_menu_item 5452 s_line = usl m_separator 5453 x = ustatusadd menu x_status_open get g_m 54 no_key 5454 x = umsg menu s_add umsg c_item s_line 0 0 0 0 0 5455 x = ustatusadd menu x_status_index get g_m 55 no_key 5456 x = ustatusadd menu x_status_paste get g_m 56 no_key 5457 login_item = ustatusadd menu x_status_login get g_m 57 no_key 5458 put g_m 53 login_item 5459 if eq get g_n 14 1 5460 service = uloginservice 5461 if ne service 0 5462 if eq umsg service usl m_status 0 0 0 1 5463 x = umsg login_item usl m_set_state 1 0 0 5464 end 5465 end 5466 end 5467 comma_key = uns x_key_comma 5468 x = ustatusadd menu x_status_settings get g_m 58 comma_key 5469 x = ustatusadd menu x_status_clear get g_m 59 no_key 5470 x = umsg menu s_add umsg c_item s_line 0 0 0 0 0 5471 q_key = uns x_key_q 5472 s_quit = usl m_terminate 5473 quit_item = ustatusadd menu x_quit s_quit q_key 5474 x = umsg quit_item usl m_set_target umsg ucl c_app usl m_shared 0 0 0 0 0 5475 ret menu 5476 end 5477 5478 note put the icon in the menu bar (a check has none; with HOPMENU it says the menu's items instead) 5479 fn ustatus to void 5480 menu = ustatusmenu 5481 if eq get g_n 14 0 5482 n = ucs x_env_menu 5483 upr 0 ulong libptr g_nm 0 1024 5484 if eq ucall 9 0 5485 ret 5486 end 5487 entries = umsg menu usl m_item_array 0 0 0 5488 sat = usl m_at 5489 s_title = usl m_item_title 5490 cnt = umsg entries usl m_count 0 0 0 5491 p = uptxt 0 x_menu_word 5492 for i ulong cnt bound 32 5493 title_bytes = umsg umsg umsg entries sat i 0 0 s_title 0 0 0 get g_o 5 0 0 0 5494 if gt i 0 5495 put g_nm p 124 5496 p = add p 1 5497 end 5498 p = ufetchat p title_bytes 5499 end 5500 put g_nm p 10 5501 upr 0 1 5502 upr 8 ulong libptr g_nm 0 1024 5503 upr 16 add p 1 5504 x = ucall 3 5505 ret 5506 end 5507 bar = umsg ucl c_status_bar usl m_system_status_bar 0 0 0 5508 s_length = usl m_status_item_length 5509 upr 64 `13835058055282163712` 5510 item = umsg bar s_length 0 0 0 5511 if eq item 0 5512 ret 5513 end 5514 item = umsg item usl m_retain 0 0 0 5515 put g_m 52 item 5516 button = umsg item usl m_button 0 0 0 5517 c_i = ucl c_image 5518 s_symbol = usl m_symbol_image 5519 symbol_name = uns x_status_symbol 5520 said_name = uns x_app 5521 image = umsg c_i s_symbol symbol_name said_name 0 5522 if ne image 0 5523 x = umsg button usl m_set_image image 0 0 5524 end 5525 x = umsg item usl m_set_item_menu menu 0 0 5526 center = umsg ucl c_center usl m_default_center 0 0 0 5527 s_observe = usl m_add_observer 5528 quitting = uconst s_will_terminate 5529 upr 40 0 5530 x = umsg center s_observe get g_o 27 get g_m 62 quitting 5531 end 5532 5533 note what the menu of the icon tells this program (which: the selector); true when it was one of its 5534 fn ustatusevent which ulong to bool 5535 if eq which get g_m 62 5536 utunnelstop 5537 ret true 5538 end 5539 if eq which get g_m 54 5540 ushow 5541 ret true 5542 end 5543 if eq which get g_m 55 5544 uindexstart 5545 ret true 5546 end 5547 if eq which get g_m 56 5548 upasteask 5549 ret true 5550 end 5551 if eq which get g_m 57 5552 ulogintoggle 5553 ret true 5554 end 5555 if eq which get g_m 58 5556 usettings 5557 ret true 5558 end 5559 if eq which get g_m 59 5560 uclipclear 5561 ret true 5562 end 5563 ret false 5564 end 5565 5566 note the six more things this program is told by selector (entry 13 hears them all) 5567 fn ustatusmethods mine ulong to bool 5568 ok = umethod mine m_menu_open 13 t_v 5569 ok = and ok umethod mine m_menu_index 13 t_v 5570 ok = and ok umethod mine m_menu_paste 13 t_v 5571 ok = and ok umethod mine m_menu_login 13 t_v 5572 ok = and ok umethod mine m_menu_settings 13 t_v 5573 ok = and ok umethod mine m_menu_clear 13 t_v 5574 put g_m 54 usl m_menu_open 5575 put g_m 55 usl m_menu_index 5576 put g_m 56 usl m_menu_paste 5577 put g_m 57 usl m_menu_login 5578 put g_m 58 usl m_menu_settings 5579 put g_m 59 usl m_menu_clear 5580 ret ok 5581 end 5582 5583 note ---- forwarded ports: the ssh links Hop keeps open (Sources/Factory.swift, TunnelManager) ---- 5584 note Hop's settings name ports of other computers to have on this Mac (a model's server, the factory, the 5585 note knowledge base). At the start and every 20 seconds each one whose link is not running is looked at: when 5586 note nothing on this Mac serves its port (nc is asked, as a program of its own), ssh is started for it with Hop's own options (a link of its own, never 5587 note the shared connection, so it ends cleanly). A port something else serves is left alone, and so Hop and this 5588 note program do not fight over one. When this program quits it ends its links. Not here yet: dropping the links 5589 note at once when the network changes (ssh notices by itself within 45 seconds, and the link is made anew). 5590 note the whole number an object of the settings holds: 0 when it is not a number, is a yes or a no, or is not 5591 note whole (8080.9 is no port, and Hop takes none of these either) 5592 fn uwhole obj ulong to ulong 5593 if not uisnumber obj 5594 ret 0 5595 end 5596 yes_object = uconst s_cf_true 5597 no_object = uconst s_cf_false 5598 if or eq obj yes_object eq obj no_object 5599 ret 0 5600 end 5601 v = umsg obj usl m_integer_value 0 0 0 5602 same_v = umsg ucl c_number usl m_number_integer v 0 0 5603 if eq and umsg obj usl m_is_equal_number same_v 0 0 255 0 5604 ret 0 5605 end 5606 ret v 5607 end 5608 5609 note one forwarded port to keep: added to list when both ports are ports, the ssh name is there, and this Mac's 5610 note port is not in the list already 5611 fn utunneladd list ulong local ulong remote ulong host ulong to void 5612 if or or eq local 0 gt local 65535 or eq remote 0 gt remote 65535 5613 ret 5614 end 5615 if not uiskind host 9 5616 ret 5617 end 5618 if eq umsg host usl m_length 0 0 0 0 5619 ret 5620 end 5621 sat = usl m_at 5622 s_whole = usl m_integer_value 5623 cnt = umsg list usl m_count 0 0 0 5624 for i ulong cnt bound 256 5625 if eq umsg umsg umsg list sat i 0 0 sat 0 0 0 s_whole 0 0 0 local 5626 ret 5627 end 5628 end 5629 entry = umsg ucl c_mutable_array usl m_array 0 0 0 5630 sadd = usl m_add_object 5631 c_n_v = ucl c_number 5632 s_number = usl m_number_integer 5633 x = umsg entry sadd umsg c_n_v s_number local 0 0 0 0 5634 x = umsg entry sadd umsg c_n_v s_number remote 0 0 0 0 5635 x = umsg entry sadd host 0 0 5636 x = umsg list sadd entry 0 0 5637 end 5638 5639 note the forwarded ports of the settings: the ones named there, and the one to the knowledge base when it runs 5640 note on another computer 5641 fn utunnelsload config ulong to void 5642 links = umsg ucl c_mutable_array usl m_array 0 0 0 5643 if ne config 0 5644 named = ukeyed config k_tunnels 5645 if uiskind named 8 5646 sat = usl m_at 5647 cnt = umsg named usl m_count 0 0 0 5648 for i ulong cnt bound 256 5649 t = umsg named sat i 0 0 5650 if uiskind t 7 5651 utunneladd links uwhole ukeyed t k_local_port uwhole ukeyed t k_remote_port ukeyed t k_ssh_host 5652 end 5653 end 5654 end 5655 cx = ukeyed config k_cortex 5656 if uiskind cx 7 5657 if uyes ukeyed cx k_enabled 5658 address = ukeyed cx k_url 5659 if uiskind address 9 5660 url = umsg ucl c_url usl m_urlstr address 0 0 5661 if ne url 0 5662 utunneladd links uwhole umsg url usl m_url_port 0 0 0 uwhole ukeyed cx k_remote_port ukeyed cx k_host 5663 end 5664 end 5665 end 5666 end 5667 end 5668 if ne get g_m 60 0 5669 x = umsg get g_m 60 usl m_release 0 0 0 5670 end 5671 put g_m 60 umsg links usl m_retain 0 0 0 5672 put g_n 62 umsg links usl m_count 0 0 0 5673 if eq get g_m 61 0 5674 running = umsg ucl c_mutable_dict usl m_dictionary 0 0 0 5675 put g_m 61 umsg running usl m_retain 0 0 0 5676 asking = umsg ucl c_mutable_dict usl m_dictionary 0 0 0 5677 put g_m 63 umsg asking usl m_retain 0 0 0 5678 end 5679 end 5680 5681 note start the ssh link for one forwarded port (a check starts its stand-in, never ssh itself) 5682 fn utunnelstart local ulong remote ulong host ulong to void 5683 tool = uns x_real_ssh 5684 if eq get g_n 14 0 5685 n = ucs x_env_ssh 5686 upr 0 ulong libptr g_nm 0 1024 5687 given = ucall 9 5688 if eq given 0 5689 ret 5690 end 5691 n = ufetch given 5692 tool = unsb 5693 end 5694 manager = umsg ucl c_file_manager usl m_default_manager 0 0 0 5695 if eq and umsg manager usl m_is_executable tool 0 0 255 0 5696 ret 5697 end 5698 arguments = umsg uwords x_tunnel_args usl m_mutable_copy 0 0 0 5699 p = uptxt 0 x_loopback 5700 p = upnum p local 5701 put g_nm p 58 5702 p = uptxt add p 1 x_loopback 5703 p = upnum p remote 5704 put g_nm p 0 5705 forward = unsb 5706 sadd = usl m_add_object 5707 x = umsg arguments sadd forward 0 0 5708 x = umsg arguments sadd host 0 0 5709 task = umsg umsg ucl c_task usl m_alloc 0 0 0 usl m_init 0 0 0 5710 x = umsg task usl m_set_launch tool 0 0 5711 x = umsg task usl m_set_arguments arguments 0 0 5712 quiet = umsg ucl c_file_handle usl m_null_device 0 0 0 5713 x = umsg task usl m_set_output quiet 0 0 5714 x = umsg task usl m_set_error quiet 0 0 5715 x = umsg task usl m_set_input quiet 0 0 5716 x = umsg task usl m_launch 0 0 0 5717 put g_n 61 add get g_n 61 1 5718 c_n_v = ucl c_number 5719 s_number = usl m_number_integer 5720 port_key = umsg c_n_v s_number local 0 0 5721 x = umsg get g_m 61 usl m_set_object task port_key 0 5722 note the list of this Mac's links keeps the program now, and the program its words 5723 srel = usl m_release 5724 x = umsg task srel 0 0 0 5725 x = umsg arguments srel 0 0 0 5726 end 5727 5728 note is the link of this Mac's port running 5729 fn utunnelalive port_key ulong to bool 5730 task = umsg get g_m 61 usl m_object_for_key port_key 0 0 5731 if eq task 0 5732 ret false 5733 end 5734 ret eq and umsg task usl m_is_running 0 0 0 255 1 5735 end 5736 5737 note ask whether something on this Mac serves the port: nc tries it for two seconds at most, as a program of its 5738 note own, so this program never waits on a port that does not answer (Hop asks with a two second limit too). 5739 note probeDone: is told when it has ended 5740 fn uprobestart local ulong port_key ulong to void 5741 tool = uns x_nc 5742 manager = umsg ucl c_file_manager usl m_default_manager 0 0 0 5743 if eq and umsg manager usl m_is_executable tool 0 0 255 0 5744 ret 5745 end 5746 arguments = umsg uwords x_nc_args usl m_mutable_copy 0 0 0 5747 p = upnum 0 local 5748 put g_nm p 0 5749 port_text = unsb 5750 x = umsg arguments usl m_add_object port_text 0 0 5751 task = umsg umsg ucl c_task usl m_alloc 0 0 0 usl m_init 0 0 0 5752 x = umsg task usl m_set_launch tool 0 0 5753 x = umsg task usl m_set_arguments arguments 0 0 5754 quiet = umsg ucl c_file_handle usl m_null_device 0 0 0 5755 x = umsg task usl m_set_output quiet 0 0 5756 x = umsg task usl m_set_error quiet 0 0 5757 x = umsg task usl m_set_input quiet 0 0 5758 center = umsg ucl c_center usl m_default_center 0 0 0 5759 s_observe = usl m_add_observer 5760 ended = uconst s_task_ended 5761 upr 40 task 5762 x = umsg center s_observe get g_o 27 get g_m 64 ended 5763 x = umsg get g_m 63 usl m_set_object task port_key 0 5764 x = umsg task usl m_launch 0 0 0 5765 note the list of askers keeps the program now, and the program its words 5766 srel = usl m_release 5767 x = umsg task srel 0 0 0 5768 x = umsg arguments srel 0 0 0 5769 end 5770 5771 note the asking has ended (about: the notice, whose object is the program that asked). A port nothing serves, 5772 note whose link is still not running, gets its link 5773 fn uprobedone about ulong to void 5774 if or eq about 0 eq get g_m 63 0 5775 ret 5776 end 5777 task = umsg about usl m_note_object 0 0 0 5778 if eq task 0 5779 ret 5780 end 5781 x = umsg task usl m_retain 0 0 0 5782 center = umsg ucl c_center usl m_default_center 0 0 0 5783 x = umsg center usl m_remove_all_observer get g_o 27 0 task 5784 served = eq and umsg task usl m_termination 0 0 0 `4294967295` 0 5785 port_keys = umsg get g_m 63 usl m_all_keys_for task 0 0 5786 sat = usl m_at 5787 s_whole = usl m_integer_value 5788 s_drop = usl m_remove_for_key 5789 links = get g_m 60 5790 cnt = umsg port_keys usl m_count 0 0 0 5791 for i ulong cnt bound 16 5792 port_key = umsg port_keys sat i 0 0 5793 local = umsg port_key s_whole 0 0 0 5794 x = umsg get g_m 63 s_drop port_key 0 0 5795 if and not served ne links 0 5796 if not utunnelalive port_key 5797 many = umsg links usl m_count 0 0 0 5798 for j ulong many bound 256 5799 entry = umsg links sat j 0 0 5800 if eq umsg umsg entry sat 0 0 0 s_whole 0 0 0 local 5801 utunnelstart local umsg umsg entry sat 1 0 0 s_whole 0 0 0 umsg entry sat 2 0 0 5802 end 5803 end 5804 end 5805 end 5806 end 5807 x = umsg task usl m_release 0 0 0 5808 end 5809 5810 note look at every forwarded port: for one whose link is not running, and that is not being asked about already, 5811 note it is asked whether something serves the port 5812 fn utunnelcheck to void 5813 links = get g_m 60 5814 if or or eq links 0 eq get g_m 61 0 eq get g_m 63 0 5815 ret 5816 end 5817 if not uremoteok 5818 ret 5819 end 5820 sat = usl m_at 5821 s_whole = usl m_integer_value 5822 s_keyed = usl m_object_for_key 5823 c_n_v = ucl c_number 5824 s_number = usl m_number_integer 5825 cnt = umsg links usl m_count 0 0 0 5826 for i ulong cnt bound 256 5827 entry = umsg links sat i 0 0 5828 local = umsg umsg entry sat 0 0 0 s_whole 0 0 0 5829 port_key = umsg c_n_v s_number local 0 0 5830 if not utunnelalive port_key 5831 if eq umsg get g_m 63 s_keyed port_key 0 0 0 5832 uprobestart local port_key 5833 end 5834 end 5835 end 5836 end 5837 5838 note twice a second: every 20 seconds, and half a second after the start, the forwarded ports are looked at 5839 fn utunneltick to void 5840 ticks = get g_n 60 5841 put g_n 60 add ticks 1 5842 if eq sub ticks mul div ticks 40 40 0 5843 utunnelcheck 5844 end 5845 end 5846 5847 note this program is ending (quitting, or a check at its end): its links and its askers end with it 5848 fn utunnelstop to void 5849 sat = usl m_at 5850 s_running = usl m_is_running 5851 s_end = usl m_terminate_task 5852 s_values = usl m_all_values 5853 for which ulong 2 5854 kept = get g_m 61 5855 if eq which 1 5856 kept = get g_m 63 5857 end 5858 if ne kept 0 5859 tasks = umsg kept s_values 0 0 0 5860 cnt = umsg tasks usl m_count 0 0 0 5861 for i ulong cnt bound 256 5862 task = umsg tasks sat i 0 0 5863 if eq and umsg task s_running 0 0 0 255 1 5864 x = umsg task s_end 0 0 0 5865 end 5866 end 5867 end 5868 end 5869 end 5870 5871 note hear when this program is about to quit (appQuit:) and when a port has been asked about (probeDone:) 5872 fn uquitwatch mine ulong to bool 5873 ok = umethod mine m_app_quit 13 t_v 5874 ok = and ok umethod mine m_probe_done 13 t_v 5875 put g_m 62 usl m_app_quit 5876 put g_m 64 usl m_probe_done 5877 ret ok 5878 end 5879 5880 note ---- screens: the list shows one kind of thing, and typing looks in it ---- 5881 note the copied things: all of them, pinned first, or the ones that have every typed word 5882 fn uscreenclips to void 5883 uclipmatch 1024 5884 h = get g_n 28 5885 for i ulong h bound 1024 5886 put g_rk i 6 5887 put g_hit i get g_cm i 5888 put g_why i 0 5889 end 5890 put g_n 1 h 5891 end 5892 5893 note the saved accounts: all of them, or the ones whose name has the typed text 5894 fn uscreenaccounts to void 5895 nacc = get g_n 31 5896 a = get g_n 12 5897 n = get g_n 13 5898 typed_low = ulong 0 5899 if and gt n 0 le n 255 5900 for i ulong n bound 256 5901 put g_nm i get g_q add a i 5902 end 5903 put g_nm n 0 5904 typed = unsb 5905 if ne typed 0 5906 typed_low = umsg typed usl m_lowercase 0 0 0 5907 end 5908 end 5909 slower = usl m_lowercase 5910 scontains = usl m_contains 5911 h = ulong 0 5912 for i ulong nacc bound 800 5913 keep = true 5914 if gt n 0 5915 keep = false 5916 if ne typed_low 0 5917 name_low = umsg umsg get g_m 18 get g_m 16 i 0 0 slower 0 0 0 5918 keep = eq and umsg name_low scontains typed_low 0 0 255 1 5919 end 5920 end 5921 if keep 5922 put g_rk h 5 5923 put g_hit h i 5924 put g_why h 0 5925 h = add h 1 5926 end 5927 end 5928 put g_n 1 h 5929 end 5930 5931 note show screen number which (0: everything again): the field is emptied and the list made anew 5932 fn uscreen which ulong to void 5933 put g_n 36 which 5934 put g_nm 0 0 5935 x = umsg get g_o 0 get g_o 8 unsb 0 0 5936 utyped 5937 end 5938 5939 note make the list anew from what is known now, keeping the first row selected 5940 fn urefresh to void 5941 unarrow 5942 x = umsg get g_o 1 get g_o 7 0 0 0 5943 put g_n 6 0 5944 if gt get g_n 1 0 5945 uchoose 0 5946 end 5947 ushowst 5948 end 5949 5950 note pin or unpin (what 1) or delete (what 2) copied thing i in the history, then show the history as it is now. 5951 note Like recording it is this program's to do only while Hop is not running 5952 fn uclipedit i ulong what ulong to void 5953 if ge i get g_n 24 5954 ret 5955 end 5956 if and eq get g_n 14 1 uhoprunning 5957 ret 5958 end 5959 shown_item = umsg get g_m 14 get g_m 16 i 0 0 5960 if not uiskind shown_item 7 5961 ret 5962 end 5963 id_text = ukeyed shown_item k_id 5964 if not uiskind id_text 9 5965 ret 5966 end 5967 items = uclipsmutable 5968 if eq items 0 5969 ret 5970 end 5971 sat = usl m_at 5972 sequal = usl m_equal_string 5973 cnt = umsg items usl m_count 0 0 0 5974 found = cnt 5975 for j ulong cnt bound 100000 5976 if eq found cnt 5977 e = umsg items sat j 0 0 5978 if uiskind e 7 5979 other_id = ukeyed e k_id 5980 if uiskind other_id 9 5981 if eq and umsg other_id sequal id_text 0 0 255 1 5982 found = j 5983 end 5984 end 5985 end 5986 end 5987 end 5988 if eq found cnt 5989 ret 5990 end 5991 e = umsg items sat found 0 0 5992 if eq what 1 5993 flip = ulong 1 5994 if uclippinned e 5995 flip = 0 5996 end 5997 flag = umsg ucl c_number usl m_number_bool flip 0 0 5998 x = umsg e usl m_set_object flag uns k_pinned 0 5999 else 6000 image_name = ukeyed e k_image 6001 if uiskind image_name 9 6002 if ne and umsg image_name usl m_contains uns x_slash_text 0 0 255 1 6003 folder = uhoppath x_clip_images 6004 if ne folder 0 6005 gone = umsg folder usl m_append_string image_name 0 0 6006 manager = umsg ucl c_file_manager usl m_default_manager 0 0 0 6007 x = umsg manager usl m_remove_item gone 0 0 6008 end 6009 end 6010 end 6011 x = umsg items usl m_remove_at found 0 0 6012 end 6013 if eq uclipswrite items 1 6014 uloadclips 6015 urefresh 6016 end 6017 end 6018 6019 note the menu's Pin or Unpin and Delete from History: on the selected row when it is a copied thing 6020 fn uclipmenu what ulong to void 6021 r = get g_n 6 6022 if or ge r get g_n 1 ne ulong get g_rk r 6 6023 ret 6024 end 6025 uclipedit get g_hit r what 6026 end 6027 6028 note open Hop's settings file in TextEdit, as Hop does (a check: with the program macOS has for it). When there 6029 note is no settings file yet an empty one is made, which Hop reads as all its built-in settings 6030 fn usettings to void 6031 path = uhoppath x_config 6032 if eq path 0 6033 ret 6034 end 6035 url = umsg ucl c_url usl m_furl path 0 0 6036 ws = umsg ucl c_ws usl m_shws 0 0 0 6037 if eq get g_n 14 0 6038 put g_n 9 and umsg ws usl m_open url 0 0 255 6039 ret 6040 end 6041 manager = umsg ucl c_file_manager usl m_default_manager 0 0 0 6042 if eq and umsg manager usl m_file_exists path 0 0 255 0 6043 d = umsg uns x_empty_settings usl m_data_using 4 0 0 6044 x = umsg d usl m_write_file path 1 0 6045 upr 0 umsg path get g_o 5 0 0 0 6046 upr 8 384 6047 x = ucall 16 6048 end 6049 urls = umsg ucl c_array usl m_array_with url 0 0 6050 editor = umsg ucl c_url usl m_furl uns x_textedit 0 0 6051 how = umsg ucl c_open_config usl m_configuration 0 0 0 6052 s_open = usl m_open_urls_with 6053 upr 40 0 6054 x = umsg ws s_open urls editor how 6055 put g_n 9 1 6056 end 6057 6058 note the rows to show: a screen's own, else what is offered when nothing is typed, else what the one box's 6059 note rules give for the text 6060 fn unarrow to void 6061 if eq get g_n 36 1 6062 uscreenclips 6063 ret 6064 end 6065 if eq get g_n 36 2 6066 uscreenaccounts 6067 ret 6068 end 6069 if eq get g_n 13 0 6070 usuggest 6071 ret 6072 end 6073 m = ulong 0 6074 for k ulong get g_n 0 bound 2048 6075 s = uscore k 6076 if gt s 0 6077 put g_mk m k 6078 put g_ms m sub s 1 6079 m = add m 1 6080 end 6081 end 6082 usearch 6083 urankrows m 6084 end 6085 6086 note "H of N apps" into the status line 6087 fn ushowst to void 6088 p = upnum 0 get g_n 1 6089 if eq get g_n 36 0 6090 p = uptxt p x_of 6091 p = upnum p get g_n 0 6092 p = uptxt p x_apps 6093 end 6094 if eq get g_n 36 1 6095 p = uptxt p x_copied_things 6096 end 6097 if eq get g_n 36 2 6098 p = uptxt p x_accounts_word 6099 end 6100 if ne get g_m 23 0 6101 p = uptxt p x_indexing 6102 end 6103 p = uremotenote p 6104 put g_nm p 0 6105 str = unsb 6106 x = umsg get g_o 2 get g_o 8 str 0 0 6107 end 6108 6109 note select row r of the list and bring it into view 6110 fn uchoose r ulong to void 6111 put g_n 6 r 6112 ix = umsg get g_o 13 get g_o 14 r 0 0 6113 x = umsg get g_o 1 get g_o 12 ix 0 0 6114 x = umsg get g_o 1 get g_o 15 r 0 0 6115 end 6116 6117 note what the list shows was typed into the field: read it, narrow, show 6118 fn utyped to void 6119 uaskstop 6120 str = umsg get g_o 0 get g_o 6 0 0 0 6121 p = umsg str get g_o 5 0 0 0 6122 n = ufetch p 6123 if gt n 255 6124 n = 255 6125 end 6126 for i ulong n bound 256 6127 put g_q i get g_nm i 6128 end 6129 put g_n 4 n 6130 a = ulong 0 6131 while lt a n bound 256 6132 c = ulong get g_q a 6133 if and ne c 32 ne c 9 6134 break 6135 end 6136 a = add a 1 6137 end 6138 e = n 6139 while gt e a bound 256 6140 c = ulong get g_q sub e 1 6141 if and ne c 32 ne c 9 6142 break 6143 end 6144 e = sub e 1 6145 end 6146 put g_n 12 a 6147 put g_n 13 sub e a 6148 udecide 6149 uremotesoon 6150 unarrow 6151 x = umsg get g_o 1 get g_o 7 0 0 0 6152 put g_n 6 0 6153 if gt get g_n 1 0 6154 uchoose 0 6155 end 6156 ushowst 6157 end 6158 6159 note open app k: its folder, "/", its name and ".app" as a file address, handed to the workspace 6160 fn ulaunch k ulong to void 6161 p = ulong 0 6162 if eq ulong get g_dir k 0 6163 p = uptxt 0 x_dir1 6164 else 6165 p = uptxt 0 x_dir2 6166 end 6167 p = uptxt p x_slash 6168 p = upname p k 6169 p = uptxt p x_dotapp 6170 put g_nm p 0 6171 str = unsb 6172 c = ucl c_url 6173 s = usl m_furl 6174 url = umsg c s str 0 0 6175 c = ucl c_ws 6176 s = usl m_shws 6177 ws = umsg c s 0 0 0 6178 s = usl m_open 6179 put g_n 9 and umsg ws s url 0 0 255 6180 end 6181 6182 note open the web address the typed text stands for 6183 fn uopenaddr to void 6184 p = upaddr 0 6185 put g_nm p 0 6186 str = unsb 6187 u = umsg get g_o 16 get g_o 17 str 0 0 6188 c = ucl c_ws 6189 s = usl m_shws 6190 ws = umsg c s 0 0 0 6191 s = usl m_open 6192 put g_n 9 and umsg ws s u 0 0 255 6193 end 6194 6195 note ---- copied things: Hop's encrypted clipboard history (Sources/Clipboard.swift), read and never written ---- 6196 note The history is one file, sealed with AES-256-GCM (the core's fn gcunlock) under a key that Hop keeps in the 6197 note login Keychain as an item of Apple's security tool and reads through that tool; the panel reads it the same 6198 note way. The key and the unsealed bytes are wiped from the core's buffers as soon as they are used. The panel 6199 note only reads the history: Hop, when it runs, is the one that keeps it, and it sees what the panel puts on 6200 note the clipboard like anything else that is copied. A check (HOPCHECK) never asks the tool and never touches 6201 note the real clipboard: it takes the key from HOPCLIPKEY and pastes into a board of its own. 6202 note the clipboard key into the core's c_k; 1 when it is there 6203 fn uclipkey to ulong 6204 encoded = ulong 0 6205 item_name = ulong 0 6206 if eq get g_n 14 0 6207 n = ucs x_env_clipkey 6208 upr 0 ulong libptr g_nm 0 1024 6209 key_text = ucall 9 6210 if eq key_text 0 6211 ret 0 6212 end 6213 n = ufetch key_text 6214 if and and gt n 5 eq get g_nm 0 116 and eq get g_nm 3 108 eq get g_nm 4 58 6215 for i ulong sub n 5 bound 1024 6216 put g_nm i get g_nm add 5 i 6217 end 6218 put g_nm sub n 5 0 6219 item_name = unsb 6220 else 6221 encoded = unsb 6222 end 6223 else 6224 item_name = uns x_clip_service 6225 end 6226 if ne item_name 0 6227 task = umsg ucl c_task usl m_alloc 0 0 0 6228 task = umsg task usl m_init 0 0 0 6229 x = umsg task usl m_set_launch uns x_security 0 0 6230 arguments = umsg ucl c_mutable_array usl m_array 0 0 0 6231 sadd = usl m_add_object 6232 x = umsg arguments sadd uns x_find 0 0 6233 x = umsg arguments sadd uns x_dash_s 0 0 6234 x = umsg arguments sadd item_name 0 0 6235 x = umsg arguments sadd uns x_dash_a 0 0 6236 x = umsg arguments sadd uns x_clip_account 0 0 6237 x = umsg arguments sadd uns x_dash_w 0 0 6238 x = umsg task usl m_set_arguments arguments 0 0 6239 tube = umsg ucl c_pipe usl m_pipe 0 0 0 6240 x = umsg task usl m_set_output tube 0 0 6241 quiet = umsg ucl c_file_handle usl m_null_device 0 0 0 6242 x = umsg task usl m_set_error quiet 0 0 6243 x = umsg task usl m_launch 0 0 0 6244 reader = umsg tube usl m_reading 0 0 0 6245 d = umsg reader usl m_read_end 0 0 0 6246 x = umsg task usl m_wait 0 0 0 6247 if ne and umsg task usl m_termination 0 0 0 `4294967295` 0 6248 ret 0 6249 end 6250 if eq d 0 6251 ret 0 6252 end 6253 whole = umsg ucl c_str usl m_alloc 0 0 0 6254 whole = umsg whole usl m_init_data_encoding d 4 0 6255 if eq whole 0 6256 ret 0 6257 end 6258 blanks = umsg ucl c_charset usl m_whitespace 0 0 0 6259 encoded = umsg whole usl m_trim blanks 0 0 6260 end 6261 if eq encoded 0 6262 ret 0 6263 end 6264 kd = umsg ucl c_data usl m_alloc 0 0 0 6265 kd = umsg kd usl m_init_base64 encoded 0 0 6266 if eq kd 0 6267 ret 0 6268 end 6269 if ne umsg kd usl m_length 0 0 0 32 6270 ret 0 6271 end 6272 src = umsg kd usl m_bytes 0 0 0 6273 upr 0 ulong libptr c_k 0 32 6274 upr 8 src 6275 upr 16 32 6276 x = ucall 8 6277 ret 1 6278 end 6279 6280 note wipe the first m unsealed bytes of the core's buffer 6281 fn uforget m ulong to void 6282 if eq m 0 6283 ret 6284 end 6285 upr 0 ulong libptr c_d 0 m 6286 upr 8 0 6287 upr 16 m 6288 x = ucall 17 6289 end 6290 6291 note the sealed bytes of d (an NSData: the nonce, the data, the tag) unsealed into the core's c_d with the 6292 note clipboard key; the count of data bytes plus 1, or 0 when it cannot be done (no key, or not sealed by it) 6293 fn uunseal d ulong to ulong 6294 n = umsg d usl m_length 0 0 0 6295 if or lt n 28 gt n `16777244` 6296 ret 0 6297 end 6298 src = umsg d usl m_bytes 0 0 0 6299 if eq uclipkey 0 6300 ret 0 6301 end 6302 m = sub n 28 6303 upr 0 ulong libptr c_n 0 12 6304 upr 8 src 6305 upr 16 12 6306 x = ucall 8 6307 if gt m 0 6308 upr 0 ulong libptr c_d 0 m 6309 upr 8 add src 12 6310 upr 16 m 6311 x = ucall 8 6312 end 6313 upr 0 ulong libptr c_tg 0 16 6314 upr 8 add src sub n 16 6315 upr 16 16 6316 x = ucall 8 6317 good = gcunlock m 6318 gcwipe 6319 if eq good 0 6320 ret 0 6321 end 6322 ret add m 1 6323 end 6324 6325 note the text a copied thing is shown by: its text without the blanks around it, a mark where a line ends, the 6326 note first 80 characters; "Image" for a picture 6327 fn uclippreview item ulong to ulong 6328 if not uiskind item 7 6329 ret uns x_image 6330 end 6331 words = ukeyed item k_text 6332 if not uiskind words 9 6333 ret uns x_image 6334 end 6335 blanks = umsg ucl c_charset usl m_whitespace 0 0 0 6336 t = umsg words usl m_trim blanks 0 0 6337 put g_nm 0 10 6338 put g_nm 1 0 6339 line_end = unsb 6340 put g_nm 0 32 6341 put g_nm 1 226 6342 put g_nm 2 143 6343 put g_nm 3 142 6344 put g_nm 4 32 6345 put g_nm 5 0 6346 mark = unsb 6347 t = umsg t usl m_replace line_end mark 0 6348 if gt umsg t usl m_length 0 0 0 80 6349 cut = umsg t usl m_composed_at 80 0 0 6350 t = umsg t usl m_substring_to cut 0 0 6351 end 6352 ret t 6353 end 6354 6355 note read the history: the copied things, the text each is shown by, which are pinned, and the order they are 6356 note searched in. Nothing is kept when the file is not there, the key is not to be had or the file is not Hop's 6357 fn uloadclips to void 6358 put g_n 24 0 6359 d = uhopfile x_clipboard_file 6360 if eq d 0 6361 ret 6362 end 6363 r = uunseal d 6364 if le r 1 6365 ret 6366 end 6367 m = sub r 1 6368 plain = umsg ucl c_data usl m_data_bytes ulong libptr c_d 0 m m 0 6369 uforget m 6370 items = umsg ucl c_json usl m_json_object plain 0 0 6371 if not uiskind items 8 6372 ret 6373 end 6374 cnt = umsg items usl m_count 0 0 0 6375 if gt cnt 1024 6376 cnt = 1024 6377 end 6378 sret = usl m_retain 6379 srel = usl m_release 6380 if ne get g_m 14 0 6381 x = umsg get g_m 14 srel 0 0 0 6382 x = umsg get g_m 15 srel 0 0 0 6383 end 6384 put g_m 14 umsg items sret 0 0 0 6385 shown_by = umsg ucl c_mutable_array usl m_array 0 0 0 6386 put g_m 15 umsg shown_by sret 0 0 0 6387 sat = usl m_at 6388 put g_m 16 sat 6389 sadd = usl m_add_object 6390 for i ulong cnt bound 1024 6391 item = umsg items sat i 0 0 6392 pv = uclippreview item 6393 x = umsg shown_by sadd pv 0 0 6394 put g_cp i 0 6395 if uiskind item 7 6396 pin = ukeyed item k_pinned 6397 if uisnumber pin 6398 if eq and umsg pin usl m_bool_value 0 0 0 255 1 6399 put g_cp i 1 6400 end 6401 end 6402 end 6403 end 6404 pos = ulong 0 6405 for i ulong cnt bound 1024 6406 if eq ulong get g_cp i 1 6407 put g_ci pos i 6408 pos = add pos 1 6409 end 6410 end 6411 for i ulong cnt bound 1024 6412 if eq ulong get g_cp i 0 6413 put g_ci pos i 6414 pos = add pos 1 6415 end 6416 end 6417 put g_n 24 cnt 6418 end 6419 6420 note the text copied thing i is shown by into g_nm from byte p; the byte after it 6421 fn uclipname p ulong i ulong to ulong 6422 if or ge i get g_n 24 ge p 900 6423 ret p 6424 end 6425 pv = umsg get g_m 15 get g_m 16 i 0 0 6426 src = umsg pv get g_o 5 0 0 0 6427 if eq src 0 6428 ret p 6429 end 6430 upr 0 src 6431 n = ucall 7 6432 if gt add p n 900 6433 n = sub 900 p 6434 end 6435 if eq n 0 6436 ret p 6437 end 6438 upr 0 ulong libptr g_nm p n 6439 upr 8 src 6440 upr 16 n 6441 x = ucall 8 6442 ret add p n 6443 end 6444 6445 note the newest copied thing's text takes the place of the typed text (on 1) so that the address helpers work on 6446 note it, and gives it back (on 0). Only used while nothing is typed 6447 fn uclipaddr on ulong to void 6448 if eq on 1 6449 n = get g_n 25 6450 for i ulong n bound 256 6451 put g_q i get g_ca i 6452 end 6453 put g_n 12 0 6454 put g_n 13 n 6455 put g_n 10 get g_n 26 6456 else 6457 put g_n 13 0 6458 put g_n 10 0 6459 end 6460 end 6461 6462 note the copied things that match the typed text, as Hop's search does: the pinned ones first, each in lower 6463 note case has to contain every typed word (a picture counts as "image"); the first "most" of them into g_cm 6464 note (for a whole screen with nothing typed: all of them) 6465 fn uclipmatch most ulong to void 6466 put g_n 28 0 6467 cnt = get g_n 24 6468 if eq cnt 0 6469 ret 6470 end 6471 a = get g_n 12 6472 n = get g_n 13 6473 if and eq n 0 gt most 8 6474 every = cnt 6475 if gt every most 6476 every = most 6477 end 6478 for pos ulong every bound 1024 6479 put g_cm pos get g_ci pos 6480 end 6481 put g_n 28 every 6482 ret 6483 end 6484 if or eq n 0 gt n 255 6485 ret 6486 end 6487 for i ulong n bound 256 6488 put g_nm i get g_q add a i 6489 end 6490 put g_nm n 0 6491 typed = unsb 6492 if eq typed 0 6493 ret 6494 end 6495 slower = usl m_lowercase 6496 typed_low = umsg typed slower 0 0 0 6497 parts = umsg typed_low usl m_components uns x_space 0 0 6498 nt = umsg parts usl m_count 0 0 0 6499 scontains = usl m_contains 6500 slen = usl m_length 6501 sat = get g_m 16 6502 image_low = uns x_image_low 6503 found = ulong 0 6504 for pos ulong cnt bound 1024 6505 if lt found most 6506 i = get g_ci pos 6507 item = umsg get g_m 14 sat i 0 0 6508 hay = image_low 6509 if uiskind item 7 6510 words = ukeyed item k_text 6511 if uiskind words 9 6512 hay = umsg words slower 0 0 0 6513 end 6514 end 6515 okay = true 6516 for j ulong nt bound 64 6517 term = umsg parts sat j 0 0 6518 if gt umsg term slen 0 0 0 0 6519 if ne and umsg hay scontains term 0 0 255 1 6520 okay = false 6521 end 6522 end 6523 end 6524 if okay 6525 put g_cm found i 6526 found = add found 1 6527 end 6528 end 6529 end 6530 put g_n 28 found 6531 end 6532 6533 note put copied thing i on the clipboard: its text, or its picture unsealed (as PNG data). A check uses a board 6534 note of its own 6535 fn upasteclip i ulong to void 6536 if ge i get g_n 24 6537 ret 6538 end 6539 item = umsg get g_m 14 get g_m 16 i 0 0 6540 if not uiskind item 7 6541 ret 6542 end 6543 pboard = ulong 0 6544 if eq get g_n 14 1 6545 pboard = umsg ucl c_pasteboard usl m_general_pasteboard 0 0 0 6546 else 6547 pboard = umsg ucl c_pasteboard usl m_board_named uns x_check_board 0 0 6548 end 6549 x = umsg pboard usl m_clear 0 0 0 6550 words = ukeyed item k_text 6551 if uiskind words 9 6552 x = umsg pboard usl m_set_string_type words uns x_type_string 0 6553 put g_n 29 1 6554 ret 6555 end 6556 name = ukeyed item k_image 6557 if not uiskind name 9 6558 ret 6559 end 6560 if eq and umsg name usl m_contains uns x_slash_text 0 0 255 1 6561 ret 6562 end 6563 folder = uhoppath x_clip_images 6564 if eq folder 0 6565 ret 6566 end 6567 path = umsg folder usl m_append_string name 0 0 6568 d = umsg ucl c_data usl m_data_file path 0 0 6569 if eq d 0 6570 ret 6571 end 6572 r = uunseal d 6573 if le r 1 6574 ret 6575 end 6576 m = sub r 1 6577 picture = umsg ucl c_data usl m_data_bytes ulong libptr c_d 0 m m 0 6578 uforget m 6579 x = umsg pboard usl m_set_data_type picture uns x_type_png 0 6580 put g_n 29 2 6581 end 6582 6583 note press Command V for the app that is in front again, as Hop does after it has put something on the clipboard 6584 fn usendpaste to void 6585 for half ulong 2 6586 upr 0 0 6587 upr 8 9 6588 upr 16 sub 1 half 6589 ev = ucall 19 6590 if ne ev 0 6591 upr 0 ev 6592 upr 8 `1048576` 6593 x = ucall 20 6594 upr 0 0 6595 upr 8 ev 6596 x = ucall 21 6597 upr 0 ev 6598 x = ucall 22 6599 end 6600 end 6601 end 6602 6603 note a moment from now, press Command V; only when this program is allowed to control the Mac (Accessibility) 6604 fn ulaterpaste to void 6605 if eq and ucall 18 255 0 6606 ret 6607 end 6608 s_after = usl m_perform_after 6609 s_paste = usl m_paste_now 6610 upr 64 bitcast ulong 0.15f64 6611 x = umsg get g_o 27 s_after s_paste 0 0 6612 end 6613 6614 note ---- recording what is copied, as Hop does (Sources/Clipboard.swift, poll) ---- 6615 note Only while Hop itself is not running: two programs must not write the same history. The history is read 6616 note again at that moment, changed and written whole, sealed under the same key with a fresh nonce (the core's fn 6617 note gclock), for the owner only. Before this program's first change in a run the history as it was is set 6618 note aside next to it (clipboard.before-hop-omega.bin). What is marked concealed or transient is never kept. 6619 note seal the first m bytes of the core's c_d under the clipboard key; nonce, data and tag as NSData, or 0 6620 fn useal m ulong to ulong 6621 if or eq m 0 gt m `16777216` 6622 ret 0 6623 end 6624 if eq uclipkey 0 6625 ret 0 6626 end 6627 upr 0 ulong libptr c_n 0 12 6628 upr 8 12 6629 x = ucall 27 6630 gclock m 6631 gcwipe 6632 sealed = umsg ucl c_mutable_data usl m_data 0 0 0 6633 sappend = usl m_append_bytes 6634 x = umsg sealed sappend ulong libptr c_n 0 12 12 0 6635 x = umsg sealed sappend ulong libptr c_d 0 m m 0 6636 x = umsg sealed sappend ulong libptr c_tg 0 16 16 0 6637 ret sealed 6638 end 6639 6640 note the history as it is on disk now, as a list that can be changed: an empty one when there is no file yet, 6641 note 0 when there is no key or the file is not Hop's 6642 fn uclipsmutable to ulong 6643 path = uhoppath x_clipboard_file 6644 if eq path 0 6645 ret 0 6646 end 6647 manager = umsg ucl c_file_manager usl m_default_manager 0 0 0 6648 if eq and umsg manager usl m_file_exists path 0 0 255 0 6649 if eq uclipkey 0 6650 ret 0 6651 end 6652 gcwipe 6653 ret umsg ucl c_mutable_array usl m_array 0 0 0 6654 end 6655 d = umsg ucl c_data usl m_data_file path 0 0 6656 if eq d 0 6657 ret 0 6658 end 6659 r = uunseal d 6660 if le r 1 6661 ret 0 6662 end 6663 m = sub r 1 6664 plain = umsg ucl c_data usl m_data_bytes ulong libptr c_d 0 m m 0 6665 uforget m 6666 items = umsg ucl c_json usl m_json_object plain 1 0 6667 if not uiskind items 8 6668 ret 0 6669 end 6670 ret items 6671 end 6672 6673 note write the list as the history; 1 when it was written 6674 fn uclipswrite items ulong to ulong 6675 data = umsg ucl c_json usl m_json_data items 0 0 6676 if eq data 0 6677 ret 0 6678 end 6679 n = umsg data usl m_length 0 0 0 6680 if or eq n 0 gt n `16777216` 6681 ret 0 6682 end 6683 s_write = usl m_write_file 6684 if eq get g_n 33 0 6685 before = uhopfile x_clipboard_file 6686 if ne before 0 6687 aside = uhoppath x_clip_backup 6688 x = umsg before s_write aside 1 0 6689 upr 0 ulong libptr g_nm 0 1024 6690 upr 8 384 6691 x = ucall 16 6692 end 6693 put g_n 33 1 6694 end 6695 src = umsg data usl m_bytes 0 0 0 6696 upr 0 ulong libptr c_d 0 n 6697 upr 8 src 6698 upr 16 n 6699 x = ucall 8 6700 sealed = useal n 6701 uforget n 6702 if eq sealed 0 6703 ret 0 6704 end 6705 path = uhoppath x_clipboard_file 6706 if eq path 0 6707 ret 0 6708 end 6709 ok = and umsg sealed s_write path 1 0 255 6710 path = uhoppath x_clipboard_file 6711 upr 0 ulong libptr g_nm 0 1024 6712 upr 8 384 6713 x = ucall 16 6714 ret ok 6715 end 6716 6717 note is the copied thing e pinned 6718 fn uclippinned e ulong to bool 6719 if not uiskind e 7 6720 ret false 6721 end 6722 pin = ukeyed e k_pinned 6723 if not uisnumber pin 6724 ret false 6725 end 6726 ret eq and umsg pin usl m_bool_value 0 0 0 255 1 6727 end 6728 6729 note what is on the pasteboard pb goes into the history as Hop puts it there: text that is already there moves 6730 note to the front, new text or a picture (as PNG, sealed in a file of its own) is added in front with the app it 6731 note came from; then the unpinned ones over the limit go, the oldest first 6732 fn ucliprecord pb ulong to void 6733 types = umsg pb usl m_types 0 0 0 6734 if ne types 0 6735 shas = usl m_contains_object 6736 if eq and umsg types shas uns x_skip0 0 0 255 1 6737 ret 6738 end 6739 if eq and umsg types shas uns x_skip1 0 0 255 1 6740 ret 6741 end 6742 if eq and umsg types shas uns x_skip2 0 0 255 1 6743 ret 6744 end 6745 if eq and umsg types shas uns x_skip3 0 0 255 1 6746 ret 6747 end 6748 if eq and umsg types shas uns x_skip4 0 0 255 1 6749 ret 6750 end 6751 if eq and umsg types shas uns x_skip5 0 0 255 1 6752 ret 6753 end 6754 end 6755 items = uclipsmutable 6756 if eq items 0 6757 ret 6758 end 6759 source = ulong 0 6760 if eq get g_n 14 1 6761 front_app = umsg umsg ucl c_ws usl m_shws 0 0 0 usl m_frontmost 0 0 0 6762 if ne front_app 0 6763 source = umsg front_app usl m_localized_name 0 0 0 6764 end 6765 end 6766 cnum = ucl c_number 6767 x = umsg ucl c_date usl m_reference_now 0 0 0 6768 now_bits = ugr 64 6769 s_double = usl m_number_double 6770 upr 64 now_bits 6771 moment = umsg cnum s_double 0 0 0 6772 sset = usl m_set_object 6773 sat = usl m_at 6774 sins = usl m_insert_at 6775 copied = umsg pb usl m_string_for_type uns x_type_string 0 0 6776 has_text = false 6777 if ne copied 0 6778 if gt umsg copied usl m_length 0 0 0 0 6779 has_text = true 6780 end 6781 end 6782 fresh_item = ulong 0 6783 if has_text 6784 if gt umsg copied usl m_byte_length 4 0 0 512000 6785 ret 6786 end 6787 cnt = umsg items usl m_count 0 0 0 6788 found = cnt 6789 sequal = usl m_equal_string 6790 for i ulong cnt bound 100000 6791 if eq found cnt 6792 e = umsg items sat i 0 0 6793 if uiskind e 7 6794 words = ukeyed e k_text 6795 if uiskind words 9 6796 if eq and umsg words sequal copied 0 0 255 1 6797 found = i 6798 end 6799 end 6800 end 6801 end 6802 end 6803 if lt found cnt 6804 e = umsg items sat found 0 0 6805 kept = umsg e usl m_retain 0 0 0 6806 x = umsg e sset moment uns k_date 0 6807 x = umsg items usl m_remove_at found 0 0 6808 x = umsg items sins e 0 0 6809 x = umsg e usl m_release 0 0 0 6810 else 6811 fresh_item = umsg ucl c_mutable_dict usl m_dictionary 0 0 0 6812 x = umsg fresh_item sset copied uns k_text 0 6813 end 6814 else 6815 picture = umsg ucl c_image usl m_alloc 0 0 0 6816 picture = umsg picture usl m_init_pasteboard pb 0 0 6817 if eq picture 0 6818 ret 6819 end 6820 tiff = umsg picture usl m_tiff 0 0 0 6821 if eq tiff 0 6822 ret 6823 end 6824 bitmap = umsg ucl c_bitmap usl m_rep_with_data tiff 0 0 6825 if eq bitmap 0 6826 ret 6827 end 6828 no_properties = umsg ucl c_mutable_dict usl m_dictionary 0 0 0 6829 png = umsg bitmap usl m_rep_using 4 no_properties 0 6830 if eq png 0 6831 ret 6832 end 6833 pn = umsg png usl m_length 0 0 0 6834 if or eq pn 0 gt pn `16777216` 6835 ret 6836 end 6837 src = umsg png usl m_bytes 0 0 0 6838 upr 0 ulong libptr c_d 0 pn 6839 upr 8 src 6840 upr 16 pn 6841 x = ucall 8 6842 sealed = useal pn 6843 uforget pn 6844 if eq sealed 0 6845 ret 6846 end 6847 folder = uhoppath x_clip_images 6848 if eq folder 0 6849 ret 6850 end 6851 manager = umsg ucl c_file_manager usl m_default_manager 0 0 0 6852 s_create = usl m_create_dir 6853 upr 40 0 6854 x = umsg manager s_create folder 1 0 6855 file_name = umsg umsg umsg ucl c_uuid usl m_uuid 0 0 0 usl m_uuid_string 0 0 0 usl m_append_string uns x_dot_bin 0 0 6856 file_path = umsg folder usl m_append_string file_name 0 0 6857 if eq and umsg sealed usl m_write_file file_path 1 0 255 0 6858 ret 6859 end 6860 fresh_item = umsg ucl c_mutable_dict usl m_dictionary 0 0 0 6861 x = umsg fresh_item sset file_name uns k_image 0 6862 end 6863 if ne fresh_item 0 6864 id_text = umsg umsg ucl c_uuid usl m_uuid 0 0 0 usl m_uuid_string 0 0 0 6865 x = umsg fresh_item sset id_text uns k_id 0 6866 x = umsg fresh_item sset moment uns k_date 0 6867 if ne source 0 6868 x = umsg fresh_item sset source uns k_source 0 6869 end 6870 no = umsg cnum usl m_number_bool 0 0 0 6871 x = umsg fresh_item sset no uns k_pinned 0 6872 x = umsg items sins fresh_item 0 0 6873 end 6874 note the unpinned ones over the limit go, from the end 6875 limit = get g_n 34 6876 if lt limit 50 6877 limit = 50 6878 end 6879 cnt = umsg items usl m_count 0 0 0 6880 loose = ulong 0 6881 for i ulong cnt bound 100000 6882 if not uclippinned umsg items sat i 0 0 6883 loose = add loose 1 6884 end 6885 end 6886 if gt loose limit 6887 drop = sub loose limit 6888 manager = umsg ucl c_file_manager usl m_default_manager 0 0 0 6889 for back ulong cnt bound 100000 6890 i = sub sub cnt 1 back 6891 if gt drop 0 6892 e = umsg items sat i 0 0 6893 if not uclippinned e 6894 if uiskind e 7 6895 image_name = ukeyed e k_image 6896 if uiskind image_name 9 6897 if ne and umsg image_name usl m_contains uns x_slash_text 0 0 255 1 6898 folder = uhoppath x_clip_images 6899 if ne folder 0 6900 gone = umsg folder usl m_append_string image_name 0 0 6901 x = umsg manager usl m_remove_item gone 0 0 6902 end 6903 end 6904 end 6905 end 6906 x = umsg items usl m_remove_at i 0 0 6907 drop = sub drop 1 6908 end 6909 end 6910 end 6911 end 6912 x = uclipswrite items 6913 end 6914 6915 note is Hop itself running 6916 fn uhoprunning to bool 6917 others = umsg ucl c_running_app usl m_running_with uns x_hop_id 0 0 6918 if eq others 0 6919 ret false 6920 end 6921 ret gt umsg others usl m_count 0 0 0 0 6922 end 6923 6924 note twice a second: when the clipboard has changed and Hop is not there to keep the history, this program does 6925 fn ucliptick to void 6926 uindextick 6927 utunneltick 6928 pb = umsg ucl c_pasteboard usl m_general_pasteboard 0 0 0 6929 cc = umsg pb usl m_change_count 0 0 0 6930 if eq cc get g_n 35 6931 ret 6932 end 6933 put g_n 35 cc 6934 if uhoprunning 6935 ret 6936 end 6937 ucliprecord pb 6938 end 6939 6940 note after this program put something on the clipboard itself: that change is not a new copied thing; a text that 6941 note was pasted moves to the front of the history, as in Hop 6942 fn uclipmine was_text ulong to void 6943 pb = umsg ucl c_pasteboard usl m_general_pasteboard 0 0 0 6944 put g_n 35 umsg pb usl m_change_count 0 0 0 6945 if and eq was_text 1 not uhoprunning 6946 ucliprecord pb 6947 end 6948 end 6949 6950 note is the app in front a browser, by Hop's list 6951 fn ufrontbrowser to ulong 6952 id = get g_m 11 6953 if eq id 0 6954 ret 0 6955 end 6956 sequal = usl m_equal_string 6957 if eq and umsg id sequal uns x_browser0 0 0 255 1 6958 ret 1 6959 end 6960 if eq and umsg id sequal uns x_browser1 0 0 255 1 6961 ret 1 6962 end 6963 if eq and umsg id sequal uns x_browser2 0 0 255 1 6964 ret 1 6965 end 6966 if eq and umsg id sequal uns x_browser3 0 0 255 1 6967 ret 1 6968 end 6969 if eq and umsg id sequal uns x_browser4 0 0 255 1 6970 ret 1 6971 end 6972 if eq and umsg id sequal uns x_browser5 0 0 255 1 6973 ret 1 6974 end 6975 if eq and umsg id sequal uns x_browser6 0 0 255 1 6976 ret 1 6977 end 6978 if eq and umsg id sequal uns x_browser7 0 0 255 1 6979 ret 1 6980 end 6981 if eq and umsg id sequal uns x_browser8 0 0 255 1 6982 ret 1 6983 end 6984 ret 0 6985 end 6986 6987 note the Ask row's text into g_nm from byte p: "Ask NAME: TEXT", or why it cannot ask; the byte after it 6988 fn uaskrow p ulong to ulong 6989 if eq get g_m 3 0 6990 ret uptxt p x_ask_none 6991 end 6992 name_bytes = umsg get g_m 2 get g_o 5 0 0 0 6993 q = uptxt p x_ask 6994 upr 0 name_bytes 6995 n = ucall 7 6996 if gt n 200 6997 n = 200 6998 end 6999 upr 0 ulong libptr g_nm q n 7000 upr 8 name_bytes 7001 upr 16 n 7002 x = ucall 8 7003 q = add q n 7004 q = uptxt q x_colon 7005 a = get g_n 12 7006 n = get g_n 13 7007 for i ulong n bound 256 7008 put g_nm add q i get g_q add a i 7009 end 7010 ret add q n 7011 end 7012 7013 note the text of row r into g_nm from byte p (an app's name, the address, a file's whole path, or the Ask row); the byte after it 7014 fn uprow p ulong r ulong to ulong 7015 if eq ulong get g_rk r 8 7016 ret uaskrow p 7017 end 7018 if eq ulong get g_rk r 10 7019 ret uremoterow p get g_hit r 7020 end 7021 if eq ulong get g_rk r 9 7022 q = uptxt p x_agent_row 7023 a = get g_n 12 7024 n = get g_n 13 7025 for i ulong n bound 256 7026 put g_nm add q i get g_q add a i 7027 end 7028 ret add q n 7029 end 7030 if eq ulong get g_rk r 6 7031 ret uclipname p get g_hit r 7032 end 7033 if eq ulong get g_rk r 5 7034 ret ustrat get g_m 18 p get g_hit r 7035 end 7036 if eq ulong get g_rk r 3 7037 if eq get g_hit r 0 7038 ret uptxt p x_screen0 7039 end 7040 if eq get g_hit r 2 7041 ret uptxt p x_screen2 7042 end 7043 ret uptxt p x_screen1 7044 end 7045 if eq ulong get g_rk r 4 7046 if eq get g_hit r 0 7047 ret uptxt p x_command0 7048 end 7049 if eq get g_hit r 2 7050 ret uptxt p x_command2 7051 end 7052 if eq get g_hit r 3 7053 ret uptxt p x_command3 7054 end 7055 ret uptxt p x_command1 7056 end 7057 if and eq ulong get g_rk r 2 eq get g_n 13 0 7058 uclipaddr 1 7059 q = upaddr p 7060 uclipaddr 0 7061 ret q 7062 end 7063 if eq ulong get g_rk r 2 7064 ret upaddr p 7065 end 7066 if eq ulong get g_rk r 7 7067 ret ufilepath p get g_hit r 7068 end 7069 ret upname p get g_hit r 7070 end 7071 7072 note one turn of the event loop: wait for an event until date d and hand it to AppKit 7073 fn utick app ulong sn ulong se ulong mode ulong d ulong to void 7074 upr 0 app 7075 upr 8 sn 7076 upr 16 `18446744073709551615` 7077 upr 24 d 7078 upr 32 mode 7079 upr 40 1 7080 ev = ucall 2 7081 if ne ev 0 7082 x = umsg app se ev 0 0 7083 end 7084 end 7085 7086 note put the panel away. A program that stays also empties the field, shows every app again and hides itself, so 7087 note the app that was in front before has the keyboard back 7088 fn uhide to void 7089 uaskstop 7090 put g_n 36 0 7091 x = umsg get g_o 19 get g_o 20 0 0 0 7092 if eq get g_n 14 1 7093 put g_nm 0 0 7094 x = umsg get g_o 0 get g_o 8 unsb 0 0 7095 utyped 7096 x = umsg get g_o 21 get g_o 22 0 0 0 7097 end 7098 end 7099 7100 note bring the panel back: in front with the keyboard in the field for a program that stays, else just visible 7101 fn ushow to void 7102 if eq get g_n 14 1 7103 ufront 7104 uloadclips 7105 uloadvault 7106 if eq get g_m 3 0 7107 uloadconfig 7108 end 7109 if eq get g_n 13 0 7110 unarrow 7111 x = umsg get g_o 1 get g_o 7 0 0 0 7112 put g_n 6 0 7113 if gt get g_n 1 0 7114 uchoose 0 7115 end 7116 ushowst 7117 end 7118 x = umsg get g_o 21 get g_o 23 1 0 0 7119 x = umsg get g_o 19 get g_o 24 0 0 0 7120 x = umsg get g_o 19 get g_o 25 get g_o 0 0 0 7121 else 7122 x = umsg get g_o 19 get g_o 26 0 0 0 7123 end 7124 end 7125 7126 note the library function at address f on the register file; x0 as it came back 7127 fn ucallf f ulong to ulong 7128 lr = libcall f g_rg 0 128 7129 ret ugr 0 7130 end 7131 7132 note a global key: a Carbon hot key (key code, modifiers) whose handler is callback entry 5. 0 when both the 7133 note handler and the key were taken; the hot key's id is 'HOPO' 1 7134 fn ukey code ulong mods ulong to ulong 7135 n = ucs s_carbon 7136 upr 0 ulong libptr g_nm 0 1024 7137 upr 8 2 7138 lr = libcall ulong libfn 0 g_rg 0 128 7139 target_fn = usym s_event_target 7140 install_fn = usym s_install_handler 7141 register_fn = usym s_register_key 7142 if or or eq target_fn 0 eq install_fn 0 eq register_fn 0 7143 ret 1 7144 end 7145 target = ucallf target_fn 7146 put g_ev 0 98 7147 put g_ev 1 121 7148 put g_ev 2 101 7149 put g_ev 3 107 7150 put g_ev 4 5 7151 upr 0 target 7152 upr 8 ulong libfn 7 7153 upr 16 1 7154 upr 24 ulong libptr g_ev 0 16 7155 upr 32 0 7156 upr 40 0 7157 installed = and ucallf install_fn `4294967295` 7158 upr 0 code 7159 upr 8 mods 7160 upr 16 `5507124751` 7161 upr 24 target 7162 upr 32 0 7163 upr 40 ulong libptr g_ev 8 8 7164 registered = and ucallf register_fn `4294967295` 7165 ret or installed registered 7166 end 7167 7168 note one menu item: title, action (a selector) and key. An unsized text takes two of a function's six places 7169 fn uitem menu ulong title view uchar * action_sel ulong key view uchar * to void 7170 c = ucl c_menu_item 7171 s = usl m_alloc 7172 item = umsg c s 0 0 0 7173 title_string = uns title 7174 key_string = uns key 7175 s = usl m_init_item 7176 item = umsg item s title_string action_sel key_string 7177 s = usl m_add_item 7178 x = umsg menu s item 0 0 7179 end 7180 7181 note a menu bar entry with an empty menu under it; the menu 7182 fn usubmenu bar ulong title view uchar * to ulong 7183 c = ucl c_menu_item 7184 s = usl m_alloc 7185 sinit = usl m_init 7186 entry = umsg c s 0 0 0 7187 entry = umsg entry sinit 0 0 0 7188 s = usl m_add_item 7189 x = umsg bar s entry 0 0 7190 c = ucl c_menu 7191 s = usl m_alloc 7192 menu = umsg c s 0 0 0 7193 title_string = uns title 7194 s = usl m_init_title 7195 menu = umsg menu s title_string 0 0 7196 s = usl m_set_submenu 7197 x = umsg entry s menu 0 0 7198 ret menu 7199 end 7200 7201 note the menu: Quit, and Edit with the four commands the field's editor answers itself 7202 fn umenu app ulong to void 7203 c = ucl c_menu 7204 s = usl m_alloc 7205 sinit = usl m_init 7206 bar = umsg c s 0 0 0 7207 bar = umsg bar sinit 0 0 0 7208 app_menu = usubmenu bar x_app 7209 a = usl m_terminate 7210 uitem app_menu x_quit a x_key_q 7211 edit_menu = usubmenu bar x_edit 7212 a = usl m_cut 7213 uitem edit_menu x_cut a x_key_x 7214 a = usl m_copy 7215 uitem edit_menu x_copy a x_key_c 7216 a = usl m_paste 7217 uitem edit_menu x_paste a x_key_v 7218 a = usl m_select_all 7219 uitem edit_menu x_select_all a x_key_a 7220 clip_menu = usubmenu bar x_clip_menu 7221 a = usl m_pin_clip 7222 uitem clip_menu x_pin_item a x_key_p 7223 a = usl m_delete_clip 7224 uitem clip_menu x_delete_item a x_key_d 7225 agent_menu = usubmenu bar x_agent_menu 7226 a = usl m_agent_stop 7227 uitem agent_menu x_stop_item a x_key_period 7228 s = usl m_set_menu 7229 x = umsg app s bar 0 0 7230 ustatus 7231 end 7232 7233 note the methods of OmegaHopPanel. 0 controlTextDidChange: 1 numberOfRowsInTableView: 7234 note 2 tableView:objectValueForTableColumn:row: (e is the row) 3 go: (the field's action, Enter: c is the sender; 7235 note it is remembered, and opened when g_n 7 allows) 4 control:textView:doCommandBySelector: (e is 7236 note the command: the arrows move the selection, Escape puts the panel away; 1 says the key was handled) 7237 note 5 the hot key's handler (a C function for Carbon: 0 says no error) 6 applicationShouldHandleReopen: 7238 note hasVisibleWindows: (a click on the Dock icon, or the app opened again) 7 URLSession:dataTask:didReceiveData: 7239 note (e is the data) 8 URLSession:task:didCompleteWithError: (d the task, e the problem or nothing) 7240 note 9 pasteNow: (a moment after a copied thing was chosen) 10 clipTick: (twice a second, to see what was copied) 7241 note 11 pinClip: 12 deleteClip: (the Clipboard menu, on the selected copied thing) 13 agentOut: agentErr: 7242 note agentEnd: stopAgent: (what the agent's program tells, and the Agent menu; b is the selector, c what came) 7243 fn libback k ulong a ulong b ulong c ulong d ulong e ulong to ulong 7244 if eq k 0 7245 utyped 7246 ret 0 7247 end 7248 if eq k 1 7249 ret get g_n 1 7250 end 7251 if eq k 2 7252 if ge e get g_n 1 7253 ret 0 7254 end 7255 p = ulong 0 7256 if eq ulong get g_rk e 7 7257 p = ufilerow 0 get g_hit e 7258 else 7259 if eq ulong get g_rk e 2 7260 p = uptxt 0 x_open 7261 end 7262 if eq ulong get g_rk e 6 7263 p = uptxt 0 x_paste_row 7264 end 7265 p = uprow p e 7266 if or or eq ulong get g_rk e 1 eq ulong get g_rk e 6 eq ulong get g_rk e 2 7267 p = uwhy p e 7268 end 7269 if eq ulong get g_rk e 5 7270 q = uptxt p x_gap 7271 q2 = ustrat get g_m 19 q get g_hit e 7272 if gt q2 q 7273 p = q2 7274 end 7275 end 7276 if and eq ulong get g_rk e 6 or ne get g_n 13 0 ne get g_n 36 0 7277 if eq ulong get g_cp get g_hit e 1 7278 p = uptxt p x_gap 7279 p = uptxt p x_pinned 7280 end 7281 end 7282 if eq ulong get g_rk e 3 7283 p = uptxt p x_gap 7284 if eq get g_hit e 0 7285 p = uptxt p x_screen0_about 7286 end 7287 if eq get g_hit e 1 7288 p = uptxt p x_screen1_about 7289 end 7290 if eq get g_hit e 2 7291 p = uptxt p x_screen2_about 7292 end 7293 end 7294 if and eq ulong get g_rk e 4 eq get g_hit e 0 7295 p = uptxt p x_gap 7296 p = uptxt p x_command0_about 7297 end 7298 end 7299 put g_nm p 0 7300 ret unsb 7301 end 7302 if eq k 3 7303 put g_n 3 add get g_n 3 1 7304 if and ne c 0 lt get g_n 6 get g_n 1 7305 put g_n 8 add get g_n 6 1 7306 if and eq ulong get g_rk get g_n 6 3 eq get g_hit get g_n 6 2 7307 if ne get g_m 4 0 7308 uanswershow 7309 uanswerview 1 7310 end 7311 ret 0 7312 end 7313 if eq ulong get g_rk get g_n 6 3 7314 uscreen add get g_hit get g_n 6 1 7315 ret 0 7316 end 7317 if and eq ulong get g_rk get g_n 6 4 eq get g_hit get g_n 6 3 7318 uchatnew 7319 uscreen get g_n 36 7320 ret 0 7321 end 7322 if eq get g_n 46 1 7323 uagentrun 7324 ret 0 7325 end 7326 if eq get g_n 7 1 7327 rk = ulong get g_rk get g_n 6 7328 if or eq rk 8 eq rk 9 7329 if eq rk 8 7330 uask 7331 else 7332 uagentrun 7333 end 7334 else 7335 if eq rk 2 7336 if eq get g_n 13 0 7337 uclipaddr 1 7338 uopenaddr 7339 uclipaddr 0 7340 else 7341 uopenaddr 7342 end 7343 end 7344 if eq rk 4 7345 if eq get g_hit get g_n 6 0 7346 usettings 7347 end 7348 if eq get g_hit get g_n 6 2 7349 uindexstart 7350 end 7351 if eq get g_hit get g_n 6 1 7352 if eq get g_n 14 1 7353 x = umsg umsg ucl c_app usl m_shared 0 0 0 usl m_terminate 0 0 0 7354 end 7355 end 7356 end 7357 if eq rk 6 7358 put g_n 29 0 7359 upasteclip get g_hit get g_n 6 7360 if eq get g_n 14 1 7361 uclipmine get g_n 29 7362 end 7363 end 7364 if eq rk 5 7365 ucopysecret get g_hit get g_n 6 7366 if eq get g_n 14 1 7367 uclipmine 0 7368 end 7369 end 7370 if eq rk 10 7371 uremoteopen get g_hit get g_n 6 7372 end 7373 if eq rk 7 7374 uopenfile get g_hit get g_n 6 7375 urecordfile get g_hit get g_n 6 7376 end 7377 if eq rk 1 7378 ulaunch get g_hit get g_n 6 7379 urecordapp get g_hit get g_n 6 7380 end 7381 put g_n 5 1 7382 if eq get g_n 14 1 7383 uhide 7384 if eq rk 6 7385 ulaterpaste 7386 end 7387 end 7388 end 7389 end 7390 if and eq get g_n 7 0 eq get g_n 23 1 7391 rk = ulong get g_rk get g_n 6 7392 if eq rk 6 7393 upasteclip get g_hit get g_n 6 7394 end 7395 if eq rk 5 7396 ucopysecret get g_hit get g_n 6 7397 end 7398 if eq rk 10 7399 uremoteopen get g_hit get g_n 6 7400 end 7401 if eq rk 7 7402 urecordfile get g_hit get g_n 6 7403 end 7404 if eq rk 1 7405 urecordapp get g_hit get g_n 6 7406 end 7407 end 7408 end 7409 end 7410 if eq k 4 7411 if eq e get g_o 9 7412 if lt add get g_n 6 1 get g_n 1 7413 uchoose add get g_n 6 1 7414 end 7415 ret 1 7416 end 7417 if eq e get g_o 10 7418 if gt get g_n 6 0 7419 uchoose sub get g_n 6 1 7420 end 7421 ret 1 7422 end 7423 if eq e get g_o 11 7424 if ne get g_n 36 0 7425 uscreen 0 7426 ret 1 7427 end 7428 put g_n 5 1 7429 uhide 7430 ret 1 7431 end 7432 end 7433 if eq k 5 7434 ushow 7435 ret 0 7436 end 7437 if eq k 7 7438 unetdata e 7439 ret 0 7440 end 7441 if eq k 8 7442 unetdone d e 7443 ret 0 7444 end 7445 if eq k 9 7446 usendpaste 7447 ret 0 7448 end 7449 if eq k 10 7450 ucliptick 7451 ret 0 7452 end 7453 if eq k 11 7454 uclipmenu 1 7455 ret 0 7456 end 7457 if eq k 12 7458 uclipmenu 2 7459 ret 0 7460 end 7461 if eq k 13 7462 uagentevent b c 7463 ret 0 7464 end 7465 if eq k 6 7466 ushow 7467 ret 1 7468 end 7469 ret 0 7470 end 7471 7472 note one method of the class: selector text, callback entry, type text 7473 fn umethod c ulong t view uchar * entry ulong ty view uchar * to bool 7474 s = usl t 7475 n = ucs ty 7476 upr 0 c 7477 upr 8 s 7478 upr 16 ulong libfn int add 2 entry 7479 upr 24 ulong libptr g_nm 0 1024 7480 ret eq and ucall 5 255 1 7481 end 7482 7483 fn main to int 7484 n = ucs s_appkit 7485 upr 0 ulong libptr g_nm 0 1024 7486 upr 8 2 7487 lr = libcall ulong libfn 0 g_rg 0 128 7488 if eq ugr 0 0 7489 ret 2 7490 end 7491 put g_f 0 usym s_gc 7492 put g_f 1 usym s_sr 7493 put g_f 2 usym s_ms 7494 put g_f 3 usym s_wr 7495 put g_f 4 usym s_acp 7496 put g_f 5 usym s_cam 7497 put g_f 6 usym s_rcp 7498 put g_f 7 usym s_strlen 7499 put g_f 8 usym s_memcpy 7500 put g_f 9 usym s_getenv 7501 put g_f 10 usym s_malloc 7502 put g_f 11 usym s_memmem 7503 put g_f 12 usym s_memchr 7504 put g_f 13 usym s_memrchr 7505 put g_f 14 usym s_pow 7506 put g_f 15 usym s_log2 7507 put g_f 16 usym s_chmod 7508 put g_f 17 usym s_memset 7509 put g_f 18 usym s_trusted 7510 put g_f 19 usym s_key_event 7511 put g_f 20 usym s_event_flags 7512 put g_f 21 usym s_event_post 7513 put g_f 22 usym s_cf_release 7514 put g_f 23 usym s_item_copy 7515 put g_f 24 usym s_item_add 7516 put g_f 25 usym s_item_delete 7517 put g_f 26 usym s_interaction 7518 put g_f 27 usym s_random 7519 put g_f 28 usym s_free 7520 put g_f 29 usym s_iopolicy 7521 put g_f 30 usym s_home_directory 7522 for i ulong 31 7523 if eq get g_f i 0 7524 ret 3 7525 end 7526 end 7527 put g_o 3 ucl c_str 7528 put g_o 4 usl m_utf 7529 put g_o 5 usl m_cstr 7530 put g_m 16 usl m_at 7531 put g_m 7 ucl c_dict 7532 put g_m 8 ucl c_array 7533 put g_m 9 ucl c_str 7534 x = uindexmode 7535 if eq x 0 7536 ret 0 7537 end 7538 if eq x 1 7539 ret 1 7540 end 7541 put g_o 6 usl m_strval 7542 put g_o 7 usl m_reload 7543 put g_o 8 usl m_setstr 7544 put g_o 9 usl m_down 7545 put g_o 10 usl m_up 7546 put g_o 11 usl m_cancel 7547 put g_o 12 usl m_selrow 7548 put g_o 13 ucl c_ixset 7549 put g_o 14 usl m_ixwith 7550 put g_o 15 usl m_scrrow 7551 put g_o 16 ucl c_url 7552 put g_o 17 usl m_urlstr 7553 put g_o 18 usl m_host 7554 c = ucl c_pool 7555 s = usl m_alloc 7556 pool = umsg c s 0 0 0 7557 sinit = usl m_init 7558 pool = umsg pool sinit 0 0 0 7559 ufolder x_dir1 0 7560 ufolder x_dir2 1 7561 ubuildmap 7562 n = ucs x_env_front 7563 upr 0 ulong libptr g_nm 0 1024 7564 front_text = ucall 9 7565 if ne front_text 0 7566 n = ufetch front_text 7567 put g_m 11 umsg unsb usl m_retain 0 0 0 7568 end 7569 n = ucs x_env 7570 upr 0 ulong libptr g_nm 0 1024 7571 if eq ucall 9 0 7572 put g_n 14 1 7573 else 7574 put g_n 14 0 7575 upr 0 0 7576 x = ucall 26 7577 rn = ucs x_env_screen 7578 upr 0 ulong libptr g_nm 0 1024 7579 screen_text = ucall 9 7580 if ne screen_text 0 7581 rn = ufetch screen_text 7582 if eq get g_nm 0 99 7583 put g_n 36 1 7584 end 7585 if eq get g_nm 0 97 7586 put g_n 36 2 7587 end 7588 end 7589 rn = ucs x_env_clipdo 7590 upr 0 ulong libptr g_nm 0 1024 7591 do_text = ucall 9 7592 if ne do_text 0 7593 rn = ufetch do_text 7594 if eq get g_nm 0 112 7595 put g_n 37 1 7596 end 7597 if eq get g_nm 0 100 7598 put g_n 37 2 7599 end 7600 if eq get g_nm 0 99 7601 put g_n 37 3 7602 end 7603 end 7604 end 7605 uloadindex 7606 uloadvault 7607 uloadconfig 7608 if eq get g_n 14 0 7609 rn = ucs x_env_cliprec 7610 upr 0 ulong libptr g_nm 0 1024 7611 if ne ucall 9 0 7612 ucliprecord umsg ucl c_pasteboard usl m_board_named uns x_check_board 0 0 7613 end 7614 end 7615 uloadclips 7616 put g_n 4 0 7617 put g_n 13 0 7618 unarrow 7619 if eq get g_n 0 0 7620 ret 4 7621 end 7622 c = ucl c_app 7623 s = usl m_shared 7624 app = umsg c s 0 0 0 7625 n = ucs x_env 7626 upr 0 ulong libptr g_nm 0 1024 7627 envp = ucall 9 7628 chk = ne envp 0 7629 opn = false 7630 ovr = false 7631 asking = false 7632 idle = false 7633 tl = ulong 0 7634 pol = ulong 0 7635 put g_n 7 1 7636 if chk 7637 pol = 1 7638 put g_n 7 0 7639 n = ufetch envp 7640 skip = ulong 0 7641 if and ge n 5 and or eq get g_nm 0 111 eq get g_nm 0 116 eq get g_nm 4 58 7642 skip = 5 7643 end 7644 if and ge n 4 and eq get g_nm 0 97 eq get g_nm 3 58 7645 skip = 4 7646 asking = true 7647 put g_n 7 1 7648 end 7649 if and eq n 4 and eq get g_nm 0 105 eq get g_nm 3 101 7650 skip = 4 7651 idle = true 7652 end 7653 if and ge n 6 and eq get g_nm 0 97 eq get g_nm 5 58 7654 skip = 6 7655 asking = true 7656 put g_n 46 1 7657 end 7658 if gt skip 0 7659 ovr = true 7660 if eq get g_nm 0 111 7661 opn = true 7662 put g_n 7 1 7663 end 7664 tl = sub n skip 7665 if gt tl 60 7666 tl = 60 7667 end 7668 for i ulong tl bound 64 7669 put g_t i get g_nm add skip i 7670 end 7671 end 7672 rn = ucs x_env_record 7673 upr 0 ulong libptr g_nm 0 1024 7674 if ne ucall 9 0 7675 put g_n 23 1 7676 end 7677 rn = ucs x_env_row 7678 upr 0 ulong libptr g_nm 0 1024 7679 row_text = ucall 9 7680 if ne row_text 0 7681 rn = ufetch row_text 7682 row_pick = ulong 0 7683 for i ulong rn bound 4 7684 row_digit = ulong get g_nm i 7685 if and ge row_digit 48 le row_digit 57 7686 row_pick = add mul row_pick 10 sub row_digit 48 7687 end 7688 end 7689 put g_n 30 row_pick 7690 end 7691 end 7692 s = usl m_policy 7693 x = umsg app s pol 0 0 7694 note the class whose methods are the callback entries 7695 c = ucl c_obj 7696 n = ucs c_mine 7697 upr 0 c 7698 upr 8 ulong libptr g_nm 0 1024 7699 upr 16 0 7700 mine = ucall 4 7701 if eq mine 0 7702 ret 5 7703 end 7704 ok = umethod mine m_change 0 t_v 7705 ok = and ok umethod mine m_rows 1 t_q 7706 ok = and ok umethod mine m_value 2 t_o 7707 ok = and ok umethod mine m_go 3 t_v 7708 ok = and ok umethod mine m_cmd 4 t_b 7709 ok = and ok umethod mine m_reopen 6 t_reopen 7710 ok = and ok umethod mine m_did_data 7 t_session 7711 ok = and ok umethod mine m_did_complete 8 t_session 7712 ok = and ok umethod mine m_paste_now 9 t_v 7713 ok = and ok umethod mine m_clip_tick 10 t_v 7714 ok = and ok umethod mine m_pin_clip 11 t_v 7715 ok = and ok umethod mine m_delete_clip 12 t_v 7716 ok = and ok umethod mine m_agent_out 13 t_v 7717 ok = and ok umethod mine m_agent_err 13 t_v 7718 ok = and ok umethod mine m_agent_end 13 t_v 7719 ok = and ok umethod mine m_agent_stop 13 t_v 7720 put g_m 38 usl m_agent_out 7721 put g_m 39 usl m_agent_err 7722 put g_m 40 usl m_agent_end 7723 put g_m 41 usl m_agent_stop 7724 ok = and ok umoremethods mine 7725 ok = and ok ustatusmethods mine 7726 ok = and ok uquitwatch mine 7727 uchecklate 7728 if not ok 7729 ret 6 7730 end 7731 upr 0 mine 7732 x = ucall 6 7733 s = usl m_alloc 7734 me = umsg mine s 0 0 0 7735 me = umsg me sinit 0 0 0 7736 put g_o 27 me 7737 note the window 7738 c = ucl c_win 7739 s = usl m_alloc 7740 w = umsg c s 0 0 0 7741 s = usl m_initwi 7742 urect 240.0f64 260.0f64 520.0f64 360.0f64 7743 w = umsg w s 3 2 0 7744 if eq w 0 7745 ret 7 7746 end 7747 str = uns x_title 7748 s = usl m_title 7749 x = umsg w s str 0 0 7750 s = usl m_conten 7751 cv = umsg w s 0 0 0 7752 sadd = usl m_addsub 7753 sframe = usl m_initfr 7754 note the search field 7755 c = ucl c_field 7756 s = usl m_alloc 7757 fld = umsg c s 0 0 0 7758 urect 16.0f64 316.0f64 488.0f64 28.0f64 7759 fld = umsg fld sframe 0 0 0 7760 str = uns x_hint 7761 s = usl m_placeh 7762 x = umsg fld s str 0 0 7763 s = usl m_setdel 7764 x = umsg fld s me 0 0 7765 s = usl m_settar 7766 x = umsg fld s me 0 0 7767 s = usl m_setact 7768 sgo = usl m_go 7769 x = umsg fld s sgo 0 0 7770 x = umsg cv sadd fld 0 0 7771 put g_o 0 fld 7772 note the status line 7773 str = uns x_hint 7774 c = ucl c_field 7775 s = usl m_label 7776 lbl = umsg c s str 0 0 7777 s = usl m_setfra 7778 urect 16.0f64 8.0f64 488.0f64 20.0f64 7779 x = umsg lbl s 0 0 0 7780 x = umsg cv sadd lbl 0 0 7781 put g_o 2 lbl 7782 note the list 7783 c = ucl c_scroll 7784 s = usl m_alloc 7785 sv = umsg c s 0 0 0 7786 urect 16.0f64 36.0f64 488.0f64 272.0f64 7787 sv = umsg sv sframe 0 0 0 7788 c = ucl c_table 7789 s = usl m_alloc 7790 tv = umsg c s 0 0 0 7791 urect 0.0f64 0.0f64 470.0f64 272.0f64 7792 tv = umsg tv sframe 0 0 0 7793 c = ucl c_col 7794 s = usl m_alloc 7795 col = umsg c s 0 0 0 7796 str = uns x_name 7797 s = usl m_initid 7798 col = umsg col s str 0 0 7799 s = usl m_setwid 7800 upr 64 bitcast ulong 460.0f64 7801 x = umsg col s 0 0 0 7802 s = usl m_addcol 7803 x = umsg tv s col 0 0 7804 s = usl m_header 7805 x = umsg tv s 0 0 0 7806 s = usl m_dataso 7807 x = umsg tv s me 0 0 7808 s = usl m_docvie 7809 x = umsg sv s tv 0 0 7810 s = usl m_scroll 7811 x = umsg sv s 1 0 0 7812 x = umsg cv sadd sv 0 0 7813 put g_o 1 tv 7814 put g_o 28 sv 7815 note the answer: a text view in the list's place, hidden until a question is asked 7816 c = ucl c_scroll 7817 s = usl m_alloc 7818 answer_scroll = umsg c s 0 0 0 7819 urect 16.0f64 36.0f64 488.0f64 272.0f64 7820 answer_scroll = umsg answer_scroll sframe 0 0 0 7821 c = ucl c_text_view 7822 s = usl m_alloc 7823 answer_text = umsg c s 0 0 0 7824 urect 0.0f64 0.0f64 470.0f64 272.0f64 7825 answer_text = umsg answer_text sframe 0 0 0 7826 x = umsg answer_text usl m_set_editable 0 0 0 7827 x = umsg answer_scroll usl m_docvie answer_text 0 0 7828 x = umsg answer_scroll usl m_scroll 1 0 0 7829 x = umsg answer_scroll usl m_set_hidden 1 0 0 7830 x = umsg cv sadd answer_scroll 0 0 7831 put g_o 29 answer_scroll 7832 put g_o 30 answer_text 7833 ushowst 7834 s = usl m_finish 7835 x = umsg app s 0 0 0 7836 put g_o 19 w 7837 put g_o 20 usl m_order_out 7838 put g_o 21 app 7839 put g_o 22 usl m_hide_app 7840 put g_o 23 usl m_activ 7841 put g_o 24 usl m_key 7842 put g_o 25 usl m_firstr 7843 put g_o 26 usl m_front 7844 s = usl m_released 7845 x = umsg w s 0 0 0 7846 s = usl m_set_app_delegate 7847 x = umsg app s me 0 0 7848 if chk 7849 put g_n 14 0 7850 put g_n 15 ukey 80 6912 7851 else 7852 put g_n 14 1 7853 put g_n 15 ukey 49 2048 7854 umenu app 7855 note keep the history of what is copied while Hop is not running: look twice a second 7856 first_board = umsg ucl c_pasteboard usl m_general_pasteboard 0 0 0 7857 put g_n 35 umsg first_board usl m_change_count 0 0 0 7858 c_t = ucl c_timer 7859 s_timer = usl m_timer 7860 s_tick = usl m_clip_tick 7861 upr 64 bitcast ulong 0.5f64 7862 upr 40 1 7863 x = umsg c_t s_timer get g_o 27 s_tick 0 7864 if and not uhoprunning uindexstale 7865 uindexstart 7866 end 7867 if not uhoprunning 7868 uremoterefreshall 7869 end 7870 end 7871 ushow 7872 if gt get g_n 1 0 7873 uchoose 0 7874 end 7875 svis = usl m_visibl 7876 vis = and umsg w svis 0 0 0 255 7877 mode = uns x_mode 7878 cd = ucl c_date 7879 sd = usl m_since 7880 sn = usl m_next 7881 se = usl m_send 7882 schanged = usl m_change 7883 total = get g_n 0 7884 if not chk 7885 note a person uses it: AppKit's own event loop, until the app is quit 7886 s = usl m_run 7887 x = umsg app s 0 0 0 7888 ret 0 7889 end 7890 note the check: about six seconds. The text goes in through the field's editor; arrow down, Enter and Escape are 7891 note commands sent to that editor, which asks the field, which asks its delegate and sends its action 7892 sfr = usl m_firstr 7893 sed = usl m_curred 7894 sins = usl m_instxt 7895 sdo = usl m_docmd 7896 snl = usl m_newln 7897 esc = ulong 0 7898 hid = ulong 0 7899 back = ulong 0 7900 for i ulong 120 7901 upr 64 bitcast ulong 0.05f64 7902 d = umsg cd sd 0 0 0 7903 utick app sn se mode d 7904 if eq i 10 7905 x = umsg w sfr fld 0 0 7906 ed = umsg fld sed 0 0 0 7907 if ovr 7908 for j ulong tl bound 64 7909 put g_nm j get g_t j 7910 end 7911 put g_nm tl 0 7912 str = unsb 7913 else 7914 str = uns x_typed 7915 end 7916 if not idle 7917 x = umsg ed sins str 0 0 7918 end 7919 end 7920 if and eq i 15 not ovr 7921 ed = umsg fld sed 0 0 0 7922 x = umsg ed sdo get g_o 9 0 0 7923 end 7924 if and and eq i 15 ovr and gt get g_n 30 0 lt get g_n 30 get g_n 1 7925 uchoose get g_n 30 7926 end 7927 if and and eq i 16 ovr ne get g_n 37 0 7928 if eq get g_n 37 3 7929 uclipclear 7930 else 7931 uclipmenu get g_n 37 7932 end 7933 end 7934 if eq i 2 7935 ustatus 7936 utunnelcheck 7937 end 7938 if eq i get g_n 48 7939 ed = umsg fld sed 0 0 0 7940 x = umsg ed sdo snl 0 0 7941 end 7942 if eq i 60 7943 uasksecond 7944 end 7945 if and and eq i 25 not asking eq get g_n 36 0 7946 put g_n 5 0 7947 x = umsg w sfr fld 0 0 7948 ed = umsg fld sed 0 0 0 7949 x = umsg ed sdo get g_o 11 0 0 7950 esc = get g_n 5 7951 put g_n 5 0 7952 if eq and umsg w svis 0 0 0 255 0 7953 hid = 1 7954 end 7955 end 7956 if eq i 30 7957 upr 0 0 7958 upr 8 0 7959 upr 16 0 7960 x = ucallf ulong libfn 7 7961 if eq and umsg w svis 0 0 0 255 1 7962 back = 1 7963 end 7964 end 7965 end 7966 note the first row, asked of the list's own data source through Objective-C, and the list's own selection 7967 shown = get g_n 1 7968 row = umsg tv usl m_selrd 0 0 0 7969 want = ulong 0 7970 if and gt shown 1 not ovr 7971 want = 1 7972 end 7973 first = umsg me usl m_value tv col 0 7974 flen = ulong 0 7975 if ne first 0 7976 p = umsg first get g_o 5 0 0 0 7977 flen = ufetch p 7978 end 7979 if gt flen 255 7980 flen = 255 7981 end 7982 for i ulong flen bound 256 7983 put g_x i get g_nm i 7984 end 7985 uvaultcheckend 7986 utunnelstop 7987 paste_text = ulong 0 7988 paste_size = ulong 0 7989 if ne get g_n 29 0 7990 pboard = umsg ucl c_pasteboard usl m_board_named uns x_check_board 0 0 7991 if eq get g_n 29 1 7992 got = umsg pboard usl m_string_for_type uns x_type_string 0 0 7993 if ne got 0 7994 paste_text = umsg got get g_o 5 0 0 0 7995 end 7996 else 7997 got = umsg pboard usl m_data_for_type uns x_type_png 0 0 7998 if ne got 0 7999 paste_size = umsg got usl m_length 0 0 0 8000 end 8001 end 8002 x = umsg pboard usl m_clear 0 0 0 8003 end 8004 p = uptxt 0 x_out1 8005 p = upnum p total 8006 p = uptxt p x_out2 8007 p = upnum p shown 8008 p = uptxt p x_out3 8009 for i ulong flen bound 256 8010 put g_nm add p i get g_x i 8011 end 8012 p = add p flen 8013 p = uptxt p x_out4 8014 p = upnum p and row 255 8015 p = uptxt p x_out5 8016 if and gt get g_n 8 0 le get g_n 8 shown 8017 p = uprow p sub get g_n 8 1 8018 end 8019 if opn 8020 p = uptxt p x_out6 8021 p = upnum p get g_n 9 8022 end 8023 if ne get g_n 29 0 8024 p = uptxt p x_out11 8025 if ne paste_text 0 8026 upr 0 paste_text 8027 pn = ucall 7 8028 if gt pn 80 8029 pn = 80 8030 end 8031 if gt pn 0 8032 upr 0 ulong libptr g_nm p pn 8033 upr 8 paste_text 8034 upr 16 pn 8035 x = ucall 8 8036 for j ulong pn bound 81 8037 if lt ulong get g_nm add p j 32 8038 put g_nm add p j 32 8039 end 8040 end 8041 p = add p pn 8042 end 8043 end 8044 if eq get g_n 29 2 8045 p = uptxt p x_png_word 8046 p = upnum p paste_size 8047 end 8048 end 8049 if ne get g_n 36 0 8050 p = uptxt p x_out12 8051 p = upnum p get g_n 36 8052 end 8053 if eq get g_n 55 1 8054 p = uptxt p x_out13 8055 p = upnum p 1 8056 end 8057 if gt get g_n 62 0 8058 p = uptxt p x_out16 8059 p = upnum p get g_n 61 8060 end 8061 if ne get g_n 51 0 8062 p = uptxt p x_out14 8063 p = upnum p get g_n 52 8064 p = uptxt p x_out15 8065 p = upnum p get g_n 51 8066 end 8067 answered = false 8068 if asking 8069 p = uptxt p x_out10 8070 if ne get g_m 4 0 8071 answer_bytes = umsg get g_m 4 get g_o 5 0 0 0 8072 upr 0 answer_bytes 8073 an = ucall 7 8074 if gt an 120 8075 an = 120 8076 end 8077 upr 0 ulong libptr g_nm p an 8078 upr 8 answer_bytes 8079 upr 16 an 8080 x = ucall 8 8081 for j ulong an bound 121 8082 if lt ulong get g_nm add p j 32 8083 put g_nm add p j 32 8084 end 8085 end 8086 p = add p an 8087 answered = and and gt an 0 eq get g_n 21 1 eq get g_n 22 1 8088 end 8089 end 8090 if not ovr 8091 p = uptxt p x_out7 8092 p = upnum p get g_n 15 8093 p = uptxt p x_out8 8094 p = upnum p hid 8095 p = uptxt p x_out9 8096 p = upnum p back 8097 end 8098 put g_nm p 10 8099 upr 0 1 8100 upr 8 ulong libptr g_nm 0 1024 8101 upr 16 add p 1 8102 x = ucall 3 8103 s = usl m_close 8104 x = umsg w s 0 0 0 8105 if ne vis 1 8106 ret 8 8107 end 8108 if ovr 8109 took = true 8110 if opn 8111 took = eq get g_n 9 1 8112 end 8113 if asking 8114 took = answered 8115 end 8116 if and and gt shown 0 eq get g_n 3 1 and gt get g_n 8 0 took 8117 ret 1 8118 end 8119 ret 9 8120 end 8121 picked = and eq get g_n 8 add want 1 eq ulong get g_rk 0 1 8122 if and and and gt shown 0 lt shown total and gt flen 0 and eq get g_n 3 1 picked and and eq esc 1 eq row want and and eq hid 1 eq back 1 eq get g_n 15 0 8123 ret 1 8124 end 8125 ret 9 8126 end