Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Dec 03 2017 05:53
    @PeterWAWood banned @matrixbot
  • Sep 28 2016 12:19
    @PeterWAWood banned @TimeSeriesLord
  • Aug 13 2016 03:23
    @PeterWAWood banned @Vexercizer
Rudolf Meijer
@meijeru
What about caret-to-offset and offset-to-caret?
Also offset-to-char
Toomas Vooglaid
@toomasv
@9214 You were right, again. I can get cursor position in rich text but not in area.
dsunanda
@dsunanda
I want a DROP-DOWN action to be triggered even if that action is the same as currently selected option.
As a toy example, I'd like N in the code below to always increment/decrement when UP/DOWN is selected. As coded, consecutive UPs (or DOWNs) do not trigger the action. Also, it'd be good if the DROP-DOWN always showed the current selection.
The commented out line, when activated, confuses Red enough to make it work the way I want. A more supported method be welcome :) Thanks.
unview/all 
view/no-wait [ n: text data 100
               drop-down  "Up"
                  data ["Up" "Down"]
                  on-change [
                       n/data: n/data + pick [1 -1] face/selected
                       ; face/selected: to-pair reduce [face/selected 1]
                       ]
      ]
GiuseppeChillemi
@GiuseppeChillemi

@toomasv

@GiuseppeChillemi

is there a way to read the/set position of the text cursor ?

Text Selection, not cursor position.

@dsunanda

The commented out line, when activated, confuses Red enough to make it work the way I want. A more supported method be welcome :) Thanks.

LOL

GiuseppeChillemi
@GiuseppeChillemi
@9214 It seems I need to use the on-focus actor and set somewhere the name of the area which triggered the event.
Vladimir Vasilyev
@9214

How hard is it to take your time and read the documentation, really?

selected facet: for lists types, index of currently selected element. For text inputs, selected text. For windows, focused face.

view window: layout [area "this" area "that" area "other" button [probe window/selected/text]]
This also concerns text selection.
GiuseppeChillemi
@GiuseppeChillemi
@9214 how hard is it for you to give me a ready solution without letting me read the documentation ? :-) (Thanks but It is very late and I am speed reading)
Vladimir Vasilyev
@9214
Do I look like a Mother Goose? I'm here to give you all the means you need to help yourself, not to spoon-feed you.
GiuseppeChillemi
@GiuseppeChillemi
Today I have also compiled a script for the first time. Is it normal to receive an error while running it from from the consolle I get no errors ?
TextSplitHelper_pers.red ...
Compiling libRedRT...
...compilation time : 2403 ms

Compiling to native code...
...compilation time : 73685 ms
...linking time     : 851 ms
...output file size : 1026560 bytes
...output file      : E:\Svi\prj-TextSplitHelper\libRedRT.dll

