r3wp [groups: 83 posts: 189283]
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

World: r3wp

[I'm new] Ask any question, and a helpful person will try to answer.

Luisc
9-Mar-2005
[1]
I don't know if i am at the right place but here it goes. I have 
been searching for a function that will copy a selected ( or clicked 
) text from an area to the clipborad ( or to a field ).  Is there 
anything in /core or /view that will do such a thing?
Anton
9-Mar-2005
[2x2]
write clipboard:// area-face/text
That's inside rebol/view VID AREA style. Is that what you mean ?
Luisc
9-Mar-2005
[4]
thank you anton
Anton
9-Mar-2005
[5x2]
Or do you mean from outside rebol - in an area somewhere on the screen 
?
no problem if it works :)
Luisc
9-Mar-2005
[7]
no in a text area -- > windows clipboard
Anton
9-Mar-2005
[8]
ok :)
Luisc
9-Mar-2005
[9]
i will try that
Anton
9-Mar-2005
[10x3]
you can also do the opposite:
set-face area-face read clipboard://
Umm, SET-FACE is new, so perhaps better:
Luisc
9-Mar-2005
[13]
it looks soo easy
Anton
9-Mar-2005
[14x2]
area-face/text: read clipboard://
area-face/line-list: none
show area-face
Luisc
9-Mar-2005
[16x2]
can you just select a text word by click in on a letter?
and send that to the clipboard
Anton
9-Mar-2005
[18]
*That's* going to take some investigating. I must go to sleep now 
though. :)
Luisc
9-Mar-2005
[19x2]
he he he thank you anton again
mercy
DideC
9-Mar-2005
[21x2]
If you mean selecting a part of the text (hilighting) and sendind 
it to the clipboard, just hit CTRL+C ;-)
If you mean sending to the clipboard the word where the cursor is, 
it's a bit more complex.
Luisc
9-Mar-2005
[23]
Yes DideC what i am looking is to click on a character in the text 
area or field  and grab a whole word delimited maybe by spaces ( 
or any other character ) and send it to the clipboard or another 
field.
Anton
10-Mar-2005
[24]
sort of auto-copy
DideC
10-Mar-2005
[25x2]
Luisc: may be there is simpler that that, but it does the job :
ctx: context bind [
	chars: charset [ #"A" - #"Z" #"a" - #"z" #"0" - #"9" #"-" #"_"]
	non-chars: complement chars

	set 'copy-word has [start end end-rule car-pos] [
		if any [not focal-face not caret] [exit]
		
		car-pos: index? caret
		end-rule: copy []
		
		parse/all head caret [
			any [
			 	start: some chars end: (

     if all [car-pos >= index? start car-pos <= index? end] [end-rule: 
     'break]
				) end-rule
				| some non-chars (start: end: none)
			]
		]

  if all [start end] [write clipboard:// probe copy/part start end]
	]
] in system/view 'focal-face

view layout [
	area "This is some text to test"

 text "To copy the word under the cursor : hit CTRL+K or press the 
 button bellow"
	button "Copy word" #"^K" [copy-word]
]
Anton
10-Mar-2005
[27x3]
There's a nice example of BIND. The whole block of words is first 
BINDed to the system/view object. Only the words that already exist 
in system/view (like 'copy-word) will be rebinded, (because objects 
cannot be extended with new words).
*Then* CONTEXT starts building a new object! of its own, from the 
spec block of binded words. But it only puts the set-words (eg. chars: 
non-chars:   but *not* 'copy-word) into the new object.
So it's a double-bind :-)
Luisc
10-Mar-2005
[30x2]
Thank you DideC this is what i was looking , i thought that parse 
will do the trick  I just did not know how. All i need to do now 
is see how fast this works with a 100KB text file.
I have been looking at scripts Anton on Bind ( found over 40 at rebol) 
. This is great !!! 8D
DideC
10-Mar-2005
[32]
I'm not a parse guru myself. May be there is a simpler solution.
Luisc
10-Mar-2005
[33]
donno but it does what i need  =)  and it looks "easy" hmmm I can 
see why someone can get addicted to rebol. I need to study more about 
bind and parse.
Henrik
10-Mar-2005
[34]
is it possible to use an object variable for a VID item, such as 
obj: make object! [t: none] where I would like view layout [obj/t: 
button "hello"] in some way? it doesn't work...
Ammon
10-Mar-2005
[35]
Yes, it is possible but requires a little work...
Anton
10-Mar-2005
[36]
o: context [var: none]
layout [button with [o/var: self]]
o/var/type ;== face
o/var/style ;== button
Ammon
10-Mar-2005
[37]
Hm...  Most elegant solution to that problem that I have seen!
BrianW
10-Mar-2005
[38]
very nice indeed :-)
Anton
10-Mar-2005
[39x3]
You just need to watch out for button facets which have the same 
name as your object 'o
For example, don't do this:
text: context [var: none]
layout [button with [text/var: self]]
** Script Error: Cannot use path on none! value
** Where: forever
** Near: text/var: self
You could avoid that with some binding.
Henrik
10-Mar-2005
[42]
thanks for the suggestions :-) I'm doing it differently now though...
Anton
10-Mar-2005
[43]
The most elegant solution would be to patch layout so it accepts 
set-paths.
Normand
12-Apr-2005
[44]
Speaking of double bind, I have no clue of the how-to to this clue. 
 In Ocaml we can make co-recursive definitions, also with negation. 
 But when I try this on Rebol, it claims the value before I have 
the time to define it:  a: not b and b: not a.   Interp: ** script 
error, b has no value.  What is the method ?  Or are we out of paradise? 
 I could use that as a form of loop, or a form of lexical closure 
to model some linguistic phenomenas.  But how?  We know the problems 
of complement of complement, but as a function value it should be 
feasible.
JaimeVargas
12-Apr-2005
[45x2]
Do you have an example,  besides:
a: not b
b: not a
In rebol this are executed serially, so the first statement fails 
because b is not defined.
Normand
12-Apr-2005
[47]
A pair number cant be defined without impair. pair is impair +1 and 
impair is pair +1.  So we have to define both at the same time.  
In logic, the negation is a function where true is false and false 
is true.  Not and complement are native to rebol.  If I try a: not 
'b b: not ''a. asking the value of a, :a, does not return not b but 
false.   Something like this does not seem to work.  What I want 
is criss-crossed functions one defined by the other.  In principle, 
Rebol being functionnal.   It should be simple, a one liner, but 
I am too newbee to find the elegant way to do this.
Ammon
12-Apr-2005
[48]
Normand, can you give us the actual code that is tripping you up 
here?  Perhaps with a look I could help you out...
Volker
12-Apr-2005
[49]
Normand, seems you do not define functions, but executes the expressions 
directly?
pair: func[][impair + 1]
impair: func[][pair + 1]
the code makes no sense but rebol accepts it perfectly.
Ladislav
12-Apr-2005
[50]
Normand: don't you mean this?:

odd?: func [i] [either i = 0 [false] [even? i - 1]]
even?: func [i] [either i = 0 [true] [odd? i - 1]]
odd? 11