CodeView.st
author Claus Gittinger <cg@exept.de>
Mon, 23 Apr 2001 10:21:56 +0200
changeset 2355 986d96f5ff6c
parent 2300 68fc714627e8
child 2382 f47c847636de
permissions -rw-r--r--
added postCreateCallBack option
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
     1
"
4
88eb91574867 *** empty log message ***
claus
parents: 2
diff changeset
     2
 COPYRIGHT (c) 1989 by Claus Gittinger
70
14443a9ea4ec *** empty log message ***
claus
parents: 59
diff changeset
     3
	      All Rights Reserved
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
     4
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
     5
 This software is furnished under a license and may be used
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
     6
 only in accordance with the terms of that license and with the
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
     8
 be provided or otherwise made available to, or used by, any
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
     9
 other person.  No title to or ownership of the software is
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    10
 hereby transferred.
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    11
"
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    12
2300
68fc714627e8 Remove leading and trailing whitwpsace when accepting a method.
Stefan Vogel <sv@exept.de>
parents: 2097
diff changeset
    13
"{ Package: 'stx:libwidg' }"
68fc714627e8 Remove leading and trailing whitwpsace when accepting a method.
Stefan Vogel <sv@exept.de>
parents: 2097
diff changeset
    14
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    15
Workspace subclass:#CodeView
1749
0d0f27322523 hook for pointerOverWord actions (quick explain)
Claus Gittinger <cg@exept.de>
parents: 1625
diff changeset
    16
	instanceVariableNames:'explainAction formatAction pointerOverWordAction'
419
2bd5f73fffd2 commentary
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
    17
	classVariableNames:''
2bd5f73fffd2 commentary
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
    18
	poolDictionaries:''
2097
66d564e3752a category change
Claus Gittinger <cg@exept.de>
parents: 2046
diff changeset
    19
	category:'Views-Text'
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    20
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    21
32
b6c23dfd5663 *** empty log message ***
claus
parents: 27
diff changeset
    22
!CodeView class methodsFor:'documentation'!
b6c23dfd5663 *** empty log message ***
claus
parents: 27
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
70
14443a9ea4ec *** empty log message ***
claus
parents: 59
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: 27
diff changeset
    38
documentation
b6c23dfd5663 *** empty log message ***
claus
parents: 27
diff changeset
    39
"
125
claus
parents: 123
diff changeset
    40
    a view for text which is known to be smalltalk code. 
419
2bd5f73fffd2 commentary
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
    41
    It adds 'explain' to the menu, and defines another action: 
125
claus
parents: 123
diff changeset
    42
      explainAction to be performed for explain.
32
b6c23dfd5663 *** empty log message ***
claus
parents: 27
diff changeset
    43
125
claus
parents: 123
diff changeset
    44
    This action is to be defined by the user of this view 
917
7b66af482567 generalized commenting/uncommenting.
Claus Gittinger <cg@exept.de>
parents: 880
diff changeset
    45
    (i.e. usually the owning browser)
121
claus
parents: 118
diff changeset
    46
419
2bd5f73fffd2 commentary
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
    47
    In addition, uncomment/comment are added to the controlMenu.
2bd5f73fffd2 commentary
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
    48
    These are smalltalk specific - if you plan to edit other language code,
2bd5f73fffd2 commentary
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
    49
    you need a different kind of CodeView for that.
2bd5f73fffd2 commentary
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
    50
125
claus
parents: 123
diff changeset
    51
    If used with a model, accept sends the changeMsg to it (as defined in EditTextView).
419
2bd5f73fffd2 commentary
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
    52
    (however, it is possible to define both changeMsg and acceptAction)
123
claus
parents: 121
diff changeset
    53
419
2bd5f73fffd2 commentary
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
    54
    See how doIt/printIt/inspectIt are handled in the superclass: Workspace.
123
claus
parents: 121
diff changeset
    55
claus
parents: 121
diff changeset
    56
    Caveat:
419
2bd5f73fffd2 commentary
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
    57
        in this version, CodeView does not yet support MVC setups for doIt
2bd5f73fffd2 commentary
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
    58
        and explain.
2bd5f73fffd2 commentary
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
    59
        If required, simulate this by setting the doItAction and
