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

[REBOL] Re: Text Area scroll.

From: didier:cadieu:freesbee at: 9-Dec-2003 23:41

Re: Text Area scroll. Here is a demo It demonstrate the adjustment of the scroller when you edit the area. More works is needed for, in example, adjusting the scroller when you change the text in the area by programing. DideC
> Hello. > > By know I learned how to use scroll bars in text areas to scroll the text > inside it (vertically and horizontally). Now I need the scroll bars to > auto-move to represent the current position being displayed in the text > view when I use the cursor keys to move around the text. I also need to > know how to scroll the text area to a specific text position (like scroll > to top and scroll to bottom). > > Any help will be apreciated. > > -Bruno
REBOL [ title: "Demo of area with scrollers" author: "Didier Cadieu (DideC)" date: 8-dec-2003 version 1.0.0 purpose: { Illustrate an area with 2 scrollers following the cursors. } ] para-scroll: func [ {move a slider according scroll position in a text field} tf {text face} sf {slider face} /redrag {also redrag the slider} /local tmp t ] [ if none? tf/para [exit] tmp: min 1x1 tf/size - 0x30 - size-text tf t: either sf/size/x > sf/size/y [1][2] sf/data: max 0 min 1 tf/para/scroll/:t / tmp/:t if redrag [sf/redrag min 1 tf/size/:t / max 1 pick size-text tf t] show sf ] tx: {1. Introduction to VID With REBOL/View it's easy and quick to create your own user interfaces. The purpose of this tutorial is to teach you the basic concepts or REBOL/View interfaces in about 20 minutes. VID is REBOL's Visual Interface Dialect. A dialect is an extension of the REBOL language that makes it easier to express or describe information, actions, or interfaces. VID is a dialect that provides a powerful method of describing user interfaces. VID is simple to learn and provides a smooth learning curve from basic user interfaces to sophisticated distributed computing applications. 1.1. Creating VID Interfaces VID interfaces are written in plain text. You can use any text editor to create and edit your VID script. Save your script as a text file, and run it with REBOL/View. } view layout [ origin 8x8 across vh3 "Area scroll demo" return text "Edit the text in this area :" return space 0x0 a: area 200x100 tx with [ link-to: none ; store the linked scrollers feel: make feel [ engage: func [face act event /local tmp] [ switch act [ down [ either not-equal? face system/view/focal-face [ focus face system/view/caret: offset-to-caret face event/offset ] [ system/view/highlight-start: system/view/highlight-end: none system/view/caret: offset-to-caret face event/offset ] show face ] over [ if not-equal? system/view/caret offset-to-caret face event/offset [ if not system/view/highlight-start [system/view/highlight-start: system/view/caret] system/view/highlight-end: system/view/caret: offset-to-caret face event/offset show face ] ] key [ ctx-text/edit-text face event get in face 'action ;**** Here is the modif to the feel object if block? face/link-to [ foreach tmp face/link-to [para-scroll/redrag face tmp] ] ] ] ] ] ] sv: scroller 16x100 [scroll-para a face] return sh: scroller 200x16 [scroll-para a face] return do [ ; store the linked scroller and init the scroller. a/link-to: reduce [sv sh] sv/redrag min 1 a/size/y / max 1 second size-text a sh/redrag min 1 a/size/x / max 1 first size-text a ] ]