FB II Compiler

PG PRO

Debugging

Memory

System

Mathematics

Resources

Disk I/O

Windows

Controls

Menus

Mouse

Keyboard

Text

Fonts

Drawing

Sound

Clipboard

Printing

Communication

ASM

Made with FB

PG PRO

Scroll button in sync with a text field


I'm working on a little Terminal programme using PG.

I have been able to keep the scroll button in sync with the incoming text using,

CALL TEINSERT (@gTheChar$ + 1, LEN(gTheChar$) - 1, gTEHndl&)
TEKEY$ = RIGHT$ (gTheChar$, 1)

However in order to get around the TEedit 32K limit I'm using the following,

txtLgth% = TEHndl&..TELength%

LONG IF gtxtLgth% > 16000
  CurrentNumLines% = TEHndl&..teNLines%
  LinesToChop% = CurrentNumLines% - OldNumLines% '(OldNumLines% is before I insert any new text)
  LinesToChop% = LinesToChop% + 1
  StartChar% = {[TEHndl&] + _teLines + 2 * LinesToChop%}' look up start
  char in line
  %[TEHndl&]+_teSelStart, 0
  %[TEHndl&]+_teSelEnd, StartChar%
  CALL TEAUTOVIEW(_FALSE,TEHndl&)
  CALL TEDELETE (TEHndl&)
  CALL TEUPDATE (TEHndl&..viewRect%,TEHndl&)
  CALL TESETSELECT(32767,32767,TEHndl&)
  CALL TEAUTOVIEW(_True,TEHndl&)
END IF

This in it's self works OK but the scroll button doesn't keep sync with the window. If I move the scroll button back up the window and then down again it updates and things return to normal.

Anyone know of a get around so that I can force PG to update the scroll bar and button after I've deleted some of the text ?

Sean


Try adding a TEKEY$ with an empty string. Not sure if it will work and you might have to play around with which line to put it between.

txtLgth% = TEHndl&..TELength%
LONG IF gtxtLgth% > 16000
  CurrentNumLines% = TEHndl&..teNLines%
  LinesToChop% = CurrentNumLines% - OldNumLines% '(OldNumLines% is before I insert any new text)
  LinesToChop% = LinesToChop% + 1
  StartChar% = {[TEHndl&] + _teLines + 2 * LinesToChop%}' look up start
  char in line
  %[TEHndl&]+_teSelStart, 0
  %[TEHndl&]+_teSelEnd, StartChar%
  CALL TEAUTOVIEW(_FALSE,TEHndl&)
  CALL TEDELETE (TEHndl&)
  CALL TEUPDATE (TEHndl&..viewRect%,TEHndl&)
  CALL TESETSELECT(32767,32767,TEHndl&)
  TEKEY$ = "" ' <--- try adding this line
  CALL TEAUTOVIEW(_True,TEHndl&)
END IF

Al Staffieri Jr.


I have a little PG Pro project which has a little terminal text window with which I want to be able to do to things.

1. Insert text using TEInsert.
2. Limit the amount of text in the window so I don't have to worry about the TEEdit 32K limit but keep been able to insert text as needed.

The first part I have achived OK using Staz's idea of using TEKEY$ for the last char I want to insert (this seems to keep the PG scroll button in sync with the edit field).

However when I start trying to limit the amount of text in the window PG seems to loose track my scrolling goes potty. However if I click in the scroll bar it seems to force PG to do an update and everything goes back into sync.

Anyone any suggestions as to how I can keep the scroll bar in sync with the text or is there a better way to do this anyway ?

My code so far,

LOCAL FN MyInsertText

  WINDOW OUTPUT #_MonitorWnd
  TEHndl& = TEHANDLE(_MonitorFld)
  osErr% = FN HLOCK(TEHndl&)
  AUTOCLIP = _False
  lastChar$ = RIGHT$(gTheChar$,1) ' gTheChar$ is the char string I want to insert.
  gTheChar$ = LEFT$(gTheChar$,(LEN(gTheChar$) - 1))

  txtLgth% = TEHndl&..TELength%
  LONG IF txtLgth% > 2000
    newSize& = txtLgth% - (LEN (gTheChar$) + 1) ' + 1 to replace the char I removed with LastChar$
    NewText& = FN NEWHANDLE (newSize&)
    LONG IF newText&
      TextHndl& = FN TEGETTEXT(TEHndl&)
      BLOCKMOVE [TextHndl&] + (LEN (gTheChar$ + 1)),[newText&],newSize&
      CALL TESETTEXT ([newText&], newSize&, TEHndl&)
      DEF DISPOSEH (newText&)
      CALL TEUPDATE(TEHndl&..teViewRect%,TEHndl&)
      txtLgth% = TEHndl&..TELength%
    END IF
  END IF
  %[TEHndl&]+_teSelStart, gtxtLgth% 'This just keep the screen from flashing when you select text.
  %[TEHndl&]+_teSelEnd, gtxtLgth%
  CALL TEINSERT (@gTheChar$ + 1, LEN(gTheChar$), TEHndl&)
  TEKEY$ = LastChar$
  AUTOCLIP = _True
END FN

Sean