summaryrefslogtreecommitdiffstats
path: root/virtual-programs
diff options
context:
space:
mode:
authorAndrés Cuervo <andrescuervor@gmail.com>2023-10-22 15:47:26 +0000
committerAndrés Cuervo <andrescuervor@gmail.com>2023-10-22 15:47:26 +0000
commit8be21e8ed1cc43f92b838c1f1a98ad871f50945c (patch)
tree329df5a91210bd324eef811f3db82d1bb4894b78 /virtual-programs
parentTest long default code (diff)
downloadfolk-8be21e8ed1cc43f92b838c1f1a98ad871f50945c.tar.gz
folk-8be21e8ed1cc43f92b838c1f1a98ad871f50945c.zip
Implement ctrl+a and ctrl+e
Diffstat (limited to 'virtual-programs')
-rw-r--r--virtual-programs/editor.folk26
1 files changed, 22 insertions, 4 deletions
diff --git a/virtual-programs/editor.folk b/virtual-programs/editor.folk
index b7f150e1..0c62f018 100644
--- a/virtual-programs/editor.folk
+++ b/virtual-programs/editor.folk
@@ -123,6 +123,14 @@ proc rotateStroke {points center angle} {
}
}
+proc getLineLength {code cursor} {
+ set lines [split $code "\n"]
+ set line [lindex $lines [lindex $cursor 1]]
+ set ll [string length $line]
+ puts "linelength: $ll"
+ return $ll
+}
+
proc getLineShift {lines} {
set longestLineLength 0
foreach line [split $lines "\n"] {
@@ -148,6 +156,7 @@ proc drawCursor {cursorPosition lineShift region} {
set shiftMultiplier [list 10 10]
# 20 20 scale is arbitrary, computing it off of Display or something .....
+ # TODO: Pull these variables from the Display file
set cursorScale [list 20 20] ;# OLD
# set cursorScale [list $cursorHeight $cursorWidth]
@@ -162,9 +171,6 @@ proc drawCursor {cursorPosition lineShift region} {
# Calculate the final cursor position
set scaledCursor [vec2::mult $cursorScale $cursorPosition]
- puts "lineShiftHalf | multipliedShift | adjustedShift | shiftedAnchor | scaledCursor"
- puts "$lineShiftHalf | $multipliedShift | $adjustedShift | $shiftedAnchor | $scaledCursor"
-
# Something is going wrong here, I think
set finalCursor [add $shiftedAnchor $scaledCursor]
# debug $finalCursor gold
@@ -259,7 +265,6 @@ Every time keyboard claims key /currentCharacter/ is down with modifiers /modifi
Claim the cursor is $cursor
}
default {
- Claim the cursor is [updateCursor $cursor {x 1}]
if {$modifier == "ctrl" & $currentCharacter == "p"} {
Wish to print $code with job id [expr {rand()}]
return
@@ -269,6 +274,19 @@ Every time keyboard claims key /currentCharacter/ is down with modifiers /modifi
Claim the cursor is [list 0 0]
return
}
+ if {$modifier == "ctrl" & $currentCharacter == "a"} {
+ Commit code { Claim $id has program code $code}
+ lassign $cursor x y
+ Claim the cursor is [list 0 $y]
+ return
+ }
+ if {$modifier == "ctrl" & $currentCharacter == "e"} {
+ Commit code { Claim $id has program code $code}
+ lassign $cursor x y
+ Claim the cursor is [list [getLineLength $code $cursor] $y]
+ return
+ }
+ Claim the cursor is [updateCursor $cursor {x 1}]
Commit code { Claim $id has program code [insertCharacter $code $currentCharacter $cursor] }
}
}