[futurebasic] RE: [FB^3] Color text in EF... again

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : February 2000 : Group Archive : Group : All Groups

From: Ken Shmidheiser <kshmidheiser@...>
Date: Wed, 9 Feb 2000 07:13:32 -0500
Ken wrote:

>Perhaps others on the list can examine this code's implementation in 
>the following engine and figure out how to correct it. The color 
>insertion works, but the entire body of text is shifted down one 
>line by the carriage return.
>
>I've commented the code in the problem area. Any suggestions on this 
>one will be welcome.


Well, I fixed my own problem. Please ignore my earlier post. The 
following code inserts colorized text just fine. Next step is to 
tweak it to work with Al's code.


Ken


Please adjust for e-mail line breaks. There are some long lines in this one.

'------- Begin --------

begin globals

DIM gObjClr.6'Select red color
gObjClr.red% = 56797
gObjClr.green% = 0
gObjClr.blue% = 0

dim gProgramEnds

end globals

local fn initialize
WINDOW 1, "Colorizing Text Selections",(0,0)-(400,245),_docNoGrow

APPLE MENU "(Ken's Colorizing Text Selections Demo"
MENU 1,0, _enable, "File"
MENU 1,1, _enable, "/QQuit"
edit menu 2

button 1,_enable, "Quit", (320,207)-(380,230), _shadow
button 2,_enable, "Click to insert colorized text...", 
(90,207)-(305,230), _push

edit = 4

EDIT FIELD 1, "Type text to be colorized here, then click button 
below or hit Return key.", (20,8)-(255,33), _statNoframed, _leftJust
EDIT FIELD -2, "", (20,35)-(380,80), _framedNoCR

EDIT FIELD 3, "Click button to insert colorized text below:", 
(20,98)-(380,110), _statNoframed, _leftJust
EDIT FIELD -4, "The colored text will be inserted here: ", 
(20,115)-(380,190), _framed'NoCR

Edit field 2

end fn


local fn textTransfer
edit$(4) = "The colored text will be inserted here: "'reset EF4

a$ = edit$(2)
theTxt$ = a$

AUTOCLIP = _false                      'disable auto-clipping
edit field 4'activate EF4 for colorizing

TEHndl& = TEHANDLE(4)                  'grab field's text edit handle
txtLgth = {[TEHndl&]+_TELength}     'get the text length

CALL TESETSELECT(txtLgth,txtLgth,TEHndl&) 'put cursor at end of field

EDIT TEXT ,,,,gObjClr.red%,gObjClr.green%,gObjClr.blue%'colorize inserted text

CALL TEINSERT(@theTxt$ + 1,LEN(theTxt$),TEHndl&)'insert the text now

SETSELECT 0,0
CALL TESETSELECT(0,0,TEHndl&)
EDIT FIELD 0

AUTOCLIP=_zTrue                       're-enable auto-clipping

delay 2000
edit field 2'reactivate EF2
edit$(2) = "I'm ready to go again."
delay 2000
edit$(2) = ""

end fn


local fn doDialog
dim evnt%
dim id%
evnt% = DIALOG(0)
id% = DIALOG(evnt)

select case evnt%
case _wndClose
select id%
case 1
gProgramEnds = _true
end select

case _efReturn
select id%
Case 2
fn textTransfer
end select

case _btnClick
select id%
case 1
gProgramEnds = _true

case 2
fn textTransfer

end select

end select
end fn

local fn doMenu
dim selectedMenu%
dim selectedItem%
selectedMenu% = MENU(_menuID)
selectedItem% = MENU(_itemID)

select case selectedMenu%
case 1
select selectedItem%
case 1
gProgramEnds = _true
end select
end select
end fn

LOCAL FN doEdit
dim k$
k$ = TEKEY$

SELECT CASE k$
case k$
EDIT TEXT ,,,,gObjClr.red%,gObjClr.green%,gObjClr.blue%'57697,0,0 '(red)
case else
EDIT TEXT ,,,,0,0,0'black
eND SELECT

TEKEY$ = k$

END FN

on dialog fn doDialog
on menu fn doMenu
ON EDIT FN doEdit

fn initialize

DO
HANDLEEVENTS
UNTIL gProgramEnds = _true

'-------- End ----------