CodeView.st
author Claus Gittinger <cg@exept.de>
Thu, 23 Nov 1995 11:44:18 +0100
changeset 201 d2888811c664
parent 174 d80a6cc3f9b2
child 206 2363a64a7c88
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
201
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    14
	 instanceVariableNames:'explainAction'
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    15
	 classVariableNames:''
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    16
	 poolDictionaries:''
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
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. 
claus
parents: 123
diff changeset
    39
    It adds explain to the menu, and defines another action: 
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
125
claus
parents: 123
diff changeset
    45
    If used with a model, accept sends the changeMsg to it (as defined in EditTextView).
121
claus
parents: 118
diff changeset
    46
    (however, it is possible to define moth changeMsg and acceptAction)
123
claus
parents: 121
diff changeset
    47
claus
parents: 121
diff changeset
    48
claus
parents: 121
diff changeset
    49
    Caveat:
claus
parents: 121
diff changeset
    50
	in this version, CodeView does not yet support MVC setups for doIt
claus
parents: 121
diff changeset
    51
	and explain.
claus
parents: 121
diff changeset
    52
	If required, simulate this by setting the doItAction and
claus
parents: 121
diff changeset
    53
	explainAction, to notify the model manually about whats going on.
32
b6c23dfd5663 *** empty log message ***
claus
parents: 27
diff changeset
    54
"
201
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    55
!
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    56
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    57
version
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    58
    ^ '$Header: /cvs/stx/stx/libwidg/CodeView.st,v 1.22 1995-11-23 10:44:18 cg Exp $'
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    59
! !
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
!CodeView methodsFor:'accessing'!
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    62
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    63
explainAction:aBlock
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    64
    "set the action to be performed on explain"
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    65
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    66
    explainAction := aBlock
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
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    69
!CodeView methodsFor:'editing'!
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    70
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    71
commentFrom:line1 to:line2
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    72
    "convenient function to comment out a block.
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    73
     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
    74
     in the first col."
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
    line1 to:line2 do:[:lineNr |
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    77
	|l|
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    78
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    79
	l := self listAt:lineNr.
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    80
	l isNil ifTrue:[l := ''].
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    81
	self at:lineNr put:(('"' , '/') , l)
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
    self textChanged.
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    84
!
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
uncommentFrom:line1 to:line2
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    87
    "convenient function to comment out a block.
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    88
     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
    89
     in the first col."
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    90
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    91
    line1 to:line2 do:[:lineNr |
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    92
	|l|
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    93
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    94
	l := self listAt:lineNr.
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    95
	(l notNil and:[l startsWith:('"' ,'/')]) ifTrue:[
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    96
	    self at:lineNr put:(l copyFrom:3)
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
    ].
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    99
    self textChanged.
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
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   102
!CodeView methodsFor:'event handling'!
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   103
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   104
keyPress:key x:x y:y
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   105
    "catch keyboard shortcuts"
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   106
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   107
    <resource: #keyboard (#Accept #Explain #Help 
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   108
	       #CommentSelection #UncommentSelection)>
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   109
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   110
    (key == #Accept)  ifTrue:[^ self accept].
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
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   119
!CodeView methodsFor:'initialization'!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   120
97
cbf495fe3b64 *** empty log message ***
claus
parents: 95
diff changeset
   121
editMenu
121
claus
parents: 118
diff changeset
   122
    "return the popUpMenu;
claus
parents: 118
diff changeset
   123
     to make this independent from what is defined in superclasses,
claus
parents: 118
diff changeset
   124
     get the superclass menu and add my functions."
131
claus
parents: 125
diff changeset
   125
97
cbf495fe3b64 *** empty log message ***
claus
parents: 95
diff changeset
   126
    |m sub idx|
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 32
diff changeset
   127
97
cbf495fe3b64 *** empty log message ***
claus
parents: 95
diff changeset
   128
    m := super editMenu.
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   129
131
claus
parents: 125
diff changeset
   130
    self sensor ctrlDown ifTrue:[
claus
parents: 125
diff changeset
   131
	m addLabels:(resources array:#('-' 'commentIt' 'uncommentIt'))
claus
parents: 125
diff changeset
   132
	  selectors:#(nil commentSelection uncommentSelection)
claus
parents: 125
diff changeset
   133
	  after:(m labels size).
claus
parents: 125
diff changeset
   134
	self hasSelection ifFalse:[
claus
parents: 125
diff changeset
   135
	    m disableAll:#(commentSelection uncommentSelection) 
claus
parents: 125
diff changeset
   136
	].
claus
parents: 125
diff changeset
   137
    ] ifFalse:[
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 32
diff changeset
   138
131
claus
parents: 125
diff changeset
   139
	"
claus
parents: 125
diff changeset
   140
	 codeViews do support #accept
claus
parents: 125
diff changeset
   141
	 ... add it after #inspectIt
claus
parents: 125
diff changeset
   142
	"
claus
parents: 125
diff changeset
   143
	idx := m indexOf:#inspectIt.
claus
parents: 125
diff changeset
   144
	idx ~~ 0 ifTrue:[
claus
parents: 125
diff changeset
   145
	    m addLabels:(resources array:#('-' 'accept'))
claus
parents: 125
diff changeset
   146
	      selectors:#(nil accept)
claus
parents: 125
diff changeset
   147
	      after:idx.
claus
parents: 125
diff changeset
   148
	].
claus
parents: 125
diff changeset
   149
claus
parents: 125
diff changeset
   150
	"
claus
parents: 125
diff changeset
   151
	 and add #explain after $gotoLine in the extra menu
claus
parents: 125
diff changeset
   152
	"
claus
parents: 125
diff changeset
   153
	sub := m subMenuAt:#others.
claus
parents: 125
diff changeset
   154
	sub notNil ifTrue:[
claus
parents: 125
diff changeset
   155
	    idx := sub indexOf:#gotoLine.
claus
parents: 125
diff changeset
   156
	    sub addLabels:(resources array:#('-' 'explain'))
claus
parents: 125
diff changeset
   157
		selectors:#(nil explain)
claus
parents: 125
diff changeset
   158
		after:idx.
claus
parents: 125
diff changeset
   159
	    self hasSelection ifFalse:[
claus
parents: 125
diff changeset
   160
		sub disable:#explain 
claus
parents: 125
diff changeset
   161
	    ].
97
cbf495fe3b64 *** empty log message ***
claus
parents: 95
diff changeset
   162
	].
59
450ce95a72a4 *** empty log message ***
claus
parents: 38
diff changeset
   163
    ].
131
claus
parents: 125
diff changeset
   164
    ^ m.
claus
parents: 125
diff changeset
   165
! !
97
cbf495fe3b64 *** empty log message ***
claus
parents: 95
diff changeset
   166
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   167
!CodeView methodsFor:'user actions'!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   168
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   169
accept
125
claus
parents: 123
diff changeset
   170
    "redefined accept action;
claus
parents: 123
diff changeset
   171
     save cursor and selection to allow restore in case of an error
claus
parents: 123
diff changeset
   172
     (we are typically compiling here ... and the compiler may show
claus
parents: 123
diff changeset
   173
     errors by highlighting them)"
95
7535cfca9509 *** empty log message ***
claus
parents: 70
diff changeset
   174
7535cfca9509 *** empty log message ***
claus
parents: 70
diff changeset
   175
    codeStartPosition := 1.
7535cfca9509 *** empty log message ***
claus
parents: 70
diff changeset
   176
    [
7535cfca9509 *** empty log message ***
claus
parents: 70
diff changeset
   177
	Object abortSignal handle:[:ex |
7535cfca9509 *** empty log message ***
claus
parents: 70
diff changeset
   178
	    self cursor:Cursor normal.
7535cfca9509 *** empty log message ***
claus
parents: 70
diff changeset
   179
	    "redraw selection in normal color"
7535cfca9509 *** empty log message ***
claus
parents: 70
diff changeset
   180
	    self selectFromLine:selectionStartLine col:selectionStartCol 
7535cfca9509 *** empty log message ***
claus
parents: 70
diff changeset
   181
			 toLine:selectionEndLine col:selectionEndCol.
7535cfca9509 *** empty log message ***
claus
parents: 70
diff changeset
   182
	    ex return
7535cfca9509 *** empty log message ***
claus
parents: 70
diff changeset
   183
	] do:[
125
claus
parents: 123
diff changeset
   184
	    super accept.
70
14443a9ea4ec *** empty log message ***
claus
parents: 59
diff changeset
   185
	]
95
7535cfca9509 *** empty log message ***
claus
parents: 70
diff changeset
   186
    ] valueNowOrOnUnwindDo:[
7535cfca9509 *** empty log message ***
claus
parents: 70
diff changeset
   187
	self unselect.
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   188
    ]
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   189
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   190
136
claus
parents: 132
diff changeset
   191
commentSelection
claus
parents: 132
diff changeset
   192
    "convenient function to comment out a block.
claus
parents: 132
diff changeset
   193
     All lines from line1 to line2 get an end-of-line comment
claus
parents: 132
diff changeset
   194
     in the first col."
claus
parents: 132
diff changeset
   195
claus
parents: 132
diff changeset
   196
    |e|
claus
parents: 132
diff changeset
   197
claus
parents: 132
diff changeset
   198
    (selectionStartCol == 1 and:[selectionEndCol == 0]) ifTrue:[
claus
parents: 132
diff changeset
   199
	self commentFrom:selectionStartLine to:selectionEndLine-1
claus
parents: 132
diff changeset
   200
    ] ifFalse:[
claus
parents: 132
diff changeset
   201
	self insert:$" atLine:selectionStartLine col:selectionStartCol.
claus
parents: 132
diff changeset
   202
	e := selectionEndCol + 1.
claus
parents: 132
diff changeset
   203
	selectionStartLine == selectionEndLine ifTrue:[e := e + 1].
claus
parents: 132
diff changeset
   204
	self insert:$" atLine:selectionEndLine col:e.
claus
parents: 132
diff changeset
   205
	self selectFromLine:selectionStartLine col:selectionStartCol
claus
parents: 132
diff changeset
   206
		     toLine:selectionEndLine col:e.
claus
parents: 132
diff changeset
   207
    ]
claus
parents: 132
diff changeset
   208
!
claus
parents: 132
diff changeset
   209
201
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   210
explain
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   211
    "explain action;
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   212
     evaluate the explainBlock passing whole contents and 
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   213
     selection as arguments."
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   214
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   215
    |text|
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   216
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   217
    explainAction notNil ifTrue:[
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   218
	text := self selection.
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   219
	text notNil ifTrue:[
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   220
	    explainAction value:(self contents) value:(text asString)
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
    ]
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   223
!
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   224
136
claus
parents: 132
diff changeset
   225
uncommentSelection
claus
parents: 132
diff changeset
   226
    "convenient function to comment out a block.
claus
parents: 132
diff changeset
   227
     All lines from line1 to line2 get an end-of-line comment
claus
parents: 132
diff changeset
   228
     in the first col."
claus
parents: 132
diff changeset
   229
claus
parents: 132
diff changeset
   230
    |e|
claus
parents: 132
diff changeset
   231
claus
parents: 132
diff changeset
   232
    (selectionStartCol == 1 and:[selectionEndCol == 0]) ifTrue:[
claus
parents: 132
diff changeset
   233
	self uncommentFrom:selectionStartLine to:selectionEndLine-1
claus
parents: 132
diff changeset
   234
    ] ifFalse:[
claus
parents: 132
diff changeset
   235
	((self characterAtLine:selectionStartLine col:selectionStartCol) == $"
claus
parents: 132
diff changeset
   236
	and:[(self characterAtLine:selectionEndLine col:selectionEndCol) == $"]) ifTrue:[
claus
parents: 132
diff changeset
   237
	    self deleteCharAtLine:selectionEndLine col:selectionEndCol.
claus
parents: 132
diff changeset
   238
	    self deleteCharAtLine:selectionStartLine col:selectionStartCol.
claus
parents: 132
diff changeset
   239
	    e := selectionEndCol - 1.
claus
parents: 132
diff changeset
   240
	    selectionStartLine == selectionEndLine ifTrue:[e := e - 1].
claus
parents: 132
diff changeset
   241
	    self selectFromLine:selectionStartLine col:selectionStartCol
claus
parents: 132
diff changeset
   242
			 toLine:selectionEndLine col:e.
claus
parents: 132
diff changeset
   243
	]
claus
parents: 132
diff changeset
   244
    ]
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   245
! !
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   246