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 ] ] ]
parseline is for Windows because of
ar1/selected: NONE ; ar1/selected
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 ] ] ]
@toomasv , which is the CF / LF bug ?
@GiuseppeChillemi This one I guess: red/red#3563
whileerror is wrong or should take other than a block?
cr lfsequence 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).
if system/platform = 'Windows [ parse copy/part area1/text area1/selected/1 + 1 [some [newline (nls: nls + 1) | skip]] ]
crlfis PiA. Solved it in ugly way - doubling newlines in Red-text, doing calculations based on
/selectedand removing extra newlines again. Made also some additional changes...
coldfunction I have been talking about: https://github.com/nedzadarek/cold.red
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:
Coldis just a noun. A verb would be better.
/intostill doc'd as only being a series, which is now really your fold accumulator, correct?
/funas 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.
sz: field 70 "1x10"