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
Toomas Vooglaid
@toomasv
Second is also easy: view [
GiuseppeChillemi
@GiuseppeChillemi
@toomasv view [ ?
Toomas Vooglaid
@toomasv
@GiuseppeChillemi Take /no-wait away.
Toomas Vooglaid
@toomasv
@GiuseppeChillemi Ok, all cleared + some more:
Red []
add-word: func [selection extra][
    append ar2/text 
        append 
            take/part 
                at ar1/text selection/1 - extra 
                selection/2 - selection/1 + 1 
            newline
]
view [
    button "highlight" [ar1/selected: 2x4 set-focus ar1] ;added from me
    below
    ar1: area 300x100 focus wrap 
    ar2: area 300x100 "" wrap
    return
    button "Cut" [
        if ar1/selected [
            nls: 0 
            parse copy/part ar1/text ar1/selected/1 + 1 [some [newline (nls: nls + 1) | skip]] 
            add-word ar1/selected nls
            ar1/selected: ar1/selected
            set-focus ar1
        ]
    ]
    field 60 hint "Find" [
        found: find ar1/text face/text
        if found [
            idx: index? found
            ar1/selected: as-pair idx idx + (length? face/text) - 1 
            add-word ar1/selected 0
            ar1/selected: none
        ]
    ]
]
Semseddin Moldibi
@endo64
@toomasv What does ar1/selected: ar1/selected line?
Toomas Vooglaid
@toomasv
@endo64 It resets selected. Otherwise, when focus is set on ar1 it doesn't highlight selection (which was cut and gone).
And the parse line is for Windows because of cr/lf problem.
GiuseppeChillemi
@GiuseppeChillemi

@toomasv

@endo64 It resets selected. Otherwise, when focus is set on ar1 it doesn't highlight selection (which was cut and gone).

I don't know which problem is it. Any link ?

Also I have made one modification:
 ar1/selected: NONE ; ar1/selected
And the software has a particular working:
GiuseppeChillemi
@GiuseppeChillemi
Insert some text, hit "highlight" and the CUT (but do not remove all text !) , then hit CUT another time (the cursor will disappear)., then click on ther far right of the text, where the invisible CR/LF should be located. Now, the whole text is highlighted from start to end . Expected working should have been "position text to the far right".
GiuseppeChillemi
@GiuseppeChillemi

@toomasv Also a question:

append ar2/text

"AR2" should be taken from a word to become dynamic:

like

append myarea/text

Where you define myarea: 'ar2 elsewere.

But this seems to not be the correct way
Vladimir Vasilyev
@9214
select get area 'text
Toomas Vooglaid
@toomasv
@GiuseppeChillemi ar1/selected: none is of course fine, if you don't want any selection after cutting. To avoid cursor disappearing reposition set-focus ar1 after if block in "Cut", i.e. as last command in "Cut".
Toomas Vooglaid
@toomasv
@GiuseppeChillemi Something like this?
Red []
add-word: func [extra area][
    append area/text 
        append 
            take/part 
                at area1/text area1/selected/1 - extra 
                area1/selected/2 - area1/selected/1 + 1 
            newline
]
view [
    button "highlight" [area1/selected: 2x4 set-focus area1] 
    below
    area1: area 300x100 focus wrap 
    panel [
        origin 0x0 below
        r2: radio "area2" data true on-change [b2/data: pick reduce [area2 area3] face/data]
        area2: area 145x100 "" wrap
        return
        r3: radio "area3" 
        area3: area 145x100 "" wrap
    ]
    return
    b2: button "Cut" data area2 [
        if area1/selected [
            nls: 0 
            parse copy/part area1/text area1/selected/1 + 1 [some [newline (nls: nls + 1) | skip]] 
            add-word nls face/data
            area1/selected: none ;area1/selected
        ]
        set-focus area1
    ]
    field 60 hint "Find" [
        found: find area1/text face/text
        if found [
            idx: index? found
            area1/selected: as-pair idx idx + (length? face/text) - 1 
            add-word 0 b2/data
            area1/selected: none
        ]
    ]
]
GiuseppeChillemi
@GiuseppeChillemi
@toomasv , which is the CF / LF bug ?
lepinekong
@lepinekong_twitter
@greggirwin from usability point of view I can't see any reason: I shouldn't have to thinking, having to think generates error, this is called poka-yoke in quality ;)
Semseddin Moldibi
@endo64

@toomasv , which is the CF / LF bug ?

@GiuseppeChillemi This one I guess: red/red#3563

nedzadarek
@nedzadarek
@lepinekong_twitter but solving it makes you feel good. To be serious, Greg just pointed you very useful function.
how does that explain while error is wrong or should take other than a block?
more choice can also mean more error
Gregg Irwin
@greggirwin
:point_up: October 17, 2018 4:50 PM @lepinekong_twitter there is a very good reason for it, and if you choose not to think, or try to understand Red, you can't expect us to think for you. If you try, and still need help, we're here, but you have to at least try.
Toomas Vooglaid
@toomasv
@GiuseppeChillemi, as @endo64 pointed (thanks!), the problem is that Windows uses cr lf sequence to mark end of line and Red turns all these into lf. But in calculations of /selectednative sequence is used, while in calculations of length? Red sequence is used, so there appears difference of results in calculations with multiline texts. Work-around is counting line-feeds in selected text and makeing appropriate corrections as above on parse-line. But this is cumbersome and should take into account other platforms (which above code does not).
To take platform into account you wrap the parse-line:
if system/platform = 'Windows [
    parse copy/part area1/text area1/selected/1 + 1 [some [newline (nls: nls + 1) | skip]] 
]
Toomas Vooglaid
@toomasv
As I can't use other platforms here, I can't check the results though.
GiuseppeChillemi
@GiuseppeChillemi

