summaryrefslogtreecommitdiffstats
path: root/virtual-programs
diff options
context:
space:
mode:
authorAndrés Cuervo <andrescuervor@gmail.com>2023-10-31 20:36:52 +0000
committerAndrés Cuervo <andrescuervor@gmail.com>2023-10-31 20:36:52 +0000
commitd3f14f3e45d709c42b2fdb3711264734ce8d4cb6 (patch)
tree19ab46a1b7a84ad82363a8a8ea2b4ddf04bf6b00 /virtual-programs
parentMerge branch 'main' into ac/editor (diff)
downloadfolk-d3f14f3e45d709c42b2fdb3711264734ce8d4cb6.tar.gz
folk-d3f14f3e45d709c42b2fdb3711264734ce8d4cb6.zip
Black hole unsupported keys
Diffstat (limited to 'virtual-programs')
-rw-r--r--virtual-programs/editor.folk38
1 files changed, 31 insertions, 7 deletions
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