*** Compilation Error: undefined word area1
*** in file: E:\Svi\prj-TextSplitHelper\TextSplitHelper_pers.red
*** near: [area1]
Vladimir Vasilyev
@9214
Either use -r -e flags or specify Options: [red-strict-check?: off] in the header.
Greg T
@gltewalt
You do kind of look like Mother Goose
GiuseppeChillemi
@GiuseppeChillemi
@9214 I have added -r -e flags, It compiled but when it starts I see what it seems a black consolle windows opening and then it disappears. The program seems crashing. What could it be ?
Vladimir Vasilyev
@9214
Have you specified Windows as a target platform?
GiuseppeChillemi
@GiuseppeChillemi
Don't know I had to specify and where to specify !
Vladimir Vasilyev
@9214
-r -e -t Windows
GiuseppeChillemi
@GiuseppeChillemi
I have read: Target: MSDOS so I thought it was self recognizing
Is compiled script faster than interpreted code ?
(Note: I had to add 'needs: view' in the header and it worked)
Vladimir Vasilyev
@9214
Hard to say. In case with -e flag the speed should be roughly the same.
nedzadarek
@nedzadarek
@dsunanda
1) You can change face/selected to other (maybe nonsensical) value. It just need to be different than currently selected.
2) You can put it into function:
view/no-wait [ 
; NEW FUNCTION:
do [
  refresh-drop-down: function [face] [face/selected: 'nonsense]
]
n: text data 100
               dd: drop-down  "Up"
                  data ["Up" "Down"]
                  on-change [
                       n/data: n/data + pick [1 -1] face/selected
               ; USED HERE:
               refresh-drop-down face

                       ]      
      ]
ps. It seems that manually changing values won't trigger on-change event.
Toomas Vooglaid
@toomasv

Workaround to get position in area. Not complete, just principle:

view [
    ar: area "Something" focus extra 1 
    on-key [switch/default event/picked [
        8 37 [face/extra: face/extra - 1] 
        20 27 46 []
    ][face/extra: face/extra + 1]] 
    on-focus [face/selected: as-pair face/extra face/extra - 1] 
    below button "Probe position" [
        probe ar/selected: as-pair ar/extra ar/extra - 1
    ] 
    field 93 hint "Do something"
]

Remembers and shows cursor position in area.

Toomas Vooglaid
@toomasv
@dsunanda Building upon @nedzadarek's solution:
view [ 
    n: text data 100
    drop-down "Up"
    data ["Up" "Down"]
    on-change [
        n/data: n/data + pick [1 -1] face/selected
        face/selected: 'none
    ]
]
Toomas Vooglaid
@toomasv
Downside is of course that drop-down's selected facet is not useful for referencing any more. This can be overcome by using extra to store selected value.
dsunanda
@dsunanda
Thanks guys - setting /SELECTED to NONE looks somehow more professional than my approach of setting it to a PAIR (I was working through non-sensical things to set it to to elict the behavior I wanted, and stopped when I hit on PAIR).
Toomas Vooglaid
@toomasv
Seems that anything works besides none, 0, 1, 2, 0.0, 1.0 and 2.0. Could be e.g. -1 very well.
dsunanda
@dsunanda
Not quite everything - the first few things I tried caused the drop-down text to go blank - one example, 1.#INF
nedzadarek
@nedzadarek
@toomasv @dsunanda when we set it to none (not word 'none) or 1.#INF it goes blank and if you roll mouse wheel it will repeat the event. Not sure if it's a bug or not.
hiiamboris
@hiiamboris
How can I compile CLI console with View module enabled? (like the one built by red-latest.exe)
Vladimir Vasilyev
@9214
@hiiamboris toolchain releases from Red website are build with Rebol SDK, which requires a license key. As for CLI with View module - perhaps you should manually #include View files?
hiiamboris
@hiiamboris
Well, I had hoped for something more or less ready to use...
Vladimir Vasilyev
@9214
Our you can just launch console with --cli flag.
@BeardPower :point_up: any ideas?
hiiamboris
@hiiamboris
--cli is not accepted by the console itself
with -t MSDOS gui-console.red it shows both GUI and the CLI, not what I want
Vladimir Vasilyev
@9214
What's the use-case though?
BeardPower
@BeardPower
@hiiamboris @9214 I never tried to enable the View module for the CLI console.
@hiiamboris Why would you need/want the CLI with View?
hiiamboris
@hiiamboris
@9214 CLI is easier to debug, less junk output and no timed actions
ne1uno
@ne1uno
old gui?
BeardPower
@BeardPower
There is no simple way to include the view modules as the GUI console is a mixture of included files and Red code to create the GUI itself.
@hiiamboris No timed actions? I don't understand.
hiiamboris
@hiiamboris
@BeardPower GUI console handles a lot of GUI events, including timer and other stuff to keep the console working
BeardPower
@BeardPower
@hiiamboris I see. And why is this an issue?
Vladimir Vasilyev
@9214
@hiiamboris if I got this right: if you compile CLI console it doesn't include View module, and if you compile GUI console it includes View but can't process any command-line arguments, e.g. --cli?
hiiamboris
@hiiamboris
Yes.
--cliis handled by the red.exe dispatcher
BeardPower
@BeardPower
@9214 --cli is just an option of the red binary compiled with the REBOL SDK.