Tools__CodeHighlightingService.st
changeset 10721 6813188d742b
parent 10710 5aa37ab3189e
child 10729 f4109bfaad31
equal deleted inserted replaced
10720:82b4939aafc5 10721:6813188d742b
    76 ! !
    76 ! !
    77 
    77 
    78 !CodeHighlightingService methodsFor:'accessing'!
    78 !CodeHighlightingService methodsFor:'accessing'!
    79 
    79 
    80 syntaxHighlighter
    80 syntaxHighlighter
    81     | app lang highlighter mthd class |
    81     | app lang highlighter |
    82 
    82 
    83     "First, ask application..."
    83     "First, ask application..."
    84     app := codeView application.
    84     app := codeView application.
    85     mthd := codeView methodHolder value.
       
    86     class := codeView classHolder value.
       
    87     app notNil ifTrue:[
    85     app notNil ifTrue:[
       
    86         | mthd class |
       
    87 
       
    88         mthd := codeView methodHolder value.
       
    89         class := codeView classHolder value.
    88         (mthd notNil and:[app respondsTo: #syntaxHighlighterForMethod:]) ifTrue:[
    90         (mthd notNil and:[app respondsTo: #syntaxHighlighterForMethod:]) ifTrue:[
    89             highlighter := app syntaxHighlighterForMethod:mthd.
    91             highlighter := app syntaxHighlighterForMethod:mthd.
    90         ] ifFalse:[
    92         ] ifFalse:[
    91             (class notNil and:[app respondsTo: #syntaxHighlighterForClass:]) ifTrue:[                        
    93             (class notNil and:[app respondsTo: #syntaxHighlighterForClass:]) ifTrue:[                        
    92                 highlighter := app syntaxHighlighterForClass: class.
    94                 highlighter := app syntaxHighlighterForClass: class.
       
    95             ] ifFalse:[
       
    96                 (class notNil and:[app respondsTo: #syntaxHighlighter]) ifTrue:[                        
       
    97                     highlighter := app syntaxHighlighterClass.
       
    98                 ].
    93             ].
    99             ].
    94         ]
   100         ]
    95     ].
   101     ].
    96     "App did not provide any highlighter..."
   102     "App did not provide any highlighter..."
    97     highlighter isNil ifTrue:[        
   103     highlighter isNil ifTrue:[        
   103     highlighter == SyntaxHighlighter ifTrue:[
   109     highlighter == SyntaxHighlighter ifTrue:[
   104         highlighter := SyntaxHighlighter2
   110         highlighter := SyntaxHighlighter2
   105     ].
   111     ].
   106     ^ highlighter
   112     ^ highlighter
   107 
   113 
   108     "Modified: / 05-07-2011 / 11:10:11 / cg"
       
   109     "Created: / 05-08-2011 / 10:48:55 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   114     "Created: / 05-08-2011 / 10:48:55 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
   115     "Modified: / 26-09-2011 / 15:50:10 / cg"
   110 !
   116 !
   111 
   117 
   112 syntaxHighlighters
   118 syntaxHighlighters
   113 
   119 
   114     | highlighters |
   120     | highlighters |
   182 !CodeHighlightingService methodsFor:'initialization'!
   188 !CodeHighlightingService methodsFor:'initialization'!
   183 
   189 
   184 initialize
   190 initialize
   185 
   191 
   186     job := (Smalltalk at:#BackgroundJob)
   192     job := (Smalltalk at:#BackgroundJob)
   187 	    named: 'Syntax Highlighting Job'
   193                 named: 'Syntax Highlighting Job'
   188 	    on:[self syntaxHighlight: true].
   194                 on:[self syntaxHighlight: true].
   189 
   195 
   190     "Created: / 29-07-2011 / 10:31:03 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   196     "Created: / 29-07-2011 / 10:31:03 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   191     "Modified: / 03-08-2011 / 16:47:53 / cg"
   197     "Modified: / 03-08-2011 / 16:47:53 / cg"
       
   198     "Modified (format): / 26-09-2011 / 15:39:56 / cg"
   192 ! !
   199 ! !
   193 
   200 
   194 !CodeHighlightingService methodsFor:'private'!
   201 !CodeHighlightingService methodsFor:'private'!
   195 
   202 
   196 codeChanged: force
   203 codeChanged: force
   289 
   296 
   290 syntaxHighlight
   297 syntaxHighlight
   291 
   298 
   292     |highlighters prio |
   299     |highlighters prio |
   293 
   300 
   294     highlighters := self syntaxHighlighters.
   301     (highlighters := self syntaxHighlighters) isEmptyOrNil ifTrue:[
   295 
       
   296     highlighters isEmptyOrNil ifTrue:[
       
   297         "No higlighter, nothing to do"
   302         "No higlighter, nothing to do"
   298         ^self
   303         ^self
   299     ].
   304     ].
   300 
   305 
   301     "/ this clobbers the codeViews modified state; therefore, we have to remember
   306     "/ this clobbers the codeViews modified state; therefore, we have to remember
   322 
   327 
   323     job startWithPriority: prio.
   328     job startWithPriority: prio.
   324 
   329 
   325     "Modified: / 07-07-2011 / 12:26:12 / Jan Vrany <jan.vrant@fit.cvut,cz>"
   330     "Modified: / 07-07-2011 / 12:26:12 / Jan Vrany <jan.vrant@fit.cvut,cz>"
   326     "Created: / 29-07-2011 / 11:07:42 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   331     "Created: / 29-07-2011 / 11:07:42 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   327     "Modified: / 22-08-2011 / 14:17:43 / cg"
   332     "Modified: / 26-09-2011 / 15:40:23 / cg"
   328 !
   333 !
   329 
   334 
   330 syntaxHighlight: delayed
   335 syntaxHighlight: delayed
   331 
   336 
   332     |oldCode oldCodeList newCode elements cls mthd highlighterClasses|
   337     |oldCode oldCodeList newCode elements cls mthd highlighterClasses|
   427 ! !
   432 ! !
   428 
   433 
   429 !CodeHighlightingService class methodsFor:'documentation'!
   434 !CodeHighlightingService class methodsFor:'documentation'!
   430 
   435 
   431 version
   436 version
   432     ^ '$Header: /cvs/stx/stx/libtool/Tools__CodeHighlightingService.st,v 1.23 2011-09-16 16:37:16 vrany Exp $'
   437     ^ '$Header: /cvs/stx/stx/libtool/Tools__CodeHighlightingService.st,v 1.24 2011-09-26 14:37:15 cg Exp $'
   433 !
   438 !
   434 
   439 
   435 version_CVS
   440 version_CVS
   436     ^ '$Header: /cvs/stx/stx/libtool/Tools__CodeHighlightingService.st,v 1.23 2011-09-16 16:37:16 vrany Exp $'
   441     ^ '$Header: /cvs/stx/stx/libtool/Tools__CodeHighlightingService.st,v 1.24 2011-09-26 14:37:15 cg Exp $'
   437 !
   442 !
   438 
   443 
   439 version_SVN
   444 version_SVN
   440     ^ '§Id: Tools__CodeHighlightingService.st 7715 2011-04-10 16:32:58Z vranyj1 §'
   445     ^ '§Id: Tools__CodeHighlightingService.st 7715 2011-04-10 16:32:58Z vranyj1 §'
   441 ! !
   446 ! !