Hello Tom,
Wednesday, March 1, 2006, 7:30:55 PM, you wrote:
> Thank you for this. Is there any chance I could get a short code example? I'm not sure I know what
> you mean by "I 'OR' either $10 or $20 to represent bold or/and italic text". What are $10 and $20? I
> hope that's not a horribly stupid question... ;-(
No problem, this is 2 bits of code - the first sets up the call to the second. Its written in PureBasic but its fairly easy to understand what it does and shouldn't be a problem converting it to C. I've added a few comments as my code usually has very little. :)
; this is in the middle of a menu select statement (kinda, but this is the simplest way to describe it!)
Case #M_Bold ; in PureBasic '#' signals a predefined constant
val=%010000 ; '%' signals the number is in binary (this number is 16)
msk=%101111
btn=#M_Bold
Gosub DoBoldUnderline
Case #M_Underline
val=%100000
msk=%011111
btn=#M_Underline
Gosub DoBoldUnderline
.
.
.
; this is the routine called from the gosubs above....
DoBoldUnderline:
startrange=SCI_GetSelectionStart() ; Scintilla calls have 'SCI_' infront of them
stoprange=SCI_GetSelectionEnd()
If startrange<>stoprange ; do this bit if text selected - it changes the selected text!
CheckHistory() ; this is basically a call to my history saver (undo/redo)
st2=SCI_GetStyleAt(startrange)&val
For LOOP=startrange To stoprange-1
sts=SCI_GetStyleAt(LOOP)
st=sts&$7f ; in PureBasic '$' singals the number is hex-decimal (this number is 127)
sts&$80
If st>=#StyleBase ; StyleBase is the offset I mentioned
st-#StyleBase
If st2=0
st | val ; in PureBasic '|' is OR
Else
st & msk ; in PureBasic '&' is AND
EndIf
SCI_StartStyling(LOOP,$ff)
SCI_SetStyling(1,(#StyleBase+st)|sts)
EndIf
Next
ClassChanged=#True ; signal for the quit routine to ask for a save before quit!
History=#True ; something has change flag for undo/redo routines
Else ; or this bit if no text selected - just sets flags for text being typed
If FontFx & val = 0
FontFx | val
Else
FontFx & msk
EndIf
EndIf
If FontFx & val = 0 ; turn the button on or off
boldunderlinestate=0
Else
boldunderlinestate=1
EndIf
UseTB(#EditToolbar)
PushTBbutton(btn,boldunderlinestate)
UseTB(#SubjectToolbar)
PushTBbutton(btn,boldunderlinestate)
Return
> Here's what I'm working on, in case anybody is interested:
> http://www.gersic.com/zulupad
Nice. :)
--
Best regards,
Anthony mailto:[EMAIL PROTECTED]
_______________________________________________ Scintilla-interest mailing list [email protected] http://mailman.lyra.org/mailman/listinfo/scintilla-interest
