Workspace.st
author Claus Gittinger <cg@exept.de>
Tue, 21 Oct 1997 20:15:06 +0200
changeset 1354 c260c896ea66
parent 1262 d69149b5be1f
child 1395 cbadcf93c173
permissions -rw-r--r--
*** empty log message ***
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
     1
"
5
claus
parents: 3
diff changeset
     2
 COPYRIGHT (c) 1989 by Claus Gittinger
59
450ce95a72a4 *** empty log message ***
claus
parents: 58
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
1354
c260c896ea66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1262
diff changeset
    13
'From Smalltalk/X, Version:3.2.1 on 20-oct-1997 at 2:11:55 pm'                  !
c260c896ea66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1262
diff changeset
    14
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    15
TextCollector subclass:#Workspace
257
605e68c1223f use new withExecuteCursorDo:
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
    16
	instanceVariableNames:'doItAction codeStartPosition errorFgColor errorBgColor'
605e68c1223f use new withExecuteCursorDo:
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
    17
	classVariableNames:'DefaultErrorForegroundColor DefaultErrorBackgroundColor'
605e68c1223f use new withExecuteCursorDo:
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
    18
	poolDictionaries:''
605e68c1223f use new withExecuteCursorDo:
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
    19
	category:'Interface-Workspace'
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    20
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    21
32
b6c23dfd5663 *** empty log message ***
claus
parents: 23
diff changeset
    22
!Workspace class methodsFor:'documentation'!
b6c23dfd5663 *** empty log message ***
claus
parents: 23
diff changeset
    23
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 32
diff changeset
    24
copyright
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 32
diff changeset
    25
"
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 32
diff changeset
    26
 COPYRIGHT (c) 1989 by Claus Gittinger
59
450ce95a72a4 *** empty log message ***
claus
parents: 58
diff changeset
    27
	      All Rights Reserved
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 32
diff changeset
    28
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 32
diff changeset
    29
 This software is furnished under a license and may be used
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 32
diff changeset
    30
 only in accordance with the terms of that license and with the
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 32
diff changeset
    31
 inclusion of the above copyright notice.   This software may not
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 32
diff changeset
    32
 be provided or otherwise made available to, or used by, any
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 32
diff changeset
    33
 other person.  No title to or ownership of the software is
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 32
diff changeset
    34
 hereby transferred.
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 32
diff changeset
    35
"
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 32
diff changeset
    36
!
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 32
diff changeset
    37
32
b6c23dfd5663 *** empty log message ***
claus
parents: 23
diff changeset
    38
documentation
b6c23dfd5663 *** empty log message ***
claus
parents: 23
diff changeset
    39
"
b6c23dfd5663 *** empty log message ***
claus
parents: 23
diff changeset
    40
    a view for editable text which can evaluate expressions.
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 32
diff changeset
    41
    I.e. its basically a view for editable text, with added
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 32
diff changeset
    42
    'doIt', 'printIt' and 'inspectIt' functions on the popup-menu.
125
claus
parents: 123
diff changeset
    43
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 32
diff changeset
    44
    The action to be performed on doIt is defined by a block,
58
28815246bbc1 *** empty log message ***
claus
parents: 54
diff changeset
    45
    which can be defined by the owner of this view.
60
f3c738c24ce6 mostly style
claus
parents: 59
diff changeset
    46
    (thus you can put a workspace into more complex widgets, and
f3c738c24ce6 mostly style
claus
parents: 59
diff changeset
    47
     control what should happen on 'doIt').
58
28815246bbc1 *** empty log message ***
claus
parents: 54
diff changeset
    48
578
5b82bc433c14 commentary
Claus Gittinger <cg@exept.de>
parents: 489
diff changeset
    49
    A useful default action is automatically defined, which simply 
5b82bc433c14 commentary
Claus Gittinger <cg@exept.de>
parents: 489
diff changeset
    50
    evaluates the selection as a smalltalk expression. 
5b82bc433c14 commentary
Claus Gittinger <cg@exept.de>
parents: 489
diff changeset
    51
    (but, a lisp or prolog workspace would define its own action,
5b82bc433c14 commentary
Claus Gittinger <cg@exept.de>
parents: 489
diff changeset
    52
     to call for another compiler/interpreter  ...)
32
b6c23dfd5663 *** empty log message ***
claus
parents: 23
diff changeset
    53
123
claus
parents: 121
diff changeset
    54
claus
parents: 121
diff changeset
    55
    Caveat:
418
777061f25321 commentary
Claus Gittinger <cg@exept.de>
parents: 368
diff changeset
    56
        in this version, Workspace does not yet support doIt in MVC setups.
777061f25321 commentary
Claus Gittinger <cg@exept.de>
parents: 368
diff changeset
    57
        For now, simulate this by setting the doItAction, to notify the
777061f25321 commentary
Claus Gittinger <cg@exept.de>
parents: 368
diff changeset
    58
        model manually about the doIt.
123
claus
parents: 121
diff changeset
    59
claus
parents: 121
diff changeset
    60
578
5b82bc433c14 commentary
Claus Gittinger <cg@exept.de>
parents: 489
diff changeset
    61
    [instance variables:]
32
b6c23dfd5663 *** empty log message ***
claus
parents: 23
diff changeset
    62
121
claus
parents: 119
diff changeset
    63
      doItAction      <Block>         block to evaluate for doIt
123
claus
parents: 121
diff changeset
    64
121
claus
parents: 119
diff changeset
    65
      errorFgColor    <Color>         fg-Color to be used when highlighting errors 
claus
parents: 119
diff changeset
    66
claus
parents: 119
diff changeset
    67
      errorBgColor    <Color>         bg-Color to be used when highlighting errors
58
28815246bbc1 *** empty log message ***
claus
parents: 54
diff changeset
    68
578
5b82bc433c14 commentary
Claus Gittinger <cg@exept.de>
parents: 489
diff changeset
    69
      codeStartPosition               private temporary
121
claus
parents: 119
diff changeset
    70
578
5b82bc433c14 commentary
Claus Gittinger <cg@exept.de>
parents: 489
diff changeset
    71
5b82bc433c14 commentary
Claus Gittinger <cg@exept.de>
parents: 489
diff changeset
    72
    [styleSheet values:]
121
claus
parents: 119
diff changeset
    73
claus
parents: 119
diff changeset
    74
      codeErrorSelectionForegroundColor     fg color to highlight errors
418
777061f25321 commentary
Claus Gittinger <cg@exept.de>
parents: 368
diff changeset
    75
                                            (default: selection fg)
777061f25321 commentary
Claus Gittinger <cg@exept.de>
parents: 368
diff changeset
    76
121
claus
parents: 119
diff changeset
    77
      codeErrorSelectionBackgroundColor     bg color to highlight errors
418
777061f25321 commentary
Claus Gittinger <cg@exept.de>
parents: 368
diff changeset
    78
                                            (default: selection bg)
578
5b82bc433c14 commentary
Claus Gittinger <cg@exept.de>
parents: 489
diff changeset
    79
5b82bc433c14 commentary
Claus Gittinger <cg@exept.de>
parents: 489
diff changeset
    80
    [see also:]
5b82bc433c14 commentary
Claus Gittinger <cg@exept.de>
parents: 489
diff changeset
    81
        Workspace EditTextView 
5b82bc433c14 commentary
Claus Gittinger <cg@exept.de>
parents: 489
diff changeset
    82
        Parser ByteCodeCompiler
583
2ec13b7ceba5 documentation
Claus Gittinger <cg@exept.de>
parents: 578
diff changeset
    83
2ec13b7ceba5 documentation
Claus Gittinger <cg@exept.de>
parents: 578
diff changeset
    84
    [author:]
2ec13b7ceba5 documentation
Claus Gittinger <cg@exept.de>
parents: 578
diff changeset
    85
        Claus Gittinger
32
b6c23dfd5663 *** empty log message ***
claus
parents: 23
diff changeset
    86
"
201
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    87
! !
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    88
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    89
!Workspace class methodsFor:'defaults'!
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
updateStyleCache
444
ef26eba8c854 added style resource directive
Claus Gittinger <cg@exept.de>
parents: 430
diff changeset
    92
    "extract values from the styleSheet and cache them in class variables"
ef26eba8c854 added style resource directive
Claus Gittinger <cg@exept.de>
parents: 430
diff changeset
    93
1354
c260c896ea66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1262
diff changeset
    94
    <resource: #style (#'codeErrorSelection.foregroundColor'
c260c896ea66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1262
diff changeset
    95
                       #'codeErrorSelection.backgroundColor')>
444
ef26eba8c854 added style resource directive
Claus Gittinger <cg@exept.de>
parents: 430
diff changeset
    96
1354
c260c896ea66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1262
diff changeset
    97
    DefaultErrorForegroundColor := StyleSheet colorAt:'codeErrorSelection.foregroundColor'.
c260c896ea66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1262
diff changeset
    98
    DefaultErrorBackgroundColor := StyleSheet colorAt:'codeErrorSelection.backgroundColor'.
444
ef26eba8c854 added style resource directive
Claus Gittinger <cg@exept.de>
parents: 430
diff changeset
    99
1354
c260c896ea66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1262
diff changeset
   100
    "Modified: 20.10.1997 / 14:06:18 / cg"
32
b6c23dfd5663 *** empty log message ***
claus
parents: 23
diff changeset
   101
! !
b6c23dfd5663 *** empty log message ***
claus
parents: 23
diff changeset
   102
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   103
!Workspace class methodsFor:'getting a System Workspace'!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   104
32
b6c23dfd5663 *** empty log message ***
claus
parents: 23
diff changeset
   105
open
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   106
    "launch a new workspace"
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   107
418
777061f25321 commentary
Claus Gittinger <cg@exept.de>
parents: 368
diff changeset
   108
    |scr topView workspace f|
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   109
418
777061f25321 commentary
Claus Gittinger <cg@exept.de>
parents: 368
diff changeset
   110
    topView := StandardSystemView 
421
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   111
                label:(self classResources string:'Workspace') 
418
777061f25321 commentary
Claus Gittinger <cg@exept.de>
parents: 368
diff changeset
   112
                minExtent:(100 @ 100).
23
69f1ba57f67a *** empty log message ***
claus
parents: 15
diff changeset
   113
418
777061f25321 commentary
Claus Gittinger <cg@exept.de>
parents: 368
diff changeset
   114
    scr := HVScrollableView for:self in:topView.
777061f25321 commentary
Claus Gittinger <cg@exept.de>
parents: 368
diff changeset
   115
    scr origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
777061f25321 commentary
Claus Gittinger <cg@exept.de>
parents: 368
diff changeset
   116
    workspace := scr scrolledView.
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   117
418
777061f25321 commentary
Claus Gittinger <cg@exept.de>
parents: 368
diff changeset
   118
    "/ adjust topViews extent according to my font
777061f25321 commentary
Claus Gittinger <cg@exept.de>
parents: 368
diff changeset
   119
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   120
    f := workspace font.
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   121
    topView extent:((f widthOf:'x') * 40) @ (f height * 10).
7
15a9291b9bd0 *** empty log message ***
claus
parents: 5
diff changeset
   122
    topView open.
131
claus
parents: 125
diff changeset
   123
    ^ workspace
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   124
58
28815246bbc1 *** empty log message ***
claus
parents: 54
diff changeset
   125
    "
28815246bbc1 *** empty log message ***
claus
parents: 54
diff changeset
   126
     Workspace open
28815246bbc1 *** empty log message ***
claus
parents: 54
diff changeset
   127
    "
418
777061f25321 commentary
Claus Gittinger <cg@exept.de>
parents: 368
diff changeset
   128
421
Claus Gittinger <cg@exept.de>
parents: 418
diff changeset
   129
    "Modified: 27.2.1996 / 17:41:08 / cg"
857
4990383442cc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 693
diff changeset
   130
!
4990383442cc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 693
diff changeset
   131
4990383442cc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 693
diff changeset
   132
openForRemote:hostName
4990383442cc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 693
diff changeset
   133
    "launch a new workspace to evaluate expression on some remote machine.
4990383442cc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 693
diff changeset
   134
     This requires the RemoteObjects package to be loaded."
4990383442cc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 693
diff changeset
   135
4990383442cc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 693
diff changeset
   136
    |server remoteCompiler workspace|
4990383442cc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 693
diff changeset
   137
4990383442cc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 693
diff changeset
   138
    RemoteObjectServer isNil ifTrue:[^ nil].
4990383442cc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 693
diff changeset
   139
4990383442cc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 693
diff changeset
   140
    server := RemoteObjectServer on:hostName.
4990383442cc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 693
diff changeset
   141
    remoteCompiler := server get:#Compiler.
4990383442cc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 693
diff changeset
   142
4990383442cc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 693
diff changeset
   143
    workspace := self open.
858
ef7ba327189b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 857
diff changeset
   144
    workspace topView label:'Remote Workspace [' , hostName , ']'.
857
4990383442cc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 693
diff changeset
   145
    workspace doItAction:
4990383442cc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 693
diff changeset
   146
                [:theCode |
4990383442cc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 693
diff changeset
   147
                    remoteCompiler 
4990383442cc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 693
diff changeset
   148
                        evaluate:theCode 
4990383442cc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 693
diff changeset
   149
                        in:nil 
4990383442cc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 693
diff changeset
   150
                        receiver:nil 
4990383442cc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 693
diff changeset
   151
                        notifying:workspace 
4990383442cc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 693
diff changeset
   152
                        logged:true 
4990383442cc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 693
diff changeset
   153
                        ifFail:nil 
4990383442cc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 693
diff changeset
   154
                ]
4990383442cc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 693
diff changeset
   155
    "
4990383442cc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 693
diff changeset
   156
     Workspace openForRemote:'andi'
4990383442cc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 693
diff changeset
   157
    "
4990383442cc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 693
diff changeset
   158
858
ef7ba327189b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 857
diff changeset
   159
    "Modified: 28.10.1996 / 17:51:44 / cg"
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   160
! !
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   161
201
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   162
!Workspace methodsFor:'accessing'!
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   163
201
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   164
doItAction
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   165
    "return the action to be performed when 'doIt' is selected"
32
b6c23dfd5663 *** empty log message ***
claus
parents: 23
diff changeset
   166
201
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   167
    ^ doItAction
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   168
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   169
418
777061f25321 commentary
Claus Gittinger <cg@exept.de>
parents: 368
diff changeset
   170
doItAction:aOneArgBlock
777061f25321 commentary
Claus Gittinger <cg@exept.de>
parents: 368
diff changeset
   171
    "define the action to be performed when 'doIt' is selected.
777061f25321 commentary
Claus Gittinger <cg@exept.de>
parents: 368
diff changeset
   172
     The block will be evaluated, passing the selection as a String argument. 
777061f25321 commentary
Claus Gittinger <cg@exept.de>
parents: 368
diff changeset
   173
     A default doItAction is set for you in the initialize method."
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   174
418
777061f25321 commentary
Claus Gittinger <cg@exept.de>
parents: 368
diff changeset
   175
    doItAction := aOneArgBlock
777061f25321 commentary
Claus Gittinger <cg@exept.de>
parents: 368
diff changeset
   176
777061f25321 commentary
Claus Gittinger <cg@exept.de>
parents: 368
diff changeset
   177
    "Modified: 27.2.1996 / 15:31:37 / cg"
201
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   178
! !
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   179
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   180
!Workspace methodsFor:'compiler interface'!
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   181
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   182
currentSourceCode
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   183
    "special interface to compiler - called by parser
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   184
     to get the updated source code after a corrected error"
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   185
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   186
    ^ self contents
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   187
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   188
201
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   189
wantChangeLog
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   190
    "sent by the compiler to ask if a changeLog entry should
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   191
     be written. Return true here."
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   192
201
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   193
    ^ true
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   194
! !
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   195
418
777061f25321 commentary
Claus Gittinger <cg@exept.de>
parents: 368
diff changeset
   196
!Workspace methodsFor:'compiler interface - error handling'!
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   197
201
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   198
correctableError:aString position:relPos to:relEndPos from:aCompiler
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   199
    "compiler notifies us of a correctable error;
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   200
     hilight the error (relPos to relEndPos) and show a Box asking for continue/correct/abort;
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   201
     this method should return true to the compiler if user wants the error
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   202
     to be corrected; false otherwise"
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   203
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   204
    |action|
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   205
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   206
    self highlightingErrorPosition:relPos to:relEndPos do:[
368
53476ee1fbee checkin from browser
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
   207
        action := OptionBox 
53476ee1fbee checkin from browser
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
   208
                      request:aString
53476ee1fbee checkin from browser
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
   209
                      label:'Error'
53476ee1fbee checkin from browser
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
   210
                      form:(WarningBox iconBitmap)
53476ee1fbee checkin from browser
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
   211
                      buttonLabels:#('cancel' 'correct' 'continue')
53476ee1fbee checkin from browser
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
   212
                      values:#(#abort #correct #continue)
53476ee1fbee checkin from browser
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
   213
                      default:#continue.
201
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
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   216
    action == #abort ifTrue:[
368
53476ee1fbee checkin from browser
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
   217
        Object abortSignal raise.
53476ee1fbee checkin from browser
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
   218
        ^ false
201
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   219
    ].
368
53476ee1fbee checkin from browser
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
   220
    ^ action == #correct
53476ee1fbee checkin from browser
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
   221
53476ee1fbee checkin from browser
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
   222
    "Modified: 20.2.1996 / 20:48:52 / cg"
201
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
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   225
error:aString position:relPos to:relEndPos asWarning:asWarning
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   226
    "compiler notifies us of an error; hilight the error (relPos to relEndPos) 
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   227
     and show a Box asking for continue/abort."
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
    |answer|
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   230
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   231
    self highlightingErrorPosition:relPos to:relEndPos do:[
213
6286d3f36c14 raise warningSignal if handled (allows warnBoxes from compiler to be suppressed in debugger)
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   232
        |box lbl|
201
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   233
213
6286d3f36c14 raise warningSignal if handled (allows warnBoxes from compiler to be suppressed in debugger)
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   234
        WarningSignal isHandled ifTrue:[
6286d3f36c14 raise warningSignal if handled (allows warnBoxes from compiler to be suppressed in debugger)
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   235
            WarningSignal raiseErrorString:aString.
6286d3f36c14 raise warningSignal if handled (allows warnBoxes from compiler to be suppressed in debugger)
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   236
            ^ false
6286d3f36c14 raise warningSignal if handled (allows warnBoxes from compiler to be suppressed in debugger)
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   237
        ].
201
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   238
213
6286d3f36c14 raise warningSignal if handled (allows warnBoxes from compiler to be suppressed in debugger)
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   239
        "
6286d3f36c14 raise warningSignal if handled (allows warnBoxes from compiler to be suppressed in debugger)
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   240
         ask if we should abort or continue
6286d3f36c14 raise warningSignal if handled (allows warnBoxes from compiler to be suppressed in debugger)
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   241
        "
6286d3f36c14 raise warningSignal if handled (allows warnBoxes from compiler to be suppressed in debugger)
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   242
        box := YesNoBox title:aString
6286d3f36c14 raise warningSignal if handled (allows warnBoxes from compiler to be suppressed in debugger)
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   243
                      yesText:(resources string:'continue')
6286d3f36c14 raise warningSignal if handled (allows warnBoxes from compiler to be suppressed in debugger)
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   244
                       noText:(resources string:'abort').
6286d3f36c14 raise warningSignal if handled (allows warnBoxes from compiler to be suppressed in debugger)
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   245
6286d3f36c14 raise warningSignal if handled (allows warnBoxes from compiler to be suppressed in debugger)
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   246
        asWarning ifTrue:[
6286d3f36c14 raise warningSignal if handled (allows warnBoxes from compiler to be suppressed in debugger)
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   247
            lbl := 'Compiler warning'
6286d3f36c14 raise warningSignal if handled (allows warnBoxes from compiler to be suppressed in debugger)
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   248
        ] ifFalse:[
6286d3f36c14 raise warningSignal if handled (allows warnBoxes from compiler to be suppressed in debugger)
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   249
            lbl := 'Compiler error'.
6286d3f36c14 raise warningSignal if handled (allows warnBoxes from compiler to be suppressed in debugger)
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   250
        ].
6286d3f36c14 raise warningSignal if handled (allows warnBoxes from compiler to be suppressed in debugger)
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   251
        box label:lbl.
6286d3f36c14 raise warningSignal if handled (allows warnBoxes from compiler to be suppressed in debugger)
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   252
        box form:(WarningBox iconBitmap).
921
459081e64241 destroy box after use
Claus Gittinger <cg@exept.de>
parents: 858
diff changeset
   253
        answer := box confirm.  
459081e64241 destroy box after use
Claus Gittinger <cg@exept.de>
parents: 858
diff changeset
   254
        box destroy.
201
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   255
    ].
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   256
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   257
    "
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   258
     do the abort if we have to
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   259
    "
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   260
    answer ifFalse:[    
213
6286d3f36c14 raise warningSignal if handled (allows warnBoxes from compiler to be suppressed in debugger)
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   261
        Object abortSignal raise.
201
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   262
    ].
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   263
    ^ false
213
6286d3f36c14 raise warningSignal if handled (allows warnBoxes from compiler to be suppressed in debugger)
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   264
6286d3f36c14 raise warningSignal if handled (allows warnBoxes from compiler to be suppressed in debugger)
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   265
    "Created: 24.11.1995 / 22:56:34 / cg"
921
459081e64241 destroy box after use
Claus Gittinger <cg@exept.de>
parents: 858
diff changeset
   266
    "Modified: 7.1.1997 / 23:00:45 / cg"
201
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   267
!
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   268
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   269
error:aString position:relPos to:relEndPos from:aCompiler
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   270
    "compiler notifies us of an error; hilight the error (relPos to relEndPos) 
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   271
     and show a Box asking for continue/abort."
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   272
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   273
    ^ self error:aString position:relPos to:relEndPos asWarning:false
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   274
!
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   275
59
450ce95a72a4 *** empty log message ***
claus
parents: 58
diff changeset
   276
highlightingErrorPosition:relPos to:relEndPos do:aBlock
450ce95a72a4 *** empty log message ***
claus
parents: 58
diff changeset
   277
    "evaluate aBlock while some selection is shown highlighted with error colors."
58
28815246bbc1 *** empty log message ***
claus
parents: 54
diff changeset
   278
59
450ce95a72a4 *** empty log message ***
claus
parents: 58
diff changeset
   279
    |absPosition fg bg|
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   280
58
28815246bbc1 *** empty log message ***
claus
parents: 54
diff changeset
   281
    "
28815246bbc1 *** empty log message ***
claus
parents: 54
diff changeset
   282
     change color of selection & hide cursor
28815246bbc1 *** empty log message ***
claus
parents: 54
diff changeset
   283
    "
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   284
    fg := selectionFgColor.
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   285
    bg := selectionBgColor.
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   286
    selectionBgColor := errorBgColor.
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   287
    selectionFgColor := errorFgColor.
58
28815246bbc1 *** empty log message ***
claus
parents: 54
diff changeset
   288
    self hideCursor.
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   289
58
28815246bbc1 *** empty log message ***
claus
parents: 54
diff changeset
   290
    "
28815246bbc1 *** empty log message ***
claus
parents: 54
diff changeset
   291
     select the text - relEndPos may be nil in which case the whole line is selected
28815246bbc1 *** empty log message ***
claus
parents: 54
diff changeset
   292
     we have to adjust the positions given by the compiler, since they
28815246bbc1 *** empty log message ***
claus
parents: 54
diff changeset
   293
     are relative to the texts start (the compiler did stream-read the code).
28815246bbc1 *** empty log message ***
claus
parents: 54
diff changeset
   294
    "
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   295
    codeStartPosition isNil ifTrue:[codeStartPosition := 1].
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   296
    absPosition := codeStartPosition + relPos - 1.
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   297
    relEndPos isNil ifTrue:[
59
450ce95a72a4 *** empty log message ***
claus
parents: 58
diff changeset
   298
	self selectLineWhereCharacterPosition:absPosition
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   299
    ] ifFalse:[
59
450ce95a72a4 *** empty log message ***
claus
parents: 58
diff changeset
   300
	self selectFromCharacterPosition:absPosition to:(codeStartPosition + relEndPos - 1)
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   301
    ].
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   302
    self makeSelectionVisible.
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   303
155
claus
parents: 146
diff changeset
   304
    device flush.
58
28815246bbc1 *** empty log message ***
claus
parents: 54
diff changeset
   305
59
450ce95a72a4 *** empty log message ***
claus
parents: 58
diff changeset
   306
    aBlock valueNowOrOnUnwindDo:[
450ce95a72a4 *** empty log message ***
claus
parents: 58
diff changeset
   307
	"
450ce95a72a4 *** empty log message ***
claus
parents: 58
diff changeset
   308
	 undo selection color change and show cursor again
450ce95a72a4 *** empty log message ***
claus
parents: 58
diff changeset
   309
	"
450ce95a72a4 *** empty log message ***
claus
parents: 58
diff changeset
   310
	selectionFgColor := fg.
450ce95a72a4 *** empty log message ***
claus
parents: 58
diff changeset
   311
	selectionBgColor := bg.
450ce95a72a4 *** empty log message ***
claus
parents: 58
diff changeset
   312
	self showCursor.
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   313
    ].
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   314
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   315
116
claus
parents: 97
diff changeset
   316
warning:aString position:relPos to:relEndPos from:aCompiler 
32
b6c23dfd5663 *** empty log message ***
claus
parents: 23
diff changeset
   317
    "compiler notifies us of a warning - same behavior as error"
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   318
95
7535cfca9509 *** empty log message ***
claus
parents: 79
diff changeset
   319
    self error:aString position:relPos to:relEndPos asWarning:true 
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   320
! !
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   321
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   322
!Workspace methodsFor:'events'!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   323
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   324
keyPress:key x:x y:y
132
claus
parents: 131
diff changeset
   325
922
e6a5e1cf9565 resource spec updated
Claus Gittinger <cg@exept.de>
parents: 921
diff changeset
   326
    <resource: #keyboard (#DoIt #InspectIt #PrintIt #'CmdF*' #'CtrlF*')>
132
claus
parents: 131
diff changeset
   327
131
claus
parents: 125
diff changeset
   328
    |cmd commands fKey|
60
f3c738c24ce6 mostly style
claus
parents: 59
diff changeset
   329
32
b6c23dfd5663 *** empty log message ***
claus
parents: 23
diff changeset
   330
    (key == #DoIt)      ifTrue:[^ self doIt].
23
69f1ba57f67a *** empty log message ***
claus
parents: 15
diff changeset
   331
    (key == #InspectIt) ifTrue:[^ self inspectIt].
418
777061f25321 commentary
Claus Gittinger <cg@exept.de>
parents: 368
diff changeset
   332
    (key == #PrintIt)   ifTrue:[^ self printIt].
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 32
diff changeset
   333
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 32
diff changeset
   334
    "
131
claus
parents: 125
diff changeset
   335
     Ctrl-Fn or Cmd-Fn evaluates a key-sequence (n = 0..99)
60
f3c738c24ce6 mostly style
claus
parents: 59
diff changeset
   336
     (I added Ctrl-Fn, because some windowmanagers already use cmd-fn)
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 32
diff changeset
   337
     see TextView>>keyPress:x:y:
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 32
diff changeset
   338
    "
131
claus
parents: 125
diff changeset
   339
    key isSymbol ifTrue:[
418
777061f25321 commentary
Claus Gittinger <cg@exept.de>
parents: 368
diff changeset
   340
        (key startsWith:'CmdF') ifTrue:[
777061f25321 commentary
Claus Gittinger <cg@exept.de>
parents: 368
diff changeset
   341
            fKey := key copyFrom:4 
777061f25321 commentary
Claus Gittinger <cg@exept.de>
parents: 368
diff changeset
   342
        ] ifFalse:[
777061f25321 commentary
Claus Gittinger <cg@exept.de>
parents: 368
diff changeset
   343
            (key startsWith:'CtrlF') ifTrue:[
777061f25321 commentary
Claus Gittinger <cg@exept.de>
parents: 368
diff changeset
   344
               fKey := key copyFrom:5 
777061f25321 commentary
Claus Gittinger <cg@exept.de>
parents: 368
diff changeset
   345
            ]
777061f25321 commentary
Claus Gittinger <cg@exept.de>
parents: 368
diff changeset
   346
        ].
131
claus
parents: 125
diff changeset
   347
    ].
claus
parents: 125
diff changeset
   348
    fKey notNil ifTrue:[
418
777061f25321 commentary
Claus Gittinger <cg@exept.de>
parents: 368
diff changeset
   349
        fKey := fKey asSymbol.
777061f25321 commentary
Claus Gittinger <cg@exept.de>
parents: 368
diff changeset
   350
        commands := Smalltalk at:#FunctionKeySequences ifAbsent:[nil].
777061f25321 commentary
Claus Gittinger <cg@exept.de>
parents: 368
diff changeset
   351
        commands notNil ifTrue:[
777061f25321 commentary
Claus Gittinger <cg@exept.de>
parents: 368
diff changeset
   352
            cmd := commands at:fKey ifAbsent:[nil].
777061f25321 commentary
Claus Gittinger <cg@exept.de>
parents: 368
diff changeset
   353
            cmd notNil ifTrue:[
777061f25321 commentary
Claus Gittinger <cg@exept.de>
parents: 368
diff changeset
   354
                AbortSignal "ErrorSignal" handle:[:ex |
777061f25321 commentary
Claus Gittinger <cg@exept.de>
parents: 368
diff changeset
   355
                    self warn:'error occurred in keyboard macro'.
777061f25321 commentary
Claus Gittinger <cg@exept.de>
parents: 368
diff changeset
   356
                    ex return.
777061f25321 commentary
Claus Gittinger <cg@exept.de>
parents: 368
diff changeset
   357
                ] do:[
777061f25321 commentary
Claus Gittinger <cg@exept.de>
parents: 368
diff changeset
   358
                    Parser evaluate:cmd asString
777061f25321 commentary
Claus Gittinger <cg@exept.de>
parents: 368
diff changeset
   359
                           receiver:self
777061f25321 commentary
Claus Gittinger <cg@exept.de>
parents: 368
diff changeset
   360
                          notifying:nil
777061f25321 commentary
Claus Gittinger <cg@exept.de>
parents: 368
diff changeset
   361
                            compile:false.
777061f25321 commentary
Claus Gittinger <cg@exept.de>
parents: 368
diff changeset
   362
                ].
777061f25321 commentary
Claus Gittinger <cg@exept.de>
parents: 368
diff changeset
   363
                ^ self
777061f25321 commentary
Claus Gittinger <cg@exept.de>
parents: 368
diff changeset
   364
            ]
777061f25321 commentary
Claus Gittinger <cg@exept.de>
parents: 368
diff changeset
   365
        ]
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 32
diff changeset
   366
    ].
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 32
diff changeset
   367
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   368
    super keyPress:key x:x y:y
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 32
diff changeset
   369
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 32
diff changeset
   370
    "
418
777061f25321 commentary
Claus Gittinger <cg@exept.de>
parents: 368
diff changeset
   371
     example uses of function keys:
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 32
diff changeset
   372
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 32
diff changeset
   373
     to set tab-distance to 4-cols,
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 32
diff changeset
   374
     select the following:
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 32
diff changeset
   375
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 32
diff changeset
   376
       self setTab4
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 32
diff changeset
   377
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 32
diff changeset
   378
     then, press shift-F2 to define the sequence;
95
7535cfca9509 *** empty log message ***
claus
parents: 79
diff changeset
   379
     press cmd-F2 to execute it 
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 32
diff changeset
   380
     voila: you have set 4-tabs.
95
7535cfca9509 *** empty log message ***
claus
parents: 79
diff changeset
   381
     (some window managers (MWM, 4DWM have cmd-Fn redefined; use Ctrl-Fn then).
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 32
diff changeset
   382
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 32
diff changeset
   383
     to switch back, perform the same procedure with:
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 32
diff changeset
   384
418
777061f25321 commentary
Claus Gittinger <cg@exept.de>
parents: 368
diff changeset
   385
        self setTab8
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 32
diff changeset
   386
60
f3c738c24ce6 mostly style
claus
parents: 59
diff changeset
   387
     Within the expression, 'self' is bound to the view. Thus, you can do
f3c738c24ce6 mostly style
claus
parents: 59
diff changeset
   388
     all kinds of fancy things.
f3c738c24ce6 mostly style
claus
parents: 59
diff changeset
   389
     For example:
95
7535cfca9509 *** empty log message ***
claus
parents: 79
diff changeset
   390
       if you like a browser to come up on the selection when pressing Cmd-F3:
60
f3c738c24ce6 mostly style
claus
parents: 59
diff changeset
   391
       select:
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 32
diff changeset
   392
418
777061f25321 commentary
Claus Gittinger <cg@exept.de>
parents: 368
diff changeset
   393
        |sel|
777061f25321 commentary
Claus Gittinger <cg@exept.de>
parents: 368
diff changeset
   394
        sel := self selection asString withoutSeparators.
777061f25321 commentary
Claus Gittinger <cg@exept.de>
parents: 368
diff changeset
   395
        (Smalltalk includesKey:sel asSymbol) ifTrue:[
777061f25321 commentary
Claus Gittinger <cg@exept.de>
parents: 368
diff changeset
   396
            (Smalltalk at:sel asSymbol) isClass ifTrue:[
777061f25321 commentary
Claus Gittinger <cg@exept.de>
parents: 368
diff changeset
   397
                SystemBrowser browseClass:(Smalltalk at:sel asSymbol)
777061f25321 commentary
Claus Gittinger <cg@exept.de>
parents: 368
diff changeset
   398
            ]
777061f25321 commentary
Claus Gittinger <cg@exept.de>
parents: 368
diff changeset
   399
        ]
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 32
diff changeset
   400
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 32
diff changeset
   401
     then, press shift-F3 to define the command.
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 32
diff changeset
   402
     press cmd-F3 to execute it (select some classname before).
60
f3c738c24ce6 mostly style
claus
parents: 59
diff changeset
   403
     (notice: on the Indy, Cmd-F3 is already used by the window manager)
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 32
diff changeset
   404
95
7535cfca9509 *** empty log message ***
claus
parents: 79
diff changeset
   405
     if you like a file-include command on Cmd-F4:
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 32
diff changeset
   406
     select:
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 32
diff changeset
   407
418
777061f25321 commentary
Claus Gittinger <cg@exept.de>
parents: 368
diff changeset
   408
        |sel|
777061f25321 commentary
Claus Gittinger <cg@exept.de>
parents: 368
diff changeset
   409
        sel := self selection.
777061f25321 commentary
Claus Gittinger <cg@exept.de>
parents: 368
diff changeset
   410
        sel notNil ifTrue:[
777061f25321 commentary
Claus Gittinger <cg@exept.de>
parents: 368
diff changeset
   411
            sel := sel asString withoutSeparators.
777061f25321 commentary
Claus Gittinger <cg@exept.de>
parents: 368
diff changeset
   412
            s := FileStream readonlyFileNamed:sel.
777061f25321 commentary
Claus Gittinger <cg@exept.de>
parents: 368
diff changeset
   413
            s notNil ifTrue:[
777061f25321 commentary
Claus Gittinger <cg@exept.de>
parents: 368
diff changeset
   414
                self paste:(s contents asString).
777061f25321 commentary
Claus Gittinger <cg@exept.de>
parents: 368
diff changeset
   415
                s close
777061f25321 commentary
Claus Gittinger <cg@exept.de>
parents: 368
diff changeset
   416
            ]
777061f25321 commentary
Claus Gittinger <cg@exept.de>
parents: 368
diff changeset
   417
        ]
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 32
diff changeset
   418
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 32
diff changeset
   419
    this will paste the contents of the file at the current cusor position.
60
f3c738c24ce6 mostly style
claus
parents: 59
diff changeset
   420
    (select above expression, press Shift-F4,
f3c738c24ce6 mostly style
claus
parents: 59
diff changeset
   421
     then select any filename and press Cmd-F4)
418
777061f25321 commentary
Claus Gittinger <cg@exept.de>
parents: 368
diff changeset
   422
        try it here: /etc/passwd 
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 32
diff changeset
   423
    "
418
777061f25321 commentary
Claus Gittinger <cg@exept.de>
parents: 368
diff changeset
   424
922
e6a5e1cf9565 resource spec updated
Claus Gittinger <cg@exept.de>
parents: 921
diff changeset
   425
    "Modified: 9.1.1997 / 12:18:30 / cg"
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   426
! !
201
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   427
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   428
!Workspace methodsFor:'execution'!
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   429
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   430
doItWithValueDo:aBlock
418
777061f25321 commentary
Claus Gittinger <cg@exept.de>
parents: 368
diff changeset
   431
    "helper for doIt, printIt and inspectIt. 
777061f25321 commentary
Claus Gittinger <cg@exept.de>
parents: 368
diff changeset
   432
     Evaluate the selection and, if all went well, evaluate the argument, 
777061f25321 commentary
Claus Gittinger <cg@exept.de>
parents: 368
diff changeset
   433
     aBlock with the value.
777061f25321 commentary
Claus Gittinger <cg@exept.de>
parents: 368
diff changeset
   434
     Most work is in preparing for proper cleanup in case of abort
777061f25321 commentary
Claus Gittinger <cg@exept.de>
parents: 368
diff changeset
   435
     or other exception while the evaluation is performed.
777061f25321 commentary
Claus Gittinger <cg@exept.de>
parents: 368
diff changeset
   436
     (restore cursor, selectionColors etc.)"
201
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   437
929
22265f1bb110 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
   438
    |code selLine selCol endLine endCol cLine cCol cleanUp|
201
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   439
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   440
    code := self selection.
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   441
    code notNil ifTrue:[
257
605e68c1223f use new withExecuteCursorDo:
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
   442
        codeStartPosition := self characterPositionOfSelection.
201
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   443
257
605e68c1223f use new withExecuteCursorDo:
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
   444
        "
605e68c1223f use new withExecuteCursorDo:
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
   445
         remember selection for later - if there is an error,
605e68c1223f use new withExecuteCursorDo:
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
   446
         the notification method will highlight it.
605e68c1223f use new withExecuteCursorDo:
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
   447
         thus destroying the current selection
605e68c1223f use new withExecuteCursorDo:
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
   448
        "
605e68c1223f use new withExecuteCursorDo:
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
   449
        selLine := selectionStartLine.
605e68c1223f use new withExecuteCursorDo:
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
   450
        selCol := selectionStartCol.
605e68c1223f use new withExecuteCursorDo:
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
   451
        endLine := selectionEndLine.
605e68c1223f use new withExecuteCursorDo:
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
   452
        endCol := selectionEndCol.
605e68c1223f use new withExecuteCursorDo:
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
   453
        cCol := cursorCol.
605e68c1223f use new withExecuteCursorDo:
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
   454
        cLine := cursorLine.
201
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   455
257
605e68c1223f use new withExecuteCursorDo:
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
   456
        "
605e68c1223f use new withExecuteCursorDo:
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
   457
         cleanup: restore previous selection and cursor positions
605e68c1223f use new withExecuteCursorDo:
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
   458
        "
605e68c1223f use new withExecuteCursorDo:
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
   459
        cleanUp := [
605e68c1223f use new withExecuteCursorDo:
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
   460
                self selectFromLine:selLine col:selCol toLine:endLine col:endCol.
605e68c1223f use new withExecuteCursorDo:
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
   461
                cLine notNil ifTrue:[
605e68c1223f use new withExecuteCursorDo:
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
   462
                    self cursorLine:cLine col:cCol
605e68c1223f use new withExecuteCursorDo:
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
   463
                ].
605e68c1223f use new withExecuteCursorDo:
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
   464
        ].
201
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   465
257
605e68c1223f use new withExecuteCursorDo:
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
   466
        "
605e68c1223f use new withExecuteCursorDo:
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
   467
         perform the action.
605e68c1223f use new withExecuteCursorDo:
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
   468
         Be careful to release the reference to the value;
605e68c1223f use new withExecuteCursorDo:
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
   469
         otherwise, we could keep lots of garbage from being freed
605e68c1223f use new withExecuteCursorDo:
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
   470
         until the view gets closed
605e68c1223f use new withExecuteCursorDo:
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
   471
        "
605e68c1223f use new withExecuteCursorDo:
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
   472
        self topView withExecuteCursorDo:[
605e68c1223f use new withExecuteCursorDo:
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
   473
            [
605e68c1223f use new withExecuteCursorDo:
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
   474
                AbortSignal handle:[:ex |
605e68c1223f use new withExecuteCursorDo:
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
   475
                     ex return
605e68c1223f use new withExecuteCursorDo:
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
   476
                ] do:[
929
22265f1bb110 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
   477
                    |value|
22265f1bb110 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
   478
257
605e68c1223f use new withExecuteCursorDo:
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
   479
                    doItAction notNil ifTrue:[
929
22265f1bb110 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
   480
                        value := doItAction value:(code asString).
257
605e68c1223f use new withExecuteCursorDo:
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
   481
                        cleanUp value. cleanUp := nil.
605e68c1223f use new withExecuteCursorDo:
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
   482
                        aBlock value:value.
605e68c1223f use new withExecuteCursorDo:
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
   483
                    ]
605e68c1223f use new withExecuteCursorDo:
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
   484
                ]
605e68c1223f use new withExecuteCursorDo:
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
   485
            ] valueNowOrOnUnwindDo:[
929
22265f1bb110 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
   486
                cleanUp notNil ifTrue:[
22265f1bb110 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
   487
                    cleanUp value. cleanUp := nil
22265f1bb110 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
   488
                ].
257
605e68c1223f use new withExecuteCursorDo:
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
   489
            ]
605e68c1223f use new withExecuteCursorDo:
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
   490
        ].
201
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   491
    ]
257
605e68c1223f use new withExecuteCursorDo:
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
   492
929
22265f1bb110 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
   493
    "Modified: 11.1.1997 / 20:56:30 / cg"
201
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   494
! !
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   495
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   496
!Workspace methodsFor:'initialize / release'!
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   497
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   498
initStyle
966
824e0ecc0e6f comments
Claus Gittinger <cg@exept.de>
parents: 929
diff changeset
   499
    "setup viewStyle specifics"
824e0ecc0e6f comments
Claus Gittinger <cg@exept.de>
parents: 929
diff changeset
   500
201
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   501
    super initStyle.
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   502
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   503
    errorFgColor := DefaultErrorForegroundColor.
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   504
    errorFgColor isNil ifTrue:[errorFgColor := selectionFgColor].
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   505
    errorBgColor := DefaultErrorBackgroundColor.
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   506
    errorBgColor isNil ifTrue:[
966
824e0ecc0e6f comments
Claus Gittinger <cg@exept.de>
parents: 929
diff changeset
   507
        device hasColors ifTrue:[
824e0ecc0e6f comments
Claus Gittinger <cg@exept.de>
parents: 929
diff changeset
   508
            errorBgColor := Color red
824e0ecc0e6f comments
Claus Gittinger <cg@exept.de>
parents: 929
diff changeset
   509
        ] ifFalse:[
824e0ecc0e6f comments
Claus Gittinger <cg@exept.de>
parents: 929
diff changeset
   510
            errorBgColor := selectionBgColor
824e0ecc0e6f comments
Claus Gittinger <cg@exept.de>
parents: 929
diff changeset
   511
        ]
201
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   512
    ].
966
824e0ecc0e6f comments
Claus Gittinger <cg@exept.de>
parents: 929
diff changeset
   513
824e0ecc0e6f comments
Claus Gittinger <cg@exept.de>
parents: 929
diff changeset
   514
    "Modified: 22.1.1997 / 11:58:00 / cg"
201
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   515
!
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   516
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   517
initialize
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   518
    super initialize.
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   519
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   520
    showMatchingParenthesis := true.
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   521
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   522
    self initializeDoITAction.
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   523
!
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   524
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   525
initializeDoITAction
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   526
    "set up the block to be evaluated for doIts.
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   527
     This is done here in a separate method to allow easier
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   528
     redefinition in subclasses"
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   529
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   530
    doItAction := [:theCode |
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   531
	Compiler 
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   532
	    evaluate:theCode 
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   533
	    in:nil 
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   534
	    receiver:nil 
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   535
	    notifying:self 
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   536
	    logged:true 
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   537
	    ifFail:nil 
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   538
    ].
1251
f8d97e73a18b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1107
diff changeset
   539
!
f8d97e73a18b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1107
diff changeset
   540
f8d97e73a18b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1107
diff changeset
   541
reinitialize
f8d97e73a18b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1107
diff changeset
   542
    super reinitialize.
f8d97e73a18b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1107
diff changeset
   543
    self cursor:Cursor normal.
f8d97e73a18b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1107
diff changeset
   544
f8d97e73a18b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1107
diff changeset
   545
    "Created: 17.6.1997 / 15:39:02 / cg"
201
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   546
! !
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   547
418
777061f25321 commentary
Claus Gittinger <cg@exept.de>
parents: 368
diff changeset
   548
!Workspace methodsFor:'menu & menu actions'!
777061f25321 commentary
Claus Gittinger <cg@exept.de>
parents: 368
diff changeset
   549
777061f25321 commentary
Claus Gittinger <cg@exept.de>
parents: 368
diff changeset
   550
doIt
777061f25321 commentary
Claus Gittinger <cg@exept.de>
parents: 368
diff changeset
   551
    "user selected 'doIt' from menu; show a wait-cursor, evaluate the code
777061f25321 commentary
Claus Gittinger <cg@exept.de>
parents: 368
diff changeset
   552
     and finally restore cursor; return result of evaluation"
777061f25321 commentary
Claus Gittinger <cg@exept.de>
parents: 368
diff changeset
   553
777061f25321 commentary
Claus Gittinger <cg@exept.de>
parents: 368
diff changeset
   554
    self doItWithValueDo:[:result | ]
777061f25321 commentary
Claus Gittinger <cg@exept.de>
parents: 368
diff changeset
   555
!
777061f25321 commentary
Claus Gittinger <cg@exept.de>
parents: 368
diff changeset
   556
777061f25321 commentary
Claus Gittinger <cg@exept.de>
parents: 368
diff changeset
   557
editMenu
1107
25753e7f960f commentary
Claus Gittinger <cg@exept.de>
parents: 966
diff changeset
   558
    "return my popUpMenu; thats the superclasses menu
25753e7f960f commentary
Claus Gittinger <cg@exept.de>
parents: 966
diff changeset
   559
     PLUS st-evaluation items: doIt, printIt and inspectIt."
25753e7f960f commentary
Claus Gittinger <cg@exept.de>
parents: 966
diff changeset
   560
489
5816aa12fec8 resources
Claus Gittinger <cg@exept.de>
parents: 444
diff changeset
   561
    <resource: #keyboard (#DoIt #PrintIt #InspectIt)>
1262
d69149b5be1f resource flag: #menu -> #programMenu
Claus Gittinger <cg@exept.de>
parents: 1251
diff changeset
   562
    <resource: #programMenu>
489
5816aa12fec8 resources
Claus Gittinger <cg@exept.de>
parents: 444
diff changeset
   563
418
777061f25321 commentary
Claus Gittinger <cg@exept.de>
parents: 368
diff changeset
   564
    |m idx|
777061f25321 commentary
Claus Gittinger <cg@exept.de>
parents: 368
diff changeset
   565
777061f25321 commentary
Claus Gittinger <cg@exept.de>
parents: 368
diff changeset
   566
    m := super editMenu.
777061f25321 commentary
Claus Gittinger <cg@exept.de>
parents: 368
diff changeset
   567
777061f25321 commentary
Claus Gittinger <cg@exept.de>
parents: 368
diff changeset
   568
    "
777061f25321 commentary
Claus Gittinger <cg@exept.de>
parents: 368
diff changeset
   569
     workspaces support #doIt, #printIt and #inspectIt
777061f25321 commentary
Claus Gittinger <cg@exept.de>
parents: 368
diff changeset
   570
     add them after paste.
777061f25321 commentary
Claus Gittinger <cg@exept.de>
parents: 368
diff changeset
   571
    "
777061f25321 commentary
Claus Gittinger <cg@exept.de>
parents: 368
diff changeset
   572
    idx := m indexOf:#paste.
777061f25321 commentary
Claus Gittinger <cg@exept.de>
parents: 368
diff changeset
   573
    idx == 0 ifTrue:[idx := m indexOf:#pasteOrReplace].
777061f25321 commentary
Claus Gittinger <cg@exept.de>
parents: 368
diff changeset
   574
    idx ~~ 0 ifTrue:[
430
022b667e0d70 added accelerator display
Claus Gittinger <cg@exept.de>
parents: 421
diff changeset
   575
        m addLabels:(resources array:#('-' 'doIt' 'printIt' 'inspectIt'))
022b667e0d70 added accelerator display
Claus Gittinger <cg@exept.de>
parents: 421
diff changeset
   576
          selectors:#(nil doIt printIt inspectIt)
922
e6a5e1cf9565 resource spec updated
Claus Gittinger <cg@exept.de>
parents: 921
diff changeset
   577
          accelerators:#(nil #DoIt #PrintIt #InspectIt)
430
022b667e0d70 added accelerator display
Claus Gittinger <cg@exept.de>
parents: 421
diff changeset
   578
          after:idx
418
777061f25321 commentary
Claus Gittinger <cg@exept.de>
parents: 368
diff changeset
   579
    ].
777061f25321 commentary
Claus Gittinger <cg@exept.de>
parents: 368
diff changeset
   580
777061f25321 commentary
Claus Gittinger <cg@exept.de>
parents: 368
diff changeset
   581
    self hasSelection ifFalse:[
430
022b667e0d70 added accelerator display
Claus Gittinger <cg@exept.de>
parents: 421
diff changeset
   582
        m disableAll:#(printIt doIt inspectIt) 
418
777061f25321 commentary
Claus Gittinger <cg@exept.de>
parents: 368
diff changeset
   583
    ].
777061f25321 commentary
Claus Gittinger <cg@exept.de>
parents: 368
diff changeset
   584
777061f25321 commentary
Claus Gittinger <cg@exept.de>
parents: 368
diff changeset
   585
    ^ m.
430
022b667e0d70 added accelerator display
Claus Gittinger <cg@exept.de>
parents: 421
diff changeset
   586
1262
d69149b5be1f resource flag: #menu -> #programMenu
Claus Gittinger <cg@exept.de>
parents: 1251
diff changeset
   587
    "Modified: 3.7.1997 / 13:54:06 / cg"
418
777061f25321 commentary
Claus Gittinger <cg@exept.de>
parents: 368
diff changeset
   588
!
777061f25321 commentary
Claus Gittinger <cg@exept.de>
parents: 368
diff changeset
   589
777061f25321 commentary
Claus Gittinger <cg@exept.de>
parents: 368
diff changeset
   590
inspectIt
777061f25321 commentary
Claus Gittinger <cg@exept.de>
parents: 368
diff changeset
   591
    "user selected 'inspectIt' from menu; use doIt to evaluate the code
777061f25321 commentary
Claus Gittinger <cg@exept.de>
parents: 368
diff changeset
   592
     and start an inspector on the result"
777061f25321 commentary
Claus Gittinger <cg@exept.de>
parents: 368
diff changeset
   593
777061f25321 commentary
Claus Gittinger <cg@exept.de>
parents: 368
diff changeset
   594
    self doItWithValueDo:[:result | result inspect]
777061f25321 commentary
Claus Gittinger <cg@exept.de>
parents: 368
diff changeset
   595
!
777061f25321 commentary
Claus Gittinger <cg@exept.de>
parents: 368
diff changeset
   596
777061f25321 commentary
Claus Gittinger <cg@exept.de>
parents: 368
diff changeset
   597
printIt
777061f25321 commentary
Claus Gittinger <cg@exept.de>
parents: 368
diff changeset
   598
    "user selected 'printIt' from menu; use doIt to evaluate the code
777061f25321 commentary
Claus Gittinger <cg@exept.de>
parents: 368
diff changeset
   599
     and insert result of evaluation into my text.
777061f25321 commentary
Claus Gittinger <cg@exept.de>
parents: 368
diff changeset
   600
     If the text is readOnly, do nothing."
777061f25321 commentary
Claus Gittinger <cg@exept.de>
parents: 368
diff changeset
   601
777061f25321 commentary
Claus Gittinger <cg@exept.de>
parents: 368
diff changeset
   602
    readOnly ifTrue:[
693
8369529a2ac4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 658
diff changeset
   603
        self beep
418
777061f25321 commentary
Claus Gittinger <cg@exept.de>
parents: 368
diff changeset
   604
    ] ifFalse:[ 
777061f25321 commentary
Claus Gittinger <cg@exept.de>
parents: 368
diff changeset
   605
        self doItWithValueDo:[:result | 
777061f25321 commentary
Claus Gittinger <cg@exept.de>
parents: 368
diff changeset
   606
            self cursorLine:selectionEndLine col:(selectionEndCol + 1).
777061f25321 commentary
Claus Gittinger <cg@exept.de>
parents: 368
diff changeset
   607
            self insertSelectedStringAtCursor:(result displayString "printString")
777061f25321 commentary
Claus Gittinger <cg@exept.de>
parents: 368
diff changeset
   608
        ]
777061f25321 commentary
Claus Gittinger <cg@exept.de>
parents: 368
diff changeset
   609
    ]
777061f25321 commentary
Claus Gittinger <cg@exept.de>
parents: 368
diff changeset
   610
693
8369529a2ac4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 658
diff changeset
   611
    "Modified: 28.5.1996 / 16:59:04 / cg"
418
777061f25321 commentary
Claus Gittinger <cg@exept.de>
parents: 368
diff changeset
   612
! !
777061f25321 commentary
Claus Gittinger <cg@exept.de>
parents: 368
diff changeset
   613
206
2363a64a7c88 version at the end
Claus Gittinger <cg@exept.de>
parents: 201
diff changeset
   614
!Workspace class methodsFor:'documentation'!
2363a64a7c88 version at the end
Claus Gittinger <cg@exept.de>
parents: 201
diff changeset
   615
2363a64a7c88 version at the end
Claus Gittinger <cg@exept.de>
parents: 201
diff changeset
   616
version
1354
c260c896ea66 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1262
diff changeset
   617
    ^ '$Header: /cvs/stx/stx/libwidg/Workspace.st,v 1.56 1997-10-21 18:14:11 cg Exp $'
858
ef7ba327189b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 857
diff changeset
   618
! !