AbstractSyntaxHighlighter.st
changeset 3561 f04a8db1590f
parent 3469 a12113e5281d
child 3599 a999663bd83f
equal deleted inserted replaced
3560:b0c86d7cb860 3561:f04a8db1590f
     8  be provided or otherwise made available to, or used by, any
     8  be provided or otherwise made available to, or used by, any
     9  other person.  No title to or ownership of the software is
     9  other person.  No title to or ownership of the software is
    10  hereby transferred.
    10  hereby transferred.
    11 "
    11 "
    12 "{ Package: 'stx:libcomp' }"
    12 "{ Package: 'stx:libcomp' }"
       
    13 
       
    14 "{ NameSpace: Smalltalk }"
    13 
    15 
    14 Parser subclass:#AbstractSyntaxHighlighter
    16 Parser subclass:#AbstractSyntaxHighlighter
    15 	instanceVariableNames:'method sourceText preferences fullSelectorCheck'
    17 	instanceVariableNames:'method sourceText preferences fullSelectorCheck'
    16 	classVariableNames:''
    18 	classVariableNames:''
    17 	poolDictionaries:''
    19 	poolDictionaries:''
   444 	p2 := p2 min:sourceText size
   446 	p2 := p2 min:sourceText size
   445     ].
   447     ].
   446     sourceText emphasizeFrom:pos1 to:p2 with:e
   448     sourceText emphasizeFrom:pos1 to:p2 with:e
   447 
   449 
   448     "Created: / 01-06-2012 / 21:44:17 / cg"
   450     "Created: / 01-06-2012 / 21:44:17 / cg"
       
   451 !
       
   452 
       
   453 mark:sourceText from:pos1 to:pos2 withEmphasis:fontEmp ifNil:fontEmp2 color:fgClr1 ifNil:fgClr2 backgroundColor:bgClr
       
   454     |e p2 clr fgClr|
       
   455 
       
   456     fgClr := fgClr1 ? fgClr2.
       
   457     (fgClr isNil or:[fgClr = Color black]) ifTrue:[
       
   458         e := fontEmp ? fontEmp2
       
   459     ] ifFalse:[
       
   460         clr := fgClr onDevice:Screen current.
       
   461         (fontEmp ? fontEmp2) isNil ifTrue:[
       
   462             e := (#color->clr)
       
   463         ] ifFalse:[
       
   464             e := Text addEmphasis:(fontEmp ? fontEmp2) to:(#color->clr).
       
   465         ]
       
   466     ].
       
   467     bgClr notNil ifTrue:[
       
   468         e := Text addEmphasis:(#backgroundColor->bgClr) to:e.
       
   469     ].
       
   470     (p2 := pos2) isNil ifTrue:[
       
   471         p2 := sourceText size
       
   472     ] ifFalse:[
       
   473         p2 := p2 min:sourceText size
       
   474     ].
       
   475     sourceText emphasizeFrom:pos1 to:p2 with:e
       
   476 
       
   477     "Created: / 01-06-2012 / 21:44:17 / cg"
   449 ! !
   478 ! !
   450 
   479 
   451 !AbstractSyntaxHighlighter methodsFor:'accessing'!
   480 !AbstractSyntaxHighlighter methodsFor:'accessing'!
   452 
   481 
   453 method:aMethod
   482 method:aMethod
   597 	mark:sourceText from:pos1 to:pos2 withEmphasis:fontEmp color:fgClr1 ifNil:fgClr2 backgroundColor:bgClr
   626 	mark:sourceText from:pos1 to:pos2 withEmphasis:fontEmp color:fgClr1 ifNil:fgClr2 backgroundColor:bgClr
   598 
   627 
   599     "Created: / 13-02-2012 / 11:48:09 / cg"
   628     "Created: / 13-02-2012 / 11:48:09 / cg"
   600 !
   629 !
   601 
   630 
       
   631 markFrom:pos1 to:pos2 withEmphasis:fontEmp ifNil:fontEmp2 color:fgClr1 ifNil:fgClr2 backgroundColor:bgClr
       
   632     self class
       
   633         mark:sourceText from:pos1 to:pos2 withEmphasis:fontEmp ifNil:fontEmp2 color:fgClr1 ifNil:fgClr2 backgroundColor:bgClr
       
   634 
       
   635     "Created: / 13-02-2012 / 11:48:09 / cg"
       
   636 !
       
   637 
   602 markVariable:v
   638 markVariable:v
   603     |pos endPos|
   639     |pos endPos|
   604 
   640 
   605     pos := tokenPosition.
   641     pos := tokenPosition.
   606     endPos := pos+tokenName size-1.
   642     endPos := pos+tokenName size-1.
   610 ! !
   646 ! !
   611 
   647 
   612 !AbstractSyntaxHighlighter class methodsFor:'documentation'!
   648 !AbstractSyntaxHighlighter class methodsFor:'documentation'!
   613 
   649 
   614 version
   650 version
   615     ^ '$Header: /cvs/stx/stx/libcomp/AbstractSyntaxHighlighter.st,v 1.32 2014-06-10 10:21:56 cg Exp $'
   651     ^ '$Header: /cvs/stx/stx/libcomp/AbstractSyntaxHighlighter.st,v 1.33 2015-02-01 21:53:37 cg Exp $'
   616 !
   652 !
   617 
   653 
   618 version_CVS
   654 version_CVS
   619     ^ '$Header: /cvs/stx/stx/libcomp/AbstractSyntaxHighlighter.st,v 1.32 2014-06-10 10:21:56 cg Exp $'
   655     ^ '$Header: /cvs/stx/stx/libcomp/AbstractSyntaxHighlighter.st,v 1.33 2015-02-01 21:53:37 cg Exp $'
   620 !
   656 !
   621 
   657 
   622 version_SVN
   658 version_SVN
   623     ^ '$ Id $'
   659     ^ '$ Id $'
   624 ! !
   660 ! !
       
   661