[REBOL] speed up view
From: rotenca::telvia::it at: 4-Jul-2002 19:58
This little hack to speed up view.
I think that something like this should be present at native level in View.
Author: "Italian Connexion (Gabriele Santilli - Romano Paolo Tenca)"
Purpose: "Event filtering --- speeds up view!"
;the words of this context are the event/type to compress
no-queue: context 
wake-event: func [event /local no-btn] bind [
either not pop-face [
either any [pop-face = event/face within? event/offset win-offset?
pop-face pop-face/size] [
if block? get in pop-face 'pane [
no-btn: foreach item pop-face/pane [if get in item 'action
[break/return false] true]
if any [all [event/type = 'up no-btn] event/type = 'close]
if pop-face/action [
if not find [move time] event/type [hide-popup]
none? find pop-list pop-face
] in system/view 'self
awake: func [port no-queue /local event events lasttype] [
events: clear 
while [event: pick port 1] [
either all [in no-queue event/type lasttype = event/type] [
change back tail events event
insert tail events event
foreach event events [
if wake-event event [return true]
system/ports/wait-list/1/awake: func [port] [awake port no-queue]
to-ob: func [blk [block!]][
blk: copy blk
forall blk [change blk to-set-word first blk]
context insert blk none
set 'eat func [
/forever for [block!]
/only blk [block!]
either forever [
no-queue: to-ob for
if not only [blk: [move key offset scroll-line scroll-page]]
if all [free not empty? blk][
awake system/view/event-port to-ob blk
to compress all the events of type 'offset and 'move:
eat/forever [offset move]
to remove all events compression:
to compress only once (at the end of a VID action for example)
the events of type [move key offset scroll-line scroll-page]:
to compress only once the events of type 'move 'scroll-line
eat/only [move scroll-line scroll-page]
e: ne: 1
view layout [
area 200x50 wrap "Try to move the slider up and down keeping the left
button pressed and see the difference"
text white "Standard"
slider [print ["pressed not eated" ne] ne: ne + 1 loop delay ]
text white "Eated"
slider [print ["pressed eated " e] e: e + 1 loop delay  eat/only