CodeView.st
author Claus Gittinger <cg@exept.de>
Wed, 12 Jun 1996 14:55:00 +0200
changeset 760 62824e1f2607
parent 583 2ec13b7ceba5
child 880 a75287739271
permissions -rw-r--r--
checkin from browser
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
     1
"
4
88eb91574867 *** empty log message ***
claus
parents: 2
diff changeset
     2
 COPYRIGHT (c) 1989 by Claus Gittinger
70
14443a9ea4ec *** empty log message ***
claus
parents: 59
diff changeset
     3
	      All Rights Reserved
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
     4
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
     5
 This software is furnished under a license and may be used
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
     6
 only in accordance with the terms of that license and with the
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
     8
 be provided or otherwise made available to, or used by, any
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
     9
 other person.  No title to or ownership of the software is
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    10
 hereby transferred.
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    11
"
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    12
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    13
Workspace subclass:#CodeView
419
2bd5f73fffd2 commentary
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
    14
	instanceVariableNames:'explainAction'
2bd5f73fffd2 commentary
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
    15
	classVariableNames:''
2bd5f73fffd2 commentary
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
    16
	poolDictionaries:''
2bd5f73fffd2 commentary
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
    17
	category:'Interface-Workspace'
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    18
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    19
32
b6c23dfd5663 *** empty log message ***
claus
parents: 27
diff changeset
    20
!CodeView class methodsFor:'documentation'!
b6c23dfd5663 *** empty log message ***
claus
parents: 27
diff changeset
    21
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 32
diff changeset
    22
copyright
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 32
diff changeset
    23
"
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 32
diff changeset
    24
 COPYRIGHT (c) 1989 by Claus Gittinger
70
14443a9ea4ec *** empty log message ***
claus
parents: 59
diff changeset
    25
	      All Rights Reserved
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 32
diff changeset
    26
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 32
diff changeset
    27
 This software is furnished under a license and may be used
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 32
diff changeset
    28
 only in accordance with the terms of that license and with the
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 32
diff changeset
    29
 inclusion of the above copyright notice.   This software may not
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 32
diff changeset
    30
 be provided or otherwise made available to, or used by, any
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 32
diff changeset
    31
 other person.  No title to or ownership of the software is
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 32
diff changeset
    32
 hereby transferred.
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 32
diff changeset
    33
"
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 32
diff changeset
    34
!
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 32
diff changeset
    35
32
b6c23dfd5663 *** empty log message ***
claus
parents: 27
diff changeset
    36
documentation
b6c23dfd5663 *** empty log message ***
claus
parents: 27
diff changeset
    37
"
125
claus
parents: 123
diff changeset
    38
    a view for text which is known to be smalltalk code. 
419
2bd5f73fffd2 commentary
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
    39
    It adds 'explain' to the menu, and defines another action: 
125
claus
parents: 123
diff changeset
    40
      explainAction to be performed for explain.
32
b6c23dfd5663 *** empty log message ***
claus
parents: 27
diff changeset
    41
125
claus
parents: 123
diff changeset
    42
    This action is to be defined by the user of this view 
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 32
diff changeset
    43
    (i.e. ususally the owning browser)
121
claus
parents: 118
diff changeset
    44
419
2bd5f73fffd2 commentary
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
    45
    In addition, uncomment/comment are added to the controlMenu.
2bd5f73fffd2 commentary
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
    46
    These are smalltalk specific - if you plan to edit other language code,
2bd5f73fffd2 commentary
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
    47
    you need a different kind of CodeView for that.
2bd5f73fffd2 commentary
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
    48
125
claus
parents: 123
diff changeset
    49
    If used with a model, accept sends the changeMsg to it (as defined in EditTextView).
419
2bd5f73fffd2 commentary
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
    50
    (however, it is possible to define both changeMsg and acceptAction)
123
claus
parents: 121
diff changeset
    51
419
2bd5f73fffd2 commentary
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
    52
    See how doIt/printIt/inspectIt are handled in the superclass: Workspace.
123
claus
parents: 121
diff changeset
    53
claus
parents: 121
diff changeset
    54
    Caveat:
419
2bd5f73fffd2 commentary
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
    55
        in this version, CodeView does not yet support MVC setups for doIt
2bd5f73fffd2 commentary
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
    56
        and explain.
2bd5f73fffd2 commentary
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
    57
        If required, simulate this by setting the doItAction and
2bd5f73fffd2 commentary
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
    58
        explainAction, to notify the model manually about whats going on.
583
2ec13b7ceba5 documentation
Claus Gittinger <cg@exept.de>
parents: 489
diff changeset
    59
2ec13b7ceba5 documentation
Claus Gittinger <cg@exept.de>
parents: 489
diff changeset
    60
    [author:]
2ec13b7ceba5 documentation
Claus Gittinger <cg@exept.de>
parents: 489
diff changeset
    61
        Claus Gittinger
2ec13b7ceba5 documentation
Claus Gittinger <cg@exept.de>
parents: 489
diff changeset
    62
2ec13b7ceba5 documentation
Claus Gittinger <cg@exept.de>
parents: 489
diff changeset
    63
    [see also:]
2ec13b7ceba5 documentation
Claus Gittinger <cg@exept.de>
parents: 489
diff changeset
    64
        Workspace EditTextView TextView
32
b6c23dfd5663 *** empty log message ***
claus
parents: 27
diff changeset
    65
"
201
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    66
! !
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    67
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    68
!CodeView methodsFor:'accessing'!
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    69
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    70
explainAction:aBlock
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    71
    "set the action to be performed on explain"
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    72
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    73
    explainAction := aBlock
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    74
! !
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    75
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    76
!CodeView methodsFor:'editing'!
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    77
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    78
commentFrom:line1 to:line2
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    79
    "convenient function to comment out a block.
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    80
     All lines from line1 to line2 get an end-of-line comment
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    81
     in the first col."
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    82
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    83
    line1 to:line2 do:[:lineNr |
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    84
	|l|
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    85
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    86
	l := self listAt:lineNr.
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    87
	l isNil ifTrue:[l := ''].
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    88
	self at:lineNr put:(('"' , '/') , l)
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    89
    ].
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    90
    self textChanged.
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    91
!
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    92
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    93
uncommentFrom:line1 to:line2
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    94
    "convenient function to comment out a block.
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    95
     All lines from line1 to line2 get an end-of-line comment
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    96
     in the first col."
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    97
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    98
    line1 to:line2 do:[:lineNr |
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    99
	|l|
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   100
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   101
	l := self listAt:lineNr.
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   102
	(l notNil and:[l startsWith:('"' ,'/')]) ifTrue:[
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   103
	    self at:lineNr put:(l copyFrom:3)
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   104
	]
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   105
    ].
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   106
    self textChanged.
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   107
! !
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   108
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   109
!CodeView methodsFor:'event handling'!
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   110
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   111
keyPress:key x:x y:y
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   112
    "catch keyboard shortcuts"
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   113
274
6df4bb990f04 handle accept where acceptAction is define (this was a historic leftover)
Claus Gittinger <cg@exept.de>
parents: 206
diff changeset
   114
    <resource: #keyboard (#Explain #Help 
201
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   115
	       #CommentSelection #UncommentSelection)>
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   116
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   117
    (key == #Explain) ifTrue:[^ self explain].
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   118
    (key == #Help)    ifTrue:[^ self explain].
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   119
    (key == #CommentSelection)    ifTrue:[^ self commentSelection].
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   120
    (key == #UncommentSelection)  ifTrue:[^ self uncommentSelection].
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   121
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   122
    super keyPress:key x:x y:y
32
b6c23dfd5663 *** empty log message ***
claus
parents: 27
diff changeset
   123
! !
b6c23dfd5663 *** empty log message ***
claus
parents: 27
diff changeset
   124
419
2bd5f73fffd2 commentary
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
   125
!CodeView methodsFor:'menu & menu actions'!
2bd5f73fffd2 commentary
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
   126
2bd5f73fffd2 commentary
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
   127
accept
2bd5f73fffd2 commentary
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
   128
    "redefined accept action;
2bd5f73fffd2 commentary
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
   129
     save cursor and selection to allow restore in case of an error
2bd5f73fffd2 commentary
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
   130
     (we are typically compiling here ... and the compiler may show
2bd5f73fffd2 commentary
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
   131
     errors by highlighting them)"
2bd5f73fffd2 commentary
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
   132
2bd5f73fffd2 commentary
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
   133
    codeStartPosition := 1.
2bd5f73fffd2 commentary
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
   134
    [
2bd5f73fffd2 commentary
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
   135
	AbortSignal handle:[:ex |
2bd5f73fffd2 commentary
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
   136
	    self cursor:Cursor normal.
2bd5f73fffd2 commentary
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
   137
	    "redraw selection in normal color"
2bd5f73fffd2 commentary
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
   138
	    self selectFromLine:selectionStartLine col:selectionStartCol 
2bd5f73fffd2 commentary
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
   139
			 toLine:selectionEndLine col:selectionEndCol.
2bd5f73fffd2 commentary
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
   140
	    ex return
2bd5f73fffd2 commentary
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
   141
	] do:[
2bd5f73fffd2 commentary
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
   142
	    super accept.
2bd5f73fffd2 commentary
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
   143
	]
2bd5f73fffd2 commentary
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
   144
    ] valueNowOrOnUnwindDo:[
2bd5f73fffd2 commentary
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
   145
	self unselect.
2bd5f73fffd2 commentary
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
   146
    ]
2bd5f73fffd2 commentary
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
   147
!
2bd5f73fffd2 commentary
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
   148
2bd5f73fffd2 commentary
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
   149
commentSelection
2bd5f73fffd2 commentary
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
   150
    "convenient function to comment out a block.
2bd5f73fffd2 commentary
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
   151
     All lines from line1 to line2 get an end-of-line comment
2bd5f73fffd2 commentary
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
   152
     in the first col."
2bd5f73fffd2 commentary
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
   153
2bd5f73fffd2 commentary
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
   154
    |e|
2bd5f73fffd2 commentary
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
   155
2bd5f73fffd2 commentary
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
   156
    (selectionStartCol == 1 and:[selectionEndCol == 0]) ifTrue:[
2bd5f73fffd2 commentary
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
   157
	self commentFrom:selectionStartLine to:selectionEndLine-1
2bd5f73fffd2 commentary
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
   158
    ] ifFalse:[
2bd5f73fffd2 commentary
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
   159
	self insert:$" atLine:selectionStartLine col:selectionStartCol.
2bd5f73fffd2 commentary
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
   160
	e := selectionEndCol + 1.
2bd5f73fffd2 commentary
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
   161
	selectionStartLine == selectionEndLine ifTrue:[e := e + 1].
2bd5f73fffd2 commentary
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
   162
	self insert:$" atLine:selectionEndLine col:e.
2bd5f73fffd2 commentary
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
   163
	self selectFromLine:selectionStartLine col:selectionStartCol
2bd5f73fffd2 commentary
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
   164
		     toLine:selectionEndLine col:e.
2bd5f73fffd2 commentary
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
   165
    ]
2bd5f73fffd2 commentary
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
   166
!
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   167
97
cbf495fe3b64 *** empty log message ***
claus
parents: 95
diff changeset
   168
editMenu
121
claus
parents: 118
diff changeset
   169
    "return the popUpMenu;
claus
parents: 118
diff changeset
   170
     to make this independent from what is defined in superclasses,
claus
parents: 118
diff changeset
   171
     get the superclass menu and add my functions."
131
claus
parents: 125
diff changeset
   172
489
5816aa12fec8 resources
Claus Gittinger <cg@exept.de>
parents: 464
diff changeset
   173
    <resource: #keyboard (#CommentSelection #UncommentSelection 
5816aa12fec8 resources
Claus Gittinger <cg@exept.de>
parents: 464
diff changeset
   174
                          #Accept #Explain)>
5816aa12fec8 resources
Claus Gittinger <cg@exept.de>
parents: 464
diff changeset
   175
464
6bd2186ca548 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 430
diff changeset
   176
    |m sub|
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 32
diff changeset
   177
97
cbf495fe3b64 *** empty log message ***
claus
parents: 95
diff changeset
   178
    m := super editMenu.
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   179
131
claus
parents: 125
diff changeset
   180
    self sensor ctrlDown ifTrue:[
430
022b667e0d70 added accelerator display
Claus Gittinger <cg@exept.de>
parents: 419
diff changeset
   181
        m addLabels:(resources array:#('-' 'commentIt' 'uncommentIt'))
022b667e0d70 added accelerator display
Claus Gittinger <cg@exept.de>
parents: 419
diff changeset
   182
          selectors:#(nil commentSelection uncommentSelection)
022b667e0d70 added accelerator display
Claus Gittinger <cg@exept.de>
parents: 419
diff changeset
   183
          accelerators:#(nil CommentSelection UncommentSelection)
464
6bd2186ca548 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 430
diff changeset
   184
          after:#again.
430
022b667e0d70 added accelerator display
Claus Gittinger <cg@exept.de>
parents: 419
diff changeset
   185
022b667e0d70 added accelerator display
Claus Gittinger <cg@exept.de>
parents: 419
diff changeset
   186
        self hasSelection ifFalse:[
022b667e0d70 added accelerator display
Claus Gittinger <cg@exept.de>
parents: 419
diff changeset
   187
            m disableAll:#(commentSelection uncommentSelection) 
022b667e0d70 added accelerator display
Claus Gittinger <cg@exept.de>
parents: 419
diff changeset
   188
        ].
131
claus
parents: 125
diff changeset
   189
    ] ifFalse:[
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 32
diff changeset
   190
430
022b667e0d70 added accelerator display
Claus Gittinger <cg@exept.de>
parents: 419
diff changeset
   191
        "
022b667e0d70 added accelerator display
Claus Gittinger <cg@exept.de>
parents: 419
diff changeset
   192
         codeViews do support #accept
022b667e0d70 added accelerator display
Claus Gittinger <cg@exept.de>
parents: 419
diff changeset
   193
         ... add it after #inspectIt
022b667e0d70 added accelerator display
Claus Gittinger <cg@exept.de>
parents: 419
diff changeset
   194
        "
464
6bd2186ca548 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 430
diff changeset
   195
        m addLabels:(resources array:#('-' 'accept'))
6bd2186ca548 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 430
diff changeset
   196
          selectors:#(nil accept)
6bd2186ca548 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 430
diff changeset
   197
          accelerators:#(nil #Accept)
6bd2186ca548 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 430
diff changeset
   198
          after:#inspectIt.
131
claus
parents: 125
diff changeset
   199
430
022b667e0d70 added accelerator display
Claus Gittinger <cg@exept.de>
parents: 419
diff changeset
   200
        "
022b667e0d70 added accelerator display
Claus Gittinger <cg@exept.de>
parents: 419
diff changeset
   201
         and add #explain after $gotoLine in the extra menu
022b667e0d70 added accelerator display
Claus Gittinger <cg@exept.de>
parents: 419
diff changeset
   202
        "
022b667e0d70 added accelerator display
Claus Gittinger <cg@exept.de>
parents: 419
diff changeset
   203
        sub := m subMenuAt:#others.
022b667e0d70 added accelerator display
Claus Gittinger <cg@exept.de>
parents: 419
diff changeset
   204
        sub notNil ifTrue:[
022b667e0d70 added accelerator display
Claus Gittinger <cg@exept.de>
parents: 419
diff changeset
   205
            sub addLabels:(resources array:#('-' 'explain'))
022b667e0d70 added accelerator display
Claus Gittinger <cg@exept.de>
parents: 419
diff changeset
   206
                selectors:#(nil explain)
022b667e0d70 added accelerator display
Claus Gittinger <cg@exept.de>
parents: 419
diff changeset
   207
                accelerators:#(nil Explain)
464
6bd2186ca548 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 430
diff changeset
   208
                after:#gotoLine.
430
022b667e0d70 added accelerator display
Claus Gittinger <cg@exept.de>
parents: 419
diff changeset
   209
022b667e0d70 added accelerator display
Claus Gittinger <cg@exept.de>
parents: 419
diff changeset
   210
            self hasSelection ifFalse:[
022b667e0d70 added accelerator display
Claus Gittinger <cg@exept.de>
parents: 419
diff changeset
   211
                sub disable:#explain 
022b667e0d70 added accelerator display
Claus Gittinger <cg@exept.de>
parents: 419
diff changeset
   212
            ].
022b667e0d70 added accelerator display
Claus Gittinger <cg@exept.de>
parents: 419
diff changeset
   213
        ].
59
450ce95a72a4 *** empty log message ***
claus
parents: 38
diff changeset
   214
    ].
131
claus
parents: 125
diff changeset
   215
    ^ m.
430
022b667e0d70 added accelerator display
Claus Gittinger <cg@exept.de>
parents: 419
diff changeset
   216
489
5816aa12fec8 resources
Claus Gittinger <cg@exept.de>
parents: 464
diff changeset
   217
    "Modified: 7.3.1996 / 13:13:55 / cg"
136
claus
parents: 132
diff changeset
   218
!
claus
parents: 132
diff changeset
   219
201
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   220
explain
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   221
    "explain action;
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   222
     evaluate the explainBlock passing whole contents and 
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   223
     selection as arguments."
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   224
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   225
    |text|
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   226
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   227
    explainAction notNil ifTrue:[
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   228
	text := self selection.
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   229
	text notNil ifTrue:[
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   230
	    explainAction value:(self contents) value:(text asString)
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   231
	]
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   232
    ]
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   233
!
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   234
136
claus
parents: 132
diff changeset
   235
uncommentSelection
claus
parents: 132
diff changeset
   236
    "convenient function to comment out a block.
claus
parents: 132
diff changeset
   237
     All lines from line1 to line2 get an end-of-line comment
claus
parents: 132
diff changeset
   238
     in the first col."
claus
parents: 132
diff changeset
   239
claus
parents: 132
diff changeset
   240
    |e|
claus
parents: 132
diff changeset
   241
claus
parents: 132
diff changeset
   242
    (selectionStartCol == 1 and:[selectionEndCol == 0]) ifTrue:[
claus
parents: 132
diff changeset
   243
	self uncommentFrom:selectionStartLine to:selectionEndLine-1
claus
parents: 132
diff changeset
   244
    ] ifFalse:[
claus
parents: 132
diff changeset
   245
	((self characterAtLine:selectionStartLine col:selectionStartCol) == $"
claus
parents: 132
diff changeset
   246
	and:[(self characterAtLine:selectionEndLine col:selectionEndCol) == $"]) ifTrue:[
claus
parents: 132
diff changeset
   247
	    self deleteCharAtLine:selectionEndLine col:selectionEndCol.
claus
parents: 132
diff changeset
   248
	    self deleteCharAtLine:selectionStartLine col:selectionStartCol.
claus
parents: 132
diff changeset
   249
	    e := selectionEndCol - 1.
claus
parents: 132
diff changeset
   250
	    selectionStartLine == selectionEndLine ifTrue:[e := e - 1].
claus
parents: 132
diff changeset
   251
	    self selectFromLine:selectionStartLine col:selectionStartCol
claus
parents: 132
diff changeset
   252
			 toLine:selectionEndLine col:e.
claus
parents: 132
diff changeset
   253
	]
claus
parents: 132
diff changeset
   254
    ]
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   255
! !
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   256
206
2363a64a7c88 version at the end
Claus Gittinger <cg@exept.de>
parents: 201
diff changeset
   257
!CodeView class methodsFor:'documentation'!
2363a64a7c88 version at the end
Claus Gittinger <cg@exept.de>
parents: 201
diff changeset
   258
2363a64a7c88 version at the end
Claus Gittinger <cg@exept.de>
parents: 201
diff changeset
   259
version
583
2ec13b7ceba5 documentation
Claus Gittinger <cg@exept.de>
parents: 489
diff changeset
   260
    ^ '$Header: /cvs/stx/stx/libwidg/CodeView.st,v 1.30 1996-04-25 16:44:11 cg Exp $'
206
2363a64a7c88 version at the end
Claus Gittinger <cg@exept.de>
parents: 201
diff changeset
   261
! !