Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Oct 20 22:59
    @dockimbel banned @SmackMacDougal
  • Dec 03 2017 05:53
    @PeterWAWood banned @matrixbot
  • Sep 28 2016 12:19
    @PeterWAWood banned @TimeSeriesLord
  • Aug 13 2016 03:23
    @PeterWAWood banned @Vexercizer
Greg T
@gltewalt
Oh I think I figured it out
bitset is zero based index
>> 84 >> 1
== 42
binary! is one based index
>> shift/left 42 1
== 84
Greg T
@gltewalt
Have to shift right one bit if calculating a value from a bitsets "on" an "off" bits
I assumed to conversion did that for us
Toomas Vooglaid
@toomasv
:+1:
Semseddin Moldibi
@endo64
Would be nice to put into a wiki page
Toomas Vooglaid
@toomasv
Then correct way to look at bitset values is:
>> c: to-bitset #{2A}
== make bitset! #{2A}
>> repeat i length? c [prin pick [1 0] c/(i - 1)]
00101010
>> c: to-integer 2#{00101010}
== 42
Greg T
@gltewalt
:+1:
GiuseppeChillemi
@GiuseppeChillemi
Is there a way to know which area has focus ?
Also, is there a way to read the/set position of the text cursor ?
A last one: where do I find documentation about RTF and how to color text ?
(in RED)
Toomas Vooglaid
@toomasv

@GiuseppeChillemi

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

I think I showed to you once.

Vladimir Vasilyev
@9214
@toomasv text selection, but not cursor position.
Toomas Vooglaid
@toomasv
Position too
Vladimir Vasilyev
@9214
And how would you do that?
Toomas Vooglaid
@toomasv
I may remember wrongly. Let me try to remember. But I'll have to move now.
Vladimir Vasilyev
@9214
:suspect:
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.