Last active
August 11, 2018 19:24
-
-
Save toomasv/afa3e5a34edb8c626df5902e0efb78ee to your computer and use it in GitHub Desktop.
Multi-selection text-list
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-08-10 | |
Last: 2018-08-11 | |
Purpose: {Attempt at multi-selection text-list style} | |
] | |
cnt: 0 | |
view [ | |
style multi-selection-text-list: text-list | |
on-create [face/extra: object [key: none selected: none selection: copy [] nums: copy [] layer: none]] | |
on-select [ | |
face/extra/selected: face/selected | |
unless face/extra/layer [ | |
fc: face | |
append face/parent/pane layout/only [ | |
box draw [fill-pen #0078d7] | |
on-down [ | |
unless fc/extra/key [ | |
fc/selected: event/offset/y / 16 + 1 | |
append clear fc/extra/selection copy pick fc/data fc/selected | |
append clear fc/extra/nums fc/selected | |
clear at fc/extra/layer/draw 3 | |
probe fc/extra/selection | |
] | |
] | |
on-key-down [fc/actors/on-key-down fc event] | |
on-key-up [fc/actors/on-key-up fc event] | |
] | |
fc/extra/layer: last fc/parent/pane | |
do [ | |
fc/extra/layer/offset: fc/offset | |
fc/extra/layer/size: fc/size | |
] | |
] | |
] | |
on-change [ | |
case [ | |
find [left-control right-control] face/extra/key [ | |
face/extra/selection: unique append face/extra/selection copy pick face/data face/selected | |
face/extra/nums: unique append face/extra/nums face/selected | |
] | |
find [left-shift right-shift] face/extra/key [ | |
face/extra/selection: copy unique append face/extra/selection | |
copy/part | |
at face/data ( | |
minimum: min face/extra/selected face/selected | |
) + m: either face/extra/selected < face/selected [1][0] | |
absolute face/extra/selected - face/selected | |
repeat i absolute face/extra/selected - face/selected [ | |
append face/extra/nums minimum + i - 1 + m | |
] | |
face/extra/nums: unique face/extra/nums | |
] | |
'else [ | |
append clear face/extra/selection copy pick face/data face/selected | |
append clear face/extra/nums face/selected | |
] | |
] | |
probe face/extra/selection | |
;probe face/extra/nums | |
either 1 < length? face/extra/nums [ | |
clear at face/extra/layer/draw 3 | |
len: either face/size/y < (15 * length? face/data) [20][3] | |
nums: face/extra/nums | |
forall nums [ | |
unless nums/1 = face/selected [ | |
append face/extra/layer/draw compose [ | |
pen (hex-to-rgb #0078d7) | |
box (as-pair 2 (nums/1 - 1 * 15 + 2)) (as-pair face/size/x - len (nums/1 * 15 + 1)) | |
pen white | |
text (as-pair 2 (nums/1 - 1 * 15 + 2)) (face/extra/selection/(index? nums)) | |
] | |
] | |
] | |
][clear at face/extra/layer/draw 3] | |
] | |
on-key-down [face/extra/key: event/key] | |
on-key-up [face/extra/key: none] | |
multi-selection-text-list data ["One" "Two" "Three" "Four" "Five" "Six" "Seven"] | |
;multi-selection-text-list data ["alpha" "beta" "gamma" "delta" "epsilon" "zeta" "eta" "theta" "iota" "kappa" "lambda"] | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment