Last active
September 4, 2019 18:41
-
-
Save toomasv/4f08339e854669247d4f34aa7a8c1a3b to your computer and use it in GitHub Desktop.
Actors for tabbing window
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
] | |
] | |
] | |
] | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment