Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

Cursor

 [1/7] from: hijim:pronet at: 1-Jul-2001 14:31


Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit I have two questions. First, is there a way to use the function keys and/or the alt-keys in the manner of key #"^p" [write clipboard:// <P> ] Second, when using a text area in REBOL/View, is there a word that keeps track of the cursor position? I would like to use it to skip to that position and insert a string such as "<P>". I think I know how to do this if I can access the cursor position in the file.(A related question would be: I'm working on an editor that will insert html tags at the cursor position when I use a hotkey. As it stands now, I can use some of the control keys to copy to the clipboard. I can then insert the tags with ctrl-v. It works, but it's not very elegant. I'll attach the script for the editor. Don't try the slider. It doesn't work. I just put it in to see if I could figure out how to make it work using a couple of example scripts. I haven't been successful yet. Any help appreciated, Jim -- Attached file included as plaintext by Listar -- -- File: Html.r rebol [Title: "Clip and Paste Editor"] a-file: "" foc: does [focus text-file] html-end: does [append a-file { <image src = "line.gif"> <P> </blockquote> </body> </html> }] reb-source: [{REBOL [ Title: "" File: Date:} now/date { Author: "Jim Clatfelter" Purpose: [] ] view/layout [ ] } ] reb: reform reb-source view layout [ backdrop silver across space 10 text "CONTROL KEYS:" font [space: 1x0] bold text "P=<P> B=<BR> N=&nbsp L=<LI> K=<PRE></PRE>" font [space: 1x0] bold text "D=Date" font [space: 1x0] red bold space 0 return text-file: area 700x350 a-file ivory white font-name font-fixed s1: slider 16x350 [ probe s1/data text-file/para/origin/y: sl/data - 1 * (negate size/y) - size/y + 2 show text-file ] return button 70 "Open" [ file-path: request-file/title/keep "Open File" "Open" if file-path <> none [ a-file: read/string to-file file-path text-file/text: a-file file-path size: size-text text-file ; for slider? text-file/para/origin: 4x4 ; for slider? show text-file top-flag: true focus text-file ] ] button 70 "Save" #"^s" [ file-path: request-file/title/keep "Save File" "Save" if file-path <> none [ write first file-path text-file/text] ] button 70 "Print" [write %//prn append a-file #"^L"] button 70 "Quit" #"^q" [unview/all] key #"^p" [write clipboard:// "<P>"] key #"^b" [write clipboard:// "<BR>"] key #"^n" [write clipboard:// " &nbsp; "] key #"^l" [write clipboard:// "<LI>"] key #"^k" [write clipboard:// "<PRE></PRE>"] key #"^D" [write clipboard:// to-string now/date] button 70 "REBOL" [insert a-file reb foc] button 70 "HTML" [insert a-file { <html> <head> <title> TITLE </title> </head> <body><blockquote> <h1> </h1> <image src = "line.gif"> <P> } html-end foc] ]

 [2/7] from: agem:crosswinds at: 2-Jul-2001 1:00


RE: [REBOL] Cursor [hijim--pronet--net] wrote:
> Content-Type: text/plain; charset=us-ascii > Content-Transfer-Encoding: 7bit
<<quoted lines omitted: 15>>
> using a couple of example scripts. I haven't been successful yet. > Any help appreciated,
system/view/caret is current cursor and system/view/focal-face its face. so if your-face = system/view/focal-face you can insert system/view/caret "some text"
> Jim
-Volker

 [3/7] from: hijim:pronet at: 1-Jul-2001 19:34