2bd5f73fffd2 commentary
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
    60
        explainAction, to notify the model manually about whats going on.
583
2ec13b7ceba5 documentation
Claus Gittinger <cg@exept.de>
parents: 489
diff changeset
    61
917
7b66af482567 generalized commenting/uncommenting.
Claus Gittinger <cg@exept.de>
parents: 880
diff changeset
    62
    [instance variables:]
7b66af482567 generalized commenting/uncommenting.
Claus Gittinger <cg@exept.de>
parents: 880
diff changeset
    63
        commentStrings          <Array>         an array with 2 entries;
7b66af482567 generalized commenting/uncommenting.
Claus Gittinger <cg@exept.de>
parents: 880
diff changeset
    64
                                                the first defining the EOL-comment string,
7b66af482567 generalized commenting/uncommenting.
Claus Gittinger <cg@exept.de>
parents: 880
diff changeset
    65
                                                the 2nd (another array) defining opening
7b66af482567 generalized commenting/uncommenting.
Claus Gittinger <cg@exept.de>
parents: 880
diff changeset
    66
                                                and closing comment strings.
7b66af482567 generalized commenting/uncommenting.
Claus Gittinger <cg@exept.de>
parents: 880
diff changeset
    67
                                                Default to ST/X comments,
7b66af482567 generalized commenting/uncommenting.
Claus Gittinger <cg@exept.de>
parents: 880
diff changeset
    68
                                                can be changed in an instance for other
7b66af482567 generalized commenting/uncommenting.
Claus Gittinger <cg@exept.de>
parents: 880
diff changeset
    69
                                                programming languages.
7b66af482567 generalized commenting/uncommenting.
Claus Gittinger <cg@exept.de>
parents: 880
diff changeset
    70
583
2ec13b7ceba5 documentation
Claus Gittinger <cg@exept.de>
parents: 489
diff changeset
    71
    [author:]
2ec13b7ceba5 documentation
Claus Gittinger <cg@exept.de>
parents: 489
diff changeset
    72
        Claus Gittinger
2ec13b7ceba5 documentation
Claus Gittinger <cg@exept.de>
parents: 489
diff changeset
    73
2ec13b7ceba5 documentation
Claus Gittinger <cg@exept.de>
parents: 489
diff changeset
    74
    [see also:]
2ec13b7ceba5 documentation
Claus Gittinger <cg@exept.de>
parents: 489
diff changeset
    75
        Workspace EditTextView TextView
32
b6c23dfd5663 *** empty log message ***
claus
parents: 27
diff changeset
    76
"
201
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
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    79
!CodeView methodsFor:'accessing'!
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    80
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    81
explainAction:aBlock
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    82
    "set the action to be performed on explain"
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    83
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
    84
    explainAction := aBlock
1625
2203f9f0d3f3 preps for formatting;
Claus Gittinger <cg@exept.de>
parents: 1516
diff changeset
    85
!
2203f9f0d3f3 preps for formatting;
Claus Gittinger <cg@exept.de>
parents: 1516
diff changeset
    86
2203f9f0d3f3 preps for formatting;
Claus Gittinger <cg@exept.de>
parents: 1516
diff changeset
    87
formatAction:aBlock
2203f9f0d3f3 preps for formatting;
Claus Gittinger <cg@exept.de>
parents: 1516
diff changeset
    88
    "set the action to be performed on format"
2203f9f0d3f3 preps for formatting;
Claus Gittinger <cg@exept.de>
parents: 1516
diff changeset
    89
2203f9f0d3f3 preps for formatting;
Claus Gittinger <cg@exept.de>
parents: 1516
diff changeset
    90
    formatAction := aBlock
2203f9f0d3f3 preps for formatting;
Claus Gittinger <cg@exept.de>
parents: 1516
diff changeset
    91
2203f9f0d3f3 preps for formatting;
Claus Gittinger <cg@exept.de>
parents: 1516
diff changeset
    92
    "Created: / 17.2.1998 / 17:05:13 / cg"
1749
0d0f27322523 hook for pointerOverWord actions (quick explain)
Claus Gittinger <cg@exept.de>
parents: 1625
diff changeset
    93
!
0d0f27322523 hook for pointerOverWord actions (quick explain)
Claus Gittinger <cg@exept.de>
parents: 1625
diff changeset
    94
0d0f27322523 hook for pointerOverWord actions (quick explain)
Claus Gittinger <cg@exept.de>
parents: 1625
diff changeset
    95
pointerOverWordAction:aBlock
0d0f27322523 hook for pointerOverWord actions (quick explain)
Claus Gittinger <cg@exept.de>
parents: 1625
diff changeset
    96
    pointerOverWordAction := aBlock.
0d0f27322523 hook for pointerOverWord actions (quick explain)
Claus Gittinger <cg@exept.de>
parents: 1625
diff changeset
    97
    pointerOverWordAction notNil ifTrue:[
0d0f27322523 hook for pointerOverWord actions (quick explain)
Claus Gittinger <cg@exept.de>
parents: 1625
diff changeset
    98
        self enableMotionEvents.
0d0f27322523 hook for pointerOverWord actions (quick explain)
Claus Gittinger <cg@exept.de>
parents: 1625
diff changeset
    99
    ] ifFalse:[
0d0f27322523 hook for pointerOverWord actions (quick explain)
Claus Gittinger <cg@exept.de>
parents: 1625
diff changeset
   100
        self disableMotionEvents
0d0f27322523 hook for pointerOverWord actions (quick explain)
Claus Gittinger <cg@exept.de>
parents: 1625
diff changeset
   101
    ]
0d0f27322523 hook for pointerOverWord actions (quick explain)
Claus Gittinger <cg@exept.de>
parents: 1625
diff changeset
   102
0d0f27322523 hook for pointerOverWord actions (quick explain)
Claus Gittinger <cg@exept.de>
parents: 1625
diff changeset
   103
201
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   104
! !
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   105
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   106
!CodeView methodsFor:'event handling'!
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   107
1749
0d0f27322523 hook for pointerOverWord actions (quick explain)
Claus Gittinger <cg@exept.de>
parents: 1625
diff changeset
   108
buttonMotion:state x:x y:y
0d0f27322523 hook for pointerOverWord actions (quick explain)
Claus Gittinger <cg@exept.de>
parents: 1625
diff changeset
   109
    |col line word|
0d0f27322523 hook for pointerOverWord actions (quick explain)
Claus Gittinger <cg@exept.de>
parents: 1625
diff changeset
   110
0d0f27322523 hook for pointerOverWord actions (quick explain)
Claus Gittinger <cg@exept.de>
parents: 1625
diff changeset
   111
    pointerOverWordAction notNil ifTrue:[
0d0f27322523 hook for pointerOverWord actions (quick explain)
Claus Gittinger <cg@exept.de>
parents: 1625
diff changeset
   112
        state == 0 ifTrue:[
0d0f27322523 hook for pointerOverWord actions (quick explain)
Claus Gittinger <cg@exept.de>
parents: 1625
diff changeset
   113
            line := self visibleLineOfY:y.
0d0f27322523 hook for pointerOverWord actions (quick explain)
Claus Gittinger <cg@exept.de>
parents: 1625
diff changeset
   114
            col := self colOfX:x inVisibleLine:line.
0d0f27322523 hook for pointerOverWord actions (quick explain)
Claus Gittinger <cg@exept.de>
parents: 1625
diff changeset
   115
            line := self visibleLineToAbsoluteLine:line.
0d0f27322523 hook for pointerOverWord actions (quick explain)
Claus Gittinger <cg@exept.de>
parents: 1625
diff changeset
   116
0d0f27322523 hook for pointerOverWord actions (quick explain)
Claus Gittinger <cg@exept.de>
parents: 1625
diff changeset
   117
            self wordAtLine:line col:col do:[:selectLine :beginCol :endLine :endCol :flag |
0d0f27322523 hook for pointerOverWord actions (quick explain)
Claus Gittinger <cg@exept.de>
parents: 1625
diff changeset
   118
                word := self listAt:selectLine from:beginCol to:endCol.
0d0f27322523 hook for pointerOverWord actions (quick explain)
Claus Gittinger <cg@exept.de>
parents: 1625
diff changeset
   119
                word notNil ifTrue:[
0d0f27322523 hook for pointerOverWord actions (quick explain)
Claus Gittinger <cg@exept.de>
parents: 1625
diff changeset
   120
                    pointerOverWordAction value:word value:line value:col
0d0f27322523 hook for pointerOverWord actions (quick explain)
Claus Gittinger <cg@exept.de>
parents: 1625
diff changeset
   121
                ]
0d0f27322523 hook for pointerOverWord actions (quick explain)
Claus Gittinger <cg@exept.de>
parents: 1625
diff changeset
   122
            ].
0d0f27322523 hook for pointerOverWord actions (quick explain)
Claus Gittinger <cg@exept.de>
parents: 1625
diff changeset
   123
            ^ self
0d0f27322523 hook for pointerOverWord actions (quick explain)
Claus Gittinger <cg@exept.de>
parents: 1625
diff changeset
   124
        ].
0d0f27322523 hook for pointerOverWord actions (quick explain)
Claus Gittinger <cg@exept.de>
parents: 1625
diff changeset
   125
    ].
0d0f27322523 hook for pointerOverWord actions (quick explain)
Claus Gittinger <cg@exept.de>
parents: 1625
diff changeset
   126
    super buttonMotion:state x:x y:y
0d0f27322523 hook for pointerOverWord actions (quick explain)
Claus Gittinger <cg@exept.de>
parents: 1625
diff changeset
   127
0d0f27322523 hook for pointerOverWord actions (quick explain)
Claus Gittinger <cg@exept.de>
parents: 1625
diff changeset
   128
!
0d0f27322523 hook for pointerOverWord actions (quick explain)
Claus Gittinger <cg@exept.de>
parents: 1625
diff changeset
   129
201
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   130
keyPress:key x:x y:y
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   131
    "catch keyboard shortcuts"
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   132
274
6df4bb990f04 handle accept where acceptAction is define (this was a historic leftover)
Claus Gittinger <cg@exept.de>
parents: 206
diff changeset
   133
    <resource: #keyboard (#Explain #Help 
1625
2203f9f0d3f3 preps for formatting;
Claus Gittinger <cg@exept.de>
parents: 1516
diff changeset
   134
			  #CommentSelection #UncommentSelection)>
201
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   135
1625
2203f9f0d3f3 preps for formatting;
Claus Gittinger <cg@exept.de>
parents: 1516
diff changeset
   136
    (key == #Format)  ifTrue:[^ self format].
201
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   137
    (key == #Explain) ifTrue:[^ self explain].
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   138
    (key == #Help)    ifTrue:[^ self explain].
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   139
    (key == #CommentSelection)    ifTrue:[^ self commentSelection].
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   140
    (key == #UncommentSelection)  ifTrue:[^ self uncommentSelection].
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   141
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   142
    super keyPress:key x:x y:y
922
e6a5e1cf9565 resource spec updated
Claus Gittinger <cg@exept.de>
parents: 918
diff changeset
   143
1625
2203f9f0d3f3 preps for formatting;
Claus Gittinger <cg@exept.de>
parents: 1516
diff changeset
   144
    "Modified: / 17.2.1998 / 17:05:23 / cg"
32
b6c23dfd5663 *** empty log message ***
claus
parents: 27
diff changeset
   145
! !
b6c23dfd5663 *** empty log message ***
claus
parents: 27
diff changeset
   146
419
2bd5f73fffd2 commentary
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
   147
!CodeView methodsFor:'menu & menu actions'!
2bd5f73fffd2 commentary
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
   148
2bd5f73fffd2 commentary
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
   149
accept
2bd5f73fffd2 commentary
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
   150
    "redefined accept action;
2bd5f73fffd2 commentary
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
   151
     save cursor and selection to allow restore in case of an error
2bd5f73fffd2 commentary
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
   152
     (we are typically compiling here ... and the compiler may show
2bd5f73fffd2 commentary
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
   153
     errors by highlighting them)"
2bd5f73fffd2 commentary
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
   154
1106
7afde7c75396 added #disableAccept interface
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
   155
    acceptEnabled == false ifTrue:[
7afde7c75396 added #disableAccept interface
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
   156
        device beep.
7afde7c75396 added #disableAccept interface
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
   157
        ^ self
7afde7c75396 added #disableAccept interface
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
   158
    ].
7afde7c75396 added #disableAccept interface
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
   159
419
2bd5f73fffd2 commentary
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
   160
    codeStartPosition := 1.
2bd5f73fffd2 commentary
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
   161
    [
1106
7afde7c75396 added #disableAccept interface
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
   162
        AbortSignal handle:[:ex |
7afde7c75396 added #disableAccept interface
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
   163
            self cursor:Cursor normal.
7afde7c75396 added #disableAccept interface
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
   164
            "redraw selection in normal color"
7afde7c75396 added #disableAccept interface
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
   165
            self selectFromLine:selectionStartLine col:selectionStartCol 
7afde7c75396 added #disableAccept interface
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
   166
                         toLine:selectionEndLine col:selectionEndCol.
7afde7c75396 added #disableAccept interface
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
   167
            ex return
7afde7c75396 added #disableAccept interface
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
   168
        ] do:[
7afde7c75396 added #disableAccept interface
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
   169
            super accept.
7afde7c75396 added #disableAccept interface
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
   170
        ]
419
2bd5f73fffd2 commentary
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
   171
    ] valueNowOrOnUnwindDo:[
1106
7afde7c75396 added #disableAccept interface
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
   172
        self unselect.
419
2bd5f73fffd2 commentary
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
   173
    ]
1106
7afde7c75396 added #disableAccept interface
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
   174
7afde7c75396 added #disableAccept interface
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
   175
    "Modified: 7.3.1997 / 11:06:13 / cg"
419
2bd5f73fffd2 commentary
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
   176
!
2bd5f73fffd2 commentary
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
   177
97
cbf495fe3b64 *** empty log message ***
claus
parents: 95
diff changeset
   178
editMenu
121
claus
parents: 118
diff changeset
   179
    "return the popUpMenu;
claus
parents: 118
diff changeset
   180
     to make this independent from what is defined in superclasses,
claus
parents: 118
diff changeset
   181
     get the superclass menu and add my functions."
131
claus
parents: 125
diff changeset
   182
489
5816aa12fec8 resources
Claus Gittinger <cg@exept.de>
parents: 464
diff changeset
   183
    <resource: #keyboard (#CommentSelection #UncommentSelection 
2046
3593143e38e3 added #format.
Claus Gittinger <cg@exept.de>
parents: 1749
diff changeset
   184
                          #Accept #Explain #Format)>
1261
bdb18f73205c resource flag: #menu -> #programMenu
Claus Gittinger <cg@exept.de>
parents: 1106
diff changeset
   185
    <resource: #programMenu>
489
5816aa12fec8 resources
Claus Gittinger <cg@exept.de>
parents: 464
diff changeset
   186
1516
677fbbd9b32f care for nil sensor
Claus Gittinger <cg@exept.de>
parents: 1396
diff changeset
   187
    |m sub sensor|
38
4b9b70b2cc87 2.10.3 pre-final version
claus
parents: 32
diff changeset
   188
97
cbf495fe3b64 *** empty log message ***
claus
parents: 95
diff changeset
   189
    m := super editMenu.
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   190
1516
677fbbd9b32f care for nil sensor
Claus Gittinger <cg@exept.de>
parents: 1396
diff changeset
   191
    ((sensor := self sensor) notNil and:[sensor ctrlDown]) ifFalse:[
430
022b667e0d70 added accelerator display
Claus Gittinger <cg@exept.de>
parents: 419
diff changeset
   192
        "
022b667e0d70 added accelerator display
Claus Gittinger <cg@exept.de>
parents: 419
diff changeset
   193
         codeViews do support #accept
022b667e0d70 added accelerator display
Claus Gittinger <cg@exept.de>
parents: 419
diff changeset
   194
         ... add it after #inspectIt
022b667e0d70 added accelerator display
Claus Gittinger <cg@exept.de>
parents: 419
diff changeset
   195
        "
464
6bd2186ca548 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 430
diff changeset
   196
        m addLabels:(resources array:#('-' 'accept'))
6bd2186ca548 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 430
diff changeset
   197
          selectors:#(nil accept)
6bd2186ca548 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 430
diff changeset
   198
          accelerators:#(nil #Accept)
6bd2186ca548 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 430
diff changeset
   199
          after:#inspectIt.
131
claus
parents: 125
diff changeset
   200
1293
c0806b73dc48 disable accept menuItem, if there is no acceptAction
Claus Gittinger <cg@exept.de>
parents: 1261
diff changeset
   201
        (acceptEnabled == false 
c0806b73dc48 disable accept menuItem, if there is no acceptAction
Claus Gittinger <cg@exept.de>
parents: 1261
diff changeset
   202
        or:[acceptAction isNil]) ifTrue:[
1106
7afde7c75396 added #disableAccept interface
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
   203
            m disable:#accept
7afde7c75396 added #disableAccept interface
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
   204
        ].
7afde7c75396 added #disableAccept interface
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
   205
430
022b667e0d70 added accelerator display
Claus Gittinger <cg@exept.de>
parents: 419
diff changeset
   206
        "
022b667e0d70 added accelerator display
Claus Gittinger <cg@exept.de>
parents: 419
diff changeset
   207
         and add #explain after $gotoLine in the extra menu
022b667e0d70 added accelerator display
Claus Gittinger <cg@exept.de>
parents: 419
diff changeset
   208
        "
022b667e0d70 added accelerator display
Claus Gittinger <cg@exept.de>
parents: 419
diff changeset
   209
        sub := m subMenuAt:#others.
022b667e0d70 added accelerator display
Claus Gittinger <cg@exept.de>
parents: 419
diff changeset
   210
        sub notNil ifTrue:[
022b667e0d70 added accelerator display
Claus Gittinger <cg@exept.de>
parents: 419
diff changeset
   211
            sub addLabels:(resources array:#('-' 'explain'))
022b667e0d70 added accelerator display
Claus Gittinger <cg@exept.de>
parents: 419
diff changeset
   212
                selectors:#(nil explain)
022b667e0d70 added accelerator display
Claus Gittinger <cg@exept.de>
parents: 419
diff changeset
   213
                accelerators:#(nil Explain)
464
6bd2186ca548 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 430
diff changeset
   214
                after:#gotoLine.
430
022b667e0d70 added accelerator display
Claus Gittinger <cg@exept.de>
parents: 419
diff changeset
   215
2046
3593143e38e3 added #format.
Claus Gittinger <cg@exept.de>
parents: 1749
diff changeset
   216
            formatAction notNil ifTrue:[
3593143e38e3 added #format.
Claus Gittinger <cg@exept.de>
parents: 1749
diff changeset
   217
                sub addLabels:(resources array:#('format'))
3593143e38e3 added #format.
Claus Gittinger <cg@exept.de>
parents: 1749
diff changeset
   218
                    selectors:#(format)
3593143e38e3 added #format.
Claus Gittinger <cg@exept.de>
parents: 1749
diff changeset
   219
                    accelerators:#(Format)
3593143e38e3 added #format.
Claus Gittinger <cg@exept.de>
parents: 1749
diff changeset
   220
                    after:#indent.
3593143e38e3 added #format.
Claus Gittinger <cg@exept.de>
parents: 1749
diff changeset
   221
            ].
3593143e38e3 added #format.
Claus Gittinger <cg@exept.de>
parents: 1749
diff changeset
   222
1625
2203f9f0d3f3 preps for formatting;
Claus Gittinger <cg@exept.de>
parents: 1516
diff changeset
   223
            (self hasSelection not
2203f9f0d3f3 preps for formatting;
Claus Gittinger <cg@exept.de>
parents: 1516
diff changeset
   224
            or:[explainAction isNil]) ifTrue:[
430
022b667e0d70 added accelerator display
Claus Gittinger <cg@exept.de>
parents: 419
diff changeset
   225
                sub disable:#explain 
022b667e0d70 added accelerator display
Claus Gittinger <cg@exept.de>
parents: 419
diff changeset
   226
            ].
022b667e0d70 added accelerator display
Claus Gittinger <cg@exept.de>
parents: 419
diff changeset
   227
        ].
59
450ce95a72a4 *** empty log message ***
claus
parents: 38
diff changeset
   228
    ].
131
claus
parents: 125
diff changeset
   229
    ^ m.
430
022b667e0d70 added accelerator display
Claus Gittinger <cg@exept.de>
parents: 419
diff changeset
   230
2046
3593143e38e3 added #format.
Claus Gittinger <cg@exept.de>
parents: 1749
diff changeset
   231
    "Modified: / 22.11.1999 / 11:41:40 / cg"
136
claus
parents: 132
diff changeset
   232
!
claus
parents: 132
diff changeset
   233
201
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   234
explain
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   235
    "explain action;
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   236
     evaluate the explainBlock passing whole contents and 
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   237
     selection as arguments."
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   238
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   239
    |text|
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   240
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   241
    explainAction notNil ifTrue:[
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   242
	text := self selection.
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   243
	text notNil ifTrue:[
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   244
	    explainAction value:(self contents) value:(text asString)
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   245
	]
d2888811c664 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 174
diff changeset
   246
    ]
1625
2203f9f0d3f3 preps for formatting;
Claus Gittinger <cg@exept.de>
parents: 1516
diff changeset
   247
!
2203f9f0d3f3 preps for formatting;
Claus Gittinger <cg@exept.de>
parents: 1516
diff changeset
   248
2203f9f0d3f3 preps for formatting;
Claus Gittinger <cg@exept.de>
parents: 1516
diff changeset
   249
format
2203f9f0d3f3 preps for formatting;
Claus Gittinger <cg@exept.de>
parents: 1516
diff changeset
   250
    "format action;
2203f9f0d3f3 preps for formatting;
Claus Gittinger <cg@exept.de>
parents: 1516
diff changeset
   251
     evaluate the formatBlock passing whole contents as argument."
2203f9f0d3f3 preps for formatting;
Claus Gittinger <cg@exept.de>
parents: 1516
diff changeset
   252
2203f9f0d3f3 preps for formatting;
Claus Gittinger <cg@exept.de>
parents: 1516
diff changeset
   253
    |text|
2203f9f0d3f3 preps for formatting;
Claus Gittinger <cg@exept.de>
parents: 1516
diff changeset
   254
2203f9f0d3f3 preps for formatting;
Claus Gittinger <cg@exept.de>
parents: 1516
diff changeset
   255
    formatAction notNil ifTrue:[
2203f9f0d3f3 preps for formatting;
Claus Gittinger <cg@exept.de>
parents: 1516
diff changeset
   256
	text := self contents.
2203f9f0d3f3 preps for formatting;
Claus Gittinger <cg@exept.de>
parents: 1516
diff changeset
   257
	text notNil ifTrue:[
2203f9f0d3f3 preps for formatting;
Claus Gittinger <cg@exept.de>
parents: 1516
diff changeset
   258
	    formatAction value:(text asString)
2203f9f0d3f3 preps for formatting;
Claus Gittinger <cg@exept.de>
parents: 1516
diff changeset
   259
	]
2203f9f0d3f3 preps for formatting;
Claus Gittinger <cg@exept.de>
parents: 1516
diff changeset
   260
    ]
2203f9f0d3f3 preps for formatting;
Claus Gittinger <cg@exept.de>
parents: 1516
diff changeset
   261
2203f9f0d3f3 preps for formatting;
Claus Gittinger <cg@exept.de>
parents: 1516
diff changeset
   262
    "Created: / 17.2.1998 / 17:06:18 / cg"
2203f9f0d3f3 preps for formatting;
Claus Gittinger <cg@exept.de>
parents: 1516
diff changeset
   263
    "Modified: / 17.2.1998 / 18:25:33 / cg"
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   264
! !
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   265
206
2363a64a7c88 version at the end
Claus Gittinger <cg@exept.de>
parents: 201
diff changeset
   266
!CodeView class methodsFor:'documentation'!
2363a64a7c88 version at the end
Claus Gittinger <cg@exept.de>
parents: 201
diff changeset
   267
2363a64a7c88 version at the end
Claus Gittinger <cg@exept.de>
parents: 201
diff changeset
   268
version
2300
68fc714627e8 Remove leading and trailing whitwpsace when accepting a method.
Stefan Vogel <sv@exept.de>
parents: 2097
diff changeset
   269
    ^ '$Header: /cvs/stx/stx/libwidg/CodeView.st,v 1.44 2000-10-20 11:07:38 stefan Exp $'
206
2363a64a7c88 version at the end
Claus Gittinger <cg@exept.de>
parents: 201
diff changeset
   270
! !