diff options
| author | Andrés Cuervo <andrescuervor@gmail.com> | 2024-02-26 22:08:08 +0000 |
|---|---|---|
| committer | Andrés Cuervo <andrescuervor@gmail.com> | 2024-02-26 22:08:08 +0000 |
| commit | 731c69fdf098049018f0ce66a89a09a22892142a (patch) | |
| tree | 5c266690d6b77aa2b458afddcff77d39406a2e75 /virtual-programs | |
| parent | Make folk0 resolution 4k (diff) | |
| download | folk-731c69fdf098049018f0ce66a89a09a22892142a.tar.gz folk-731c69fdf098049018f0ce66a89a09a22892142a.zip | |
Fix printing from editors
- Fix a bug where each editor could only print once because of
a mistaken use of /nobody/ in the print conditional
- Add a timestamp to the print commit
- Prevent printing the same code twice within a second
Diffstat (limited to 'virtual-programs')
| -rw-r--r-- | virtual-programs/editor.folk | 25 |
1 files changed, 10 insertions, 15 deletions
diff --git a/virtual-programs/editor.folk b/virtual-programs/editor.folk index 00803b3b..201dc7bb 100644 --- a/virtual-programs/editor.folk +++ b/virtual-programs/editor.folk @@ -1,4 +1,3 @@ -set ::debug_print false set baseCode "Wish \$this is outlined green" # This makes all keyboards into editors automatically, so a keyboard @@ -302,24 +301,20 @@ When /page/ is a keyboard with path /kbPath/ & /page/ is an editor { } default { if {$modifier == "ctrl" & $currentCharacter == "p"} { - # TODO: Save time instead and prevent printing the same code within the same ... second? - When $id has printed /lastPrintedCode/ { - if {$lastPrintedCode == $code} { - Claim the $kbPath cursor is $cursor - if {$::debug_print} { - puts "Not printing the same code twice" + When $id has printed /lastPrintedCode/ at /previousTime/ { + if {($timestamp - $previousTime) < 1000} { + Commit "code$kbPath" { + Claim $id has program code $code + Claim $id has editor code $editorCode } + Claim the $kbPath cursor is $cursor return } } - When /nobody/ has printed /lastPrintedCode/ { - if {$::debug_print} { - puts "Printing $code" - } - Commit print { Claim $id has printed $code} - Wish to print $code with job id [expr {rand()}] - return - } + + Commit print { Claim $id has printed $code at $timestamp} + Wish to print $code with job id [expr {rand()}] + Commit "code$kbPath" { Claim $id has program code $code Claim $id has editor code $editorCode |
