From d1f893a98e80b3baf25aa9d30f8305c586569e66 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Wed, 25 May 2022 15:47:11 -0700 Subject: M-left/M-right for word-based motions --- keychord.lua | 1 + text.lua | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/keychord.lua b/keychord.lua index 12feef7..1e319dd 100644 --- a/keychord.lua +++ b/keychord.lua @@ -13,6 +13,7 @@ function App.combine_modifiers(key) local down = love.keyboard.isDown if down('lctrl') or down('rctrl') then result = result..'C-' + print(result) end if down('lalt') or down('ralt') then result = result..'M-' diff --git a/text.lua b/text.lua index 7ff7baf..0668d17 100644 --- a/text.lua +++ b/text.lua @@ -772,6 +772,28 @@ function Text.keychord_pressed(chord) Text.left() elseif chord == 'right' then Text.right() + -- left/right by one word + -- C- hotkeys reserved for drawings, so we'll use M- + elseif chord == 'M-left' then + while true do + Text.left() + if Cursor1.pos == 1 then break end + assert(Cursor1.pos > 1) + local offset = utf8.offset(Lines[Cursor1.line].data, Cursor1.pos) + assert(offset > 1) + if Lines[Cursor1.line].data:sub(offset-1,offset-1) == ' ' then + break + end + end + elseif chord == 'M-right' then + while true do + Text.right() + if Cursor1.pos > utf8.len(Lines[Cursor1.line].data) then break end + local offset = utf8.offset(Lines[Cursor1.line].data, Cursor1.pos) + if Lines[Cursor1.line].data:sub(offset,offset) == ' ' then + break + end + end elseif chord == 'home' then Cursor1.pos = 1 elseif chord == 'end' then -- cgit 1.4.1-2-gfad0 9fa117ed3070e46e75fd8f4e339368af17d5e'>commit diff stats
path: root/transect/ex6.k2
blob: cd68f861a1b663661f08281691977a5395324d0c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
## print out a (global variable) string to stdout

var size : int = 14
var x : (array character) = "hello, world!"

fn main [
  call write 1/stdout, x, size
  call exit, 0
]

fn write fd : int, x : (address array byte), size : int [
  EBX <- copy fd
  ECX <- copy x
  EDX <- copy size
  EAX <- copy 4/write
  syscall
]

fn exit x : int [
  code/EBX <- copy x
  code/EAX <- copy 1/exit
  syscall
]