Skip to content

Instantly share code, notes, and snippets.

@toomasv
Last active October 18, 2018 17:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save toomasv/2cda8fb4ebe258d76c8f0cfddaf478e3 to your computer and use it in GitHub Desktop.
Save toomasv/2cda8fb4ebe258d76c8f0cfddaf478e3 to your computer and use it in GitHub Desktop.
Scrapping words from text
Red [
Date: 2018-10-18
On-request-of: "@GiuseppeChillemi"
]
add-word: func [txt area][
txt2: take/part at txt area1/selected/1
area1/selected/2 - area1/selected/1 + 1
if system/platform = 'Windows [
parse txt [some [newline remove newline | skip]]
parse txt2 [some [newline remove newline | skip]]
]
area1/text: txt
append append area/text txt2 newline
]
tx: "Sed^/ut^/perspiciatis^/unde^/omnis^/iste^/natus^/error^/sit"
init: 1x10
view [
below
button "Highlight" 70 [area1/selected: sz/data set-focus area1]
sz: field 70
button "Restore" 70 [
area1/text: copy tx
area2/text: copy "" area3/text: copy ""
]
return
area1: area 300x200 focus wrap tx on-select [
sz/text: form any [face/selected init]
]
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" 70 data area2 [
if area1/selected [
nls1: nls2: 0
if system/platform = 'Windows [
parse txt: copy area1/text [some [newline c: (c: insert c newline) :c | skip]]
]
add-word txt face/data
area1/selected: none
]
set-focus area1
]
field 70 hint "Find" [
found: find area1/text face/text
if found [
idx: index? found
if system/platform = 'Windows [
parse copy/part area1/text idx [some [newline (idx: idx + 1) | skip]]
]
area1/selected: as-pair idx idx + (length? face/text) - 1
sz/text: form area1/selected
set-focus area1
]
]
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment