Workspace.st
author Claus Gittinger <cg@exept.de>
Mon, 26 Feb 1996 22:42:02 +0100
changeset 403 ee8f6d080077
parent 368 53476ee1fbee
child 418 777061f25321
permissions -rw-r--r--
preserve cursor (error while searching)
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
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    13
TextCollector subclass:#Workspace
257
605e68c1223f use new withExecuteCursorDo:
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
    14
	instanceVariableNames:'doItAction codeStartPosition errorFgColor errorBgColor'
605e68c1223f use new withExecuteCursorDo:
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
    15
	classVariableNames:'DefaultErrorForegroundColor DefaultErrorBackgroundColor'
605e68c1223f use new withExecuteCursorDo:
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
    16
	poolDictionaries:''
605e68c1223f use new withExecuteCursorDo:
Claus Gittinger <cg@exept.de>
parents: 237
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: 23
diff changeset
    20
!Workspace class methodsFor:'documentation'!
b6c23dfd5663 *** empty log message ***
claus
parents: 23
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
59
450ce95a72a4 *** empty log message ***
claus
parents: 58
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: 23
diff changeset
    36
documentation
b6c23dfd5663 *** empty log message ***
claus
parents: 23
diff changeset
    37
"
b6c23dfd5663 *** empty log message ***
claus
parents: 23
diff changeset
    38
    a view for editable text which can evaluate expressions.
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 32
diff changeset
    39
    I.e. its basically a view for editable text, with added
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 32
diff changeset
    40
    'doIt', 'printIt' and 'inspectIt' functions on the popup-menu.
125
claus
parents: 123
diff changeset
    41
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 32
diff changeset
    42
    The action to be performed on doIt is defined by a block,
58
28815246bbc1 *** empty log message ***
claus
parents: 54
diff changeset
    43
    which can be defined by the owner of this view.
60
f3c738c24ce6 mostly style
claus
parents: 59
diff changeset
    44
    (thus you can put a workspace into more complex widgets, and
f3c738c24ce6 mostly style
claus
parents: 59
diff changeset
    45
     control what should happen on 'doIt').
58
28815246bbc1 *** empty log message ***
claus
parents: 54
diff changeset
    46
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 32
diff changeset
    47
    A useful default action is setup, which simply evaluates the
125
claus
parents: 123
diff changeset
    48
    selection as a smalltalk expression. 
claus
parents: 123
diff changeset
    49
    (but, a lisp or prolog view could define its own action ...)
32
b6c23dfd5663 *** empty log message ***
claus
parents: 23
diff changeset
    50
123
claus
parents: 121
diff changeset
    51
claus
parents: 121
diff changeset
    52
    Caveat:
claus
parents: 121
diff changeset
    53
	in this version, Workspace does not yet support doIt in MVC setups.
claus
parents: 121
diff changeset
    54
	For now, simulate this by setting the doItAction, to notify the
claus
parents: 121
diff changeset
    55
	model manually about the doIt.
claus
parents: 121
diff changeset
    56
claus
parents: 121
diff changeset
    57
32
b6c23dfd5663 *** empty log message ***
claus
parents: 23
diff changeset
    58
    instance variables:
b6c23dfd5663 *** empty log message ***
claus
parents: 23
diff changeset
    59
121
claus
parents: 119
diff changeset
    60
      doItAction      <Block>         block to evaluate for doIt
123
claus
parents: 121
diff changeset
    61
121
claus
parents: 119
diff changeset
    62
      codeStartPosition               temporary
claus
parents: 119
diff changeset
    63
claus
parents: 119
diff changeset
    64
      errorFgColor    <Color>         fg-Color to be used when highlighting errors 
claus
parents: 119
diff changeset
    65
claus
parents: 119
diff changeset
    66
      errorBgColor    <Color>         bg-Color to be used when highlighting errors
58
28815246bbc1 *** empty log message ***
claus
parents: 54
diff changeset
    67
121
claus
parents: 119
diff changeset
    68
claus
parents: 119
diff changeset
    69
    styleSheet values:
claus
parents: 119
diff changeset
    70
claus
parents: 119
diff changeset
    71
      codeErrorSelectionForegroundColor     fg color to highlight errors
123
claus
parents: 121
diff changeset
    72
					    (default: selection fg)
121
claus
parents: 119
diff changeset
    73
      codeErrorSelectionBackgroundColor     bg color to highlight errors
123
claus
parents: 121
diff changeset
    74
					    (default: selection bg)
32
b6c23dfd5663 *** empty log message ***
claus
parents: 23
diff changeset
    75
"
201
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    76
! !
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    77
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    78
!Workspace class methodsFor:'defaults'!
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    79
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    80
updateStyleCache
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    81
    DefaultErrorForegroundColor := StyleSheet colorAt:'codeErrorSelectionForegroundColor'.
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    82
    DefaultErrorBackgroundColor := StyleSheet colorAt:'codeErrorSelectionBackgroundColor'.
32
b6c23dfd5663 *** empty log message ***
claus
parents: 23
diff changeset
    83
! !
b6c23dfd5663 *** empty log message ***
claus
parents: 23
diff changeset
    84
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    85
!Workspace class methodsFor:'getting a System Workspace'!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    86
32
b6c23dfd5663 *** empty log message ***
claus
parents: 23
diff changeset
    87
open
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    88
    "launch a new workspace"
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    89
23
69f1ba57f67a *** empty log message ***
claus
parents: 15
diff changeset
    90
    |scrollable scr topView workspace f|
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    91
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    92
    topView := StandardSystemView label:'Workspace' minExtent:(100 @ 100).
23
69f1ba57f67a *** empty log message ***
claus
parents: 15
diff changeset
    93
69f1ba57f67a *** empty log message ***
claus
parents: 15
diff changeset
    94
    scrollable := true.
69f1ba57f67a *** empty log message ***
claus
parents: 15
diff changeset
    95
    scrollable ifTrue:[
59
450ce95a72a4 *** empty log message ***
claus
parents: 58
diff changeset
    96
	scr := HVScrollableView "ScrollableView" for:self in:topView.
450ce95a72a4 *** empty log message ***
claus
parents: 58
diff changeset
    97
	scr origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
450ce95a72a4 *** empty log message ***
claus
parents: 58
diff changeset
    98
	workspace := scr scrolledView.
23
69f1ba57f67a *** empty log message ***
claus
parents: 15
diff changeset
    99
    ] ifFalse:[
59
450ce95a72a4 *** empty log message ***
claus
parents: 58
diff changeset
   100
	workspace := super origin:(0.0 @ 0.0) corner:(1.0 @ 1.0) in:topView.
450ce95a72a4 *** empty log message ***
claus
parents: 58
diff changeset
   101
	workspace level:0.
23
69f1ba57f67a *** empty log message ***
claus
parents: 15
diff changeset
   102
    ].
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   103
58
28815246bbc1 *** empty log message ***
claus
parents: 54
diff changeset
   104
    "adjust topViews extent according to my font"
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   105
    f := workspace font.
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   106
    topView extent:((f widthOf:'x') * 40) @ (f height * 10).
7
15a9291b9bd0 *** empty log message ***
claus
parents: 5
diff changeset
   107
    topView open.
131
claus
parents: 125
diff changeset
   108
    ^ workspace
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   109
58
28815246bbc1 *** empty log message ***
claus
parents: 54
diff changeset
   110
    "
28815246bbc1 *** empty log message ***
claus
parents: 54
diff changeset
   111
     Workspace open
28815246bbc1 *** empty log message ***
claus
parents: 54
diff changeset
   112
    "
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   113
! !
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   114
201
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   115
!Workspace methodsFor:'accessing'!
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   116
201
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   117
doItAction
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   118
    "return the action to be performed when 'doIt' is selected"
32
b6c23dfd5663 *** empty log message ***
claus
parents: 23
diff changeset
   119
201
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   120
    ^ doItAction
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   121
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   122
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   123
doItAction:aBlock
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   124
    "define the action to be performed when 'doIt' is selected"
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   125
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   126
    doItAction := aBlock
201
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   127
! !
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   128
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   129
!Workspace methodsFor:'compiler interface'!
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   130
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   131
currentSourceCode
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   132
    "special interface to compiler - called by parser
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   133
     to get the updated source code after a corrected error"
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   134
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   135
    ^ self contents
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   136
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   137
201
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   138
wantChangeLog
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   139
    "sent by the compiler to ask if a changeLog entry should
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   140
     be written. Return true here."
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   141
201
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   142
    ^ true
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   143
! !
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   144
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   145
!Workspace methodsFor:'error handling'!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   146
201
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   147
correctableError:aString position:relPos to:relEndPos from:aCompiler
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   148
    "compiler notifies us of a correctable error;
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   149
     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
   150
     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
   151
     to be corrected; false otherwise"
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   152
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   153
    |action|
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   154
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   155
    self highlightingErrorPosition:relPos to:relEndPos do:[
368
53476ee1fbee checkin from browser
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
   156
        action := OptionBox 
53476ee1fbee checkin from browser
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
   157
                      request:aString
53476ee1fbee checkin from browser
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
   158
                      label:'Error'
53476ee1fbee checkin from browser
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
   159
                      form:(WarningBox iconBitmap)
53476ee1fbee checkin from browser
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
   160
                      buttonLabels:#('cancel' 'correct' 'continue')
53476ee1fbee checkin from browser
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
   161
                      values:#(#abort #correct #continue)
53476ee1fbee checkin from browser
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
   162
                      default:#continue.
201
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   163
    ].
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   164
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   165
    action == #abort ifTrue:[
368
53476ee1fbee checkin from browser
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
   166
        Object abortSignal raise.
53476ee1fbee checkin from browser
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
   167
        ^ false
201
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   168
    ].
368
53476ee1fbee checkin from browser
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
   169
    ^ action == #correct
53476ee1fbee checkin from browser
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
   170
53476ee1fbee checkin from browser
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
   171
    "Modified: 20.2.1996 / 20:48:52 / cg"
201
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   172
!
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   173
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   174
error:aString position:relPos to:relEndPos asWarning:asWarning
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   175
    "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
   176
     and show a Box asking for continue/abort."
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   177
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   178
    |answer|
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
    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
   181
        |box lbl|
201
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   182
213
6286d3f36c14 raise warningSignal if handled (allows warnBoxes from compiler to be suppressed in debugger)
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   183
        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
   184
            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
   185
            ^ false
6286d3f36c14 raise warningSignal if handled (allows warnBoxes from compiler to be suppressed in debugger)
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   186
        ].
201
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   187
213
6286d3f36c14 raise warningSignal if handled (allows warnBoxes from compiler to be suppressed in debugger)
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   188
        "
6286d3f36c14 raise warningSignal if handled (allows warnBoxes from compiler to be suppressed in debugger)
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   189
         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
   190
        "
6286d3f36c14 raise warningSignal if handled (allows warnBoxes from compiler to be suppressed in debugger)
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   191
        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
   192
                      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
   193
                       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
   194
6286d3f36c14 raise warningSignal if handled (allows warnBoxes from compiler to be suppressed in debugger)
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   195
        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
   196
            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
   197
        ] ifFalse:[
6286d3f36c14 raise warningSignal if handled (allows warnBoxes from compiler to be suppressed in debugger)
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   198
            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
   199
        ].
6286d3f36c14 raise warningSignal if handled (allows warnBoxes from compiler to be suppressed in debugger)
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   200
        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
   201
        box form:(WarningBox iconBitmap).
6286d3f36c14 raise warningSignal if handled (allows warnBoxes from compiler to be suppressed in debugger)
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   202
        answer := box confirm.
201
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
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
     do the abort if we have to
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   207
    "
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   208
    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
   209
        Object abortSignal raise.
201
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   210
    ].
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   211
    ^ 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
   212
6286d3f36c14 raise warningSignal if handled (allows warnBoxes from compiler to be suppressed in debugger)
Claus Gittinger <cg@exept.de>
parents: 208
diff changeset
   213
    "Created: 24.11.1995 / 22:56:34 / cg"
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
error:aString position:relPos to:relEndPos from:aCompiler
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   217
    "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
   218
     and show a Box asking for continue/abort."
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   219
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   220
    ^ self error:aString position:relPos to:relEndPos asWarning:false
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
59
450ce95a72a4 *** empty log message ***
claus
parents: 58
diff changeset
   223
highlightingErrorPosition:relPos to:relEndPos do:aBlock
450ce95a72a4 *** empty log message ***
claus
parents: 58
diff changeset
   224
    "evaluate aBlock while some selection is shown highlighted with error colors."
58
28815246bbc1 *** empty log message ***
claus
parents: 54
diff changeset
   225
59
450ce95a72a4 *** empty log message ***
claus
parents: 58
diff changeset
   226
    |absPosition fg bg|
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   227
58
28815246bbc1 *** empty log message ***
claus
parents: 54
diff changeset
   228
    "
28815246bbc1 *** empty log message ***
claus
parents: 54
diff changeset
   229
     change color of selection & hide cursor
28815246bbc1 *** empty log message ***
claus
parents: 54
diff changeset
   230
    "
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   231
    fg := selectionFgColor.
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   232
    bg := selectionBgColor.
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   233
    selectionBgColor := errorBgColor.
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   234
    selectionFgColor := errorFgColor.
58
28815246bbc1 *** empty log message ***
claus
parents: 54
diff changeset
   235
    self hideCursor.
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   236
58
28815246bbc1 *** empty log message ***
claus
parents: 54
diff changeset
   237
    "
28815246bbc1 *** empty log message ***
claus
parents: 54
diff changeset
   238
     select the text - relEndPos may be nil in which case the whole line is selected
28815246bbc1 *** empty log message ***
claus
parents: 54
diff changeset
   239
     we have to adjust the positions given by the compiler, since they
28815246bbc1 *** empty log message ***
claus
parents: 54
diff changeset
   240
     are relative to the texts start (the compiler did stream-read the code).
28815246bbc1 *** empty log message ***
claus
parents: 54
diff changeset
   241
    "
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   242
    codeStartPosition isNil ifTrue:[codeStartPosition := 1].
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   243
    absPosition := codeStartPosition + relPos - 1.
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   244
    relEndPos isNil ifTrue:[
59
450ce95a72a4 *** empty log message ***
claus
parents: 58
diff changeset
   245
	self selectLineWhereCharacterPosition:absPosition
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   246
    ] ifFalse:[
59
450ce95a72a4 *** empty log message ***
claus
parents: 58
diff changeset
   247
	self selectFromCharacterPosition:absPosition to:(codeStartPosition + relEndPos - 1)
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   248
    ].
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   249
    self makeSelectionVisible.
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   250
155
claus
parents: 146
diff changeset
   251
    device flush.
58
28815246bbc1 *** empty log message ***
claus
parents: 54
diff changeset
   252
59
450ce95a72a4 *** empty log message ***
claus
parents: 58
diff changeset
   253
    aBlock valueNowOrOnUnwindDo:[
450ce95a72a4 *** empty log message ***
claus
parents: 58
diff changeset
   254
	"
450ce95a72a4 *** empty log message ***
claus
parents: 58
diff changeset
   255
	 undo selection color change and show cursor again
450ce95a72a4 *** empty log message ***
claus
parents: 58
diff changeset
   256
	"
450ce95a72a4 *** empty log message ***
claus
parents: 58
diff changeset
   257
	selectionFgColor := fg.
450ce95a72a4 *** empty log message ***
claus
parents: 58
diff changeset
   258
	selectionBgColor := bg.
450ce95a72a4 *** empty log message ***
claus
parents: 58
diff changeset
   259
	self showCursor.
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   260
    ].
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   261
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   262
116
claus
parents: 97
diff changeset
   263
warning:aString position:relPos to:relEndPos from:aCompiler 
32
b6c23dfd5663 *** empty log message ***
claus
parents: 23
diff changeset
   264
    "compiler notifies us of a warning - same behavior as error"
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   265
95
7535cfca9509 *** empty log message ***
claus
parents: 79
diff changeset
   266
    self error:aString position:relPos to:relEndPos asWarning:true 
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   267
! !
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   268
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   269
!Workspace methodsFor:'events'!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   270
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   271
keyPress:key x:x y:y
132
claus
parents: 131
diff changeset
   272
claus
parents: 131
diff changeset
   273
    <resource: #keyboard (#DoIt #InspectIt #PrintIt)>
claus
parents: 131
diff changeset
   274
131
claus
parents: 125
diff changeset
   275
    |cmd commands fKey|
60
f3c738c24ce6 mostly style
claus
parents: 59
diff changeset
   276
32
b6c23dfd5663 *** empty log message ***
claus
parents: 23
diff changeset
   277
    (key == #DoIt)      ifTrue:[^ self doIt].
23
69f1ba57f67a *** empty log message ***
claus
parents: 15
diff changeset
   278
    (key == #InspectIt) ifTrue:[^ self inspectIt].
79
6d917a89f7b7 *** empty log message ***
claus
parents: 67
diff changeset
   279
    (key == #PrintIt)   ifTrue:[
6d917a89f7b7 *** empty log message ***
claus
parents: 67
diff changeset
   280
	readOnly ifFalse:[self printIt].
6d917a89f7b7 *** empty log message ***
claus
parents: 67
diff changeset
   281
	^ self
6d917a89f7b7 *** empty log message ***
claus
parents: 67
diff changeset
   282
    ].
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 32
diff changeset
   283
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 32
diff changeset
   284
    "
131
claus
parents: 125
diff changeset
   285
     Ctrl-Fn or Cmd-Fn evaluates a key-sequence (n = 0..99)
60
f3c738c24ce6 mostly style
claus
parents: 59
diff changeset
   286
     (I added Ctrl-Fn, because some windowmanagers already use cmd-fn)
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 32
diff changeset
   287
     see TextView>>keyPress:x:y:
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 32
diff changeset
   288
    "
131
claus
parents: 125
diff changeset
   289
    key isSymbol ifTrue:[
claus
parents: 125
diff changeset
   290
	(key startsWith:'CmdF') ifTrue:[
claus
parents: 125
diff changeset
   291
	    fKey := key copyFrom:4 
claus
parents: 125
diff changeset
   292
	] ifFalse:[
claus
parents: 125
diff changeset
   293
	    (key startsWith:'CtrlF') ifTrue:[
claus
parents: 125
diff changeset
   294
	       fKey := key copyFrom:5 
claus
parents: 125
diff changeset
   295
	    ]
claus
parents: 125
diff changeset
   296
	].
claus
parents: 125
diff changeset
   297
    ].
claus
parents: 125
diff changeset
   298
    fKey notNil ifTrue:[
claus
parents: 125
diff changeset
   299
	fKey := fKey asSymbol.
95
7535cfca9509 *** empty log message ***
claus
parents: 79
diff changeset
   300
	commands := Smalltalk at:#FunctionKeySequences ifAbsent:[nil].
7535cfca9509 *** empty log message ***
claus
parents: 79
diff changeset
   301
	commands notNil ifTrue:[
131
claus
parents: 125
diff changeset
   302
	    cmd := commands at:fKey ifAbsent:[nil].
95
7535cfca9509 *** empty log message ***
claus
parents: 79
diff changeset
   303
	    cmd notNil ifTrue:[
365
cb7a40a691f3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 257
diff changeset
   304
		AbortSignal "ErrorSignal" handle:[:ex |
131
claus
parents: 125
diff changeset
   305
		    self warn:'error occurred in keyboard macro'.
claus
parents: 125
diff changeset
   306
		    ex return.
claus
parents: 125
diff changeset
   307
		] do:[
claus
parents: 125
diff changeset
   308
		    Parser evaluate:cmd asString
claus
parents: 125
diff changeset
   309
			   receiver:self
claus
parents: 125
diff changeset
   310
			  notifying:nil
claus
parents: 125
diff changeset
   311
			    compile:false.
claus
parents: 125
diff changeset
   312
		].
95
7535cfca9509 *** empty log message ***
claus
parents: 79
diff changeset
   313
		^ self
59
450ce95a72a4 *** empty log message ***
claus
parents: 58
diff changeset
   314
	    ]
450ce95a72a4 *** empty log message ***
claus
parents: 58
diff changeset
   315
	]
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 32
diff changeset
   316
    ].
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 32
diff changeset
   317
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   318
    super keyPress:key x:x y:y
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 32
diff changeset
   319
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 32
diff changeset
   320
    "
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 32
diff changeset
   321
     example uses of funtion keys:
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 32
diff changeset
   322
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 32
diff changeset
   323
     to set tab-distance to 4-cols,
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 32
diff changeset
   324
     select the following:
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 32
diff changeset
   325
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 32
diff changeset
   326
       self setTab4
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 32
diff changeset
   327
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 32
diff changeset
   328
     then, press shift-F2 to define the sequence;
95
7535cfca9509 *** empty log message ***
claus
parents: 79
diff changeset
   329
     press cmd-F2 to execute it 
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 32
diff changeset
   330
     voila: you have set 4-tabs.
95
7535cfca9509 *** empty log message ***
claus
parents: 79
diff changeset
   331
     (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
   332
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 32
diff changeset
   333
     to switch back, perform the same procedure with:
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 32
diff changeset
   334
59
450ce95a72a4 *** empty log message ***
claus
parents: 58
diff changeset
   335
	self setTab8
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 32
diff changeset
   336
60
f3c738c24ce6 mostly style
claus
parents: 59
diff changeset
   337
     Within the expression, 'self' is bound to the view. Thus, you can do
f3c738c24ce6 mostly style
claus
parents: 59
diff changeset
   338
     all kinds of fancy things.
f3c738c24ce6 mostly style
claus
parents: 59
diff changeset
   339
     For example:
95
7535cfca9509 *** empty log message ***
claus
parents: 79
diff changeset
   340
       if you like a browser to come up on the selection when pressing Cmd-F3:
60
f3c738c24ce6 mostly style
claus
parents: 59
diff changeset
   341
       select:
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 32
diff changeset
   342
59
450ce95a72a4 *** empty log message ***
claus
parents: 58
diff changeset
   343
	|sel|
450ce95a72a4 *** empty log message ***
claus
parents: 58
diff changeset
   344
	sel := self selection asString withoutSeparators.
450ce95a72a4 *** empty log message ***
claus
parents: 58
diff changeset
   345
	(Smalltalk includesKey:sel asSymbol) ifTrue:[
450ce95a72a4 *** empty log message ***
claus
parents: 58
diff changeset
   346
	    (Smalltalk at:sel asSymbol) isClass ifTrue:[
450ce95a72a4 *** empty log message ***
claus
parents: 58
diff changeset
   347
		SystemBrowser browseClass:(Smalltalk at:sel asSymbol)
450ce95a72a4 *** empty log message ***
claus
parents: 58
diff changeset
   348
	    ]
450ce95a72a4 *** empty log message ***
claus
parents: 58
diff changeset
   349
	]
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 32
diff changeset
   350
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 32
diff changeset
   351
     then, press shift-F3 to define the command.
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 32
diff changeset
   352
     press cmd-F3 to execute it (select some classname before).
60
f3c738c24ce6 mostly style
claus
parents: 59
diff changeset
   353
     (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
   354
95
7535cfca9509 *** empty log message ***
claus
parents: 79
diff changeset
   355
     if you like a file-include command on Cmd-F4:
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 32
diff changeset
   356
     select:
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 32
diff changeset
   357
59
450ce95a72a4 *** empty log message ***
claus
parents: 58
diff changeset
   358
	|sel|
450ce95a72a4 *** empty log message ***
claus
parents: 58
diff changeset
   359
	sel := self selection.
450ce95a72a4 *** empty log message ***
claus
parents: 58
diff changeset
   360
	sel notNil ifTrue:[
450ce95a72a4 *** empty log message ***
claus
parents: 58
diff changeset
   361
	    sel := sel asString withoutSeparators.
450ce95a72a4 *** empty log message ***
claus
parents: 58
diff changeset
   362
	    s := FileStream readonlyFileNamed:sel.
450ce95a72a4 *** empty log message ***
claus
parents: 58
diff changeset
   363
	    s notNil ifTrue:[
450ce95a72a4 *** empty log message ***
claus
parents: 58
diff changeset
   364
		self paste:(s contents asString).
450ce95a72a4 *** empty log message ***
claus
parents: 58
diff changeset
   365
		s close
450ce95a72a4 *** empty log message ***
claus
parents: 58
diff changeset
   366
	    ]
450ce95a72a4 *** empty log message ***
claus
parents: 58
diff changeset
   367
	]
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 32
diff changeset
   368
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 32
diff changeset
   369
    this will paste the contents of the file at the current cusor position.
60
f3c738c24ce6 mostly style
claus
parents: 59
diff changeset
   370
    (select above expression, press Shift-F4,
f3c738c24ce6 mostly style
claus
parents: 59
diff changeset
   371
     then select any filename and press Cmd-F4)
f3c738c24ce6 mostly style
claus
parents: 59
diff changeset
   372
	try it here: /etc/passwd 
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 32
diff changeset
   373
    "
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   374
! !
201
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   375
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   376
!Workspace methodsFor:'execution'!
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   377
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   378
doIt
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   379
    "user selected 'doIt' from menu; show a wait-cursor, evaluate the code
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   380
     and finally restore cursor; return result of evaluation"
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   381
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   382
    self doItWithValueDo:[:result | ]
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   383
!
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   384
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   385
doItWithValueDo:aBlock
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   386
    "helper for doIt, printIt and inspectIt. Evaluate the selection and,
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   387
     if all went well, evaluate the argument, aBlock with the value."
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   388
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   389
    |code value selLine selCol endLine endCol cLine cCol cleanUp|
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   390
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   391
    code := self selection.
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   392
    code notNil ifTrue:[
257
605e68c1223f use new withExecuteCursorDo:
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
   393
        codeStartPosition := self characterPositionOfSelection.
201
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   394
257
605e68c1223f use new withExecuteCursorDo:
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
   395
        "
605e68c1223f use new withExecuteCursorDo:
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
   396
         remember selection for later - if there is an error,
605e68c1223f use new withExecuteCursorDo:
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
   397
         the notification method will highlight it.
605e68c1223f use new withExecuteCursorDo:
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
   398
         thus destroying the current selection
605e68c1223f use new withExecuteCursorDo:
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
   399
        "
605e68c1223f use new withExecuteCursorDo:
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
   400
        selLine := selectionStartLine.
605e68c1223f use new withExecuteCursorDo:
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
   401
        selCol := selectionStartCol.
605e68c1223f use new withExecuteCursorDo:
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
   402
        endLine := selectionEndLine.
605e68c1223f use new withExecuteCursorDo:
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
   403
        endCol := selectionEndCol.
605e68c1223f use new withExecuteCursorDo:
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
   404
        cCol := cursorCol.
605e68c1223f use new withExecuteCursorDo:
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
   405
        cLine := cursorLine.
201
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   406
257
605e68c1223f use new withExecuteCursorDo:
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
   407
        "
605e68c1223f use new withExecuteCursorDo:
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
   408
         cleanup: restore previous selection and cursor positions
605e68c1223f use new withExecuteCursorDo:
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
   409
        "
605e68c1223f use new withExecuteCursorDo:
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
   410
        cleanUp := [
605e68c1223f use new withExecuteCursorDo:
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
   411
                self selectFromLine:selLine col:selCol toLine:endLine col:endCol.
605e68c1223f use new withExecuteCursorDo:
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
   412
                cLine notNil ifTrue:[
605e68c1223f use new withExecuteCursorDo:
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
   413
                    self cursorLine:cLine col:cCol
605e68c1223f use new withExecuteCursorDo:
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
   414
                ].
605e68c1223f use new withExecuteCursorDo:
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
   415
        ].
201
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   416
257
605e68c1223f use new withExecuteCursorDo:
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
   417
        "
605e68c1223f use new withExecuteCursorDo:
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
   418
         perform the action.
605e68c1223f use new withExecuteCursorDo:
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
   419
         Be careful to release the reference to the value;
605e68c1223f use new withExecuteCursorDo:
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
   420
         otherwise, we could keep lots of garbage from being freed
605e68c1223f use new withExecuteCursorDo:
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
   421
         until the view gets closed
605e68c1223f use new withExecuteCursorDo:
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
   422
        "
605e68c1223f use new withExecuteCursorDo:
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
   423
        self topView withExecuteCursorDo:[
605e68c1223f use new withExecuteCursorDo:
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
   424
            [
605e68c1223f use new withExecuteCursorDo:
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
   425
                AbortSignal handle:[:ex |
605e68c1223f use new withExecuteCursorDo:
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
   426
                     ex return
605e68c1223f use new withExecuteCursorDo:
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
   427
                ] do:[
605e68c1223f use new withExecuteCursorDo:
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
   428
                    doItAction notNil ifTrue:[
605e68c1223f use new withExecuteCursorDo:
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
   429
                        value := doItAction value:code asString.
605e68c1223f use new withExecuteCursorDo:
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
   430
                        cleanUp value. cleanUp := nil.
605e68c1223f use new withExecuteCursorDo:
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
   431
                        aBlock value:value.
605e68c1223f use new withExecuteCursorDo:
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
   432
                    ]
605e68c1223f use new withExecuteCursorDo:
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
   433
                ]
605e68c1223f use new withExecuteCursorDo:
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
   434
            ] valueNowOrOnUnwindDo:[
605e68c1223f use new withExecuteCursorDo:
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
   435
                cleanUp notNil ifTrue:[cleanUp value. cleanUp := nil].
605e68c1223f use new withExecuteCursorDo:
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
   436
                value := nil
605e68c1223f use new withExecuteCursorDo:
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
   437
            ]
605e68c1223f use new withExecuteCursorDo:
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
   438
        ].
201
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   439
    ]
257
605e68c1223f use new withExecuteCursorDo:
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
   440
605e68c1223f use new withExecuteCursorDo:
Claus Gittinger <cg@exept.de>
parents: 237
diff changeset
   441
    "Modified: 14.12.1995 / 21:00:05 / cg"
201
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   442
!
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   443
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   444
inspectIt
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   445
    "user selected 'inspectIt' from menu; use doIt to evaluate the code
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   446
     and start an inspector on the result"
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   447
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   448
    self doItWithValueDo:[:result | result inspect]
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   449
!
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   450
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   451
printIt
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   452
    "user selected 'printIt' from menu; use doIt to evaluate the code
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   453
     and insert result of evaluation into my text"
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   454
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   455
    self doItWithValueDo:[:result | 
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   456
	self cursorLine:selectionEndLine col:(selectionEndCol + 1).
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   457
	self insertSelectedStringAtCursor:(result displayString "printString")
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   458
    ]
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   459
! !
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   460
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   461
!Workspace methodsFor:'initialize / release'!
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   462
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   463
editMenu
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   464
    |m idx|
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   465
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   466
    m := super editMenu.
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   467
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   468
    "
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   469
     workspaces support #doIt, #printIt and #inspectIt
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   470
     add them after paste.
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   471
    "
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   472
    idx := m indexOf:#paste.
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   473
    idx == 0 ifTrue:[idx := m indexOf:#pasteOrReplace].
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   474
    idx ~~ 0 ifTrue:[
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   475
	m addLabels:(resources array:#('-' 'doIt' 'printIt' 'inspectIt'))
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   476
	  selectors:#(nil doIt printIt inspectIt)
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   477
	  after:idx.
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   478
    ].
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   479
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   480
    self hasSelection ifFalse:[
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   481
	m disableAll:#(printIt doIt inspectIt) 
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   482
    ].
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   483
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   484
    ^ m.
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   485
!
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   486
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   487
initStyle
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   488
    super initStyle.
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   489
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   490
    errorFgColor := DefaultErrorForegroundColor.
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   491
    errorFgColor isNil ifTrue:[errorFgColor := selectionFgColor].
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   492
    errorBgColor := DefaultErrorBackgroundColor.
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   493
    errorBgColor isNil ifTrue:[
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   494
	device hasColors ifTrue:[
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   495
	    errorBgColor := Color red
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   496
	] ifFalse:[
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   497
	    errorBgColor := selectionBgColor
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   498
	]
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   499
    ].
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   500
!
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   501
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   502
initialize
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   503
    super initialize.
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   504
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   505
    showMatchingParenthesis := true.
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   506
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   507
    self initializeDoITAction.
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   508
!
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   509
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   510
initializeDoITAction
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   511
    "set up the block to be evaluated for doIts.
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   512
     This is done here in a separate method to allow easier
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   513
     redefinition in subclasses"
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   514
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   515
    doItAction := [:theCode |
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   516
	Compiler 
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   517
	    evaluate:theCode 
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   518
	    in:nil 
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   519
	    receiver:nil 
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   520
	    notifying:self 
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   521
	    logged:true 
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   522
	    ifFail:nil 
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
206
2363a64a7c88 version at the end
Claus Gittinger <cg@exept.de>
parents: 201
diff changeset
   526
!Workspace class methodsFor:'documentation'!
2363a64a7c88 version at the end
Claus Gittinger <cg@exept.de>
parents: 201
diff changeset
   527
2363a64a7c88 version at the end
Claus Gittinger <cg@exept.de>
parents: 201
diff changeset
   528
version
368
53476ee1fbee checkin from browser
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
   529
^ '$Header: /cvs/stx/stx/libwidg/Workspace.st,v 1.37 1996-02-20 20:36:47 cg Exp $'! !