From d3f14f3e45d709c42b2fdb3711264734ce8d4cb6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Cuervo?= Date: Tue, 31 Oct 2023 16:36:52 -0400 Subject: Black hole unsupported keys --- virtual-programs/editor.folk | 38 +++++++++++++++++++++++++++++++------- 1 file changed, 31 insertions(+), 7 deletions(-) (limited to 'virtual-programs') diff --git a/virtual-programs/editor.folk b/virtual-programs/editor.folk index 28648ecd..c7fb553a 100644 --- a/virtual-programs/editor.folk +++ b/virtual-programs/editor.folk @@ -58,10 +58,7 @@ proc deleteCharacter {code cursor} { set thisLine [lindex $lines $y] set mergedLine [string cat $previousLine $thisLine] lset lines [expr {$y - 1}] $mergedLine - lset lines $y "" ;# this sucks, instead delete the line - # TODO: - # - move cursor to end of previous line - # lreplace lines $y $y + lset lines $y "" set newLines {} for {set i 0} {$i < [llength $lines]} {incr i} { if {$i != $y} { @@ -77,6 +74,16 @@ proc deleteCharacter {code cursor} { return [join $lines "\n"] } +proc deleteToBeginning {code cursor} { + set lines [split $code "\n"] + lassign $cursor x y + set line [lindex $lines $y] + set newLine [string range $line $x end] + lset lines $y $newLine + return [join $lines "\n"] +} + + proc insertNewline {code cursor} { set lines [split $code "\n"] lassign $cursor x y @@ -281,9 +288,6 @@ Every time keyboard claims key /currentCharacter/ is down with modifiers /modifi } Commit code { Claim $id has program code [deleteCharacter $code $cursor] } } - DELETE { - # TODO: Implement DELETE, operates like BACKSPACE, but in the opposite direction - } SPACE { Claim the cursor is [updateCursor $cursor {x 1}] Commit code { Claim $id has program code [insertCharacter $code " " $cursor] } @@ -293,10 +297,21 @@ Every time keyboard claims key /currentCharacter/ is down with modifiers /modifi Claim the cursor is [list 0 [lindex $updatedCursor 1]] Commit code { Claim $id has program code [insertNewline $code $cursor] } } + DELETE - + INSERT - + MUTE - + VOLUMEUP - + VOLUMEDOWN - LEFTSHIFT - RIGHTSHIFT - LEFTCTRL - RIGHTCTRL { + # TODO: Implement DELETE, operates like BACKSPACE, but in the opposite direction + # TODO: MUTE VOLUMEUP VOLUMEDOWN + # implement sound.folk that allows a system-wide + # volume setting to be adjusted. + # Perhaps `Wish $system volume is 0.5` or something + Claim the cursor is $cursor } default { @@ -321,6 +336,13 @@ Every time keyboard claims key /currentCharacter/ is down with modifiers /modifi Claim the cursor is [list [getLineLength $code $cursor] $y] return } + if {$modifier == "ctrl" & $currentCharacter == "u"} { + # delete from cursor back to 0 and move cursor to 0 + Commit code { Claim $id has program code $code} + lassign $cursor x y + Claim the cursor is [list 0 $y] + return + } Claim the cursor is [updateCursor $cursor {x 1}] Commit code { Claim $id has program code [insertCharacter $code $currentCharacter $cursor] } } @@ -329,6 +351,8 @@ Every time keyboard claims key /currentCharacter/ is down with modifiers /modifi } Claim $this has demo { + ## Okay, this needs to be: + # Claim $this is keyboard # Tape this program underneath the main keyboard of your system to try it out Claim $this is editor editor-1 } \ No newline at end of file -- cgit v1.2.3