CodeView.st
author Claus Gittinger <cg@exept.de>
Fri, 01 Mar 1996 14:02:46 +0100
changeset 441 e170bca66a78
parent 430 022b667e0d70
child 464 6bd2186ca548
permissions -rw-r--r--
added style resource directive
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.
32
b6c23dfd5663 *** empty log message ***
claus
parents: 27
diff changeset
    59
"
201
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    60
! !
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    61
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    62
!CodeView methodsFor:'accessing'!
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    63
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    64
explainAction:aBlock
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    65
    "set the action to be performed on explain"
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
    explainAction := aBlock
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    68
! !
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
!CodeView methodsFor:'editing'!
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    71
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    72
commentFrom:line1 to:line2
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    73
    "convenient function to comment out a block.
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    74
     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
    75
     in the first col."
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    76
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    77
    line1 to:line2 do:[:lineNr |
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    78
	|l|
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    79
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    80
	l := self listAt:lineNr.
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    81
	l isNil ifTrue:[l := ''].
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    82
	self at:lineNr put:(('"' , '/') , l)
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    83
    ].
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    84
    self textChanged.
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
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    87
uncommentFrom:line1 to:line2
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    88
    "convenient function to comment out a block.
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    89
     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
    90
     in the first col."
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
    line1 to:line2 do:[:lineNr |
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    93
	|l|
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    94
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    95
	l := self listAt:lineNr.
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    96
	(l notNil and:[l startsWith:('"' ,'/')]) ifTrue:[
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    97
	    self at:lineNr put:(l copyFrom:3)
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    98
	]
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    99
    ].
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   100
    self textChanged.
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   101
! !
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   102
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   103
!CodeView methodsFor:'event handling'!
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
keyPress:key x:x y:y
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   106
    "catch keyboard shortcuts"
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   107
274
6df4bb990f04 handle accept where acceptAction is define (this was a historic leftover)
Claus Gittinger <cg@exept.de>
parents: 206
diff changeset
   108
    <resource: #keyboard (#Explain #Help 
201
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   109
	       #CommentSelection #UncommentSelection)>
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
    (key == #Explain) ifTrue:[^ self explain].
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   112
    (key == #Help)    ifTrue:[^ self explain].
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   113
    (key == #CommentSelection)    ifTrue:[^ self commentSelection].
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   114
    (key == #UncommentSelection)  ifTrue:[^ self uncommentSelection].
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   115
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   116
    super keyPress:key x:x y:y
32
b6c23dfd5663 *** empty log message ***
claus
parents: 27
diff changeset
   117
! !
b6c23dfd5663 *** empty log message ***
claus
parents: 27
diff changeset
   118
419
2bd5f73fffd2 commentary
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
   119
!CodeView methodsFor:'menu & menu actions'!
2bd5f73fffd2 commentary
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
   120
2bd5f73fffd2 commentary
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
   121
accept
2bd5f73fffd2 commentary
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
   122
    "redefined accept action;
2bd5f73fffd2 commentary
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
   123
     save cursor and selection to allow restore in case of an error
2bd5f73fffd2 commentary
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
   124
     (we are typically compiling here ... and the compiler may show
2bd5f73fffd2 commentary
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
   125
     errors by highlighting them)"
2bd5f73fffd2 commentary
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
   126
2bd5f73fffd2 commentary
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
   127
    codeStartPosition := 1.
2bd5f73fffd2 commentary
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
   128
    [
2bd5f73fffd2 commentary
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
   129
	AbortSignal handle:[:ex |
2bd5f73fffd2 commentary
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
   130
	    self cursor:Cursor normal.
2bd5f73fffd2 commentary
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
   131
	    "redraw selection in normal color"
2bd5f73fffd2 commentary
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
   132
	    self selectFromLine:selectionStartLine col:selectionStartCol 
2bd5f73fffd2 commentary
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
   133
			 toLine:selectionEndLine col:selectionEndCol.
2bd5f73fffd2 commentary
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
   134
	    ex return
2bd5f73fffd2 commentary
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
   135
	] do:[
2bd5f73fffd2 commentary
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
   136
	    super accept.
2bd5f73fffd2 commentary
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
   137
	]
2bd5f73fffd2 commentary
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
   138
    ] valueNowOrOnUnwindDo:[
2bd5f73fffd2 commentary
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
   139
	self unselect.
2bd5f73fffd2 commentary
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
   140
    ]
2bd5f73fffd2 commentary
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
   141
!
2bd5f73fffd2 commentary
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
   142
2bd5f73fffd2 commentary
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
   143
commentSelection
2bd5f73fffd2 commentary
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
   144
    "convenient function to comment out a block.
2bd5f73fffd2 commentary
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
   145
     All lines from line1 to line2 get an end-of-line comment
2bd5f73fffd2 commentary
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
   146
     in the first col."
2bd5f73fffd2 commentary
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
   147
2bd5f73fffd2 commentary
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
   148
    |e|
2bd5f73fffd2 commentary
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
   149
2bd5f73fffd2 commentary
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
   150
    (selectionStartCol == 1 and:[selectionEndCol == 0]) ifTrue:[
2bd5f73fffd2 commentary
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
   151
	self commentFrom:selectionStartLine to:selectionEndLine-1
2bd5f73fffd2 commentary
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
   152
    ] ifFalse:[
2bd5f73fffd2 commentary
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
   153
	self insert:$" atLine:selectionStartLine col:selectionStartCol.
2bd5f73fffd2 commentary
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
   154
	e := selectionEndCol + 1.
2bd5f73fffd2 commentary
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
   155
	selectionStartLine == selectionEndLine ifTrue:[e := e + 1].
2bd5f73fffd2 commentary
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
   156
	self insert:$" atLine:selectionEndLine col:e.
2bd5f73fffd2 commentary
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
   157
	self selectFromLine:selectionStartLine col:selectionStartCol
2bd5f73fffd2 commentary
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
   158
		     toLine:selectionEndLine col:e.
2bd5f73fffd2 commentary
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
   159
    ]
2bd5f73fffd2 commentary
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
   160
!
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   161
97
cbf495fe3b64 *** empty log message ***
claus
parents: 95
diff changeset
   162
editMenu
121
claus
parents: 118
diff changeset
   163
    "return the popUpMenu;
claus
parents: 118
diff changeset
   164
     to make this independent from what is defined in superclasses,
claus
parents: 118
diff changeset
   165
     get the superclass menu and add my functions."
131
claus
parents: 125
diff changeset
   166
97
cbf495fe3b64 *** empty log message ***
claus
parents: 95
diff changeset
   167
    |m sub idx|
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 32
diff changeset
   168
97
cbf495fe3b64 *** empty log message ***
claus
parents: 95
diff changeset
   169
    m := super editMenu.
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   170
131
claus
parents: 125
diff changeset
   171
    self sensor ctrlDown ifTrue:[
430
022b667e0d70 added accelerator display
Claus Gittinger <cg@exept.de>
parents: 419
diff changeset
   172
        m addLabels:(resources array:#('-' 'commentIt' 'uncommentIt'))
022b667e0d70 added accelerator display
Claus Gittinger <cg@exept.de>
parents: 419
diff changeset
   173
          selectors:#(nil commentSelection uncommentSelection)
022b667e0d70 added accelerator display
Claus Gittinger <cg@exept.de>
parents: 419
diff changeset
   174
          accelerators:#(nil CommentSelection UncommentSelection)
022b667e0d70 added accelerator display
Claus Gittinger <cg@exept.de>
parents: 419
diff changeset
   175
          after:(m labels size).
022b667e0d70 added accelerator display
Claus Gittinger <cg@exept.de>
parents: 419
diff changeset
   176
022b667e0d70 added accelerator display
Claus Gittinger <cg@exept.de>
parents: 419
diff changeset
   177
        self hasSelection ifFalse:[
022b667e0d70 added accelerator display
Claus Gittinger <cg@exept.de>
parents: 419
diff changeset
   178
            m disableAll:#(commentSelection uncommentSelection) 
022b667e0d70 added accelerator display
Claus Gittinger <cg@exept.de>
parents: 419
diff changeset
   179
        ].
131
claus
parents: 125
diff changeset
   180
    ] ifFalse:[
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 32
diff changeset
   181
430
022b667e0d70 added accelerator display
Claus Gittinger <cg@exept.de>
parents: 419
diff changeset
   182
        "
022b667e0d70 added accelerator display
Claus Gittinger <cg@exept.de>
parents: 419
diff changeset
   183
         codeViews do support #accept
022b667e0d70 added accelerator display
Claus Gittinger <cg@exept.de>
parents: 419
diff changeset
   184
         ... add it after #inspectIt
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
        idx := m indexOf:#inspectIt.
022b667e0d70 added accelerator display
Claus Gittinger <cg@exept.de>
parents: 419
diff changeset
   187
        idx ~~ 0 ifTrue:[
022b667e0d70 added accelerator display
Claus Gittinger <cg@exept.de>
parents: 419
diff changeset
   188
            m addLabels:(resources array:#('-' 'accept'))
022b667e0d70 added accelerator display
Claus Gittinger <cg@exept.de>
parents: 419
diff changeset
   189
              selectors:#(nil accept)
022b667e0d70 added accelerator display
Claus Gittinger <cg@exept.de>
parents: 419
diff changeset
   190
              accelerators:#(nil #Accept)
022b667e0d70 added accelerator display
Claus Gittinger <cg@exept.de>
parents: 419
diff changeset
   191
              after:idx
022b667e0d70 added accelerator display
Claus Gittinger <cg@exept.de>
parents: 419
diff changeset
   192
        ].
131
claus
parents: 125
diff changeset
   193
430
022b667e0d70 added accelerator display
Claus Gittinger <cg@exept.de>
parents: 419
diff changeset
   194
        "
022b667e0d70 added accelerator display
Claus Gittinger <cg@exept.de>
parents: 419
diff changeset
   195
         and add #explain after $gotoLine in the extra menu
022b667e0d70 added accelerator display
Claus Gittinger <cg@exept.de>
parents: 419
diff changeset
   196
        "
022b667e0d70 added accelerator display
Claus Gittinger <cg@exept.de>
parents: 419
diff changeset
   197
        sub := m subMenuAt:#others.
022b667e0d70 added accelerator display
Claus Gittinger <cg@exept.de>
parents: 419
diff changeset
   198
        sub notNil ifTrue:[
022b667e0d70 added accelerator display
Claus Gittinger <cg@exept.de>
parents: 419
diff changeset
   199
            idx := sub indexOf:#gotoLine.
022b667e0d70 added accelerator display
Claus Gittinger <cg@exept.de>
parents: 419
diff changeset
   200
            sub addLabels:(resources array:#('-' 'explain'))
022b667e0d70 added accelerator display
Claus Gittinger <cg@exept.de>
parents: 419
diff changeset
   201
                selectors:#(nil explain)
022b667e0d70 added accelerator display
Claus Gittinger <cg@exept.de>
parents: 419
diff changeset
   202
                accelerators:#(nil Explain)
022b667e0d70 added accelerator display
Claus Gittinger <cg@exept.de>
parents: 419
diff changeset
   203
                after:idx.
022b667e0d70 added accelerator display
Claus Gittinger <cg@exept.de>
parents: 419
diff changeset
   204
022b667e0d70 added accelerator display
Claus Gittinger <cg@exept.de>
parents: 419
diff changeset
   205
            self hasSelection ifFalse:[
022b667e0d70 added accelerator display
Claus Gittinger <cg@exept.de>
parents: 419
diff changeset
   206
                sub disable:#explain 
022b667e0d70 added accelerator display
Claus Gittinger <cg@exept.de>
parents: 419
diff changeset
   207
            ].
022b667e0d70 added accelerator display
Claus Gittinger <cg@exept.de>
parents: 419
diff changeset
   208
        ].
59
450ce95a72a4 *** empty log message ***
claus
parents: 38
diff changeset
   209
    ].
131
claus
parents: 125
diff changeset
   210
    ^ m.
430
022b667e0d70 added accelerator display
Claus Gittinger <cg@exept.de>
parents: 419
diff changeset
   211
022b667e0d70 added accelerator display
Claus Gittinger <cg@exept.de>
parents: 419
diff changeset
   212
    "Modified: 28.2.1996 / 17:47:46 / cg"
136
claus
parents: 132
diff changeset
   213
!
claus
parents: 132
diff changeset
   214
201
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   215
explain
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   216
    "explain action;
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   217
     evaluate the explainBlock passing whole contents and 
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   218
     selection as arguments."
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   219
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   220
    |text|
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   221
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   222
    explainAction notNil ifTrue:[
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   223
	text := self selection.
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   224
	text notNil ifTrue:[
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   225
	    explainAction value:(self contents) value:(text asString)
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
    ]
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   228
!
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   229
136
claus
parents: 132
diff changeset
   230
uncommentSelection
claus
parents: 132
diff changeset
   231
    "convenient function to comment out a block.
claus
parents: 132
diff changeset
   232
     All lines from line1 to line2 get an end-of-line comment
claus
parents: 132
diff changeset
   233
     in the first col."
claus
parents: 132
diff changeset
   234
claus
parents: 132
diff changeset
   235
    |e|
claus
parents: 132
diff changeset
   236
claus
parents: 132
diff changeset
   237
    (selectionStartCol == 1 and:[selectionEndCol == 0]) ifTrue:[
claus
parents: 132
diff changeset
   238
	self uncommentFrom:selectionStartLine to:selectionEndLine-1
claus
parents: 132
diff changeset
   239
    ] ifFalse:[
claus
parents: 132
diff changeset
   240
	((self characterAtLine:selectionStartLine col:selectionStartCol) == $"
claus
parents: 132
diff changeset
   241
	and:[(self characterAtLine:selectionEndLine col:selectionEndCol) == $"]) ifTrue:[
claus
parents: 132
diff changeset
   242
	    self deleteCharAtLine:selectionEndLine col:selectionEndCol.
claus
parents: 132
diff changeset
   243
	    self deleteCharAtLine:selectionStartLine col:selectionStartCol.
claus
parents: 132
diff changeset
   244
	    e := selectionEndCol - 1.
claus
parents: 132
diff changeset
   245
	    selectionStartLine == selectionEndLine ifTrue:[e := e - 1].
claus
parents: 132
diff changeset
   246
	    self selectFromLine:selectionStartLine col:selectionStartCol
claus
parents: 132
diff changeset
   247
			 toLine:selectionEndLine col:e.
claus
parents: 132
diff changeset
   248
	]
claus
parents: 132
diff changeset
   249
    ]
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   250
! !
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   251
206
2363a64a7c88 version at the end
Claus Gittinger <cg@exept.de>
parents: 201
diff changeset
   252
!CodeView class methodsFor:'documentation'!
2363a64a7c88 version at the end
Claus Gittinger <cg@exept.de>
parents: 201
diff changeset
   253
2363a64a7c88 version at the end
Claus Gittinger <cg@exept.de>
parents: 201
diff changeset
   254
version
430
022b667e0d70 added accelerator display
Claus Gittinger <cg@exept.de>
parents: 419
diff changeset
   255
    ^ '$Header: /cvs/stx/stx/libwidg/CodeView.st,v 1.27 1996-02-28 18:49:24 cg Exp $'
206
2363a64a7c88 version at the end
Claus Gittinger <cg@exept.de>
parents: 201
diff changeset
   256
! !