From ceacf079bbc1580d1080c5acf026e77194362f62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Cuervo?= Date: Fri, 2 Feb 2024 11:28:28 -0500 Subject: Correctly filter keys pressed after editor start time Prevent keys from being processed before the editor start time. --- virtual-programs/editor.folk | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) (limited to 'virtual-programs') diff --git a/virtual-programs/editor.folk b/virtual-programs/editor.folk index 3dd03044..268fbcca 100644 --- a/virtual-programs/editor.folk +++ b/virtual-programs/editor.folk @@ -8,7 +8,10 @@ When /page/ is a keyboard with path /anything/ { Claim $page is an editor } -When /page/ is a keyboard with path /kbPath/ & /page/ is an editor & /page/ has region /r/ { +When /page/ is a keyboard with path /kbPath/ &\ + /page/ is an editor &\ + /page/ has region /r/ &\ + the clock time is /t/ { set id "$page$kbPath" Claim $id has region [region move $r up 210%] When /nobody/ claims $id has program code /c/ { @@ -17,6 +20,19 @@ When /page/ is a keyboard with path /kbPath/ & /page/ is an editor & /page/ has Claim $id has editor code $baseCode } } + + When /nobody/ claims $id has start time /startTime/ { + Commit "time$kbPath" { + Claim $id has start time $t + } + } +} + +When /page/ is a keyboard with path /kbPath/ { + On unmatch { + puts "unmatching" + Commit "time$kbPath" {} + } } proc updateCursor {oldCursor updates} { @@ -180,8 +196,10 @@ When /page/ is a keyboard with path /kbPath/ & /page/ is an editor { Every time keyboard $kbPath claims key /currentCharacter/ is /keyState/ with modifiers /modifier/ timestamp /timestamp/ &\ the $kbPath cursor is /cursor/ &\ $id has program code /code/ &\ - $id has editor code /editorCode/ { - if {$keyState == "down" || $keyState == "repeat"} { + $id has editor code /editorCode/ &\ + $id has start time /startTime/ { + if {($keyState == "down" || $keyState == "repeat") & $timestamp > ($startTime * 1000) } { + puts "$currentCharacter [expr {$timestamp > ($startTime * 1000)}]" Commit "cursor$kbPath" { switch $currentCharacter { UP { -- cgit v1.2.3