Rebol/View 'Key Event Problem
[1/9] from: tmoeller:fastmail:fm at: 7-Oct-2009 16:45
Hi,
i am just writing a small editor for myself which should have a realtime
wordcount. Simplified i have following situation:
editor: layout [ mytext: area ifo: info btn "Close" [unview]]
view editor
I am not too familiar with events in rebol. From the docs i learned that
i have to change the area definition to something like the following to
make the area react on key events:
mytext: area feel [
engage: func [face action event] [
if action = 'key [mylen: length? parse mytext/text none
ifo/text: join "Wordcount: " copy to-string mylen
show if
]
But just adding the feel to the area doesn't work.
What am i missing??
Thorsten
--
http://www.fastmail.fm - IMAP accessible web-mail
[2/9] from: henrikmk:gm:ail at: 7-Oct-2009 19:27
On Wed, Oct 7, 2009 at 4:45 PM, Thorsten Moeller <tmoeller-fastmail.fm> wrote:
> Hi,
> i am just writing a small editor for myself which should have a realtime
<<quoted lines omitted: 12>>
> But just adding the feel to the area doesn't work.
> What am i missing??
You are, with that code above, replacing the original engage function
for 'mytext, which contains all the text editing functions, so text
editing stops working. Other than that, your code would normally be
correct. Unfortunately there is no simple way in VID to just add an
on-key handler without rewriting the real engage function that is used
in the area style. You can see it like this:
probe get in get in get-style 'area 'feel 'engage
The solution is to modify that function and include it again. Cumbersome. :-)
You can also download the VID Extension Kit, which lets you do your
task, like this:
view make-window [
; ifo and if faces here
my-text: area on-key [
act [
mylen: length? parse mytext/text none
ifo/text: join "Wordcount: " copy to-string mylen
show if
]
]
]
It can be downloaded from here:
http://97.107.135.89/www.hmkdesign.dk/rebol/vid/src/builds/vid-ext-kit.r
--
Regards,
Henrik Mikael Kristensen
[3/9] from: tmoeller:fastmail:fm at: 7-Oct-2009 20:13
OK, i understand that. I downloaded the extension kit. Do you have a
documentation for the kit somewhere. I searched for it but couldn't find
and some link are already dead.
Thorsten
On Wed, 07 Oct 2009 19:27 +0200, "Henrik Mikael Kristensen"
<henrikmk-gmail.com> wrote:
> On Wed, Oct 7, 2009 at 4:45 PM, Thorsten Moeller <tmoeller-fastmail.fm>
> wro
<<quoted lines omitted: 56>>
> To unsubscribe from the list, just send an email to
> lists at rebol.com with unsubscribe as the subject.
--
http://www.fastmail.fm - Faster than the air-speed velocity of an
unladen european swallow
[4/9] from: henrikmk:g:mail at: 7-Oct-2009 20:22
On Wed, Oct 7, 2009 at 8:13 PM, Thorsten Moeller <tmoeller-fastmail.fm> wrote:
> OK, i understand that. I downloaded the extension kit. Do you have a
> documentation for the kit somewhere. I searched for it but couldn't find
> and some link are already dead.
I have, but I'll have to mail the link to you privately, as I don't
want the server to be hammered too much just yet. Also the docs will
differ slightly from the build you have downloaded.
--
Regards,
Henrik Mikael Kristensen
[5/9] from: nick:guitarz at: 7-Oct-2009 20:29
Hi Thorsten,
You could just use a timer event on the info style:
view layout [
i: info rate 0 feel [
engage: func [f a e] [
if a = 'time [
l: length? parse m/text none
i/text: join "Wordcount: " l
show i
]
]
]
m: area
]
HTH :)
- Nick
Quoting Thorsten Moeller <tmoeller-fastmail.fm>:
[6/9] from: moliad:gmai:l at: 10-Oct-2009 16:50
Nick,
that is such a nice trick :-)
-MAx
On Wed, Oct 7, 2009 at 11:29 PM, Nick Antonaccio <nick-guitarz.org> wrote:
[7/9] from: nick:guitarz at: 11-Oct-2009 22:36
Thanks Max :)
It works quickly, even with large files, but can be a major resource
hog. Using a text file with 112000 words, and a rate of 0, it
increased my CPU usage to 50%. Setting the rate to 10 reduced CPU
usage to 33%, rate 5 reduced CPU usage to around 18%, and rate 1 only
used about 8% (I had a number of other windows open, which accounted
for about 3% CPU usage.
Thorsten, use a slower rate, if it makes sense in your app (does the
update need to happen more often than once, or maybe 2-3 times per
second?).
Quoting Maxim Olivier-Adlhoch <moliad-gmail.com>:
[8/9] from: tmoeller:fastmail:fm at: 12-Oct-2009 9:30
Hi Nick,
thanks for your suggestions. I have to try it. I planned to have it in
realtime and made a test with Henrik's vid extensions. This worked well
for be but needs the extensions. I will give your trick a try as well,
together with the hints you provided. I don't think the single file will
become that large, but youll never know.
Thanks
Thorsten
On Sun, 11 Oct 2009 22:36 -0700, "Nick Antonaccio" <nick-guitarz.org>
wrote:
> Thanks Max :)
> It works quickly, even with large files, but can be a major resource
<<quoted lines omitted: 100>>
> To unsubscribe from the list, just send an email to
> lists at rebol.com with unsubscribe as the subject.
--
http://www.fastmail.fm - Access your email from home and the web
[9/9] from: semseddinm:bircom at: 12-Oct-2009 10:42
Hi, what about the checksum control to test m/text changed or not, if
changed then parse and count the words. I did not try but this may
reduce the CPU cost.
if not-equal? old-checksum new-checksum [...]
Notes
- Quoted lines have been omitted from some messages.
View the message alone to see the lines that have been omitted