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

[REBOL] Re: Cursor

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] ]