Hi Volker, Thanks for the cursor information. I've used it to insert the html tags with buttons. I wonder if there's also a way to change the value of the caret so that when I insert 3 characters, I can also move the cursor ahead 3 characters. You can view the caret, but can you move it too? I get error messages if I try to use one of the green buttons when the text area is empty. I'll keep experimenting to see if I can get around that. Obviously, you can't insert anything if there's no text there to begin with! Maybe I need to check that text exists first. Any help here on how to make the button action conditional is welcome. Thanks again, Jim Script follows: (I hope this format doesn't break the lines in email.) rebol [Title: "HTML Tag Editor"] a-file: "" foc: does [focus text-file show text-file] html-end: does [append a-file { <image src = "line.gif"> <P> </blockquote> </body> </html> }] reb-source: [{REBOL [ Title: "" File: Date:} now/date { Author: "Jim Clatfelter" Purpose: [] ] view/layout [ ] } ] reb: reform reb-source view layout [ backdrop silver across space 10 style but button 70x20 green / 2 font-name font-fixed space 0 text-file: area 700x350 a-file ivory white font-name font-fixed s1: slider 16x350 [ probe s1/data text-file/para/origin/y: sl/data - 1 * (negate size/y) - size/y + 2 show text-file ] return pad 0x2 but "<P>" #"^p" [insert system/view/caret "<P>" show text-file] but "<BR>" #"^b" [insert system/view/caret "<BR>" show text-file] but "&nbsp" #"^n" [insert system/view/caret " &nbsp; " show text-file] but "<PRE>" #"^k" [insert system/view/caret "<PRE></PRE>" show text-file] but "<UL>" [insert system/view/caret {</UL> <LI> </UL>} show text-file] but "<OL>" [insert system/view/caret {</OL> <LI> </OL>} show text-file] but "<LI>" #"^l" [insert system/view/caret "<LI>" show text-file] but "Link" [insert system/view/caret {<a href=""> </a>} show text-file] but "Image" [insert system/view/caret {<image src = "" align="left" hspace=10>} show text-file] but "Date" #"^D" [insert system/view/caret to-string now/date show text-file] return pad 0x4 button 70 "Open" [ file-path: request-file/title/keep "Open File" "Open" if file-path <> none [ a-file: read/string to-file file-path system/view/focal-face text-file/text: a-file file-path size: size-text text-file ; for slider? text-file/para/origin: 4x4 ; for slider? show text-file top-flag: true focus text-file ] ] button 70 "Save" #"^s" [ file-path: request-file/title/keep "Save File" "Save" if file-path <> none [ write first file-path text-file/text] ] button 70 "Print" [write %//prn append a-file #"^L"] button 70 "Quit" #"^q" [unview/all] button 70 "REBOL" [insert a-file reb foc] button 70 "HTML" [insert a-file { <html> <head> <title> TITLE </title> </head> <body><blockquote> <h1> </h1> <image src = "line.gif"> <P> } html-end foc] ]

 [4/7] from: agem:crosswinds at: 2-Jul-2001 5:27


RE: [REBOL] Re: Cursor Hi Jim. cool Eddi :) [hijim--pronet--net] wrote:
> Hi Volker, > > Thanks for the cursor information. I've used it to insert the html tags with buttons. I wonder > if there's also a way to change the value of the caret so that when I insert 3 characters, I can > also move the cursor ahead 3 characters. You can view the caret, but can you move it too? >
yes. system/view/caret: skip system/view/caret 3
> I get error messages if I try to use one of the green buttons when the text area is empty. I'll > keep experimenting to see if I can get around that. Obviously, you can't insert anything if > there's no text there to begin with! Maybe I need to check that text exists first. Any help here > on how to make the button action conditional is welcome. >
but "<P>" #"" [ if text-file <> system/view/focal-face [return] ; <<<< insert system/view/caret "<P>" show text-file] should work. check is too nice if you have multiple text-fields.. ;-)
> Thanks again, > > Jim
;-) Volker

 [5/7] from: g::santilli::tiscalinet::it at: 2-Jul-2001 18:56


Hello [agem--crosswinds--net]! On 02-Lug-01, you wrote: a> yes. system/view/caret: skip system/view/caret 3 In this case, I'd suggest: system/view/caret: insert system/view/caret "whatever" which will put the cursor just after what you inserted, whatever its length. Regards, Gabriele. -- Gabriele Santilli <[giesse--writeme--com]> - Amigan - REBOL programmer Amiga Group Italia sez. L'Aquila -- http://www.amyresource.it/AGI/

 [6/7] from: agem:crosswinds at: 2-Jul-2001 20:32


RE: [REBOL] Re: Cursor [g--santilli--tiscalinet--it] wrote:
> Hello [agem--crosswinds--net]! > On 02-Lug-01, you wrote:
<<quoted lines omitted: 3>>
> which will put the cursor just after what you inserted, whatever > its length.
Yep, better :)
> Regards, > Gabriele.
;-) Volker

 [7/7] from: hijim:pronet at: 2-Jul-2001 19:42


Hi Volker, I put your cursor positioning method in a function, so all I have to enter is jump #. That way the cursor will land just where I want it. The image tag has the cursor land right between the quotation marks, just before .jpg. Then I can enter the image file name. Thanks to Gabriele too. I'm glad to know any method of positioning the cursor. I added the conditional also, so that the buttons are inactive if the file is empty. That works great! Thanks. But I'm still getting error messages when a file is opened and displayed with no cursor visible on the screen. How do I open a file and make sure that the cursor is not off the screen. (I'd really like it if I never lost focus on the text area and never lost sight of the cursor.) I tried system/view/caret: 1, but this didn't work. How do I put the caret at a chosen position? I'll include the script below. I added a FIND button, but I haven't tried to experiment with it yet. I'd like to be able to search for a word and have the cursor and display move to the word. I'm a rank beginner at this, so that will have to wait. One step at a time! rebol [Title: "HTML Tag Editor"] a-file: "" foc: does [focus text-file show text-file] ins: func [x] [insert system/view/caret x] jump: func [x] [system/view/caret: skip system/view/caret x] html-end: does [append a-file { <image src = "line.gif"> <P> </blockquote> </body> </html> }] reb-source: [{REBOL [ Title: "" File: Date:} now/date { Author: "Jim Clatfelter" Purpose: [] ] view/layout [ ] } ] reb: reform reb-source view layout [ backdrop silver across space 10 style but button 70x20 green / 2 font-name font-fixed space 0 text-file: area 700x350 a-file ivory white font-name font-fixed s1: slider 16x350 [ probe s1/data text-file/para/origin/y: sl/data - 1 * (negate size/y) - size/y + 2 show text-file ] return pad 0x2 but "<P>" #"" [if text-file <> system/view/focal-face [return] ins "<P>" jump 3 show text-file] but "<BR>" #"" [if text-file <> system/view/focal-face [return] ins "<BR>" jump 4 show text-file] but "&nbsp" #"" [if text-file <> system/view/focal-face [return] ins "&nbsp; " jump 7 show text-file] but "<PRE>" #"" [if text-file <> system/view/focal-face [return] ins "<PRE></PRE>" jump 5 show text-file] but "<UL>" #"" [if text-file <> system/view/focal-face [return] ins {</UL> <LI> </UL>} jump 10 show text-file] but "<OL>" [if text-file <> system/view/focal-face [return] ins {</OL> <LI> </OL>} jump 10 show text-file] but "<LI>" #"" [if text-file <> system/view/focal-face [return] ins "<LI>" jump 4 show text-file] but "Link" #"" [if text-file <> system/view/focal-face [return] ins {<a href=""> </a>} jump 9 show text-file] but "Image" #"" [if text-file <> system/view/focal-face [return] ins {<image src = ".jpg" align="left" hspace=10>} jump 14 show text-file] but "Date" #"" [if text-file <> system/view/focal-face [return] ins to-string now/date show text-file] return pad 0x4 button 70 "Open" #"^o" [ file-path: request-file/title/keep "Open File" "Open" if file-path <> none [ a-file: read/string to-file file-path system/view/focal-face text-file/text: a-file file-path size: size-text text-file ; for slider? text-file/para/origin: 4x4 ; for slider? show text-file top-flag: true focus text-file ] ] button 70 "Save" #"^s" [ file-path: request-file/title/keep "Save File" "Save" if file-path <> none [ write first file-path text-file/text] ] button 70 "Print" #"^p" [write %//prn append a-file #"^L"] button 70 "Find" field 140x26 font-name font-fixed ivory white button 70 button 70 "REBOL" [insert a-file reb show text-file] button 70 "HTML" [insert a-file { <html> <head> <title> TITLE </title> </head> <body><blockquote> <h1> </h1> <image src = "line.gif"> <P> } html-end foc] button 70 red "Quit" #"^q" [unview/all] ]

Notes
  • Quoted lines have been omitted from some messages.
    View the message alone to see the lines that have been omitted