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

Scroll text area?

 [1/5] from: hijim:pronet at: 5-Jul-2001 19:09


Volker showed me how to move the cursor position, but can I scroll the text in the text area? All I want is page up and down and top and end of file to be displayed with buttons. There must be a way to scroll the display. Anyone? Jim Jim Clatfelter wrote:

 [2/5] from: g:santilli:tiscalinet:it at: 6-Jul-2001 19:48


Hello Jim! On 06-Lug-01, you wrote: JC> There must be a way to scroll the display. face/para/scroll is what you're after. Regards, Gabriele. -- Gabriele Santilli <[giesse--writeme--com]> - Amigan - REBOL programmer Amiga Group Italia sez. L'Aquila -- http://www.amyresource.it/AGI/

 [3/5] from: agem:crosswinds at: 6-Jul-2001 22:31


RE: [REBOL] Scroll text area? [hijim--pronet--net] wrote:
> > Volker showed me how to move the cursor position, but can I scroll the text > in the text area? All I want is page up and down and top and end of file to > be displayed with buttons. There must be a way to scroll the display. > > Anyone? >
[rebol [] protect-system ???: func ['word value] [ print [mold :word mold type? :value ":" mold :value] word :value] {Hi Jim. lets look at} source scroll-para [;the source: scroll-para: func [tf sf /local tmp] [ if none? tf/para [exit] tmp: min 0x0 tf/size - (size-text tf) - 0x30 either sf/size/x > sf/size/y [tf/para/scroll/x: sf/data * first tmp] [ tf/para/scroll/y: sf/data * second tmp] show tf ] ] {this nice function is usually used like} context [ view center-face layout [ title "simple slider" across my-slider: slider 16x480 [scroll-para my-area my-slider] my-area: area para [] 640x480 (read first request-file) ] ] {for the hand-made way, we see 'tf/para/scroll/y and 'size-text tf the first lets you set a position for your text, the 'size-text gives you the size of the full text. this is used to make scrolling relativ there. its nice to play with it.} {but we have a slider! it can do the work! set 'my-slider/data between 0 .. 1} context [ view center-face layout [ title "we jump!" across button "1/2" [ my-slider/data: 0.5 scroll-para my-area my-slider show [my-slider] ] return my-slider: slider 16x480 [scroll-para my-area my-slider] my-area: area para [] 640x480 (read first request-file) ] ] {so we can set slider & cursor together, now we have to do something with pages. has vid something ready? hm. http://www.cs.unm.edu/~whip/objview.r is always a nice tool. (on jeffs reb), but it does not work to look in 'system/view here?! trick 2: to get an overview for faces i use } layout [my-area: area do [probe my-area/feel]] {and we see somewhere key [edit-text face event get in face 'action] 'edit-text ? grumbling. must be somewhere.. trick 3: to get an overview of objects:} probe first system/view ;this one is where you find caret and that probe first system/view/vid probe first system/view/vid/vid-feel ; no.. {well, long not looked at. /view 1.2 now..} help ctx- probe first ctx-text ;lalala :) {but psst! its a function! do not wake!} probe get in ctx-text 'edit-text ;not probe ctx-text/edit-text ! { AHA! set-caret: [view*/caret: offset-to-caret face tmp] page-up: [ tmp/y: tmp/y - face/size/y if not head? view*/line-info/start set-caret ] page-down: [ tmp/y: tmp/y + face/size/y if not tail? offset-to-caret face tmp set-caret ] but then it gets complicated.. nono. i calculate a bit myself: } context [ face: none view center-face layout [ title "page-jumper" across button "down" [ my-slider/data: my-slider/data + (my-area/size/y / second size-text my-area) scroll-para my-area my-slider show [my-slider] ] button "up" [ my-slider/data: my-slider/data - (my-area/size/y / second size-text my-area) scroll-para my-area my-slider show [my-slider] ] return my-slider: slider 16x480 [scroll-para my-area my-slider] my-area: area para [] 640x480 (read first request-file) ] ] {seems, i misunderstood something. it jumps only part of pages. needs more work.. } ] ;-) Volker

 [4/5] from: hijim:pronet at: 6-Jul-2001 20:34


Hi Volker, Thanks for the instructions on scrolling! I got the slider going with just 2 lines of your code. It sure makes things better. I also included 2 buttons for HOME and END, though they seem unnecessary. Page up and down would be nice, but it sounds much more complicated. It would have to scroll by lines. I really think the slider is enough, so I'll probably remove the HOME and END buttons. Then I'll have room for 4 more buttons. I don't use tables very often, but I could add table tags. Thanks again for all your help. I now have an editor that is customized for the tags I use most often. So far, I've used it more to write REBOL scripts than web pages. I used it to write it! Much appreciation, Jim rebol [Title: "HTML Tag Editor"] a-file: "" put: func [a b] [if text-file <> system/view/focal-face [return] insert system/view/caret a system/view/caret: skip system/view/caret b show text-file] jump: func [x] [system/view/caret: skip system/view/caret x show text-file] reb-source: [{REBOL [ Title: "" File: Date:} now/date { Author: "Jim Clatfelter" Purpose: [] ] view/layout [ ] } ] reb: reform reb-source view layout [ backdrop silver across space 0 style but button 72x20 green / 2 font-name font-fixed style but2 button 36x20 green / 2 font-name font-fixed style but3 button 72 gold text-file: area para [] 700x400 a-file silver white font-name font-fixed my-slider: slider 20x400 silver / 2 gold [scroll-para text-file my-slider] return pad 0x2 key #"^-" #"" [if text-file <> system/view/focal-face [return] system/view/caret: skip system/view/caret 0 show text-file] ; disable tab key but "<P>" #"" [put "<P>" 3] but "<BR>" #"" [put "<BR>" 4] but "&nbsp" #"" [put " &nbsp; " 8] but "<PRE>" #"" [put "<PRE></PRE>" 5] but "<UL>" #"" [put {</UL> <LI> </UL>} 10 ] but "<OL>" [put {</OL> <LI> </OL>} 10 ] but "<LI>" #"" [put "<LI>" 4] but "Link" #"" [put {<A HREF=""> </A>} 9] but "Image" #"" [put {<IMAGE SRC = ".jpg" ALIGN=left HSPACE=10>} 14] but "Clear" #"" [put {<BR CLEAR=all>} 15] return pad 0x4 but "<CENTER>" #"" [put "<CENTER></CENTER>" 8] but2 "H1" #"" [put "<H1></H1>" 4] but2 "H2" #"" [put "<H2></H2>" 4] but2 "H3" #"" [put "<H3></H3>" 4] but2 "H4" #"" [put "<H4></H4>" 4] but "Quote" #"" [put "<BLOCKQUOTE></BLOCKQUOTE>" 12] but2 "B" #"" [put "<B></B>" 3] but2 "I" #"" [put "<I></I>" 3] but2 "U" #"" [put "<U></U>" 3] but2 "HR" #"" [put "<HR>" 4] but "<FONT>" #"" [put {<FONT FACE="arial,helvetica"></FONT>} 29] but2 "+" #"" [put {<FONT SIZE="+1"></FONT>} 16] but2 "-" #"" [put {<FONT SIZE="-1"></FONT>} 16] but "line.gif" #"" [put {<IMAGE SRC = "line.gif">} 24] but "Date" #"" [put to-string now/date length? to-string now/date] return pad 0x4 button 72 "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 focus text-file show text-file top-flag: true ] ] button 72 "Save" #"^s" [ file-path: request-file/title/keep "Save File" "Save" if file-path <> none [ write first file-path text-file/text ] ] button 72 "Print" #"^p" [write %//prn join a-file #"^L"] button 72 "REBOL" #"" [if text-file <> system/view/focal-face [return] insert a-file reb show text-file jump 20] button 72 "HTML" [append a-file { <IMAGE SRC = "line.gif"> <P> </BLOCKQUOTE> </BODY> </HTML> } insert a-file { <HTML> <HEAD> <TITLE></TITLE> </HEAD> <BODY BGCOLOR="white"><BLOCKQUOTE> <H1> </H1> <IMAGE SRC = "line.gif"> <P> } focus text-file show text-file ] but3 "Home" [my-slider/data: 0 scroll-para text-file my-slider show [my-slider]] but3 "End" [my-slider/data: 1 scroll-para text-file my-slider show [my-slider]] button 72 red "Quit" #"^q" [unview/all] ]

 [5/5] from: hijim:pronet at: 6-Jul-2001 22:24


Volker, I got the buttons. It doesn't matter that they scroll slightly less than a page. That might be an advantage. Perfect! Jim rebol [Title: "HTML Tag Editor"] a-file: "" put: func [a b] [if text-file <> system/view/focal-face [return] insert system/view/caret a system/view/caret: skip system/view/caret b show text-file] jump: func [x] [system/view/caret: skip system/view/caret x show text-file] scroll-para: func [tf sf /local tmp] [ if none? tf/para [exit] tmp: min 0x0 tf/size - (size-text tf) - 0x30 either sf/size/x > sf/size/y [tf/para/scroll/x: sf/data * first tmp] [ tf/para/scroll/y: sf/data * second tmp] show tf ] reb-source: [{REBOL [ Title: "" File: Date:} now/date { Author: "Jim Clatfelter" Purpose: [] ] view/layout [ ] } ] reb: reform reb-source <PRE></PRE> view layout [ backdrop silver across space 0 style but button 72x20 green / 2 font-name font-fixed style but2 button 36x20 green / 2 font-name font-fixed style but3 button 72 gold text-file: area para [] 700x400 a-file silver white font-name font-fixed my-slider: slider 20x400 silver / 1.5 gold [scroll-para text-file my-slider] return pad 0x2 key #"^-" #"" [if text-file <> system/view/focal-face [return] system/view/caret: skip system/view/caret 0 show text-file] ; disable tab key but "<P>" #"" [put "<P>" 3] but "<BR>" #"" [put "<BR>" 4] but "&nbsp" #"" [put " &nbsp; " 8] but "<PRE>" #"" [put "<PRE></PRE>" 5] but "<UL>" #"" [put {</UL> <LI> </UL>} 10 ] but "<OL>" [put {</OL> <LI> </OL>} 10 ] but "<LI>" #"" [put "<LI>" 4] but "Link" #"" [put {<A HREF=""> </A>} 9] but "Image" #"" [put {<IMAGE SRC = ".jpg" ALIGN=left HSPACE=10>} 14] but "Clear" #"" [put {<BR CLEAR=all>} 15] return pad 0x4 but "<CENTER>" #"" [put "<CENTER></CENTER>" 8] but2 "H1" #"" [put "<H1></H1>" 4] but2 "H2" #"" [put "<H2></H2>" 4] but2 "H3" #"" [put "<H3></H3>" 4] but2 "H4" #"" [put "<H4></H4>" 4] but "Quote" #"" [put "<BLOCKQUOTE></BLOCKQUOTE>" 12] but2 "B" #"" [put "<B></B>" 3] but2 "I" #"" [put "<I></I>" 3] but2 "U" #"" [put "<U></U>" 3] but2 "HR" #"" [put "<HR>" 4] but "<FONT>" #"" [put {<FONT FACE="arial,helvetica"></FONT>} 29] but2 "+" #"" [put {<FONT SIZE="+1"></FONT>} 16] but2 "-" #"" [put {<FONT SIZE="-1"></FONT>} 16] but "line.gif" #"" [put {<IMAGE SRC = "line.gif">} 24] but "Date" #"" [put to-string now/date length? to-string now/date] return pad 0x4 button 72 "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 focus text-file show text-file top-flag: true ] ] button 72 "Save" #"^s" [ file-path: request-file/title/keep "Save File" "Save" if file-path <> none [ write first file-path text-file/text ] ] button 72 "Print" #"^p" [write %//prn join a-file #"^L"] button 72 "REBOL" #"" [if text-file <> system/view/focal-face [return] insert a-file reb show text-file jump 20] button 72 "HTML" [append a-file { <IMAGE SRC = "line.gif"> <P> </BLOCKQUOTE> </BODY> </HTML> } insert a-file { <HTML> <HEAD> <TITLE></TITLE> </HEAD> <BODY BGCOLOR="white"><BLOCKQUOTE> <H1> </H1> <IMAGE SRC = "line.gif"> <P> } focus text-file show text-file ] but3 "Home" [my-slider/data: 0 scroll-para text-file my-slider show [my-slider]] but3 "PgDn" [my-slider/data: my-slider/data + (text-file/size/y / second size-text text-file) scroll-para text-file my-slider show [my-slider]] but3 "PgUp" [my-slider/data: my-slider/data - (text-file/size/y / second size-text text-file) scroll-para text-file my-slider show [my-slider]] but3 "End" [my-slider/data: 1 scroll-para text-file my-slider show [my-slider]] button 72 red "Quit" #"^q" [unview/all] ]