Skip to content

Instantly share code, notes, and snippets.

@toomasv
Last active September 4, 2019 18:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save toomasv/4f08339e854669247d4f34aa7a8c1a3b to your computer and use it in GitHub Desktop.
Save toomasv/4f08339e854669247d4f34aa7a8c1a3b to your computer and use it in GitHub Desktop.
Actors for tabbing window
Red [
Author: "Toomas Vooglaid"
Date: 2018-10-22
Purpose: {To use as options to tabbing window}
Licence: "Public domain"
]
[
actors: object [
on-created: func [face event][
unless face/selected [
face/selected: either all [
face/pane/1/type = 'text
face/pane/1/options/style = 'label
][face/pane/2][face/pane/1]
]
]
select-face: func [face event /local next-face][
idx: index? find face/pane face/selected
step: either find event/flags 'shift [
if idx = 1 [idx: (length? face/pane) + 1]
-1
][
if idx = length? face/pane [idx: 0]
1
]
next-face: face/pane/(idx + step)
either all [
next-face/type = 'text
next-face/options/style = 'label
][
either all [idx = 2 negative? step] [last face/pane][face/pane/(2 * step + idx)]
][
next-face
]
]
tmp-text: copy ""
tabbing?: yes
on-key-down: func [face event][
tabbing?: either event/key = tab [
if attempt/safer [face/selected/options/style = 'text][
take/last face/pane
]
all [
event/face/type = 'area
append clear tmp-text any [event/face/text ""]
]
face/selected: select-face event/window event
if attempt/safer [face/selected/options/style = 'text][
fc: face/selected
append face/pane layout/only compose/deep [
at (fc/offset) box (fc/size) draw [pen sky box 0x0 (fc/size - 1)]
]
]
yes
][no]
]
on-change: func [face event] [
all [
event/face/type = 'area
either tabbing? [
append clear event/face/text tmp-text
][
append clear tmp-text event/face/text
]
]
]
]
]
@gurzgri
Copy link

gurzgri commented Apr 17, 2019

--- 20: if idx = 1 [idx: length? face/pane + 1]
+++ 20: if idx = 1 [idx: 1 + length? face/pane]

@toomasv
Copy link
Author

toomasv commented Sep 4, 2019

@gurzgri Thanks! Corrected

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment