j
This commit is contained in:
parent
5b65c4c0e4
commit
985aa16236
13 changed files with 1381 additions and 241 deletions
26
client/odin/daemon_sync.odin
Normal file
26
client/odin/daemon_sync.odin
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
package main
|
||||
|
||||
import "core:time"
|
||||
|
||||
Daemon_Sync_State :: struct {
|
||||
pending: bool,
|
||||
last_edit: time.Time,
|
||||
}
|
||||
|
||||
SDL_DAEMON_SYNC_DEBOUNCE_MS :: 250
|
||||
|
||||
daemon_sync_schedule :: proc(sync: ^Daemon_Sync_State) {
|
||||
sync.pending = true
|
||||
sync.last_edit = time.now()
|
||||
}
|
||||
|
||||
daemon_sync_now :: proc(sync: ^Daemon_Sync_State, daemon: ^Daemon_Client, editor: ^Editor, open: bool) {
|
||||
daemon_sync_active_buffer(daemon, editor, open)
|
||||
sync.pending = false
|
||||
}
|
||||
|
||||
daemon_sync_flush_if_due :: proc(sync: ^Daemon_Sync_State, daemon: ^Daemon_Client, editor: ^Editor) {
|
||||
if !sync.pending || !daemon.connected do return
|
||||
if time.diff(sync.last_edit, time.now()) < SDL_DAEMON_SYNC_DEBOUNCE_MS * time.Millisecond do return
|
||||
daemon_sync_now(sync, daemon, editor, false)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue