@@ -52,6 +52,11 @@ RabbitMain(args) {
52
52
}
53
53
}
54
54
55
+ ; TODO: better handling of first run
56
+ local first_run := ! FileExist (RabbitUserDataPath() . " \default.custom.yaml" )
57
+ || ! FileExist (RabbitUserDataPath() . " \rabbit.custom.yaml" )
58
+ || ! FileExist (RabbitUserDataPath() . " \user.yaml" )
59
+
55
60
rabbit_traits := CreateTraits()
56
61
global rime
57
62
rime.setup(rabbit_traits)
@@ -60,7 +65,10 @@ RabbitMain(args) {
60
65
61
66
local m := (args.Length == 0 ) ? RABBIT_PARTIAL_MAINTENANCE : args[1 ]
62
67
if m ! = RABBIT_NO_MAINTENANCE {
63
- if rime.start_maintenance(m == RABBIT_FULL_MAINTENANCE)
68
+ if first_run {
69
+ SetDefaultKeyboard(layout)
70
+ Deploy()
71
+ } else if rime.start_maintenance(m == RABBIT_FULL_MAINTENANCE)
64
72
rime.join_maintenance_thread()
65
73
} else {
66
74
TrayTip ()
@@ -87,6 +95,7 @@ RabbitMain(args) {
87
95
88
96
UpdateTrayTip(schema_name, ascii_mode, full_shape, ascii_punct)
89
97
}
98
+ SetupTrayMenu()
90
99
OnMessage (AHK_NOTIFYICON, ClickHandler.Bind())
91
100
if ! RabbitConfig.global_ascii
92
101
SetTimer (UpdateWinAscii)
@@ -427,23 +436,28 @@ UpdateWinAscii(target := false, use_target := false, proc_name := "", by_tray_ic
427
436
return
428
437
}
429
438
RabbitGlobals.active_win := proc_name
439
+ ; TODO: current state might not be accurate due to non-atomic
440
+ current := !! rime.get_option(session_id, " ascii_mode" )
430
441
if use_target {
431
442
; force to use passed target
432
- RabbitGlobals.process_ascii[proc_name] := target
443
+ RabbitGlobals.process_ascii[proc_name] := !! target
433
444
} else if RabbitGlobals.process_ascii.Has(proc_name) {
434
445
; not first time to active window, restore the ascii_mode
435
446
target := RabbitGlobals.process_ascii[proc_name]
436
- rime.set_option(session_id, " ascii_mode" , target)
447
+ if current ! == target
448
+ rime.set_option(session_id, " ascii_mode" , target)
437
449
} else if RabbitConfig.preset_process_ascii.Has(proc_name) {
438
450
; in preset, set ascii_mode as preset
439
451
target := RabbitConfig.preset_process_ascii[proc_name]
440
- RabbitGlobals.process_ascii[proc_name] := target
441
- rime.set_option(session_id, " ascii_mode" , target)
452
+ RabbitGlobals.process_ascii[proc_name] := !! target
453
+ if current ! == target
454
+ rime.set_option(session_id, " ascii_mode" , target)
442
455
} else {
443
456
; not in preset, set ascii_mode to false
444
457
target := false
445
- RabbitGlobals.process_ascii[proc_name] := target
446
- rime.set_option(session_id, " ascii_mode" , target)
458
+ RabbitGlobals.process_ascii[proc_name] := !! target
459
+ if current ! == target
460
+ rime.set_option(session_id, " ascii_mode" , target)
447
461
}
448
462
UpdateTrayTip(, target)
449
463
UpdateTrayIcon()
0 commit comments