@toomasv

I am working on windows, the code miscalculates the starting positions of the selection if you have multiple eol in your text.
On the starting area it cuts as N characters before the starting selection poin as the number of end of line.

GiuseppeChillemi
@GiuseppeChillemi
note: here Windows 10
Toomas Vooglaid
@toomasv
@GiuseppeChillemi As I said, the problem with crlf is PiA. Solved it in ugly way - doubling newlines in Red-text, doing calculations based on /selected and removing extra newlines again. Made also some additional changes...
Boleslav Březovský
@rebolek
Red should handle line endings consistently. It does so in console, GUI should behave the same (converting everything to LF for Red and to OS-specific style for OS).
Toomas Vooglaid
@toomasv
@rebolek I agree, but :point_up: October 4, 2018 8:37 PM
nedzadarek
@nedzadarek
collect is under BSD or BSL license?
Vladimir Vasilyev
@9214
nedzadarek
@nedzadarek
@9214 thank you.
nedzadarek
@nedzadarek
@rebolek here is the cold function I have been talking about: https://github.com/nedzadarek/cold.red
Gregg Irwin
@greggirwin

Interesting @nedzadarek. Took me minute to grok the examples, but FPers should like it. Is there a standard name in FP parlance for collect+fold. I know collect is not standard FP, so likely not. Thoughts:

  • Cold is just a noun. A verb would be better.
  • /into still doc'd as only being a series, which is now really your fold accumulator, correct?
  • I suggest /with instead of /fun as a refinement name, which is used elsewhere in Red.

The examples show its flexibility, but the interface gets pretty tricky. Of course, I'm just seeing it for the first time.

GiuseppeChillemi
@GiuseppeChillemi
image.png
@toomasv If I hit Highlight I get that you can see in the a screenshot.
Please, don't ASK me wy I have to send you a screenshot instead of plain text :-( )
GiuseppeChillemi
@GiuseppeChillemi
the 1x10 initialization is not visible...
sz: field 70 "1x10"
This is the reason, so I pressed "highlight " with an empty field.
GiuseppeChillemi
@GiuseppeChillemi
@toomasv ; if I "highlight" and then "cut" when the field SZ is empty.
Toomas Vooglaid
@toomasv
@GiuseppeChillemi Fixed
GiuseppeChillemi
@GiuseppeChillemi
As a side note: when the error triggers, if I try to open the consolle menu I see NO MENU !
It should be a RED bug
Toomas Vooglaid
@toomasv
@GiuseppeChillemi I cannot confirm, it hasn't happened to me.
GiuseppeChillemi
@GiuseppeChillemi
As I have written time ago, RED has the habit to crash at first run and then start on the second. Window Server 2012 here,.
Gregg Irwin
@greggirwin
If you can catch any error info, please post it @GiuseppeChillemi.
GiuseppeChillemi
@GiuseppeChillemi
@greggirwin , any debug output ?
Gregg Irwin
@greggirwin
Yes, if you run the CLI console from a terminal window, and it crashes, what does it say?