ETxtView.st
author Claus Gittinger <cg@exept.de>
Tue, 21 Oct 1997 20:28:05 +0200
changeset 1355 6725ab9cc6f5
parent 1339 41b5e743d78a
child 1390 99674e1d9c85
permissions -rw-r--r--
*** empty log message ***
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
     1
"
5
claus
parents: 3
diff changeset
     2
 COPYRIGHT (c) 1989 by Claus Gittinger
59
450ce95a72a4 *** empty log message ***
claus
parents: 46
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
1355
6725ab9cc6f5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
    13
'From Smalltalk/X, Version:3.2.1 on 20-oct-1997 at 2:09:41 pm'                  !
6725ab9cc6f5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
    14
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    15
TextView subclass:#EditTextView
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
    16
	instanceVariableNames:'cursorLine cursorVisibleLine cursorCol cursorShown
331
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
    17
		prevCursorState readOnly modifiedChannel fixedSize exceptionBlock
1022
4362861fe15e allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents: 1018
diff changeset
    18
		cursorFgColor cursorBgColor cursorNoFocusFgColor cursorType
1334
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
    19
		cursorTypeNoFocus undoAction typeOfSelection lastString
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
    20
		lastReplacement lastAction replacing showMatchingParenthesis
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
    21
		hasKeyboardFocus acceptAction lockUpdates tabMeansNextField
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
    22
		autoIndent insertMode trimBlankLines wordWrap
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
    23
		replacementWordSelectStyle acceptChannel acceptEnabled'
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
    24
	classVariableNames:'DefaultCursorForegroundColor DefaultCursorBackgroundColor
1300
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
    25
		DefaultCursorType DefaultCursorNoFocusForegroundColor ST80Mode'
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
    26
	poolDictionaries:''
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
    27
	category:'Views-Text'
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    28
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    29
865
d42c7c99e67d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 840
diff changeset
    30
!EditTextView class methodsFor:'documentation'!
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    31
33
5eeef3ea8ebd added access methods for cursorLine & cursorCol
claus
parents: 25
diff changeset
    32
copyright
5eeef3ea8ebd added access methods for cursorLine & cursorCol
claus
parents: 25
diff changeset
    33
"
5eeef3ea8ebd added access methods for cursorLine & cursorCol
claus
parents: 25
diff changeset
    34
 COPYRIGHT (c) 1989 by Claus Gittinger
59
450ce95a72a4 *** empty log message ***
claus
parents: 46
diff changeset
    35
	      All Rights Reserved
33
5eeef3ea8ebd added access methods for cursorLine & cursorCol
claus
parents: 25
diff changeset
    36
5eeef3ea8ebd added access methods for cursorLine & cursorCol
claus
parents: 25
diff changeset
    37
 This software is furnished under a license and may be used
5eeef3ea8ebd added access methods for cursorLine & cursorCol
claus
parents: 25
diff changeset
    38
 only in accordance with the terms of that license and with the
5eeef3ea8ebd added access methods for cursorLine & cursorCol
claus
parents: 25
diff changeset
    39
 inclusion of the above copyright notice.   This software may not
5eeef3ea8ebd added access methods for cursorLine & cursorCol
claus
parents: 25
diff changeset
    40
 be provided or otherwise made available to, or used by, any
5eeef3ea8ebd added access methods for cursorLine & cursorCol
claus
parents: 25
diff changeset
    41
 other person.  No title to or ownership of the software is
5eeef3ea8ebd added access methods for cursorLine & cursorCol
claus
parents: 25
diff changeset
    42
 hereby transferred.
5eeef3ea8ebd added access methods for cursorLine & cursorCol
claus
parents: 25
diff changeset
    43
"
5eeef3ea8ebd added access methods for cursorLine & cursorCol
claus
parents: 25
diff changeset
    44
!
5eeef3ea8ebd added access methods for cursorLine & cursorCol
claus
parents: 25
diff changeset
    45
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    46
documentation
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    47
"
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    48
    a view for editable text - adds editing functionality to TextView
125
claus
parents: 123
diff changeset
    49
    Also, it adds accept functionality, and defines a new actionBlock: 
297
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
    50
    acceptAction to be performed for accept
125
claus
parents: 123
diff changeset
    51
claus
parents: 123
diff changeset
    52
    If used with a model, this is informed by sending it a changeMsg with
claus
parents: 123
diff changeset
    53
    the current contents as argument.
297
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
    54
    (however, it is possible to define both changeMsg and acceptAction)
125
claus
parents: 123
diff changeset
    55
309
b5c9d68e95e1 new tabbing scheme (asking via #canTab); new focus change (passing explicit to showFocus/noFocus);
Claus Gittinger <cg@exept.de>
parents: 297
diff changeset
    56
    Please read the historic notice in the ListView class.
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    57
586
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 567
diff changeset
    58
    [Instance variables:]
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    59
323
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
    60
        cursorLine              <Number>        line where cursor sits (1..)
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
    61
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
    62
        cursorVisibleLine       <Number>        visible line where cursor sits (1..nLinesShown)
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
    63
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
    64
        cursorCol               <Number>        col where cursor sits (1..)
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
    65
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
    66
        cursorShown             <Boolean>       true, if cursor is currently shown
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
    67
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
    68
        readOnly                <Boolean>       true, if text may not be edited
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
    69
1015
caf7265128b9 clear modified on accept.
Claus Gittinger <cg@exept.de>
parents: 1013
diff changeset
    70
        modifiedChannel         <ValueHolder>   holding true, if text has been modified.
caf7265128b9 clear modified on accept.
Claus Gittinger <cg@exept.de>
parents: 1013
diff changeset
    71
                                                cleared on accept.
caf7265128b9 clear modified on accept.
Claus Gittinger <cg@exept.de>
parents: 1013
diff changeset
    72
caf7265128b9 clear modified on accept.
Claus Gittinger <cg@exept.de>
parents: 1013
diff changeset
    73
        acceptChannel           <ValueHolder>   holding true, if text has been accepted.
323
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
    74
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
    75
        fixedSize               <Boolean>       true, if no lines may be added/removed
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
    76
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
    77
        exceptionBlock          <Block>         block to be evaluated when readonly text is about to be modified
586
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 567
diff changeset
    78
                                                if it returns true, the modification will be done anyway.
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 567
diff changeset
    79
                                                if it returns anything else, the modification is not done.
323
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
    80
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
    81
        cursorFgColor           <Color>         color used for cursor drawing
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
    82
        cursorBgColor           <Color>         color used for cursor drawing
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
    83
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
    84
        cursorType              <Symbol>        how the cursor is drawn; currently implemented
586
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 567
diff changeset
    85
                                                are #block (solid-block cursor), #ibeam
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 567
diff changeset
    86
                                                (vertical bar at insertion point) 
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 567
diff changeset
    87
                                                and #caret (caret below insertion-point)
323
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
    88
1334
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
    89
	cursorTypeNoFocus	<Symbol>	like above, if view has no focus
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
    90
						nil means: hide the cursor.
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
    91
323
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
    92
        undoAction              <Block>         block which undoes last cut, paste or replace
586
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 567
diff changeset
    93
                                                (not yet fully implemented)
323
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
    94
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
    95
        typeOfSelection         <Symbol>        #paste, if selection created by paste, nil otherwise
586
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 567
diff changeset
    96
                                                this affects the next keyPress: if #paste it does not
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 567
diff changeset
    97
                                                replace; otherwise it replaces the selection.
323
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
    98
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
    99
        lastCut                 <String>        last cut or replaced string
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   100
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   101
        lastReplacement         <String>        last replacement
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   102
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   103
        replacing               <Boolean>       true if entered characters replace last selection
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   104
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   105
        showMatchingParenthesis <Boolean>       if true, shows matching parenthesis
586
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 567
diff changeset
   106
                                                when entering one; this is the default.
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 567
diff changeset
   107
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 567
diff changeset
   108
        hasKeyboardFocus        <Boolean>       true if this view has the focus
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 567
diff changeset
   109
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 567
diff changeset
   110
        acceptAction            <Block>         accept action - evaluated passing the contents as 
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 567
diff changeset
   111
                                                argument 
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 567
diff changeset
   112
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 567
diff changeset
   113
        tabMeansNextField       <Boolean>       if true, Tab is ignored as input and shifts keyboard
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 567
diff changeset
   114
                                                focus to the next field. For editTextViews, this is false
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 567
diff changeset
   115
                                                by default (i.e. tabs can be entered into the text).
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 567
diff changeset
   116
                                                For some subclasses (inputFields), this may be true.
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 567
diff changeset
   117
671
f3fe0d8c604d added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents: 666
diff changeset
   118
        trimBlankLines          <Boolean>       if true, trailing blanks are
f3fe0d8c604d added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents: 666
diff changeset
   119
                                                removed when editing.
f3fe0d8c604d added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents: 666
diff changeset
   120
                                                Default is true.
f3fe0d8c604d added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents: 666
diff changeset
   121
f3fe0d8c604d added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents: 666
diff changeset
   122
        wordWrap                <Boolean>       Currently not used.
f3fe0d8c604d added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents: 666
diff changeset
   123
586
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 567
diff changeset
   124
        lockUpdates             <Boolean>       internal, private
323
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   125
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   126
        prevCursorState         <Boolean>       temporary, private
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   127
33
5eeef3ea8ebd added access methods for cursorLine & cursorCol
claus
parents: 25
diff changeset
   128
1300
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
   129
    class variables:
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
   130
        ST80Mode                <Boolean>       if true, cursor positioning is
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
   131
                                                done as in vi or ST80; i.e.
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
   132
                                                wysiwyg mode is somewhat relaxed,
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
   133
                                                in that the cursor cannot be
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
   134
                                                positioned behind a lines end.
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
   135
                                                This is not yet completely implemented.
33
5eeef3ea8ebd added access methods for cursorLine & cursorCol
claus
parents: 25
diff changeset
   136
    used globals:
5eeef3ea8ebd added access methods for cursorLine & cursorCol
claus
parents: 25
diff changeset
   137
323
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   138
        DeleteHistory           <Text>          last 1000 lines of deleted text
586
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 567
diff changeset
   139
                                                (but only if this variable exists already)
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 567
diff changeset
   140
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 567
diff changeset
   141
    [styleSheet parameters:]
121
claus
parents: 118
diff changeset
   142
323
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   143
        textCursorForegroundColor <Color>       cursor fg color; default: text background
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   144
        textCursorBackgroundColor <Color>       cursor bg color; default: text foreground
1022
4362861fe15e allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents: 1018
diff changeset
   145
        textCursorNoFocusForegroundColor 
4362861fe15e allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents: 1018
diff changeset
   146
                                  <Color>       cursor fg color if no focus; default: cursor fg color
323
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   147
        textCursorType            <Symbol>      cursor type; default:  #block
586
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 567
diff changeset
   148
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 567
diff changeset
   149
    [author:]
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 567
diff changeset
   150
        Claus Gittinger
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 567
diff changeset
   151
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 567
diff changeset
   152
    [see also:]
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   153
        CodeView Workspace TextView ListView
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   154
        EditField
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   155
"
297
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   156
!
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   157
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   158
examples
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   159
"
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   160
  non MVC operation:
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   161
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   162
    basic setup:
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   163
                                                                        [exBegin]
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   164
        |top textView|
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   165
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   166
        top := StandardSystemView new.
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   167
        top extent:300@200.
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   168
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   169
        textView := EditTextView new.
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   170
        textView origin:0.0 @ 0.0 corner:1.0 @ 1.0.
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   171
        top addSubView:textView.
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   172
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   173
        textView contents:('/etc/hosts' asFilename contentsOfEntireFile).
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   174
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   175
        top open.
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   176
                                                                        [exEnd]
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   177
297
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   178
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   179
    with vertical scrollbar:
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   180
                                                                        [exBegin]
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   181
        |top scrollView textView|
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   182
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   183
        top := StandardSystemView new.
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   184
        top extent:300@200.
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   185
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   186
        scrollView := ScrollableView for:EditTextView.
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   187
        textView := scrollView scrolledView.
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   188
        scrollView origin:0.0 @ 0.0 corner:1.0 @ 1.0.
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   189
        top addSubView:scrollView.
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   190
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   191
        textView contents:('/etc/hosts' asFilename contentsOfEntireFile).
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   192
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   193
        top open.
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   194
                                                                        [exEnd]
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   195
297
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   196
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   197
    with horizontal & vertical scrollbars:
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   198
                                                                        [exBegin]
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   199
        |top scrollView textView|
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   200
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   201
        top := StandardSystemView new.
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   202
        top extent:300@200.
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   203
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   204
        scrollView := HVScrollableView for:EditTextView.
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   205
        textView := scrollView scrolledView.
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   206
        scrollView origin:0.0 @ 0.0 corner:1.0 @ 1.0.
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   207
        top addSubView:scrollView.
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   208
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   209
        textView contents:('/etc/hosts' asFilename contentsOfEntireFile).
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   210
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   211
        top open.
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   212
                                                                        [exEnd]
297
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   213
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   214
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   215
    set the action for accept:
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   216
                                                                        [exBegin]
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   217
        |top textView|
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   218
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   219
        top := StandardSystemView new.
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   220
        top extent:300@200.
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   221
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   222
        textView := EditTextView new.
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   223
        textView origin:0.0 @ 0.0 corner:1.0 @ 1.0.
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   224
        top addSubView:textView.
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   225
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   226
        textView contents:('/etc/hosts' asFilename contentsOfEntireFile).
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   227
        textView acceptAction:[:contents |
655
acad3ef3a46c showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 654
diff changeset
   228
                                Transcript showCR:'will not overwrite the file with:'.
acad3ef3a46c showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 654
diff changeset
   229
                                Transcript showCR:contents asString
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   230
                              ].
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   231
        top open.
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   232
                                                                        [exEnd]
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   233
297
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   234
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   235
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
   236
    non-string (text) items:
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
   237
                                                                        [exBegin]
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
   238
        |top textView list|
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
   239
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
   240
        list := '/etc/hosts' asFilename contentsOfEntireFile asStringCollection.
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
   241
        1 to:list size by:2 do:[:nr |
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
   242
            list at:nr put:(Text string:(list at:nr)
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
   243
                                 emphasis:(Array with:#bold with:(#color->Color red)))
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
   244
        ].
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
   245
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
   246
        top := StandardSystemView new.
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
   247
        top extent:300@200.
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
   248
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
   249
        textView := EditTextView new.
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
   250
        textView origin:0.0 @ 0.0 corner:1.0 @ 1.0.
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
   251
        top addSubView:textView.
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
   252
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
   253
        textView contents:list.
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
   254
        top open.
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
   255
                                                                        [exEnd]
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
   256
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
   257
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
   258
297
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   259
  MVC operation:
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   260
    (the examples model here is a plug simulating a real model;
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   261
     real world applications would not use a plug ..)
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   262
                                                                        [exBegin]
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   263
        |top textView model|
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   264
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   265
        model := Plug new.
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   266
        model respondTo:#accepted:
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   267
                   with:[:newContents | 
655
acad3ef3a46c showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 654
diff changeset
   268
                                Transcript showCR:'will not overwrite the file with:'.
acad3ef3a46c showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 654
diff changeset
   269
                                Transcript showCR:newContents asString
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   270
                        ].
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   271
        model respondTo:#getList
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   272
                   with:['/etc/hosts' asFilename contentsOfEntireFile].
297
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   273
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   274
        
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   275
        top := StandardSystemView new.
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   276
        top extent:300@200.
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   277
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   278
        textView := EditTextView new.
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   279
        textView origin:0.0 @ 0.0 corner:1.0 @ 1.0.
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   280
        top addSubView:textView.
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   281
905
fa8cd14ddce2 example fixed (#listMessage:)
Claus Gittinger <cg@exept.de>
parents: 893
diff changeset
   282
        textView listMessage:#getList;
fa8cd14ddce2 example fixed (#listMessage:)
Claus Gittinger <cg@exept.de>
parents: 893
diff changeset
   283
                 model:model;
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   284
                 changeMessage:#accepted:;
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   285
                 aspect:#list.
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   286
        top open.
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   287
                                                                        [exEnd]
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   288
297
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   289
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   290
    two textViews on the same model:
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   291
                                                                        [exBegin]
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   292
        |top1 textView1 top2 textView2 model currentContents|
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   293
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   294
        model := Plug new.
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   295
        model respondTo:#accepted:
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   296
                   with:[:newContents |
655
acad3ef3a46c showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 654
diff changeset
   297
                                Transcript showCR:'accepted:'.
acad3ef3a46c showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 654
diff changeset
   298
                                Transcript showCR:newContents asString.
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   299
                                currentContents := newContents.
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   300
                                model changed:#contents
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   301
                        ].
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   302
        model respondTo:#getList
655
acad3ef3a46c showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 654
diff changeset
   303
                   with:[Transcript showCR:'query'.
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   304
                         currentContents].
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   305
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   306
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   307
        top1 := StandardSystemView new.
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   308
        top1 extent:300@200.
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   309
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   310
        textView1 := EditTextView new.
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   311
        textView1 origin:0.0 @ 0.0 corner:1.0 @ 1.0.
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   312
        top1 addSubView:textView1.
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   313
905
fa8cd14ddce2 example fixed (#listMessage:)
Claus Gittinger <cg@exept.de>
parents: 893
diff changeset
   314
        textView1 listMessage:#getList;
fa8cd14ddce2 example fixed (#listMessage:)
Claus Gittinger <cg@exept.de>
parents: 893
diff changeset
   315
                  model:model;
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   316
                  aspect:#contents;
905
fa8cd14ddce2 example fixed (#listMessage:)
Claus Gittinger <cg@exept.de>
parents: 893
diff changeset
   317
                  changeMessage:#accepted:.
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   318
        top1 open.
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   319
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   320
        top2 := StandardSystemView new.
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   321
        top2 extent:300@200.
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   322
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   323
        textView2 := EditTextView new.
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   324
        textView2 origin:0.0 @ 0.0 corner:1.0 @ 1.0.
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   325
        top2 addSubView:textView2.
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   326
905
fa8cd14ddce2 example fixed (#listMessage:)
Claus Gittinger <cg@exept.de>
parents: 893
diff changeset
   327
        textView2 listMessage:#getList;
fa8cd14ddce2 example fixed (#listMessage:)
Claus Gittinger <cg@exept.de>
parents: 893
diff changeset
   328
                  model:model;
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   329
                  aspect:#contents;
905
fa8cd14ddce2 example fixed (#listMessage:)
Claus Gittinger <cg@exept.de>
parents: 893
diff changeset
   330
                  changeMessage:#accepted:.
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   331
        top2 open.
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   332
                                                                        [exEnd]
297
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   333
"
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   334
! !
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   335
865
d42c7c99e67d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 840
diff changeset
   336
!EditTextView class methodsFor:'defaults'!
59
450ce95a72a4 *** empty log message ***
claus
parents: 46
diff changeset
   337
450ce95a72a4 *** empty log message ***
claus
parents: 46
diff changeset
   338
updateStyleCache
440
2beb33cb0146 added style resource directive
Claus Gittinger <cg@exept.de>
parents: 428
diff changeset
   339
    "extract values from the styleSheet and cache them in class variables"
2beb33cb0146 added style resource directive
Claus Gittinger <cg@exept.de>
parents: 428
diff changeset
   340
1355
6725ab9cc6f5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
   341
    <resource: #style (#'textCursor.foregroundColor' #'textCursorBackgroundColor'
6725ab9cc6f5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
   342
                       #'textCursor.noFocusForegroundColor' 
6725ab9cc6f5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
   343
                       #'textCursor.type' )>
6725ab9cc6f5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
   344
6725ab9cc6f5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
   345
    DefaultCursorForegroundColor := StyleSheet colorAt:'textCursor.foregroundColor'.
6725ab9cc6f5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
   346
    DefaultCursorBackgroundColor := StyleSheet colorAt:'textCursor.backgroundColor'.
6725ab9cc6f5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
   347
    DefaultCursorNoFocusForegroundColor := StyleSheet colorAt:'textCursor.noFocusForegroundColor'.
6725ab9cc6f5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
   348
    DefaultCursorType := StyleSheet at:'textCursor.type' default:#block.
440
2beb33cb0146 added style resource directive
Claus Gittinger <cg@exept.de>
parents: 428
diff changeset
   349
1300
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
   350
    ST80Mode := false.
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
   351
1355
6725ab9cc6f5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
   352
    "Modified: 20.10.1997 / 13:54:30 / cg"
59
450ce95a72a4 *** empty log message ***
claus
parents: 46
diff changeset
   353
! !
450ce95a72a4 *** empty log message ***
claus
parents: 46
diff changeset
   354
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   355
!EditTextView methodsFor:'ST-80 compatibility editing'!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   356
1294
dac755d4acd3 added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   357
insert:aString at:aCharacterPosition
dac755d4acd3 added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   358
    "insert a string at aCharacterPosition."
dac755d4acd3 added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   359
dac755d4acd3 added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   360
    |line col|
dac755d4acd3 added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   361
dac755d4acd3 added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   362
    line := self lineOfCharacterPosition:aCharacterPosition.
dac755d4acd3 added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   363
    col := aCharacterPosition - (self characterPositionOfLine:line col:1) + 1.
dac755d4acd3 added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   364
    self insertString:aString atLine:line col:col.
dac755d4acd3 added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   365
dac755d4acd3 added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   366
    "
dac755d4acd3 added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   367
     |top v|
dac755d4acd3 added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   368
dac755d4acd3 added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   369
     top := StandardSystemView new.
dac755d4acd3 added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   370
     top extent:300@300.
dac755d4acd3 added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   371
     v := EditTextView origin:0.0@0.0 corner:1.0@1.0 in:top.
dac755d4acd3 added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   372
     top openAndWait.
dac755d4acd3 added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   373
     v contents:'1234567890\1234567890\1234567890\' withCRs.
dac755d4acd3 added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   374
     v insert:'<- hello there' at:5.
dac755d4acd3 added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   375
    "
dac755d4acd3 added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   376
dac755d4acd3 added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   377
    "Modified: 2.8.1997 / 19:10:09 / cg"
dac755d4acd3 added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   378
!
dac755d4acd3 added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   379
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   380
insertAndSelect:aString at:aCharacterPosition
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   381
    "insert a selected string at aCharacterPosition."
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   382
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   383
    |line col|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   384
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   385
    line := self lineOfCharacterPosition:aCharacterPosition.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   386
    col := aCharacterPosition - (self characterPositionOfLine:line col:1) + 1.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   387
    self insertString:aString atLine:line col:col.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   388
    self selectFromLine:line col:col toLine:line col:col + aString size - 1
125
claus
parents: 123
diff changeset
   389
    "
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   390
     |v|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   391
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   392
     v := EditTextView new openAndWait.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   393
     v contents:'1234567890\1234567890\1234567890\' withCRs.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   394
     v insertAndSelect:'<- hello there' at:5.
125
claus
parents: 123
diff changeset
   395
    "
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   396
! !
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   397
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   398
!EditTextView methodsFor:'accessing-behavior'!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   399
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   400
acceptAction
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   401
    "return the action to be performed on accept (or nil)"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   402
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   403
    ^ acceptAction
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   404
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   405
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   406
acceptAction:aBlock
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   407
    "set the action to be performed on accept"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   408
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   409
    acceptAction := aBlock
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   410
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   411
1108
3d14bb6bceb7 added disableAccept
Claus Gittinger <cg@exept.de>
parents: 1082
diff changeset
   412
acceptEnabled:aBoolean
3d14bb6bceb7 added disableAccept
Claus Gittinger <cg@exept.de>
parents: 1082
diff changeset
   413
    "enable/disable accept. This greys the corresponding item in the menu"
3d14bb6bceb7 added disableAccept
Claus Gittinger <cg@exept.de>
parents: 1082
diff changeset
   414
3d14bb6bceb7 added disableAccept
Claus Gittinger <cg@exept.de>
parents: 1082
diff changeset
   415
    acceptEnabled := aBoolean
3d14bb6bceb7 added disableAccept
Claus Gittinger <cg@exept.de>
parents: 1082
diff changeset
   416
3d14bb6bceb7 added disableAccept
Claus Gittinger <cg@exept.de>
parents: 1082
diff changeset
   417
    "Created: 7.3.1997 / 11:04:34 / cg"
3d14bb6bceb7 added disableAccept
Claus Gittinger <cg@exept.de>
parents: 1082
diff changeset
   418
!
3d14bb6bceb7 added disableAccept
Claus Gittinger <cg@exept.de>
parents: 1082
diff changeset
   419
474
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   420
autoIndent:aBoolean
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   421
    autoIndent := aBoolean
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   422
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   423
    "Created: 5.3.1996 / 14:37:50 / cg"
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   424
!
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   425
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   426
exceptionBlock:aBlock
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   427
    "define the action to be triggered when user tries to modify
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   428
     readonly text"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   429
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   430
    exceptionBlock := aBlock
323
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   431
!
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   432
477
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
   433
insertMode:aBoolean
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
   434
    insertMode := aBoolean
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
   435
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
   436
    "Created: 6.3.1996 / 12:24:05 / cg"
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
   437
!
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
   438
323
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   439
tabMeansNextField:aBoolean
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   440
    "set/clear tabbing to the next field.
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   441
     If true, Tab is ignored and shifts the keyboard focus.
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   442
     If false, tabs can be entered into the text.
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   443
     The default is true for editTextView, false for single-line
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   444
     input fields."
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   445
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   446
    tabMeansNextField := aBoolean
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   447
! !
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   448
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   449
!EditTextView methodsFor:'accessing-contents'!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   450
1013
391290c747b3 added an acceptChannel
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
   451
acceptChannel
391290c747b3 added an acceptChannel
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
   452
    "return the valueHolder holding true if text was accepted"
391290c747b3 added an acceptChannel
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
   453
391290c747b3 added an acceptChannel
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
   454
    ^ acceptChannel
391290c747b3 added an acceptChannel
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
   455
391290c747b3 added an acceptChannel
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
   456
    "Modified: 14.2.1997 / 16:44:18 / cg"
391290c747b3 added an acceptChannel
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
   457
!
391290c747b3 added an acceptChannel
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
   458
391290c747b3 added an acceptChannel
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
   459
accepted
391290c747b3 added an acceptChannel
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
   460
    "return true if text was accepted"
391290c747b3 added an acceptChannel
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
   461
391290c747b3 added an acceptChannel
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
   462
    ^ acceptChannel value
391290c747b3 added an acceptChannel
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
   463
391290c747b3 added an acceptChannel
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
   464
    "Created: 14.2.1997 / 16:43:46 / cg"
391290c747b3 added an acceptChannel
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
   465
!
391290c747b3 added an acceptChannel
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
   466
391290c747b3 added an acceptChannel
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
   467
accepted:aBoolean
391290c747b3 added an acceptChannel
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
   468
    "set/clear the accepted flag"
391290c747b3 added an acceptChannel
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
   469
391290c747b3 added an acceptChannel
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
   470
    acceptChannel value:aBoolean
391290c747b3 added an acceptChannel
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
   471
391290c747b3 added an acceptChannel
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
   472
    "Created: 14.2.1997 / 16:44:01 / cg"
391290c747b3 added an acceptChannel
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
   473
!
391290c747b3 added an acceptChannel
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
   474
522
aa9458e4643e indent/undent did not trigger a modify
ca
parents: 503
diff changeset
   475
at:lineNr put:aLine
aa9458e4643e indent/undent did not trigger a modify
ca
parents: 503
diff changeset
   476
    (self at:lineNr) = aLine ifFalse:[
aa9458e4643e indent/undent did not trigger a modify
ca
parents: 503
diff changeset
   477
        super at:lineNr put:aLine.
aa9458e4643e indent/undent did not trigger a modify
ca
parents: 503
diff changeset
   478
        self textChanged
aa9458e4643e indent/undent did not trigger a modify
ca
parents: 503
diff changeset
   479
    ].
aa9458e4643e indent/undent did not trigger a modify
ca
parents: 503
diff changeset
   480
!
aa9458e4643e indent/undent did not trigger a modify
ca
parents: 503
diff changeset
   481
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   482
characterUnderCursor
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   483
    "return the character under the cursor - space if behond line.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   484
     For non-block cursors, this is the character immediately to the right
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   485
     of the insertion-bar or caret."
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   486
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   487
    ^ self characterAtLine:cursorLine col:cursorCol
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   488
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   489
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   490
contents
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   491
    "return the contents as a String"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   492
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   493
    list isNil ifTrue:[^ ''].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   494
    self removeTrailingBlankLines.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   495
    ^ list asStringWithCRs
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   496
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   497
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   498
cursorCol
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   499
    "return the cursors col (1..).
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   500
     This is the absolute col; NOT the visible col"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   501
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   502
    ^ cursorCol
125
claus
parents: 123
diff changeset
   503
!
claus
parents: 123
diff changeset
   504
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   505
cursorLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   506
    "return the cursors line (1..). 
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   507
     This is the absolute line; NOT the visible line"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   508
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   509
    ^ cursorLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   510
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   511
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   512
fixedSize
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   513
    "make the texts size fixed (no lines may be added).
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   514
     OBSOLETE: use readOnly"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   515
1018
427190d7026f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1017
diff changeset
   516
    self obsoleteMethodWarning:'use #readOnly:'.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   517
    readOnly ifFalse:[
1018
427190d7026f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1017
diff changeset
   518
        readOnly := true.
427190d7026f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1017
diff changeset
   519
        middleButtonMenu notNil ifTrue:[
427190d7026f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1017
diff changeset
   520
            middleButtonMenu disableAll:#(cut paste replace indent)
427190d7026f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1017
diff changeset
   521
        ]
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   522
    ]
1018
427190d7026f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1017
diff changeset
   523
427190d7026f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1017
diff changeset
   524
    "Modified: 14.2.1997 / 17:35:24 / cg"
127
claus
parents: 125
diff changeset
   525
!
claus
parents: 125
diff changeset
   526
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   527
fromFile:aFileName
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   528
    "take contents from a named file"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   529
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   530
    self contents:(aFileName asFilename readStream contents)
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   531
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   532
1037
2ff1891e1ecb added #isReadOnly
ca
parents: 1025
diff changeset
   533
isReadOnly
2ff1891e1ecb added #isReadOnly
ca
parents: 1025
diff changeset
   534
    "return true, if the text is readonly."
2ff1891e1ecb added #isReadOnly
ca
parents: 1025
diff changeset
   535
2ff1891e1ecb added #isReadOnly
ca
parents: 1025
diff changeset
   536
    ^ readOnly 
2ff1891e1ecb added #isReadOnly
ca
parents: 1025
diff changeset
   537
2ff1891e1ecb added #isReadOnly
ca
parents: 1025
diff changeset
   538
    "Modified: 14.2.1997 / 17:35:56 / cg"
2ff1891e1ecb added #isReadOnly
ca
parents: 1025
diff changeset
   539
!
2ff1891e1ecb added #isReadOnly
ca
parents: 1025
diff changeset
   540
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   541
list:something
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   542
    "position cursor home when setting contents"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   543
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   544
    super list:something.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   545
    self cursorHome
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   546
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   547
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   548
modified
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   549
    "return true if text was modified"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   550
331
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
   551
    ^ modifiedChannel value
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
   552
!
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
   553
362
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
   554
modified:aBoolean
1013
391290c747b3 added an acceptChannel
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
   555
    "set/clear the modified flag"
362
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
   556
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
   557
    modifiedChannel value:aBoolean
1013
391290c747b3 added an acceptChannel
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
   558
391290c747b3 added an acceptChannel
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
   559
    "Modified: 14.2.1997 / 16:44:05 / cg"
362
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
   560
!
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
   561
331
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
   562
modifiedChannel
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
   563
    "return the valueHolder holding true if text was modified"
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
   564
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
   565
    ^ modifiedChannel
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   566
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   567
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   568
readOnly
1018
427190d7026f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1017
diff changeset
   569
    "make the text readonly.
427190d7026f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1017
diff changeset
   570
     Somewhat obsolete - use #readOnly:"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   571
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   572
    readOnly := true
1018
427190d7026f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1017
diff changeset
   573
427190d7026f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1017
diff changeset
   574
    "Modified: 14.2.1997 / 17:35:56 / cg"
427190d7026f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1017
diff changeset
   575
!
427190d7026f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1017
diff changeset
   576
427190d7026f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1017
diff changeset
   577
readOnly:aBoolean
427190d7026f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1017
diff changeset
   578
    "make the text readonly or writable"
427190d7026f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1017
diff changeset
   579
427190d7026f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1017
diff changeset
   580
    readOnly := aBoolean
427190d7026f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1017
diff changeset
   581
427190d7026f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1017
diff changeset
   582
    "Created: 14.2.1997 / 17:35:39 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   583
! !
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   584
474
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   585
!EditTextView methodsFor:'accessing-look'!
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   586
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   587
cursorForegroundColor:color1 backgroundColor:color2
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   588
    "set both cursor foreground and cursor background colors"
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   589
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   590
    |wasOn|
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   591
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   592
    wasOn := self hideCursor.
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   593
    cursorFgColor := color1 on:device.
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   594
    cursorBgColor := color2 on:device.
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   595
    wasOn ifTrue:[self showCursor]
1333
56af09878b96 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1325
diff changeset
   596
!
56af09878b96 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1325
diff changeset
   597
56af09878b96 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1325
diff changeset
   598
cursorType:aCursorTypeSymbol
56af09878b96 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1325
diff changeset
   599
    "set the style of the text cursor.
56af09878b96 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1325
diff changeset
   600
     Currently, supported are: #block, #frame, #ibeam, #caret, #solidCaret
56af09878b96 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1325
diff changeset
   601
                               #bigCaret and #bigSolidCaret"
56af09878b96 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1325
diff changeset
   602
1334
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
   603
    cursorType := aCursorTypeSymbol.
1333
56af09878b96 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1325
diff changeset
   604
56af09878b96 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1325
diff changeset
   605
    "Created: 21.9.1997 / 13:42:23 / cg"
56af09878b96 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1325
diff changeset
   606
    "Modified: 21.9.1997 / 13:43:35 / cg"
1334
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
   607
!
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
   608
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
   609
cursorTypeNoFocus:aCursorTypeSymbol
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
   610
    "set the style of the text cursor when the view has no focus.
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
   611
     If left unspecified, this is the same as the regular cursorType."
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
   612
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
   613
    cursorTypeNoFocus := aCursorTypeSymbol
474
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   614
! !
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   615
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   616
!EditTextView methodsFor:'change & update '!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   617
125
claus
parents: 123
diff changeset
   618
accept
claus
parents: 123
diff changeset
   619
    "accept the current contents by executing the accept-action and/or
claus
parents: 123
diff changeset
   620
     changeMessage."
claus
parents: 123
diff changeset
   621
1108
3d14bb6bceb7 added disableAccept
Claus Gittinger <cg@exept.de>
parents: 1082
diff changeset
   622
    acceptEnabled == false ifTrue:[
3d14bb6bceb7 added disableAccept
Claus Gittinger <cg@exept.de>
parents: 1082
diff changeset
   623
        device beep.
3d14bb6bceb7 added disableAccept
Claus Gittinger <cg@exept.de>
parents: 1082
diff changeset
   624
        ^ self
3d14bb6bceb7 added disableAccept
Claus Gittinger <cg@exept.de>
parents: 1082
diff changeset
   625
    ].
3d14bb6bceb7 added disableAccept
Claus Gittinger <cg@exept.de>
parents: 1082
diff changeset
   626
125
claus
parents: 123
diff changeset
   627
    lockUpdates := true.
1013
391290c747b3 added an acceptChannel
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
   628
391290c747b3 added an acceptChannel
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
   629
    "/
391290c747b3 added an acceptChannel
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
   630
    "/ ST-80 way of doing it
391290c747b3 added an acceptChannel
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
   631
    "/
391290c747b3 added an acceptChannel
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
   632
    model notNil ifTrue:[
391290c747b3 added an acceptChannel
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
   633
        self sendChangeMessageWith:self argForChangeMessage.
391290c747b3 added an acceptChannel
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
   634
    ].
391290c747b3 added an acceptChannel
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
   635
757
2cc7e423f0ef only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents: 730
diff changeset
   636
    "/
2cc7e423f0ef only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents: 730
diff changeset
   637
    "/ ST/X way of doing things
2cc7e423f0ef only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents: 730
diff changeset
   638
    "/ as a historic (and temporary) leftover,
2cc7e423f0ef only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents: 730
diff changeset
   639
    "/ the block is called with a stringCollection
2cc7e423f0ef only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents: 730
diff changeset
   640
    "/ - not with the actual string
2cc7e423f0ef only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents: 730
diff changeset
   641
    "/
2cc7e423f0ef only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents: 730
diff changeset
   642
    acceptAction notNil ifTrue:[
2cc7e423f0ef only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents: 730
diff changeset
   643
        acceptAction value:self list
2cc7e423f0ef only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents: 730
diff changeset
   644
    ].
2cc7e423f0ef only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents: 730
diff changeset
   645
1017
Claus Gittinger <cg@exept.de>
parents: 1015
diff changeset
   646
    self modified:false.
1015
caf7265128b9 clear modified on accept.
Claus Gittinger <cg@exept.de>
parents: 1013
diff changeset
   647
    self accepted:true.
125
claus
parents: 123
diff changeset
   648
claus
parents: 123
diff changeset
   649
    lockUpdates := false.
757
2cc7e423f0ef only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents: 730
diff changeset
   650
1108
3d14bb6bceb7 added disableAccept
Claus Gittinger <cg@exept.de>
parents: 1082
diff changeset
   651
    "Modified: 7.3.1997 / 11:05:50 / cg"
131
claus
parents: 130
diff changeset
   652
!
claus
parents: 130
diff changeset
   653
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   654
argForChangeMessage
597
fb42c94a042e commentary
Claus Gittinger <cg@exept.de>
parents: 594
diff changeset
   655
    "return the argument to be passed with the change notification.
fb42c94a042e commentary
Claus Gittinger <cg@exept.de>
parents: 594
diff changeset
   656
     Defined as separate method for easier subclassability."
fb42c94a042e commentary
Claus Gittinger <cg@exept.de>
parents: 594
diff changeset
   657
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   658
    ^ self contents
597
fb42c94a042e commentary
Claus Gittinger <cg@exept.de>
parents: 594
diff changeset
   659
fb42c94a042e commentary
Claus Gittinger <cg@exept.de>
parents: 594
diff changeset
   660
    "Modified: 29.4.1996 / 12:42:14 / cg"
121
claus
parents: 118
diff changeset
   661
!
claus
parents: 118
diff changeset
   662
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   663
getListFromModel
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   664
    "get my contents from the model.
597
fb42c94a042e commentary
Claus Gittinger <cg@exept.de>
parents: 594
diff changeset
   665
     Redefined to ignore updates resulting from my own changes
fb42c94a042e commentary
Claus Gittinger <cg@exept.de>
parents: 594
diff changeset
   666
     (i.e. if lockUpdates is true)."
121
claus
parents: 118
diff changeset
   667
claus
parents: 118
diff changeset
   668
    "
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   669
     ignore updates from my own change
121
claus
parents: 118
diff changeset
   670
    "
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   671
    lockUpdates ifTrue:[
597
fb42c94a042e commentary
Claus Gittinger <cg@exept.de>
parents: 594
diff changeset
   672
        lockUpdates := false.
fb42c94a042e commentary
Claus Gittinger <cg@exept.de>
parents: 594
diff changeset
   673
        ^ self
121
claus
parents: 118
diff changeset
   674
    ].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   675
    ^ super getListFromModel
597
fb42c94a042e commentary
Claus Gittinger <cg@exept.de>
parents: 594
diff changeset
   676
fb42c94a042e commentary
Claus Gittinger <cg@exept.de>
parents: 594
diff changeset
   677
    "Modified: 29.4.1996 / 12:42:33 / cg"
121
claus
parents: 118
diff changeset
   678
! !
claus
parents: 118
diff changeset
   679
claus
parents: 118
diff changeset
   680
!EditTextView methodsFor:'cursor handling'!
claus
parents: 118
diff changeset
   681
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   682
cursorBacktab
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   683
    "move cursor to prev tabstop"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   684
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   685
    self cursorCol:(self prevTabBefore:cursorCol).
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   686
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   687
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   688
cursorCol:newCol
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   689
    "move cursor to some column in the current line"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   690
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   691
    |wasOn|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   692
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   693
    wasOn := self hideCursor.
672
065750d02339 added cursorCol-validation
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
   694
    cursorCol := self validateCursorCol:newCol inLine:cursorLine.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   695
    self makeCursorVisibleAndShowCursor:wasOn.
672
065750d02339 added cursorCol-validation
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
   696
065750d02339 added cursorCol-validation
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
   697
    "Modified: 22.5.1996 / 14:25:53 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   698
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   699
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   700
cursorDown
632
5af2c22002e4 dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
   701
    "move cursor down; scroll if at end of visible text;
5af2c22002e4 dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
   702
     beep if at end of physical text."
5af2c22002e4 dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
   703
5af2c22002e4 dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
   704
    |wasOn|
5af2c22002e4 dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
   705
5af2c22002e4 dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
   706
    self cursorDown:1.
5af2c22002e4 dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
   707
5af2c22002e4 dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
   708
    "/ cursor behond text ?
5af2c22002e4 dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
   709
    cursorLine > list size ifTrue:[
5af2c22002e4 dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
   710
        wasOn := self hideCursor.
674
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
   711
        cursorLine := self validateCursorLine:(list size + 1).
672
065750d02339 added cursorCol-validation
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
   712
        cursorCol := self validateCursorCol:cursorCol inLine:cursorLine.
632
5af2c22002e4 dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
   713
        cursorVisibleLine := self listLineToVisibleLine:cursorLine.
5af2c22002e4 dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
   714
        wasOn ifTrue:[self showCursor].
693
8369529a2ac4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 676
diff changeset
   715
        self beep.
632
5af2c22002e4 dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
   716
    ].
5af2c22002e4 dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
   717
693
8369529a2ac4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 676
diff changeset
   718
    "Modified: 28.5.1996 / 16:58:38 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   719
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   720
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   721
cursorDown:n
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   722
    "move cursor down by n lines; scroll if at end of visible text"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   723
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   724
    |wasOn nv|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   725
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   726
    cursorVisibleLine notNil ifTrue:[
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
   727
        wasOn := self hideCursor.
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
   728
        nv := cursorVisibleLine + n - 1.
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
   729
        (nv >= nFullLinesShown) ifTrue:[
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
   730
            self scrollDown:(nv - nFullLinesShown + 1)
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
   731
        ].
674
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
   732
        cursorLine := self validateCursorLine:(cursorLine + n).
672
065750d02339 added cursorCol-validation
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
   733
        cursorCol := self validateCursorCol:cursorCol inLine:cursorLine.
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
   734
        cursorVisibleLine := self listLineToVisibleLine:cursorLine.
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
   735
        wasOn ifTrue:[self showCursor].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   736
    ] ifFalse:[
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
   737
        cursorLine isNil ifTrue:[
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
   738
            cursorLine := firstLineShown
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
   739
        ].
674
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
   740
        cursorLine := self validateCursorLine:(cursorLine + n).
672
065750d02339 added cursorCol-validation
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
   741
        cursorCol := self validateCursorCol:cursorCol inLine:cursorLine.
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
   742
        cursorVisibleLine := self listLineToVisibleLine:cursorLine.
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
   743
        self makeCursorVisible.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   744
    ].
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
   745
674
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
   746
    "Modified: 22.5.1996 / 18:23:16 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   747
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   748
121
claus
parents: 118
diff changeset
   749
cursorHome
597
fb42c94a042e commentary
Claus Gittinger <cg@exept.de>
parents: 594
diff changeset
   750
    "scroll to top AND move cursor to first line of text."
121
claus
parents: 118
diff changeset
   751
674
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
   752
    self cursorLine:1 col:1
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
   753
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
   754
"/    |wasOn|
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
   755
"/
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
   756
"/    wasOn := self hideCursor.
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
   757
"/    self scrollToTop.
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
   758
"/    cursorLine := cursorVisibleLine := 1.
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
   759
"/    cursorCol := self validateCursorCol:1 inLine:cursorLine.
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
   760
"/    self makeCursorVisibleAndShowCursor:wasOn.
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
   761
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
   762
    "Modified: 22.5.1996 / 18:26:42 / cg"
121
claus
parents: 118
diff changeset
   763
!
claus
parents: 118
diff changeset
   764
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   765
cursorLeft
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   766
    "move cursor to left"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   767
1300
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
   768
    (cursorCol ~~ 1) ifTrue:[
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
   769
        self cursorCol:(cursorCol - 1)
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
   770
    ] ifFalse:[
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
   771
        ST80Mode == true ifTrue:[
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
   772
            self cursorUp.
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
   773
            self cursorToEndOfLine.
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
   774
        ]
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
   775
    ]
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
   776
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
   777
    "Modified: 12.8.1997 / 13:57:14 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   778
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   779
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   780
cursorLine:line col:col
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   781
    "this positions onto physical - not visible - line"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   782
676
b65b82a1ffcb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   783
    |wasOn newCol|
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   784
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   785
    wasOn := self hideCursor.
674
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
   786
    cursorLine := self validateCursorLine:line.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   787
    cursorVisibleLine := self listLineToVisibleLine:line.
672
065750d02339 added cursorCol-validation
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
   788
    (col < 1) ifTrue:[
676
b65b82a1ffcb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   789
        newCol := 1
672
065750d02339 added cursorCol-validation
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
   790
    ] ifFalse:[
676
b65b82a1ffcb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   791
        newCol := col.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   792
    ].
676
b65b82a1ffcb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   793
    cursorCol := self validateCursorCol:newCol inLine:cursorLine.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   794
    self makeCursorVisibleAndShowCursor:wasOn.
672
065750d02339 added cursorCol-validation
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
   795
676
b65b82a1ffcb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   796
    "Modified: 24.5.1996 / 14:16:14 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   797
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   798
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   799
cursorReturn
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   800
    "move cursor to start of next line; scroll if at end of visible text"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   801
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   802
    |wasOn|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   803
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   804
    self checkForExistingLine:(cursorLine + 1).
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   805
    cursorVisibleLine notNil ifTrue:[
672
065750d02339 added cursorCol-validation
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
   806
        nFullLinesShown notNil ifTrue:[
065750d02339 added cursorCol-validation
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
   807
            (cursorVisibleLine >= nFullLinesShown) ifTrue:[self scrollDown]
065750d02339 added cursorCol-validation
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
   808
        ]
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   809
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   810
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   811
    wasOn := self hideCursor.
674
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
   812
    cursorLine := self validateCursorLine:cursorLine + 1.
672
065750d02339 added cursorCol-validation
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
   813
    cursorCol := self validateCursorCol:1 inLine:cursorLine.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   814
    cursorVisibleLine := self listLineToVisibleLine:cursorLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   815
    self makeCursorVisibleAndShowCursor:wasOn.
672
065750d02339 added cursorCol-validation
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
   816
674
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
   817
    "Modified: 22.5.1996 / 18:27:34 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   818
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   819
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   820
cursorRight
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   821
    "move cursor to right"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   822
1300
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
   823
    |l|
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
   824
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
   825
    ST80Mode == true ifTrue:[
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
   826
        l := (self listAt:cursorLine).
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
   827
        cursorCol >= (l size + 1) ifTrue:[
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
   828
            self cursorReturn.
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
   829
            ^ self    
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
   830
        ]
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
   831
    ].    
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   832
    self cursorCol:(cursorCol + 1)
1300
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
   833
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
   834
    "Modified: 13.8.1997 / 15:33:48 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   835
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   836
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   837
cursorTab
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   838
    "move cursor to next tabstop"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   839
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   840
    self cursorCol:(self nextTabAfter:cursorCol).
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   841
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   842
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   843
cursorToBeginOfLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   844
    "move cursor to start of current line"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   845
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   846
    self cursorCol:1
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   847
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   848
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   849
cursorToBottom
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   850
    "move cursor to last line of text"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   851
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   852
    |wasOn newTop|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   853
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   854
    wasOn := self hideCursor.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   855
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   856
    newTop := list size - nFullLinesShown.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   857
    (newTop < 1) ifTrue:[
672
065750d02339 added cursorCol-validation
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
   858
        newTop := 1
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   859
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   860
    self scrollToLine:newTop.
674
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
   861
    cursorLine := self validateCursorLine:list size.
672
065750d02339 added cursorCol-validation
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
   862
    cursorCol := self validateCursorCol:1 inLine:cursorLine.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   863
    cursorVisibleLine := self listLineToVisibleLine:cursorLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   864
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   865
    self makeCursorVisibleAndShowCursor:wasOn.
672
065750d02339 added cursorCol-validation
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
   866
674
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
   867
    "Modified: 22.5.1996 / 18:27:45 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   868
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   869
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   870
cursorToEnd
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   871
    "move cursor down below last line of text"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   872
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   873
    |wasOn newTop l line|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   874
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   875
    l := list size.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   876
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   877
    cursorLine >= l ifTrue:[
672
065750d02339 added cursorCol-validation
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
   878
        line := self listAt:cursorLine.
065750d02339 added cursorCol-validation
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
   879
        (line isNil or:[line isEmpty]) ifTrue:[
065750d02339 added cursorCol-validation
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
   880
            ^ self
065750d02339 added cursorCol-validation
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
   881
        ]
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   882
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   883
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   884
    wasOn := self hideCursor.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   885
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   886
    l := l + 1.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   887
    newTop :=  l - nFullLinesShown.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   888
    (newTop < 1) ifTrue:[
672
065750d02339 added cursorCol-validation
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
   889
        newTop := 1
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   890
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   891
    self scrollToLine:newTop.
674
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
   892
    cursorLine := self validateCursorLine:l.
672
065750d02339 added cursorCol-validation
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
   893
    cursorCol := self validateCursorCol:1 inLine:1.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   894
    cursorVisibleLine := self listLineToVisibleLine:cursorLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   895
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   896
    self makeCursorVisibleAndShowCursor:wasOn.
672
065750d02339 added cursorCol-validation
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
   897
674
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
   898
    "Modified: 22.5.1996 / 18:27:53 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   899
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   900
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   901
cursorToEndOfLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   902
    "move cursor to end of current line"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   903
1300
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
   904
    |line|
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
   905
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
   906
    line := (self listAt:cursorLine).
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
   907
    self cursorCol:(line size + 1)
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
   908
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
   909
    "Modified: 13.8.1997 / 15:34:02 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   910
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   911
131
claus
parents: 130
diff changeset
   912
cursorToFirstVisibleLine
claus
parents: 130
diff changeset
   913
    "place cursor into the first visible line; do not scroll."
claus
parents: 130
diff changeset
   914
claus
parents: 130
diff changeset
   915
    self cursorLine:(self visibleLineToAbsoluteLine:1) col:1
claus
parents: 130
diff changeset
   916
!
claus
parents: 130
diff changeset
   917
claus
parents: 130
diff changeset
   918
cursorToLastVisibleLine
claus
parents: 130
diff changeset
   919
    "place cursor into the first visible line; do not scroll."
claus
parents: 130
diff changeset
   920
claus
parents: 130
diff changeset
   921
    self cursorLine:(self visibleLineToAbsoluteLine:nFullLinesShown) col:1
claus
parents: 130
diff changeset
   922
!
claus
parents: 130
diff changeset
   923
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   924
cursorToNextWord
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   925
    "move the cursor to the beginning of the next word"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   926
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   927
    |col line searching|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   928
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   929
    (cursorLine > list size) ifTrue:[^ self].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   930
    self wordAtLine:cursorLine col:cursorCol do:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   931
	:beginLine :beginCol :endLine :endCol :style | 
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   932
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   933
	line := endLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   934
	col := endCol + 1.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   935
	searching := true.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   936
	[searching 
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   937
	 and:[(self characterAtLine:line col:col) isSeparator]] whileTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   938
	    self wordAtLine:line col:col do:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   939
		:beginLine :beginCol :endLine :endCol :style |
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   940
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   941
		(line > list size) ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   942
		    "break out"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   943
		    searching := false
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   944
		] ifFalse:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   945
		    line := endLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   946
		    col := endCol + 1.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   947
		]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   948
	    ]
121
claus
parents: 118
diff changeset
   949
	].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   950
	self cursorLine:line col:col
121
claus
parents: 118
diff changeset
   951
    ]
claus
parents: 118
diff changeset
   952
!
claus
parents: 118
diff changeset
   953
499
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
   954
cursorToPreviousWord
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
   955
    "move the cursor to the beginning of this or the previous word"
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
   956
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
   957
    |col line searching l|
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
   958
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
   959
    (cursorLine > list size) ifTrue:[^ self].
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
   960
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
   961
    self wordAtLine:cursorLine col:cursorCol do:[
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
   962
        :beginLine :beginCol :endLine :endCol :style | 
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
   963
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
   964
        line := beginLine.
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
   965
        col := beginCol.
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
   966
        style == #wordLeft ifTrue:[
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
   967
            col := col + 1
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
   968
        ].
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
   969
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
   970
        (cursorLine == line
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
   971
        and:[cursorCol == col]) ifTrue:[
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
   972
            searching := true.
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
   973
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
   974
            col > 1 ifTrue:[
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
   975
                col := col - 1.
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
   976
            ].
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
   977
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
   978
            [searching] whileTrue:[
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
   979
                (col == 1) ifTrue:[    
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
   980
                    line == 1 ifTrue:[
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
   981
                        searching := false
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
   982
                    ] ifFalse:[
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
   983
                        line := line - 1.
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
   984
                        l := list at:line.
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
   985
                        col := l size + 1.
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
   986
                    ]
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
   987
                ] ifFalse:[
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
   988
                    (self characterAtLine:line col:col) isSeparator ifFalse:[
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
   989
                        self wordAtLine:line col:col do:[
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
   990
                            :beginLine :beginCol :endLine :endCol :style |
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
   991
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
   992
                            line := beginLine.
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
   993
                            col := beginCol.
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
   994
                            style == #wordLeft ifTrue:[
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
   995
                                col := col + 1
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
   996
                            ].
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
   997
                            searching := false.
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
   998
                        ]
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
   999
                    ] ifTrue:[
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
  1000
                        col := col - 1
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
  1001
                    ]
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
  1002
                ]
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
  1003
            ]
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
  1004
        ].
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
  1005
        self cursorLine:line col:col
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
  1006
    ]
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
  1007
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
  1008
    "Created: 8.3.1996 / 21:52:48 / cg"
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
  1009
    "Modified: 8.3.1996 / 22:12:45 / cg"
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
  1010
!
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
  1011
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1012
cursorToTop
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1013
    "move cursor to absolute home"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1014
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1015
    self cursorLine:1 col:1
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1016
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1017
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1018
cursorUp
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1019
    "move cursor up; scroll if at start of visible text"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1020
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1021
    self cursorUp:1
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1022
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1023
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1024
cursorUp:n
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1025
    "move cursor up n lines; scroll if at start of visible text"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1026
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1027
    |wasOn nv nl|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1028
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1029
    cursorLine isNil ifTrue:[
672
065750d02339 added cursorCol-validation
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  1030
        cursorLine := firstLineShown + nFullLinesShown - 1.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1031
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1032
    nl := cursorLine - n.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1033
    nl < 1 ifTrue:[nl := 1].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1034
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1035
    (nl ~~ cursorLine) ifTrue: [
672
065750d02339 added cursorCol-validation
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  1036
        wasOn := self hideCursor.
065750d02339 added cursorCol-validation
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  1037
        cursorVisibleLine notNil ifTrue:[
065750d02339 added cursorCol-validation
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  1038
            nv := cursorVisibleLine - n.
065750d02339 added cursorCol-validation
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  1039
            nv < 1 ifTrue:[
065750d02339 added cursorCol-validation
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  1040
                self scrollUp:(nv negated + 1)
065750d02339 added cursorCol-validation
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  1041
            ].
065750d02339 added cursorCol-validation
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  1042
        ].
674
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  1043
        cursorLine := self validateCursorLine:nl.
672
065750d02339 added cursorCol-validation
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  1044
        cursorVisibleLine := self listLineToVisibleLine:cursorLine.
065750d02339 added cursorCol-validation
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  1045
        cursorCol := self validateCursorCol:cursorCol inLine:cursorLine.
065750d02339 added cursorCol-validation
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  1046
        wasOn ifTrue:[self showCursor].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1047
"/
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1048
"/ to make cursor visible (even if below visible end):
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1049
"/
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1050
"/      self makeCursorVisibleAndShowCursor:wasOn.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1051
    ]
672
065750d02339 added cursorCol-validation
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  1052
674
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  1053
    "Modified: 22.5.1996 / 18:28:11 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1054
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1055
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1056
cursorVisibleLine:visibleLineNr col:colNr
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1057
    "put cursor to visibleline/col"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1058
676
b65b82a1ffcb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
  1059
    |wasOn newCol|
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1060
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1061
    wasOn := self hideCursor.
674
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  1062
    cursorLine := self validateCursorLine:(self visibleLineToAbsoluteLine:visibleLineNr).
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1063
    cursorVisibleLine := visibleLineNr.
676
b65b82a1ffcb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
  1064
    newCol := colNr.
b65b82a1ffcb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
  1065
    (newCol < 1) ifTrue:[
b65b82a1ffcb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
  1066
        newCol := 1
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1067
    ].
676
b65b82a1ffcb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
  1068
    cursorCol := self validateCursorCol:newCol inLine:cursorLine.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1069
    self makeCursorVisibleAndShowCursor:wasOn.
672
065750d02339 added cursorCol-validation
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  1070
676
b65b82a1ffcb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
  1071
    "Modified: 24.5.1996 / 14:17:06 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1072
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1073
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1074
cursorX:x y:y
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1075
    "put cursor to position next to x/y coordinate in view"
121
claus
parents: 118
diff changeset
  1076
claus
parents: 118
diff changeset
  1077
    |line col|
claus
parents: 118
diff changeset
  1078
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1079
    line := self visibleLineOfY:y.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1080
    col := self colOfX:x inVisibleLine:line.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1081
    self cursorVisibleLine:line col:col.
121
claus
parents: 118
diff changeset
  1082
!
claus
parents: 118
diff changeset
  1083
claus
parents: 118
diff changeset
  1084
drawCursor
claus
parents: 118
diff changeset
  1085
    "draw the cursor if shown and cursor is visible.
claus
parents: 118
diff changeset
  1086
     (but not, if there is a selection - to avoid confusion)"
claus
parents: 118
diff changeset
  1087
claus
parents: 118
diff changeset
  1088
    shown ifTrue:[
claus
parents: 118
diff changeset
  1089
	cursorVisibleLine notNil ifTrue:[
claus
parents: 118
diff changeset
  1090
	    self hasSelection ifFalse:[
claus
parents: 118
diff changeset
  1091
		self drawCursorCharacter
claus
parents: 118
diff changeset
  1092
	    ]
claus
parents: 118
diff changeset
  1093
	]
claus
parents: 118
diff changeset
  1094
    ]
claus
parents: 118
diff changeset
  1095
!
claus
parents: 118
diff changeset
  1096
claus
parents: 118
diff changeset
  1097
drawCursor:cursorType with:fgColor and:bgColor
claus
parents: 118
diff changeset
  1098
    "draw a cursor; the argument cursorType specifies what type
125
claus
parents: 123
diff changeset
  1099
     of cursor should be drawn.
728
3ef81000ee8c new cursorTypes: #bigCaret and #bigSolidCaret
Claus Gittinger <cg@exept.de>
parents: 698
diff changeset
  1100
     Currently, supported are: #block, #frame, #ibeam, #caret, #solidCaret
3ef81000ee8c new cursorTypes: #bigCaret and #bigSolidCaret
Claus Gittinger <cg@exept.de>
parents: 698
diff changeset
  1101
                               #bigCaret and #bigSolidCaret"
121
claus
parents: 118
diff changeset
  1102
666
9ac9adb80415 clip at margin when drawing a caret cursor
Claus Gittinger <cg@exept.de>
parents: 662
diff changeset
  1103
    |x y w char y2 x1 x2 oldPaint oldClip|
121
claus
parents: 118
diff changeset
  1104
claus
parents: 118
diff changeset
  1105
    self hasSelection ifTrue:[
662
4bcdf0cce3a7 dont let caret cursor become too small (with small fonts)
Claus Gittinger <cg@exept.de>
parents: 655
diff changeset
  1106
        "
4bcdf0cce3a7 dont let caret cursor become too small (with small fonts)
Claus Gittinger <cg@exept.de>
parents: 655
diff changeset
  1107
         hide cursor, if there is a selection
4bcdf0cce3a7 dont let caret cursor become too small (with small fonts)
Claus Gittinger <cg@exept.de>
parents: 655
diff changeset
  1108
        "
4bcdf0cce3a7 dont let caret cursor become too small (with small fonts)
Claus Gittinger <cg@exept.de>
parents: 655
diff changeset
  1109
        ^ super redrawVisibleLine:cursorVisibleLine col:cursorCol.
121
claus
parents: 118
diff changeset
  1110
    ].
claus
parents: 118
diff changeset
  1111
1334
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  1112
    cursorType == #none ifTrue:[
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  1113
	^ self
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  1114
    ].
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  1115
121
claus
parents: 118
diff changeset
  1116
    cursorType == #block ifTrue:[
662
4bcdf0cce3a7 dont let caret cursor become too small (with small fonts)
Claus Gittinger <cg@exept.de>
parents: 655
diff changeset
  1117
        super drawVisibleLine:cursorVisibleLine 
4bcdf0cce3a7 dont let caret cursor become too small (with small fonts)
Claus Gittinger <cg@exept.de>
parents: 655
diff changeset
  1118
                          col:cursorCol 
4bcdf0cce3a7 dont let caret cursor become too small (with small fonts)
Claus Gittinger <cg@exept.de>
parents: 655
diff changeset
  1119
                         with:fgColor
4bcdf0cce3a7 dont let caret cursor become too small (with small fonts)
Claus Gittinger <cg@exept.de>
parents: 655
diff changeset
  1120
                          and:bgColor.
4bcdf0cce3a7 dont let caret cursor become too small (with small fonts)
Claus Gittinger <cg@exept.de>
parents: 655
diff changeset
  1121
        ^ self
121
claus
parents: 118
diff changeset
  1122
    ].
claus
parents: 118
diff changeset
  1123
    x := (self xOfCol:cursorCol inVisibleLine:cursorVisibleLine) - leftOffset.
claus
parents: 118
diff changeset
  1124
    y := self yOfVisibleLine:cursorVisibleLine.
claus
parents: 118
diff changeset
  1125
133
claus
parents: 132
diff changeset
  1126
    oldPaint := paint. "/ do not clobber GC
121
claus
parents: 118
diff changeset
  1127
    cursorType == #frame ifTrue:[
662
4bcdf0cce3a7 dont let caret cursor become too small (with small fonts)
Claus Gittinger <cg@exept.de>
parents: 655
diff changeset
  1128
        super redrawVisibleLine:cursorVisibleLine col:cursorCol.
4bcdf0cce3a7 dont let caret cursor become too small (with small fonts)
Claus Gittinger <cg@exept.de>
parents: 655
diff changeset
  1129
4bcdf0cce3a7 dont let caret cursor become too small (with small fonts)
Claus Gittinger <cg@exept.de>
parents: 655
diff changeset
  1130
        char := self characterUnderCursor asString.
4bcdf0cce3a7 dont let caret cursor become too small (with small fonts)
Claus Gittinger <cg@exept.de>
parents: 655
diff changeset
  1131
        self paint:bgColor.
4bcdf0cce3a7 dont let caret cursor become too small (with small fonts)
Claus Gittinger <cg@exept.de>
parents: 655
diff changeset
  1132
        self displayRectangleX:x y:y 
4bcdf0cce3a7 dont let caret cursor become too small (with small fonts)
Claus Gittinger <cg@exept.de>
parents: 655
diff changeset
  1133
                         width:(font widthOf:char) height:fontHeight.
133
claus
parents: 132
diff changeset
  1134
    ] ifFalse:[
662
4bcdf0cce3a7 dont let caret cursor become too small (with small fonts)
Claus Gittinger <cg@exept.de>
parents: 655
diff changeset
  1135
        self paint:bgColor.
4bcdf0cce3a7 dont let caret cursor become too small (with small fonts)
Claus Gittinger <cg@exept.de>
parents: 655
diff changeset
  1136
        cursorType == #ibeam ifTrue:[
4bcdf0cce3a7 dont let caret cursor become too small (with small fonts)
Claus Gittinger <cg@exept.de>
parents: 655
diff changeset
  1137
            x1 := x - 1.
4bcdf0cce3a7 dont let caret cursor become too small (with small fonts)
Claus Gittinger <cg@exept.de>
parents: 655
diff changeset
  1138
            y2 := y + fontHeight - 1.
4bcdf0cce3a7 dont let caret cursor become too small (with small fonts)
Claus Gittinger <cg@exept.de>
parents: 655
diff changeset
  1139
            self displayLineFromX:x1 y:y toX:x1 y:y2. 
4bcdf0cce3a7 dont let caret cursor become too small (with small fonts)
Claus Gittinger <cg@exept.de>
parents: 655
diff changeset
  1140
            self displayLineFromX:x y:y toX:x y:y2. 
4bcdf0cce3a7 dont let caret cursor become too small (with small fonts)
Claus Gittinger <cg@exept.de>
parents: 655
diff changeset
  1141
            ^ self
4bcdf0cce3a7 dont let caret cursor become too small (with small fonts)
Claus Gittinger <cg@exept.de>
parents: 655
diff changeset
  1142
        ] ifFalse:[
4bcdf0cce3a7 dont let caret cursor become too small (with small fonts)
Claus Gittinger <cg@exept.de>
parents: 655
diff changeset
  1143
            y := y + fontHeight - 3.
728
3ef81000ee8c new cursorTypes: #bigCaret and #bigSolidCaret
Claus Gittinger <cg@exept.de>
parents: 698
diff changeset
  1144
            ((cursorType == #bigCaret) or:[cursorType == #bigSolidCaret]) ifTrue:[
1022
4362861fe15e allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents: 1018
diff changeset
  1145
                w := (fontWidth * 2 // 3) max:4.
728
3ef81000ee8c new cursorTypes: #bigCaret and #bigSolidCaret
Claus Gittinger <cg@exept.de>
parents: 698
diff changeset
  1146
                y2 := y + w + (w//2).
3ef81000ee8c new cursorTypes: #bigCaret and #bigSolidCaret
Claus Gittinger <cg@exept.de>
parents: 698
diff changeset
  1147
            ] ifFalse:[
3ef81000ee8c new cursorTypes: #bigCaret and #bigSolidCaret
Claus Gittinger <cg@exept.de>
parents: 698
diff changeset
  1148
                w := (fontWidth // 2) max:4.
3ef81000ee8c new cursorTypes: #bigCaret and #bigSolidCaret
Claus Gittinger <cg@exept.de>
parents: 698
diff changeset
  1149
                y2 := y + w.
3ef81000ee8c new cursorTypes: #bigCaret and #bigSolidCaret
Claus Gittinger <cg@exept.de>
parents: 698
diff changeset
  1150
            ].
662
4bcdf0cce3a7 dont let caret cursor become too small (with small fonts)
Claus Gittinger <cg@exept.de>
parents: 655
diff changeset
  1151
            x1 := x - w.
4bcdf0cce3a7 dont let caret cursor become too small (with small fonts)
Claus Gittinger <cg@exept.de>
parents: 655
diff changeset
  1152
            x2 := x + w.
666
9ac9adb80415 clip at margin when drawing a caret cursor
Claus Gittinger <cg@exept.de>
parents: 662
diff changeset
  1153
9ac9adb80415 clip at margin when drawing a caret cursor
Claus Gittinger <cg@exept.de>
parents: 662
diff changeset
  1154
            oldClip := self clippingRectangleOrNil.
698
8c97e2ffd1f4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 697
diff changeset
  1155
            self clippingRectangle:(margin@margin extent:(width-margin) @ (height-margin)).
666
9ac9adb80415 clip at margin when drawing a caret cursor
Claus Gittinger <cg@exept.de>
parents: 662
diff changeset
  1156
662
4bcdf0cce3a7 dont let caret cursor become too small (with small fonts)
Claus Gittinger <cg@exept.de>
parents: 655
diff changeset
  1157
            cursorType == #caret ifTrue:[
4bcdf0cce3a7 dont let caret cursor become too small (with small fonts)
Claus Gittinger <cg@exept.de>
parents: 655
diff changeset
  1158
                self lineWidth:2.
4bcdf0cce3a7 dont let caret cursor become too small (with small fonts)
Claus Gittinger <cg@exept.de>
parents: 655
diff changeset
  1159
                self displayLineFromX:x1 y:y2 toX:x y:y. 
4bcdf0cce3a7 dont let caret cursor become too small (with small fonts)
Claus Gittinger <cg@exept.de>
parents: 655
diff changeset
  1160
                self displayLineFromX:x y:y toX:x2 y:y2. 
4bcdf0cce3a7 dont let caret cursor become too small (with small fonts)
Claus Gittinger <cg@exept.de>
parents: 655
diff changeset
  1161
            ] ifFalse:[
4bcdf0cce3a7 dont let caret cursor become too small (with small fonts)
Claus Gittinger <cg@exept.de>
parents: 655
diff changeset
  1162
                "anything else: solidCaret"
4bcdf0cce3a7 dont let caret cursor become too small (with small fonts)
Claus Gittinger <cg@exept.de>
parents: 655
diff changeset
  1163
4bcdf0cce3a7 dont let caret cursor become too small (with small fonts)
Claus Gittinger <cg@exept.de>
parents: 655
diff changeset
  1164
                self fillPolygon:(Array with:(x1 @ y2)
4bcdf0cce3a7 dont let caret cursor become too small (with small fonts)
Claus Gittinger <cg@exept.de>
parents: 655
diff changeset
  1165
                                        with:(x @ y)
4bcdf0cce3a7 dont let caret cursor become too small (with small fonts)
Claus Gittinger <cg@exept.de>
parents: 655
diff changeset
  1166
                                        with:(x2 @ y2))
666
9ac9adb80415 clip at margin when drawing a caret cursor
Claus Gittinger <cg@exept.de>
parents: 662
diff changeset
  1167
            ].
9ac9adb80415 clip at margin when drawing a caret cursor
Claus Gittinger <cg@exept.de>
parents: 662
diff changeset
  1168
698
8c97e2ffd1f4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 697
diff changeset
  1169
            self clippingRectangle:oldClip
662
4bcdf0cce3a7 dont let caret cursor become too small (with small fonts)
Claus Gittinger <cg@exept.de>
parents: 655
diff changeset
  1170
        ]
121
claus
parents: 118
diff changeset
  1171
    ].
133
claus
parents: 132
diff changeset
  1172
    self paint:oldPaint.
662
4bcdf0cce3a7 dont let caret cursor become too small (with small fonts)
Claus Gittinger <cg@exept.de>
parents: 655
diff changeset
  1173
1022
4362861fe15e allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents: 1018
diff changeset
  1174
    "Modified: 18.2.1997 / 15:19:03 / cg"
121
claus
parents: 118
diff changeset
  1175
!
claus
parents: 118
diff changeset
  1176
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1177
drawCursorCharacter
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1178
    "draw the cursor. 
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1179
     (i.e. the cursor if no selection)
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1180
     - helper for many cursor methods"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1181
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1182
    hasKeyboardFocus ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1183
	self drawFocusCursor
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1184
    ] ifFalse:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1185
	self drawNoFocusCursor
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1186
    ]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1187
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1188
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1189
drawFocusCursor
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1190
    "draw the cursor when the focus is in the view."
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1191
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1192
    self hasSelection ifTrue:[
1334
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  1193
        ^ super redrawVisibleLine:cursorVisibleLine col:cursorCol.
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  1194
    ].
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  1195
    cursorType == #none ifTrue:[
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  1196
        ^ self undrawCursor
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1197
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1198
    self drawCursor:cursorType with:cursorFgColor and:cursorBgColor.
1334
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  1199
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  1200
    "Modified: 22.9.1997 / 00:16:38 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1201
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1202
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1203
drawNoFocusCursor
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1204
    "draw the cursor for the case when the view has no keyboard focus" 
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1205
1334
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  1206
    |cType|
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  1207
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1208
    self hasSelection ifTrue:[
729
0d1fb3211a41 gray noFocus-openWin solidCaret cursors
Claus Gittinger <cg@exept.de>
parents: 728
diff changeset
  1209
        ^ super redrawVisibleLine:cursorVisibleLine col:cursorCol.
121
claus
parents: 118
diff changeset
  1210
    ].
1022
4362861fe15e allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents: 1018
diff changeset
  1211
1334
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  1212
    cType := cursorTypeNoFocus ? cursorType.
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  1213
    cType == #none ifTrue:[
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  1214
        ^ self undrawCursor
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  1215
    ].
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  1216
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  1217
    cType == #block ifTrue:[
1022
4362861fe15e allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents: 1018
diff changeset
  1218
        ^ self drawCursor:#frame with:cursorNoFocusFgColor and:cursorBgColor
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1219
    ].
1022
4362861fe15e allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents: 1018
diff changeset
  1220
1334
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  1221
    ^ self drawCursor:cType with:cursorNoFocusFgColor and:cursorNoFocusFgColor.
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  1222
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  1223
    "Modified: 22.9.1997 / 00:16:13 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1224
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1225
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1226
gotoLine:aLineNumber
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1227
    "position cursor onto line, aLineNumber.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1228
     Make certain that this line is visible"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1229
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1230
    self makeLineVisible:aLineNumber.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1231
    self cursorLine:aLineNumber col:1
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1232
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1233
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1234
hideCursor
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1235
    "make cursor invisible if currently visible; 
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1236
     return true if cursor was visible before."
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1237
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1238
    cursorShown ifTrue: [
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1239
	shown ifTrue: [
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1240
	    self undrawCursor.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1241
	].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1242
	cursorShown := false.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1243
	^ true
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1244
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1245
    ^ false
121
claus
parents: 118
diff changeset
  1246
!
claus
parents: 118
diff changeset
  1247
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1248
makeCursorVisible
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1249
    "scroll text to make cursorline visible 
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1250
     (i.e. to have cursorLine in visible area)"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1251
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1252
    |line col|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1253
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1254
    cursorLine notNil ifTrue:[
479
fae6d1251888 fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 477
diff changeset
  1255
        line := cursorLine.
fae6d1251888 fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 477
diff changeset
  1256
        col := cursorCol.
fae6d1251888 fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 477
diff changeset
  1257
        "
fae6d1251888 fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 477
diff changeset
  1258
         if there is a selection, its better to
fae6d1251888 fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 477
diff changeset
  1259
         have its start being visible, instead of the end
fae6d1251888 fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 477
diff changeset
  1260
        "
fae6d1251888 fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 477
diff changeset
  1261
        (selectionStartLine notNil 
fae6d1251888 fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 477
diff changeset
  1262
        and:[selectionEndLine notNil]) ifTrue:[
fae6d1251888 fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 477
diff changeset
  1263
            expandingTop ~~ false ifTrue:[
fae6d1251888 fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 477
diff changeset
  1264
                line := selectionStartLine.
fae6d1251888 fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 477
diff changeset
  1265
                col := selectionStartCol.
fae6d1251888 fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 477
diff changeset
  1266
            ] ifFalse:[
fae6d1251888 fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 477
diff changeset
  1267
                line := selectionEndLine.
fae6d1251888 fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 477
diff changeset
  1268
                col := selectionEndCol
fae6d1251888 fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 477
diff changeset
  1269
            ]
fae6d1251888 fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 477
diff changeset
  1270
        ].
fae6d1251888 fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 477
diff changeset
  1271
        self makeLineVisible:line.
fae6d1251888 fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 477
diff changeset
  1272
        self makeColVisible:col inLine:line 
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1273
    ]
479
fae6d1251888 fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 477
diff changeset
  1274
fae6d1251888 fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 477
diff changeset
  1275
    "Modified: 6.3.1996 / 13:46:46 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1276
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1277
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1278
makeCursorVisibleAndShowCursor:flag
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1279
    "scroll to make cursorLine visible;
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1280
     if flag is true, draw the cursor"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1281
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1282
    self makeCursorVisible.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1283
    flag ifTrue:[self showCursor]
121
claus
parents: 118
diff changeset
  1284
!
claus
parents: 118
diff changeset
  1285
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1286
showCursor
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1287
    "make cursor visible if currently invisible"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1288
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1289
    cursorShown ifFalse: [
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1290
	self drawCursor.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1291
	cursorShown := true
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1292
    ]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1293
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1294
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1295
undrawCursor
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1296
    "undraw the cursor (i.e. redraw the character(s) under the cursor)"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1297
1022
4362861fe15e allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents: 1018
diff changeset
  1298
    |prevCol|
4362861fe15e allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents: 1018
diff changeset
  1299
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1300
    cursorVisibleLine notNil ifTrue:[
1022
4362861fe15e allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents: 1018
diff changeset
  1301
        prevCol := cursorCol - 1.
4362861fe15e allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents: 1018
diff changeset
  1302
728
3ef81000ee8c new cursorTypes: #bigCaret and #bigSolidCaret
Claus Gittinger <cg@exept.de>
parents: 698
diff changeset
  1303
        ((cursorType == #caret)
3ef81000ee8c new cursorTypes: #bigCaret and #bigSolidCaret
Claus Gittinger <cg@exept.de>
parents: 698
diff changeset
  1304
         or:[cursorType == #solidCaret
3ef81000ee8c new cursorTypes: #bigCaret and #bigSolidCaret
Claus Gittinger <cg@exept.de>
parents: 698
diff changeset
  1305
         or:[cursorType == #bigSolidCaret
3ef81000ee8c new cursorTypes: #bigCaret and #bigSolidCaret
Claus Gittinger <cg@exept.de>
parents: 698
diff changeset
  1306
         or:[cursorType == #bigCaret]]]) ifTrue:[
3ef81000ee8c new cursorTypes: #bigCaret and #bigSolidCaret
Claus Gittinger <cg@exept.de>
parents: 698
diff changeset
  1307
            "caret-cursor touches 4 characters"
3ef81000ee8c new cursorTypes: #bigCaret and #bigSolidCaret
Claus Gittinger <cg@exept.de>
parents: 698
diff changeset
  1308
            ((cursorCol > 1) and:[fontIsFixedWidth]) ifTrue:[
1022
4362861fe15e allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents: 1018
diff changeset
  1309
                super redrawVisibleLine:cursorVisibleLine from:prevCol to:cursorCol.
4362861fe15e allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents: 1018
diff changeset
  1310
                super redrawVisibleLine:cursorVisibleLine+1 from:prevCol to:cursorCol.
728
3ef81000ee8c new cursorTypes: #bigCaret and #bigSolidCaret
Claus Gittinger <cg@exept.de>
parents: 698
diff changeset
  1311
            ] ifFalse:[
3ef81000ee8c new cursorTypes: #bigCaret and #bigSolidCaret
Claus Gittinger <cg@exept.de>
parents: 698
diff changeset
  1312
                "care for left margin"
3ef81000ee8c new cursorTypes: #bigCaret and #bigSolidCaret
Claus Gittinger <cg@exept.de>
parents: 698
diff changeset
  1313
                super redrawVisibleLine:cursorVisibleLine; redrawVisibleLine:cursorVisibleLine+1.
3ef81000ee8c new cursorTypes: #bigCaret and #bigSolidCaret
Claus Gittinger <cg@exept.de>
parents: 698
diff changeset
  1314
            ].
3ef81000ee8c new cursorTypes: #bigCaret and #bigSolidCaret
Claus Gittinger <cg@exept.de>
parents: 698
diff changeset
  1315
            ^ self
3ef81000ee8c new cursorTypes: #bigCaret and #bigSolidCaret
Claus Gittinger <cg@exept.de>
parents: 698
diff changeset
  1316
        ].
1022
4362861fe15e allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents: 1018
diff changeset
  1317
728
3ef81000ee8c new cursorTypes: #bigCaret and #bigSolidCaret
Claus Gittinger <cg@exept.de>
parents: 698
diff changeset
  1318
        cursorType == #ibeam ifTrue:[
3ef81000ee8c new cursorTypes: #bigCaret and #bigSolidCaret
Claus Gittinger <cg@exept.de>
parents: 698
diff changeset
  1319
            "ibeam-cursor touches 2 characters"
3ef81000ee8c new cursorTypes: #bigCaret and #bigSolidCaret
Claus Gittinger <cg@exept.de>
parents: 698
diff changeset
  1320
            cursorCol > 1 ifTrue:[
1022
4362861fe15e allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents: 1018
diff changeset
  1321
                super redrawVisibleLine:cursorVisibleLine from:prevCol to:cursorCol.
728
3ef81000ee8c new cursorTypes: #bigCaret and #bigSolidCaret
Claus Gittinger <cg@exept.de>
parents: 698
diff changeset
  1322
            ] ifFalse:[
3ef81000ee8c new cursorTypes: #bigCaret and #bigSolidCaret
Claus Gittinger <cg@exept.de>
parents: 698
diff changeset
  1323
                "care for left margin"
3ef81000ee8c new cursorTypes: #bigCaret and #bigSolidCaret
Claus Gittinger <cg@exept.de>
parents: 698
diff changeset
  1324
                super redrawVisibleLine:cursorVisibleLine.
3ef81000ee8c new cursorTypes: #bigCaret and #bigSolidCaret
Claus Gittinger <cg@exept.de>
parents: 698
diff changeset
  1325
            ].
3ef81000ee8c new cursorTypes: #bigCaret and #bigSolidCaret
Claus Gittinger <cg@exept.de>
parents: 698
diff changeset
  1326
            ^ self
3ef81000ee8c new cursorTypes: #bigCaret and #bigSolidCaret
Claus Gittinger <cg@exept.de>
parents: 698
diff changeset
  1327
        ].
1334
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  1328
728
3ef81000ee8c new cursorTypes: #bigCaret and #bigSolidCaret
Claus Gittinger <cg@exept.de>
parents: 698
diff changeset
  1329
        "block is simple - just one character under cursor"
3ef81000ee8c new cursorTypes: #bigCaret and #bigSolidCaret
Claus Gittinger <cg@exept.de>
parents: 698
diff changeset
  1330
        super redrawVisibleLine:cursorVisibleLine col:cursorCol
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1331
    ]
728
3ef81000ee8c new cursorTypes: #bigCaret and #bigSolidCaret
Claus Gittinger <cg@exept.de>
parents: 698
diff changeset
  1332
1334
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  1333
    "Modified: 22.9.1997 / 00:16:50 / cg"
121
claus
parents: 118
diff changeset
  1334
!
claus
parents: 118
diff changeset
  1335
672
065750d02339 added cursorCol-validation
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  1336
validateCursorCol:col inLine:line
674
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  1337
    "check of col is a valid cursor position; return a new col-nr if not.
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  1338
     Here, no limits are enforced (and col is returned), 
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  1339
     but it may be redefined in EditFields or views which dont like the 
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  1340
     cursor to be positioned behind the end of a textLine (vi/st-80 behavior)"
672
065750d02339 added cursorCol-validation
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  1341
1300
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  1342
    |l max|
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  1343
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  1344
    ST80Mode == true ifTrue:[
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  1345
        l := (self listAt:line).
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  1346
        max := l size + 1.
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  1347
        col > max ifTrue:[
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  1348
            ^ max
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  1349
        ]
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  1350
    ].
672
065750d02339 added cursorCol-validation
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  1351
    ^ col
065750d02339 added cursorCol-validation
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  1352
065750d02339 added cursorCol-validation
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  1353
    "Created: 22.5.1996 / 14:25:30 / cg"
1300
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  1354
    "Modified: 13.8.1997 / 15:34:13 / cg"
674
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  1355
!
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  1356
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  1357
validateCursorLine:line
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  1358
    "check of line is a valid cursor line; return a fixed line-nr if not.
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  1359
     Here, no limits are enforced (and line is returned), but it may be 
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  1360
     redefined in views which dont like the cursor to be positioned
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  1361
     behind the end of the text (vi/st-80 behavior), or want to
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  1362
     skip reserved regions"
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  1363
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  1364
    ^ line
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  1365
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  1366
    "Created: 22.5.1996 / 18:22:23 / cg"
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  1367
    "Modified: 22.5.1996 / 18:30:05 / cg"
672
065750d02339 added cursorCol-validation
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  1368
!
065750d02339 added cursorCol-validation
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  1369
121
claus
parents: 118
diff changeset
  1370
withCursorOffDo:aBlock
claus
parents: 118
diff changeset
  1371
    "evaluate aBlock with cursor off; turn it on afterwards."
claus
parents: 118
diff changeset
  1372
claus
parents: 118
diff changeset
  1373
    (shown not or:[cursorShown not]) ifTrue:[
claus
parents: 118
diff changeset
  1374
	^ aBlock value
claus
parents: 118
diff changeset
  1375
    ].
claus
parents: 118
diff changeset
  1376
    self hideCursor.
claus
parents: 118
diff changeset
  1377
    aBlock valueNowOrOnUnwindDo:[
claus
parents: 118
diff changeset
  1378
	self showCursor
claus
parents: 118
diff changeset
  1379
    ]
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1380
! !
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1381
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1382
!EditTextView methodsFor:'editing'!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1383
313
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  1384
copyAndDeleteSelection
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  1385
    "copy the selection into the pastBuffer and delete it"
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  1386
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  1387
    selectionStartLine notNil ifTrue:[
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  1388
	self setTextSelection:(self selection).
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  1389
	self deleteSelection.
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  1390
    ].
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  1391
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  1392
    "Created: 27.1.1996 / 16:23:28 / cg"
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  1393
!
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  1394
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1395
deleteCharAtCursor
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1396
    "delete single character under cursor; does not merge lines"
121
claus
parents: 118
diff changeset
  1397
claus
parents: 118
diff changeset
  1398
    |wasOn|
claus
parents: 118
diff changeset
  1399
claus
parents: 118
diff changeset
  1400
    wasOn := self hideCursor.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1401
    self deleteCharAtLine:cursorLine col:cursorCol.
121
claus
parents: 118
diff changeset
  1402
    wasOn ifTrue:[self showCursor]
claus
parents: 118
diff changeset
  1403
!
claus
parents: 118
diff changeset
  1404
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1405
deleteCharAtLine:lineNr col:colNr
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1406
    "delete a single character at colNr in line lineNr"
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1407
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1408
    self deleteCharsAtLine:lineNr fromCol:colNr toCol:colNr
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1409
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1410
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1411
!
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1412
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1413
deleteCharBeforeCursor
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1414
    "delete single character to the left of cursor and move cursor to left"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1415
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1416
    |soCol wasOn lineNrAboveCursor ln|
121
claus
parents: 118
diff changeset
  1417
claus
parents: 118
diff changeset
  1418
    wasOn := self hideCursor.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1419
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1420
        (autoIndent
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1421
    and:[cursorCol  ~~ 1
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1422
    and:[cursorLine <= (list size)]]) 
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1423
     ifTrue:[
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1424
        soCol := (self leftIndentForLine:cursorLine) + 1.
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1425
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1426
        (cursorCol == soCol and:[soCol > 1]) ifTrue:[
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1427
            ln := list at:cursorLine.
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1428
            (ln notNil and:[(ln indexOfNonSeparatorStartingAt:1) < soCol]) ifTrue:[
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1429
                soCol := 1
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1430
            ]
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1431
        ]
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1432
    ] ifFalse:[
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1433
        soCol := 1
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1434
    ].
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1435
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1436
    (cursorCol == soCol) ifFalse:[
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1437
        "
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1438
         somewhere in the middle of a line
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1439
        "
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1440
        self cursorLeft.
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1441
        self deleteCharAtLine:cursorLine col:cursorCol.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1442
    ] ifTrue:[
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1443
        "
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1444
         at begin of line - merge with previous line;
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1445
         except for the very first line.
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1446
        "
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1447
        (cursorLine == 1) ifFalse:[
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1448
            lineNrAboveCursor := self validateCursorLine:(cursorLine - 1).
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1449
            lineNrAboveCursor < cursorLine ifTrue:[
1319
2739903e7a80 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1450
                self mergeLine:lineNrAboveCursor removeBlanks:false.
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1451
            ]
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1452
        ]
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1453
    ].
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1454
    wasOn ifTrue:[ self showCursor ]
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1455
1319
2739903e7a80 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  1456
    "Modified: 9.9.1997 / 09:29:14 / cg"
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1457
!
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1458
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1459
deleteCharsAtLine:lineNr fromCol:colNr
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1460
    "delete characters from colNr up to the end in line lineNr"
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1461
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1462
    |line|
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1463
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1464
    (line := self listAt:lineNr) notNil ifTrue:[
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1465
        self deleteCharsAtLine:lineNr fromCol:colNr toCol:(line size)
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1466
    ]
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1467
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1468
!
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1469
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1470
deleteCharsAtLine:lineNr toCol:colNr
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1471
    "delete characters from start up to colNr in line lineNr"
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1472
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1473
    self deleteCharsAtLine:lineNr fromCol:1 toCol:colNr
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1474
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1475
121
claus
parents: 118
diff changeset
  1476
!
claus
parents: 118
diff changeset
  1477
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1478
deleteCursorLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1479
    "delete the line where the cursor sits"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1480
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1481
    self deleteLine:cursorLine
121
claus
parents: 118
diff changeset
  1482
!
claus
parents: 118
diff changeset
  1483
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1484
deleteLine:lineNr
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1485
    "delete line"
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1486
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1487
    self deleteFromLine:lineNr toLine:lineNr
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1488
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1489
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1490
!
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1491
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1492
deleteLinesWithoutRedrawFrom:startLine to:endLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1493
    "delete lines - no redraw;
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1494
     return true, if something was really deleted"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1495
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1496
    |lastLine|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1497
331
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
  1498
    self checkModificationsAllowed ifFalse:[ ^ self].
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
  1499
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1500
    (list isNil or:[startLine > list size]) ifTrue:[^ false].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1501
    (endLine > list size) ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1502
	lastLine := list size
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1503
    ] ifFalse:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1504
	lastLine := endLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1505
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1506
    list removeFromIndex:startLine toIndex:lastLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1507
    widthOfWidestLine := nil. "/ i.e. unknown
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1508
    self textChanged.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1509
    ^ true
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1510
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1511
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1512
deleteSelection
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1513
    "delete the selection"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1514
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1515
    |wasOn startLine startCol endLine endCol|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1516
331
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
  1517
    self checkModificationsAllowed ifFalse:[ ^ self].
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
  1518
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1519
    selectionStartLine notNil ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1520
	wasOn := self hideCursor.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1521
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1522
	startLine := selectionStartLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1523
	startCol := selectionStartCol.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1524
	endLine := selectionEndLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1525
	endCol := selectionEndCol.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1526
	self unselectWithoutRedraw.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1527
	self deleteFromLine:startLine col:startCol 
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1528
		     toLine:endLine col:endCol.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1529
	cursorCol := startCol.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1530
	cursorLine := startLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1531
	cursorVisibleLine := self listLineToVisibleLine:cursorLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1532
	self makeCursorVisibleAndShowCursor:wasOn
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1533
    ]
121
claus
parents: 118
diff changeset
  1534
!
claus
parents: 118
diff changeset
  1535
claus
parents: 118
diff changeset
  1536
insertCharAtCursor:aCharacter
claus
parents: 118
diff changeset
  1537
    "insert a single character at cursor-position - advance cursor"
claus
parents: 118
diff changeset
  1538
claus
parents: 118
diff changeset
  1539
    |wasOn|
claus
parents: 118
diff changeset
  1540
claus
parents: 118
diff changeset
  1541
    wasOn := self hideCursor.
claus
parents: 118
diff changeset
  1542
    self insert:aCharacter atLine:cursorLine col:cursorCol.
claus
parents: 118
diff changeset
  1543
    aCharacter == (Character cr) ifTrue:[
claus
parents: 118
diff changeset
  1544
	self cursorReturn
claus
parents: 118
diff changeset
  1545
    ] ifFalse:[
125
claus
parents: 123
diff changeset
  1546
	self cursorRight.
121
claus
parents: 118
diff changeset
  1547
    ].
claus
parents: 118
diff changeset
  1548
    self makeCursorVisibleAndShowCursor:wasOn.
claus
parents: 118
diff changeset
  1549
!
claus
parents: 118
diff changeset
  1550
641
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  1551
insertLine:aString before:lineNr
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  1552
    "insert the line aString before line lineNr"
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  1553
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  1554
    ^ self insertLines:(Array with:aString) from:1 to:1  before:lineNr.
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  1555
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  1556
    "Modified: 14.5.1996 / 13:42:54 / cg"
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  1557
!
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  1558
155
claus
parents: 133
diff changeset
  1559
insertLines:aStringCollection before:lineNr
claus
parents: 133
diff changeset
  1560
    "insert a bunch before line lineNr"
claus
parents: 133
diff changeset
  1561
claus
parents: 133
diff changeset
  1562
    self insertLines:aStringCollection from:1 to:aStringCollection size before:lineNr
claus
parents: 133
diff changeset
  1563
claus
parents: 133
diff changeset
  1564
    "Modified: 6.9.1995 / 20:51:03 / claus"
claus
parents: 133
diff changeset
  1565
!
claus
parents: 133
diff changeset
  1566
654
d621e63baaa5 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 641
diff changeset
  1567
insertLines:lines withCR:withCr
641
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  1568
    "insert a bunch of lines at cursor position. Cursor
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  1569
     is moved behind insertion.
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  1570
     If withCr is true, append cr after last line"
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  1571
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  1572
    |start end nLines wasOn|
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  1573
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  1574
    lines notNil ifTrue:[
654
d621e63baaa5 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 641
diff changeset
  1575
        nLines := lines size.
d621e63baaa5 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 641
diff changeset
  1576
        (nLines == 1) ifTrue:[
d621e63baaa5 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 641
diff changeset
  1577
            self insertStringAtCursor:(lines at:1).
d621e63baaa5 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 641
diff changeset
  1578
            withCr ifTrue:[
d621e63baaa5 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 641
diff changeset
  1579
                self insertCharAtCursor:(Character cr)
d621e63baaa5 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 641
diff changeset
  1580
            ] 
d621e63baaa5 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 641
diff changeset
  1581
        ] ifFalse:[
d621e63baaa5 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 641
diff changeset
  1582
            (cursorCol ~~ 1) ifTrue:[
d621e63baaa5 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 641
diff changeset
  1583
                self insertStringAtCursor:(lines at:1).
d621e63baaa5 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 641
diff changeset
  1584
                self insertCharAtCursor:(Character cr).
d621e63baaa5 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 641
diff changeset
  1585
                start := 2
d621e63baaa5 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 641
diff changeset
  1586
            ] ifFalse:[
d621e63baaa5 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 641
diff changeset
  1587
                start := 1
d621e63baaa5 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 641
diff changeset
  1588
            ].
d621e63baaa5 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 641
diff changeset
  1589
            withCr ifTrue:[
d621e63baaa5 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 641
diff changeset
  1590
                end := nLines
d621e63baaa5 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 641
diff changeset
  1591
            ] ifFalse:[
d621e63baaa5 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 641
diff changeset
  1592
                end := nLines - 1
d621e63baaa5 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 641
diff changeset
  1593
            ].
d621e63baaa5 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 641
diff changeset
  1594
            (start < nLines) ifTrue:[
d621e63baaa5 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 641
diff changeset
  1595
                (end >= start) ifTrue:[
d621e63baaa5 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 641
diff changeset
  1596
                    wasOn := self hideCursor.
d621e63baaa5 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 641
diff changeset
  1597
                    self insertLines:lines from:start to:end before:cursorLine.
d621e63baaa5 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 641
diff changeset
  1598
                    cursorLine := cursorLine + (end - start + 1).
d621e63baaa5 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 641
diff changeset
  1599
                    cursorVisibleLine := self absoluteLineToVisibleLine:cursorLine.
d621e63baaa5 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 641
diff changeset
  1600
                    wasOn ifTrue:[self showCursor].
d621e63baaa5 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 641
diff changeset
  1601
                ]
d621e63baaa5 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 641
diff changeset
  1602
            ].
d621e63baaa5 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 641
diff changeset
  1603
            withCr ifFalse:[
d621e63baaa5 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 641
diff changeset
  1604
                "last line without cr"
d621e63baaa5 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 641
diff changeset
  1605
                self insertStringAtCursor:(lines at:nLines)
d621e63baaa5 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 641
diff changeset
  1606
            ]
d621e63baaa5 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 641
diff changeset
  1607
        ]
641
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  1608
    ]
654
d621e63baaa5 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 641
diff changeset
  1609
d621e63baaa5 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 641
diff changeset
  1610
    "Created: 18.5.1996 / 15:32:06 / cg"
d621e63baaa5 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 641
diff changeset
  1611
!
d621e63baaa5 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 641
diff changeset
  1612
d621e63baaa5 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 641
diff changeset
  1613
insertLines:lines withCr:withCr
d621e63baaa5 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 641
diff changeset
  1614
    "insert a bunch of lines at cursor position. Cursor
d621e63baaa5 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 641
diff changeset
  1615
     is moved behind insertion.
d621e63baaa5 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 641
diff changeset
  1616
     If withCr is true, append cr after last line"
d621e63baaa5 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 641
diff changeset
  1617
1292
ca4c9a957a32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1290
diff changeset
  1618
    self obsoleteMethodWarning:'use #insertLines:withCR:'.
ca4c9a957a32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1290
diff changeset
  1619
    self insertLines:lines withCR:withCr.
ca4c9a957a32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1290
diff changeset
  1620
ca4c9a957a32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1290
diff changeset
  1621
    "Modified: 31.7.1997 / 23:07:22 / cg"
641
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  1622
!
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  1623
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1624
insertSelectedStringAtCursor:aString
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1625
    "insert the argument, aString at cursor position and select it"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1626
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1627
    |startLine startCol|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1628
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1629
    startLine := cursorLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1630
    startCol := cursorCol.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1631
    self insertStringAtCursor:aString.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1632
    self selectFromLine:startLine col:startCol
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1633
		 toLine:cursorLine col:(cursorCol - 1)
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1634
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1635
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1636
insertString:aString atLine:lineNr col:colNr
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1637
    "insert the string, aString at line/col;
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1638
     handle cr's correctly"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1639
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1640
    |start           "{ Class: SmallInteger }"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1641
     stop            "{ Class: SmallInteger }"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1642
     end             "{ Class: SmallInteger }"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1643
     subString c
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1644
     l               "{ Class: SmallInteger }" |
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1645
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1646
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1647
    aString isNil ifTrue:[^ self].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1648
    ((aString occurrencesOf:(Character cr)) == 0) ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1649
	^ self insertStringWithoutCRs:aString atLine:lineNr col:colNr
121
claus
parents: 118
diff changeset
  1650
    ].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1651
    l := lineNr.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1652
    c := colNr.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1653
    start := 1.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1654
    end := aString size.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1655
    [start <= end] whileTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1656
	stop := aString indexOf:(Character cr) startingAt:start.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1657
	stop == 0 ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1658
	    stop := end + 1
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1659
	].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1660
	subString := aString copyFrom:start to:(stop - 1).
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1661
	self insertStringWithoutCRs:subString atLine:l col:c.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1662
	(stop < end) ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1663
	    c := c + subString size.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1664
	    self insert:(Character cr) atLine:l col:c.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1665
	    l := l + 1.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1666
	    c := 1
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1667
	].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1668
	start := stop + 1
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1669
    ]
121
claus
parents: 118
diff changeset
  1670
!
claus
parents: 118
diff changeset
  1671
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1672
insertStringAtCursor:aString
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1673
    "insert the argument, aString at cursor position
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1674
     handle cr's correctly. A nil argument is interpreted as an empty line."
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1675
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1676
    |start " { Class: SmallInteger }"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1677
     stop  " { Class: SmallInteger }"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1678
     end   " { Class: SmallInteger }"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1679
     subString|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1680
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1681
    aString isNil ifTrue:[
654
d621e63baaa5 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 641
diff changeset
  1682
        "new:"
d621e63baaa5 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 641
diff changeset
  1683
        self insertCharAtCursor:(Character cr).
d621e63baaa5 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 641
diff changeset
  1684
        ^ self
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1685
    ].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1686
    ((aString occurrencesOf:(Character cr)) == 0) ifTrue:[
654
d621e63baaa5 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 641
diff changeset
  1687
        ^ self insertStringWithoutCRsAtCursor:aString
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1688
    ].
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1689
654
d621e63baaa5 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 641
diff changeset
  1690
    self insertLines:aString asStringCollection withCR:false.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1691
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1692
"/    start := 1.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1693
"/    end := aString size.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1694
"/    "insert the 1st line"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1695
"/    (cursorCol ~~ 1) ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1696
"/        stop := aString indexOf:(Character cr) startingAt:start.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1697
"/        stop == 0 ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1698
"/            stop := end + 1
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1699
"/        ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1700
"/        subString := aString copyFrom:start to:(stop - 1).
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1701
"/        self insertStringWithoutCRsAtCursor:subString.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1702
"/        self insertCharAtCursor:(Character cr).
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1703
"/        start := stop + 1
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1704
"/    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1705
"/    "insert the block of full lines"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1706
"/
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1707
"/    [start <= end] whileTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1708
"/        stop := aString indexOf:(Character cr) startingAt:start.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1709
"/        stop == 0 ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1710
"/            stop := end + 1
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1711
"/        ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1712
"/        subString := aString copyFrom:start to:(stop - 1).
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1713
"/        self insertStringWithoutCRsAtCursor:subString.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1714
"/        (stop < end) ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1715
"/            self insertCharAtCursor:(Character cr)
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1716
"/        ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1717
"/        start := stop + 1
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1718
"/    ]
654
d621e63baaa5 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 641
diff changeset
  1719
d621e63baaa5 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 641
diff changeset
  1720
    "Modified: 18.5.1996 / 15:33:14 / cg"
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1721
!
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1722
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1723
insertStringWithoutCRs:aString atLine:lineNr col:colNr
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1724
    "insert aString (which has no crs) at lineNr/colNr"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1725
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1726
    self withoutRedrawInsertStringWithoutCRs:aString atLine:lineNr col:colNr.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1727
    shown ifTrue:[self redrawLine:lineNr from:colNr]
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1728
!
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1729
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1730
insertStringWithoutCRsAtCursor:aString
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1731
    "insert a string (which has no crs) at cursor position
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1732
     - advance cursor"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1733
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1734
    |wasOn|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1735
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1736
    aString notNil ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1737
	wasOn := self hideCursor.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1738
	self insertString:aString atLine:cursorLine col:cursorCol.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1739
	cursorCol := cursorCol + aString size.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1740
	wasOn ifTrue:[self showCursor]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1741
    ]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1742
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1743
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1744
insertTabAtCursor
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1745
    "insert spaces to next tab"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1746
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1747
    |wasOn nextTab|
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1748
121
claus
parents: 118
diff changeset
  1749
    wasOn := self hideCursor.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1750
    nextTab := self nextTabAfter:cursorCol.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1751
    self insertStringAtCursor:(String new:(nextTab - cursorCol)).
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1752
    self makeCursorVisibleAndShowCursor:wasOn.
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1753
!
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1754
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1755
removeTrailingBlankLines
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1756
    "remove all blank lines at end of text"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1757
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1758
    |lastLine "{ Class: SmallInteger }"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1759
     line finished|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1760
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1761
    lastLine := list size.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1762
    finished := false.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1763
    [finished] whileFalse:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1764
	(lastLine <= 1) ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1765
	    finished := true
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1766
	] ifFalse:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1767
	    line := list at:lastLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1768
	    line notNil ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1769
		line isBlank ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1770
		    list at:lastLine put:nil.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1771
		    line := nil
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1772
		]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1773
	    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1774
	    line notNil ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1775
		finished := true
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1776
	    ] ifFalse:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1777
		lastLine := lastLine - 1
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1778
	    ]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1779
	]
118
claus
parents: 105
diff changeset
  1780
    ].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1781
    (lastLine ~~ list size) ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1782
	list grow:lastLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1783
"/        self textChanged
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1784
    ]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1785
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1786
477
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  1787
replaceCharAtCursor:aCharacter
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  1788
    "replace a single character at cursor-position - advance cursor"
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  1789
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  1790
    |wasOn|
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  1791
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  1792
    wasOn := self hideCursor.
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  1793
    aCharacter == (Character cr) ifTrue:[
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  1794
        self cursorReturn
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  1795
    ] ifFalse:[
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  1796
        self replace:aCharacter atLine:cursorLine col:cursorCol.
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  1797
        self cursorRight.
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  1798
    ].
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  1799
    self makeCursorVisibleAndShowCursor:wasOn.
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  1800
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  1801
    "Created: 6.3.1996 / 12:27:42 / cg"
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  1802
!
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  1803
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1804
replaceSelectionBy:something
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1805
    "delete the selection (if any) and insert something, a character or string;
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1806
     leave cursor after insertion"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1807
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1808
    self replaceSelectionBy:something keepCursor:false
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1809
!
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1810
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1811
replaceSelectionBy:something keepCursor:keep
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1812
    "delete the selection (if any) and insert something, a character or string;
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1813
     leave cursor after insertion or leave it, depending on keep"
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1814
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1815
    |sel l c|
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1816
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1817
    l := cursorLine.
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1818
    c := cursorCol.
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1819
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1820
    sel := self selection.
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1821
    sel notNil ifTrue:[
477
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  1822
        lastString := sel.
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  1823
        self deleteSelection.
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  1824
        replacing := true.
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  1825
        lastReplacement := ''
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1826
    ].
840
b0071cea13fd fixed Again when spaces are replaced
Claus Gittinger <cg@exept.de>
parents: 828
diff changeset
  1827
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1828
    (something isMemberOf:Character) ifTrue:[
477
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  1829
        lastReplacement notNil ifTrue:[
840
b0071cea13fd fixed Again when spaces are replaced
Claus Gittinger <cg@exept.de>
parents: 828
diff changeset
  1830
"/ "XXX - replacing text with spaces ..."
b0071cea13fd fixed Again when spaces are replaced
Claus Gittinger <cg@exept.de>
parents: 828
diff changeset
  1831
"/            (lastReplacement endsWith:Character space) ifTrue:[
b0071cea13fd fixed Again when spaces are replaced
Claus Gittinger <cg@exept.de>
parents: 828
diff changeset
  1832
"/                lastReplacement := lastReplacement copyWithoutLast:1 "copyTo:(lastReplacement size - 1)".
b0071cea13fd fixed Again when spaces are replaced
Claus Gittinger <cg@exept.de>
parents: 828
diff changeset
  1833
"/                lastReplacement := lastReplacement copyWith:something.
b0071cea13fd fixed Again when spaces are replaced
Claus Gittinger <cg@exept.de>
parents: 828
diff changeset
  1834
"/                lastReplacement := lastReplacement copyWith:Character space
b0071cea13fd fixed Again when spaces are replaced
Claus Gittinger <cg@exept.de>
parents: 828
diff changeset
  1835
"/            ] ifFalse:[
477
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  1836
                lastReplacement := lastReplacement copyWith:something.
840
b0071cea13fd fixed Again when spaces are replaced
Claus Gittinger <cg@exept.de>
parents: 828
diff changeset
  1837
"/            ]
477
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  1838
        ].
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  1839
        insertMode ifTrue:[
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  1840
            self insertCharAtCursor:something
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  1841
        ] ifFalse:[
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  1842
            self replaceCharAtCursor:something
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  1843
        ]
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1844
    ] ifFalse:[
477
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  1845
        lastReplacement := something.
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  1846
        insertMode ifTrue:[
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  1847
            self insertStringAtCursor:something
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  1848
        ] ifFalse:[
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  1849
            self replaceStringAtCursor
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  1850
        ]
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1851
    ].
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1852
    keep ifTrue:[
477
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  1853
        self cursorLine:l col:c
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1854
    ]
477
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  1855
840
b0071cea13fd fixed Again when spaces are replaced
Claus Gittinger <cg@exept.de>
parents: 828
diff changeset
  1856
    "Modified: 9.10.1996 / 16:14:35 / cg"
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  1857
! !
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  1858
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  1859
!EditTextView methodsFor:'editing - basic'!
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  1860
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1861
deleteCharsAtLine:lineNr fromCol:startCol toCol:endCol
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1862
    "delete characters from startCol to endCol in line lineNr
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1863
    "
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1864
    |line lineSize newLine start stop|
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  1865
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  1866
    line := self listAt:lineNr.
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1867
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1868
    (self checkModificationsAllowed and:[line notNil]) ifTrue:[ 
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1869
        lineSize := line size.
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1870
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1871
        startCol == 0     ifFalse:[ start := startCol ]
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1872
                           ifTrue:[ start := 1 ]. 
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1873
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1874
        endCol > lineSize ifFalse:[ stop  := endCol ]
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1875
                           ifTrue:[ stop  := lineSize ].
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1876
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1877
        stop >= start ifTrue:[
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1878
            start ~~ 1 ifTrue:[ newLine := line copyFrom:1 to:(start-1) ]
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1879
                      ifFalse:[ newLine := '' ].
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1880
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1881
            stop == lineSize ifFalse:[
879
5bb93a1651cd cutting in a 16-bit text fixed
Claus Gittinger <cg@exept.de>
parents: 870
diff changeset
  1882
                line bitsPerCharacter > newLine bitsPerCharacter ifTrue:[
5bb93a1651cd cutting in a 16-bit text fixed
Claus Gittinger <cg@exept.de>
parents: 870
diff changeset
  1883
                    newLine := line string species fromString:newLine.
5bb93a1651cd cutting in a 16-bit text fixed
Claus Gittinger <cg@exept.de>
parents: 870
diff changeset
  1884
                ].
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1885
                newLine := newLine, (line copyFrom:(stop + 1) to:lineSize)
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1886
            ].
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1887
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1888
            (trimBlankLines and:[newLine isBlank]) ifTrue:[
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1889
                newLine := nil
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1890
            ].
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1891
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1892
            list at:lineNr put:newLine.
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1893
            widthOfWidestLine := nil.   "i.e. unknown"
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1894
            self textChanged.
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1895
            self redrawLine:lineNr from:start.
671
f3fe0d8c604d added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents: 666
diff changeset
  1896
        ]
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1897
    ]
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1898
879
5bb93a1651cd cutting in a 16-bit text fixed
Claus Gittinger <cg@exept.de>
parents: 870
diff changeset
  1899
    "Modified: 11.11.1996 / 11:24:48 / cg"
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  1900
!
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  1901
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  1902
deleteFromLine:startLine col:startCol toLine:endLine col:endCol
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  1903
    "delete all text from startLine/startCol to endLine/endCol -
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  1904
     joining lines if nescessary"
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  1905
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  1906
    |line lineSize|
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  1907
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  1908
    self checkModificationsAllowed ifFalse:[ ^ self].
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  1909
    list isNil ifTrue:[^ self].
960
29a592101ad4 care for deleting a selection behond the texts end
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  1910
    startLine > list size ifTrue:[ ^ self]. "/ deleted space below text
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  1911
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  1912
    (startLine == endLine) ifTrue:[
641
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  1913
        "/ delete chars within a line
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  1914
        self deleteCharsAtLine:startLine fromCol:startCol toCol:endCol.
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  1915
        ^ self
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  1916
    ].
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  1917
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  1918
    ((startCol == 1) and:[endCol == 0]) ifTrue:[
641
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  1919
        "/ delete full lines only
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  1920
        endLine > startLine ifTrue:[
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  1921
            self deleteFromLine:startLine toLine:(endLine - 1)
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  1922
        ].
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  1923
        ^ self
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  1924
    ].
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  1925
641
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  1926
    "/ delete right rest of 1st line
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  1927
    self deleteCharsAtLine:startLine fromCol:startCol.
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  1928
641
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  1929
    "/ delete the inner lines ...
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  1930
    endLine > (startLine + 1) ifTrue:[
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  1931
        self deleteFromLine:(startLine + 1) toLine:(endLine - 1)
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  1932
    ].
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  1933
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  1934
    (endCol ~~ 0) ifTrue:[
641
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  1935
        "/ delete the left rest of the last line
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  1936
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  1937
        self deleteCharsAtLine:(startLine + 1) toCol:endCol.
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  1938
641
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  1939
        "/ must add blanks, if startCol lies behond end of startLine
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  1940
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  1941
        line := list at:startLine.
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  1942
        lineSize := line size.
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  1943
        (startCol > lineSize) ifTrue:[
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  1944
            line isNil ifTrue:[
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  1945
                line := String new:(startCol - 1)
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  1946
            ] ifFalse:[
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  1947
                line := line , (line species new:(startCol - 1 - lineSize))
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  1948
            ].
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  1949
            list at:startLine put:line.
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  1950
            widthOfWidestLine := nil. "/ i.e. unknown
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  1951
            self textChanged.
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  1952
        ]
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  1953
    ].
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  1954
641
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  1955
    "/ merge the left rest of 1st line with right rest of last line into one
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  1956
    self mergeLine:startLine
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  1957
960
29a592101ad4 care for deleting a selection behond the texts end
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  1958
    "Modified: 18.1.1997 / 14:31:55 / cg"
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  1959
!
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  1960
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  1961
deleteFromLine:startLineNr toLine:endLineNr
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  1962
    "delete some lines"
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  1963
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  1964
    |wasOn nLines|
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  1965
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  1966
    self checkModificationsAllowed ifFalse:[ ^ self].
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  1967
    list isNil ifTrue:[^ self].
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  1968
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  1969
    wasOn := self hideCursor.
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  1970
    list removeFromIndex:startLineNr toIndex:(endLineNr min:list size).
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  1971
    widthOfWidestLine := nil. "/ i.e. unknown
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  1972
    self textChanged.
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  1973
    self redrawFromLine:startLineNr.
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  1974
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  1975
    nLines := list size.
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  1976
    (firstLineShown >= nLines) ifTrue:[
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  1977
	self makeLineVisible:nLines
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  1978
    ].
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  1979
    wasOn ifTrue:[self showCursor].
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  1980
!
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  1981
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  1982
deleteLineWithoutRedraw:lineNr
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  1983
    "delete line - no redraw;
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  1984
     return true, if something was really deleted"
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  1985
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  1986
    self checkModificationsAllowed ifFalse:[ ^ self].
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  1987
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  1988
    (list isNil or:[lineNr > list size]) ifTrue:[^ false].
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  1989
    list removeIndex:lineNr.
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  1990
    widthOfWidestLine := nil. "/ i.e. unknown
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  1991
    self textChanged.
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  1992
    ^ true
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  1993
!
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  1994
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  1995
insert:aCharacter atLine:lineNr col:colNr
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1996
    "insert a single character at lineNr/colNr; 
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1997
     set emphasis to character at current position"
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1998
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1999
    |line lineSize newLine drawCharacterOnly attribute|
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2000
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2001
    self checkModificationsAllowed ifFalse:[ ^ self].
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2002
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2003
    aCharacter == (Character cr) ifTrue:[
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2004
        self splitLine:lineNr before:colNr.
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2005
        ^ self
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2006
    ].
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2007
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2008
    drawCharacterOnly := false.
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2009
    self checkForExistingLine:lineNr.
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2010
    line := list at:lineNr.
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2011
    lineSize := line size.
671
f3fe0d8c604d added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents: 666
diff changeset
  2012
1300
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  2013
    ST80Mode ~~ true ifTrue:[
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  2014
        (trimBlankLines 
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  2015
        and:[colNr > lineSize
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  2016
        and:[aCharacter == Character space]]) ifTrue:[
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  2017
            ^ self
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  2018
        ]
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2019
    ].
671
f3fe0d8c604d added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents: 666
diff changeset
  2020
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2021
    (lineSize == 0) ifTrue:[
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2022
        newLine := aCharacter asString species new:colNr.
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2023
        drawCharacterOnly := true
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2024
    ] ifFalse: [
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2025
        (colNr > lineSize) ifTrue: [
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2026
            colNr == (lineSize +1) ifTrue:[
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2027
                attribute := line emphasisAt:lineSize
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2028
            ].
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2029
            newLine := line species new:colNr.
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2030
            newLine replaceFrom:1 to:lineSize
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2031
                           with:line startingAt:1.
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2032
            drawCharacterOnly := true
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2033
        ] ifFalse: [
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2034
            attribute := line emphasisAt:colNr.
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2035
            newLine   := line species new:(lineSize + 1).
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2036
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2037
            newLine replaceFrom:1 to:(colNr - 1)
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2038
                           with:line startingAt:1.
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2039
            newLine replaceFrom:(colNr + 1) to:(lineSize + 1)
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2040
                           with:line startingAt:colNr
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2041
        ]
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2042
    ].
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2043
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2044
    newLine at:colNr put:aCharacter.
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2045
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2046
    attribute notNil ifTrue:[
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2047
        newLine emphasisAt:colNr put:attribute
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2048
    ].
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2049
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2050
    aCharacter == (Character tab) ifTrue:[
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2051
        newLine := self withTabsExpanded:newLine.
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2052
        drawCharacterOnly := false
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2053
    ].
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2054
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2055
    list at:lineNr put:newLine.
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2056
    widthOfWidestLine notNil ifTrue:[
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2057
        widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:line).
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2058
    ].
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2059
    self textChanged.
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2060
    shown ifTrue:[
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2061
        drawCharacterOnly ifTrue:[
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2062
            self redrawLine:lineNr col:colNr
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2063
        ] ifFalse:[
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2064
            self redrawLine:lineNr from:colNr
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2065
        ]
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2066
    ]
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2067
1300
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  2068
    "Modified: 13.8.1997 / 15:37:21 / cg"
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2069
!
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2070
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2071
insertLines:someText from:start to:end before:lineNr
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2072
    "insert a bunch of lines before line lineNr"
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2073
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2074
    |text indent visLine w nLines "{ Class: SmallInteger }"
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2075
     srcY "{ Class: SmallInteger }"
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2076
     dstY "{ Class: SmallInteger }" |
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2077
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2078
    readOnly ifTrue:[
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2079
        ^ self
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2080
    ].
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2081
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2082
    autoIndent ifTrue:[
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2083
        indent := self leftIndentForLine:lineNr.
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2084
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2085
        text := someText collect:[:ln||line|
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2086
            ln notNil ifTrue:[
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2087
                line := ln withoutLeadingSeparators.
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2088
                (line isEmpty or:[indent == 0]) ifFalse:[
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2089
                    line := (String new:indent), line
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2090
                ].
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2091
                line
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2092
            ] ifFalse:[
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2093
                nil
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2094
            ]
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2095
        ].
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2096
    ] ifFalse:[
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2097
        text := someText
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2098
    ].
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2099
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2100
    visLine := self listLineToVisibleLine:lineNr.
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2101
    (shown not or:[visLine isNil]) ifTrue:[
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2102
        self withoutRedrawInsertLines:text
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2103
                                 from:start to:end
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2104
                               before:lineNr.
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2105
    ] ifFalse:[
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2106
        nLines := end - start + 1.
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2107
        ((visLine + nLines) >= nLinesShown) ifTrue:[
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2108
            self withoutRedrawInsertLines:text
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2109
                                     from:start to:end
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2110
                                   before:lineNr.
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2111
            self redrawFromVisibleLine:visLine to:nLinesShown
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2112
        ] ifFalse:[
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2113
            w := self widthForScrollBetween:(lineNr + nLines)
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2114
                                        and:(firstLineShown + nLines + nLinesShown).
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2115
            srcY := topMargin + ((visLine - 1) * fontHeight).
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2116
            dstY := srcY + (nLines * fontHeight).
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2117
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2118
            "/
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2119
            "/ scroll ...
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2120
            "/
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2121
            "
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2122
             stupid: must catchExpose before inserting new
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2123
             stuff - since catchExpose may perform redraws
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2124
            "
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2125
            self catchExpose.
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2126
            self withoutRedrawInsertLines:text
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2127
                                     from:start to:end
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2128
                                   before:lineNr.
984
dbd60475b3f5 explicit async bitBlt
Claus Gittinger <cg@exept.de>
parents: 981
diff changeset
  2129
            self 
dbd60475b3f5 explicit async bitBlt
Claus Gittinger <cg@exept.de>
parents: 981
diff changeset
  2130
                copyFrom:self 
dbd60475b3f5 explicit async bitBlt
Claus Gittinger <cg@exept.de>
parents: 981
diff changeset
  2131
                x:textStartLeft y:srcY
dbd60475b3f5 explicit async bitBlt
Claus Gittinger <cg@exept.de>
parents: 981
diff changeset
  2132
                toX:textStartLeft y:dstY
dbd60475b3f5 explicit async bitBlt
Claus Gittinger <cg@exept.de>
parents: 981
diff changeset
  2133
                width:w
dbd60475b3f5 explicit async bitBlt
Claus Gittinger <cg@exept.de>
parents: 981
diff changeset
  2134
                height:(height - dstY)
dbd60475b3f5 explicit async bitBlt
Claus Gittinger <cg@exept.de>
parents: 981
diff changeset
  2135
                async:true.
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2136
            self redrawFromVisibleLine:visLine to:(visLine + nLines - 1).
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2137
            self waitForExpose
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2138
        ].
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2139
    ].
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2140
    widthOfWidestLine notNil ifTrue:[
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2141
        text do:[:line |
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2142
            widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:line).
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2143
        ]
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2144
    ].
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2145
    self textChanged.
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2146
984
dbd60475b3f5 explicit async bitBlt
Claus Gittinger <cg@exept.de>
parents: 981
diff changeset
  2147
    "Modified: 29.1.1997 / 13:02:39 / cg"
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2148
!
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2149
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2150
mergeLine:lineNr
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2151
    "merge line lineNr with line lineNr+1"
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2152
1319
2739903e7a80 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  2153
    self mergeLine:lineNr removeBlanks:true
2739903e7a80 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  2154
2739903e7a80 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  2155
    "Modified: 9.9.1997 / 09:28:03 / cg"
2739903e7a80 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  2156
!
2739903e7a80 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  2157
2739903e7a80 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  2158
mergeLine:lineNr removeBlanks:removeBlanks
2739903e7a80 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  2159
    "merge line lineNr with line lineNr+1"
2739903e7a80 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  2160
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2161
    |leftPart rightPart bothParts nextLineNr i|
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2162
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2163
    (list notNil and:[(list size) > lineNr]) ifFalse:[
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2164
        ^ self
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2165
    ].
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2166
    leftPart := self listAt:lineNr.
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2167
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2168
    leftPart isNil ifTrue:[
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2169
        leftPart := ''.
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2170
        autoIndent ifTrue:[
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2171
            (i := self leftIndentForLine:cursorLine) == 0 ifFalse:[
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2172
                leftPart := String new:i
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2173
            ]
671
f3fe0d8c604d added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents: 666
diff changeset
  2174
        ]
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2175
    ].
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2176
    self cursorLine:lineNr col:((leftPart size) + 1).
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2177
    nextLineNr := self validateCursorLine:(lineNr + 1).
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2178
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2179
    nextLineNr > (list size) ifFalse:[
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2180
        (rightPart := self listAt:nextLineNr) isNil ifTrue:[
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2181
            rightPart := ''
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2182
        ] ifFalse:[
1319
2739903e7a80 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  2183
            removeBlanks ifTrue:[
2739903e7a80 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  2184
                rightPart := rightPart withoutLeadingSeparators.
2739903e7a80 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  2185
            ]
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2186
        ].
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2187
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2188
        bothParts := leftPart , rightPart.
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2189
        (trimBlankLines and:[bothParts isBlank]) ifTrue:[bothParts := nil].
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2190
        list at:lineNr put:bothParts.
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2191
        self redrawLine:lineNr.
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2192
        self deleteLine:nextLineNr
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2193
    ]
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2194
1319
2739903e7a80 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  2195
    "Created: 9.9.1997 / 09:27:38 / cg"
2739903e7a80 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  2196
    "Modified: 9.9.1997 / 09:28:27 / cg"
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2197
!
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2198
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2199
replace:aCharacter atLine:lineNr col:colNr
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2200
    "replace a single character at lineNr/colNr"
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2201
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2202
    |line lineSize newLine drawCharacterOnly|
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2203
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2204
    self checkModificationsAllowed ifFalse:[ ^ self].
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2205
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2206
    aCharacter == (Character cr) ifTrue:[
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2207
        ^ self
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2208
    ].
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2209
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2210
    self checkForExistingLine:lineNr.
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2211
    line := list at:lineNr.
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2212
    lineSize := line size.
671
f3fe0d8c604d added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents: 666
diff changeset
  2213
f3fe0d8c604d added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents: 666
diff changeset
  2214
    (trimBlankLines
f3fe0d8c604d added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents: 666
diff changeset
  2215
    and:[colNr > lineSize
f3fe0d8c604d added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents: 666
diff changeset
  2216
    and:[aCharacter == Character space]]) ifTrue:[
f3fe0d8c604d added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents: 666
diff changeset
  2217
        ^ self
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2218
    ].
671
f3fe0d8c604d added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents: 666
diff changeset
  2219
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2220
    (lineSize == 0) ifTrue:[
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2221
        newLine := aCharacter asString species new:colNr.
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2222
    ] ifFalse: [
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2223
        (colNr > lineSize) ifTrue: [
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2224
            newLine := line species new:colNr.
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2225
            newLine replaceFrom:1 to:lineSize with:line startingAt:1.
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2226
        ] ifFalse: [
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2227
            newLine := line copy.
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2228
        ]
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2229
    ].
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2230
    newLine at:colNr put:aCharacter.
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2231
    list at:lineNr put:newLine.
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2232
    widthOfWidestLine notNil ifTrue:[
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2233
        widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:line).
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2234
    ].
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2235
    self textChanged.
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2236
    shown ifTrue:[
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2237
        self redrawLine:lineNr col:colNr
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2238
    ]
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2239
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2240
    "Created: 6.3.1996 / 12:29:20 / cg"
671
f3fe0d8c604d added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents: 666
diff changeset
  2241
    "Modified: 22.5.1996 / 15:35:22 / cg"
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  2242
!
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  2243
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2244
splitLine:lineNr before:colNr
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2245
    "split the line linNr before colNr; the right part (from colNr)
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2246
     is cut off and inserted after lineNr; the view is redrawn"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2247
981
6e52d3876ea7 dont catchExpose, if copy is empty
Claus Gittinger <cg@exept.de>
parents: 960
diff changeset
  2248
    |line lineSize leftRest rightRest visLine w h mustWait    
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2249
     srcY    "{ Class: SmallInteger }" |
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2250
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2251
    list isNil ifFalse:[
671
f3fe0d8c604d added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents: 666
diff changeset
  2252
        lineNr > (list size) ifFalse:[
f3fe0d8c604d added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents: 666
diff changeset
  2253
            (colNr == 1) ifTrue:[
f3fe0d8c604d added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents: 666
diff changeset
  2254
                self insertLine:nil before:lineNr.
f3fe0d8c604d added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents: 666
diff changeset
  2255
                ^ self
f3fe0d8c604d added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents: 666
diff changeset
  2256
            ].
f3fe0d8c604d added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents: 666
diff changeset
  2257
            line := list at:lineNr.
f3fe0d8c604d added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents: 666
diff changeset
  2258
            line isNil ifFalse:[
f3fe0d8c604d added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents: 666
diff changeset
  2259
                lineSize := line size.
f3fe0d8c604d added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents: 666
diff changeset
  2260
                (colNr <= lineSize) ifTrue:[
f3fe0d8c604d added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents: 666
diff changeset
  2261
                    rightRest := line copyFrom:colNr to:lineSize.
f3fe0d8c604d added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents: 666
diff changeset
  2262
                    (colNr > 1) ifTrue:[
f3fe0d8c604d added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents: 666
diff changeset
  2263
                        leftRest := line copyTo:(colNr - 1)
f3fe0d8c604d added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents: 666
diff changeset
  2264
                    ]
f3fe0d8c604d added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents: 666
diff changeset
  2265
                ] ifFalse:[
f3fe0d8c604d added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents: 666
diff changeset
  2266
                    leftRest := line
f3fe0d8c604d added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents: 666
diff changeset
  2267
                ]
f3fe0d8c604d added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents: 666
diff changeset
  2268
            ].
f3fe0d8c604d added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents: 666
diff changeset
  2269
            leftRest notNil ifTrue:[
f3fe0d8c604d added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents: 666
diff changeset
  2270
                (trimBlankLines and:[leftRest isBlank]) ifTrue:[leftRest := nil]
f3fe0d8c604d added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents: 666
diff changeset
  2271
            ].
f3fe0d8c604d added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents: 666
diff changeset
  2272
            list at:lineNr put:leftRest.
f3fe0d8c604d added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents: 666
diff changeset
  2273
            self withoutRedrawInsertLine:rightRest before:(lineNr + 1).
f3fe0d8c604d added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents: 666
diff changeset
  2274
f3fe0d8c604d added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents: 666
diff changeset
  2275
            visLine := self listLineToVisibleLine:(lineNr).
f3fe0d8c604d added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents: 666
diff changeset
  2276
            visLine notNil ifTrue:[
f3fe0d8c604d added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents: 666
diff changeset
  2277
                w := self widthForScrollBetween:lineNr
f3fe0d8c604d added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents: 666
diff changeset
  2278
                                            and:(firstLineShown + nLinesShown).
f3fe0d8c604d added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents: 666
diff changeset
  2279
                srcY := topMargin + (visLine * fontHeight).
981
6e52d3876ea7 dont catchExpose, if copy is empty
Claus Gittinger <cg@exept.de>
parents: 960
diff changeset
  2280
                h := ((nLinesShown - visLine - 1) * fontHeight).
6e52d3876ea7 dont catchExpose, if copy is empty
Claus Gittinger <cg@exept.de>
parents: 960
diff changeset
  2281
                (mustWait := (w > 0 and:[h > 0])) ifTrue:[
6e52d3876ea7 dont catchExpose, if copy is empty
Claus Gittinger <cg@exept.de>
parents: 960
diff changeset
  2282
                    self catchExpose.
984
dbd60475b3f5 explicit async bitBlt
Claus Gittinger <cg@exept.de>
parents: 981
diff changeset
  2283
                    self 
dbd60475b3f5 explicit async bitBlt
Claus Gittinger <cg@exept.de>
parents: 981
diff changeset
  2284
                        copyFrom:self 
dbd60475b3f5 explicit async bitBlt
Claus Gittinger <cg@exept.de>
parents: 981
diff changeset
  2285
                        x:textStartLeft y:srcY
dbd60475b3f5 explicit async bitBlt
Claus Gittinger <cg@exept.de>
parents: 981
diff changeset
  2286
                        toX:textStartLeft y:(srcY + fontHeight)
dbd60475b3f5 explicit async bitBlt
Claus Gittinger <cg@exept.de>
parents: 981
diff changeset
  2287
                        width:w
dbd60475b3f5 explicit async bitBlt
Claus Gittinger <cg@exept.de>
parents: 981
diff changeset
  2288
                        height:((nLinesShown - visLine - 1) * fontHeight)
dbd60475b3f5 explicit async bitBlt
Claus Gittinger <cg@exept.de>
parents: 981
diff changeset
  2289
                        async:true.
981
6e52d3876ea7 dont catchExpose, if copy is empty
Claus Gittinger <cg@exept.de>
parents: 960
diff changeset
  2290
                ].
671
f3fe0d8c604d added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents: 666
diff changeset
  2291
                self redrawLine:lineNr.
f3fe0d8c604d added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents: 666
diff changeset
  2292
                self redrawLine:(lineNr + 1).
981
6e52d3876ea7 dont catchExpose, if copy is empty
Claus Gittinger <cg@exept.de>
parents: 960
diff changeset
  2293
                mustWait ifTrue:[self waitForExpose]
671
f3fe0d8c604d added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents: 666
diff changeset
  2294
            ].
f3fe0d8c604d added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents: 666
diff changeset
  2295
            widthOfWidestLine := nil. "/ unknown
f3fe0d8c604d added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents: 666
diff changeset
  2296
            self textChanged.
f3fe0d8c604d added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents: 666
diff changeset
  2297
        ]
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2298
    ]
671
f3fe0d8c604d added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents: 666
diff changeset
  2299
984
dbd60475b3f5 explicit async bitBlt
Claus Gittinger <cg@exept.de>
parents: 981
diff changeset
  2300
    "Modified: 29.1.1997 / 13:03:22 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2301
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2302
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2303
withoutRedrawInsertLine:aString before:lineNr
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2304
    "insert the argument, aString before line lineNr; the string
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2305
     becomes line nileNr; everything else is moved down; the view
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2306
     is not redrawn"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2307
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2308
    |line|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2309
331
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
  2310
    self checkModificationsAllowed ifFalse:[ ^ self].
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
  2311
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2312
    line := aString.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2313
    line notNil ifTrue:[
991
2d97ed971ce4 need a self>>contentsChanged when inserting lines.
Claus Gittinger <cg@exept.de>
parents: 984
diff changeset
  2314
        line isString ifTrue:[
2d97ed971ce4 need a self>>contentsChanged when inserting lines.
Claus Gittinger <cg@exept.de>
parents: 984
diff changeset
  2315
            line isBlank ifTrue:[
2d97ed971ce4 need a self>>contentsChanged when inserting lines.
Claus Gittinger <cg@exept.de>
parents: 984
diff changeset
  2316
                line := nil
2d97ed971ce4 need a self>>contentsChanged when inserting lines.
Claus Gittinger <cg@exept.de>
parents: 984
diff changeset
  2317
            ] ifFalse:[
2d97ed971ce4 need a self>>contentsChanged when inserting lines.
Claus Gittinger <cg@exept.de>
parents: 984
diff changeset
  2318
                (line occurrencesOf:(Character tab)) == 0 ifFalse:[
2d97ed971ce4 need a self>>contentsChanged when inserting lines.
Claus Gittinger <cg@exept.de>
parents: 984
diff changeset
  2319
                    line := self withTabsExpanded:line
2d97ed971ce4 need a self>>contentsChanged when inserting lines.
Claus Gittinger <cg@exept.de>
parents: 984
diff changeset
  2320
                ]
2d97ed971ce4 need a self>>contentsChanged when inserting lines.
Claus Gittinger <cg@exept.de>
parents: 984
diff changeset
  2321
            ]
2d97ed971ce4 need a self>>contentsChanged when inserting lines.
Claus Gittinger <cg@exept.de>
parents: 984
diff changeset
  2322
        ]
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2323
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2324
    list isNil ifTrue: [
991
2d97ed971ce4 need a self>>contentsChanged when inserting lines.
Claus Gittinger <cg@exept.de>
parents: 984
diff changeset
  2325
        list := StringCollection new:lineNr
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2326
    ] ifFalse: [
991
2d97ed971ce4 need a self>>contentsChanged when inserting lines.
Claus Gittinger <cg@exept.de>
parents: 984
diff changeset
  2327
        list grow:((list size + 1) max:lineNr)
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2328
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2329
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2330
    "I have changed 'replaceFrom:to:with:startingAt:' to correctly handle 
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2331
     overlapping copy - if it didn't, we had to use:"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2332
"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2333
    index := list size.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2334
    [index > lineNr] whileTrue: [
991
2d97ed971ce4 need a self>>contentsChanged when inserting lines.
Claus Gittinger <cg@exept.de>
parents: 984
diff changeset
  2335
        pIndex := index - 1.
2d97ed971ce4 need a self>>contentsChanged when inserting lines.
Claus Gittinger <cg@exept.de>
parents: 984
diff changeset
  2336
        list at:index put:(list at:pIndex).
2d97ed971ce4 need a self>>contentsChanged when inserting lines.
Claus Gittinger <cg@exept.de>
parents: 984
diff changeset
  2337
        index := pIndex
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2338
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2339
"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2340
    list replaceFrom:(lineNr + 1) to:(list size) with:list startingAt:lineNr.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2341
    list at:lineNr put:line.
991
2d97ed971ce4 need a self>>contentsChanged when inserting lines.
Claus Gittinger <cg@exept.de>
parents: 984
diff changeset
  2342
    self contentsChanged
2d97ed971ce4 need a self>>contentsChanged when inserting lines.
Claus Gittinger <cg@exept.de>
parents: 984
diff changeset
  2343
2d97ed971ce4 need a self>>contentsChanged when inserting lines.
Claus Gittinger <cg@exept.de>
parents: 984
diff changeset
  2344
    "Modified: 8.2.1997 / 12:38:52 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2345
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2346
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2347
withoutRedrawInsertLines:lines from:start to:end before:lineNr
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2348
    "insert a bunch of lines before line lineNr; the view is not redrawn"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2349
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2350
    |newLine newLines nLines|
121
claus
parents: 118
diff changeset
  2351
331
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
  2352
    self checkModificationsAllowed ifFalse:[ ^ self].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2353
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2354
    nLines := end - start + 1.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2355
    newLines := Array new:(lines size).
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2356
    start to:end do:[:index |
991
2d97ed971ce4 need a self>>contentsChanged when inserting lines.
Claus Gittinger <cg@exept.de>
parents: 984
diff changeset
  2357
        newLine := lines at:index.
2d97ed971ce4 need a self>>contentsChanged when inserting lines.
Claus Gittinger <cg@exept.de>
parents: 984
diff changeset
  2358
        newLine notNil ifTrue:[
2d97ed971ce4 need a self>>contentsChanged when inserting lines.
Claus Gittinger <cg@exept.de>
parents: 984
diff changeset
  2359
            newLine isString ifTrue:[
2d97ed971ce4 need a self>>contentsChanged when inserting lines.
Claus Gittinger <cg@exept.de>
parents: 984
diff changeset
  2360
                newLine isBlank ifTrue:[
2d97ed971ce4 need a self>>contentsChanged when inserting lines.
Claus Gittinger <cg@exept.de>
parents: 984
diff changeset
  2361
                    newLine := nil
2d97ed971ce4 need a self>>contentsChanged when inserting lines.
Claus Gittinger <cg@exept.de>
parents: 984
diff changeset
  2362
                ] ifFalse:[
2d97ed971ce4 need a self>>contentsChanged when inserting lines.
Claus Gittinger <cg@exept.de>
parents: 984
diff changeset
  2363
                    (newLine occurrencesOf:(Character tab)) == 0 ifFalse:[
2d97ed971ce4 need a self>>contentsChanged when inserting lines.
Claus Gittinger <cg@exept.de>
parents: 984
diff changeset
  2364
                        newLine := self withTabsExpanded:newLine
2d97ed971ce4 need a self>>contentsChanged when inserting lines.
Claus Gittinger <cg@exept.de>
parents: 984
diff changeset
  2365
                    ]
2d97ed971ce4 need a self>>contentsChanged when inserting lines.
Claus Gittinger <cg@exept.de>
parents: 984
diff changeset
  2366
                ]
2d97ed971ce4 need a self>>contentsChanged when inserting lines.
Claus Gittinger <cg@exept.de>
parents: 984
diff changeset
  2367
            ]
2d97ed971ce4 need a self>>contentsChanged when inserting lines.
Claus Gittinger <cg@exept.de>
parents: 984
diff changeset
  2368
        ].
2d97ed971ce4 need a self>>contentsChanged when inserting lines.
Claus Gittinger <cg@exept.de>
parents: 984
diff changeset
  2369
        newLines at:index put:newLine
121
claus
parents: 118
diff changeset
  2370
    ].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2371
    list isNil ifTrue: [
991
2d97ed971ce4 need a self>>contentsChanged when inserting lines.
Claus Gittinger <cg@exept.de>
parents: 984
diff changeset
  2372
        list := StringCollection new:(lineNr + nLines + 1)
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2373
    ] ifFalse: [
991
2d97ed971ce4 need a self>>contentsChanged when inserting lines.
Claus Gittinger <cg@exept.de>
parents: 984
diff changeset
  2374
        list grow:((list size + nLines) max:(lineNr + nLines - 1))
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2375
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2376
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2377
    "I have changed 'replaceFrom:to:with:startingAt:' to correctly handle 
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2378
     overlapping copy - if it didn't, we had to use:"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2379
"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2380
    index := list size.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2381
    [index > lineNr] whileTrue: [
991
2d97ed971ce4 need a self>>contentsChanged when inserting lines.
Claus Gittinger <cg@exept.de>
parents: 984
diff changeset
  2382
        pIndex := index - 1.
2d97ed971ce4 need a self>>contentsChanged when inserting lines.
Claus Gittinger <cg@exept.de>
parents: 984
diff changeset
  2383
        list at:index put:(list at:pIndex).
2d97ed971ce4 need a self>>contentsChanged when inserting lines.
Claus Gittinger <cg@exept.de>
parents: 984
diff changeset
  2384
        index := pIndex
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2385
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2386
"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2387
    list replaceFrom:(lineNr + nLines) to:(list size) with:list startingAt:lineNr.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2388
    list replaceFrom:lineNr to:(lineNr + nLines - 1) with:newLines startingAt:start.
991
2d97ed971ce4 need a self>>contentsChanged when inserting lines.
Claus Gittinger <cg@exept.de>
parents: 984
diff changeset
  2389
    self contentsChanged
2d97ed971ce4 need a self>>contentsChanged when inserting lines.
Claus Gittinger <cg@exept.de>
parents: 984
diff changeset
  2390
2d97ed971ce4 need a self>>contentsChanged when inserting lines.
Claus Gittinger <cg@exept.de>
parents: 984
diff changeset
  2391
    "Modified: 8.2.1997 / 12:38:42 / cg"
121
claus
parents: 118
diff changeset
  2392
!
claus
parents: 118
diff changeset
  2393
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2394
withoutRedrawInsertStringWithoutCRs:aString atLine:lineNr col:colNr
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2395
    "insert aString (which has no crs) at lineNr/colNr"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2396
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2397
    |isText strLen line lineSize newLine stringType sz|
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2398
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2399
    ((self checkModificationsAllowed) and:[aString notNil]) ifFalse:[ ^ self].
331
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
  2400
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2401
    strLen := aString size.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2402
    self checkForExistingLine:lineNr.
400
70fb3a81922f better create a 16bit string when pasting one into an 8bit string
Claus Gittinger <cg@exept.de>
parents: 387
diff changeset
  2403
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2404
    stringType := aString string species.
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2405
    isText     := aString isText.
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2406
    line       := list at:lineNr.
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2407
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2408
    line notNil ifTrue:[
400
70fb3a81922f better create a 16bit string when pasting one into an 8bit string
Claus Gittinger <cg@exept.de>
parents: 387
diff changeset
  2409
        lineSize := line size.
70fb3a81922f better create a 16bit string when pasting one into an 8bit string
Claus Gittinger <cg@exept.de>
parents: 387
diff changeset
  2410
        line bitsPerCharacter > aString bitsPerCharacter ifTrue:[
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2411
            stringType := line string species
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2412
        ].
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2413
        line isText ifTrue:[ isText := true ]
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2414
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2415
    ] ifFalse:[
385
a373f2dd9c60 care when editing 16bit text (dont hardcode String into the edit methods)
Claus Gittinger <cg@exept.de>
parents: 362
diff changeset
  2416
        lineSize := 0
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2417
    ].
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2418
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2419
    ((colNr == 1) and:[lineSize == 0]) ifTrue: [
385
a373f2dd9c60 care when editing 16bit text (dont hardcode String into the edit methods)
Claus Gittinger <cg@exept.de>
parents: 362
diff changeset
  2420
        newLine := aString
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2421
    ] ifFalse:[
828
6c284d7e577d withoutRedrawInsertStringWithoutCRs:aString atLine:lineNr col:colNr
ca
parents: 827
diff changeset
  2422
        (lineSize == 0 or:[colNr > lineSize]) ifTrue: [
6c284d7e577d withoutRedrawInsertStringWithoutCRs:aString atLine:lineNr col:colNr
ca
parents: 827
diff changeset
  2423
            sz := colNr + strLen - 1
6c284d7e577d withoutRedrawInsertStringWithoutCRs:aString atLine:lineNr col:colNr
ca
parents: 827
diff changeset
  2424
        ] ifFalse:[
6c284d7e577d withoutRedrawInsertStringWithoutCRs:aString atLine:lineNr col:colNr
ca
parents: 827
diff changeset
  2425
            sz := lineSize + strLen
6c284d7e577d withoutRedrawInsertStringWithoutCRs:aString atLine:lineNr col:colNr
ca
parents: 827
diff changeset
  2426
        ].
6c284d7e577d withoutRedrawInsertStringWithoutCRs:aString atLine:lineNr col:colNr
ca
parents: 827
diff changeset
  2427
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2428
        isText ifFalse:[
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2429
            newLine := stringType new:sz
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2430
        ] ifTrue:[
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2431
            newLine := Text string:(stringType new:sz)
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2432
        ].
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2433
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2434
        (lineSize ~~ 0) ifTrue: [
385
a373f2dd9c60 care when editing 16bit text (dont hardcode String into the edit methods)
Claus Gittinger <cg@exept.de>
parents: 362
diff changeset
  2435
            (colNr > lineSize) ifTrue: [
a373f2dd9c60 care when editing 16bit text (dont hardcode String into the edit methods)
Claus Gittinger <cg@exept.de>
parents: 362
diff changeset
  2436
                newLine replaceFrom:1 to:lineSize
a373f2dd9c60 care when editing 16bit text (dont hardcode String into the edit methods)
Claus Gittinger <cg@exept.de>
parents: 362
diff changeset
  2437
                               with:line startingAt:1
a373f2dd9c60 care when editing 16bit text (dont hardcode String into the edit methods)
Claus Gittinger <cg@exept.de>
parents: 362
diff changeset
  2438
            ] ifFalse: [
a373f2dd9c60 care when editing 16bit text (dont hardcode String into the edit methods)
Claus Gittinger <cg@exept.de>
parents: 362
diff changeset
  2439
                newLine replaceFrom:1 to:(colNr - 1)
a373f2dd9c60 care when editing 16bit text (dont hardcode String into the edit methods)
Claus Gittinger <cg@exept.de>
parents: 362
diff changeset
  2440
                               with:line startingAt:1.
a373f2dd9c60 care when editing 16bit text (dont hardcode String into the edit methods)
Claus Gittinger <cg@exept.de>
parents: 362
diff changeset
  2441
                newLine replaceFrom:(colNr + strLen) to:(lineSize + strLen)
a373f2dd9c60 care when editing 16bit text (dont hardcode String into the edit methods)
Claus Gittinger <cg@exept.de>
parents: 362
diff changeset
  2442
                               with:line startingAt:colNr
a373f2dd9c60 care when editing 16bit text (dont hardcode String into the edit methods)
Claus Gittinger <cg@exept.de>
parents: 362
diff changeset
  2443
            ]
a373f2dd9c60 care when editing 16bit text (dont hardcode String into the edit methods)
Claus Gittinger <cg@exept.de>
parents: 362
diff changeset
  2444
        ].
a373f2dd9c60 care when editing 16bit text (dont hardcode String into the edit methods)
Claus Gittinger <cg@exept.de>
parents: 362
diff changeset
  2445
        newLine replaceFrom:colNr to:(colNr + strLen - 1)
a373f2dd9c60 care when editing 16bit text (dont hardcode String into the edit methods)
Claus Gittinger <cg@exept.de>
parents: 362
diff changeset
  2446
                       with:aString startingAt:1
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2447
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2448
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2449
    (aString occurrencesOf:(Character tab)) == 0 ifFalse:[
385
a373f2dd9c60 care when editing 16bit text (dont hardcode String into the edit methods)
Claus Gittinger <cg@exept.de>
parents: 362
diff changeset
  2450
        newLine := self withTabsExpanded:newLine
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2451
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2452
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2453
    list at:lineNr put:newLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2454
    widthOfWidestLine notNil ifTrue:[
385
a373f2dd9c60 care when editing 16bit text (dont hardcode String into the edit methods)
Claus Gittinger <cg@exept.de>
parents: 362
diff changeset
  2455
        widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:newLine).
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2456
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2457
    self textChanged.
385
a373f2dd9c60 care when editing 16bit text (dont hardcode String into the edit methods)
Claus Gittinger <cg@exept.de>
parents: 362
diff changeset
  2458
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2459
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2460
828
6c284d7e577d withoutRedrawInsertStringWithoutCRs:aString atLine:lineNr col:colNr
ca
parents: 827
diff changeset
  2461
6c284d7e577d withoutRedrawInsertStringWithoutCRs:aString atLine:lineNr col:colNr
ca
parents: 827
diff changeset
  2462
6c284d7e577d withoutRedrawInsertStringWithoutCRs:aString atLine:lineNr col:colNr
ca
parents: 827
diff changeset
  2463
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2464
! !
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2465
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2466
!EditTextView methodsFor:'event processing'!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2467
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2468
buttonPress:button x:x y:y
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2469
    "hide the cursor when button is activated"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2470
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2471
    hasKeyboardFocus := true.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2472
    cursorShown ifTrue: [self drawCursor].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2473
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2474
    ((button == 1) or:[button == #select]) ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2475
	self hideCursor
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2476
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2477
    (button == #paste) ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2478
	self pasteOrReplace.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2479
	^ self
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2480
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2481
    super buttonPress:button x:x y:y
121
claus
parents: 118
diff changeset
  2482
!
claus
parents: 118
diff changeset
  2483
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2484
buttonRelease:button x:x y:y
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2485
    "move the cursor to the click-position of previous button press"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2486
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2487
    ((button == 1) or:[button == #select]) ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2488
	typeOfSelection := nil. 
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2489
	selectionStartLine isNil ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2490
	    clickCol notNil ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2491
		self cursorLine:clickLine col:clickCol
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2492
	    ]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2493
	] ifFalse:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2494
	    lastString := nil. "new selection invalidates remembered string"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2495
	].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2496
	self showCursor
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2497
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2498
    super buttonRelease:button x:x y:y
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2499
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2500
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2501
hasKeyboardFocus:aBoolean
893
33d35adb2702 share code of #hasKeyboardFocus:.
Claus Gittinger <cg@exept.de>
parents: 879
diff changeset
  2502
    "sent by a delegate or myself to make me show a block cursor
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2503
     (otherwise, I would not know about this)"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2504
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2505
    hasKeyboardFocus := aBoolean.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2506
    cursorShown ifTrue: [self drawCursor].
893
33d35adb2702 share code of #hasKeyboardFocus:.
Claus Gittinger <cg@exept.de>
parents: 879
diff changeset
  2507
33d35adb2702 share code of #hasKeyboardFocus:.
Claus Gittinger <cg@exept.de>
parents: 879
diff changeset
  2508
    "Modified: 11.12.1996 / 16:56:12 / cg"
121
claus
parents: 118
diff changeset
  2509
!
claus
parents: 118
diff changeset
  2510
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2511
keyPress:key x:x y:y
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2512
    "handle keyboard input"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2513
922
e6a5e1cf9565 resource spec updated
Claus Gittinger <cg@exept.de>
parents: 915
diff changeset
  2514
    <resource: #keyboard (#Paste #Insert #Cut #Again #Replace #Accept
e6a5e1cf9565 resource spec updated
Claus Gittinger <cg@exept.de>
parents: 915
diff changeset
  2515
                          #Delete #BasicDelete #BackSpace #BasicBackspace
e6a5e1cf9565 resource spec updated
Claus Gittinger <cg@exept.de>
parents: 915
diff changeset
  2516
                          #SelectWord
e6a5e1cf9565 resource spec updated
Claus Gittinger <cg@exept.de>
parents: 915
diff changeset
  2517
                          #SearchMatchingParent #SelectMatchingParents 
e6a5e1cf9565 resource spec updated
Claus Gittinger <cg@exept.de>
parents: 915
diff changeset
  2518
                          #SelectToEnd #SelectFromBeginning
e6a5e1cf9565 resource spec updated
Claus Gittinger <cg@exept.de>
parents: 915
diff changeset
  2519
                          #BeginOfLine #EndOfLine #NextWord #PreviousWord
e6a5e1cf9565 resource spec updated
Claus Gittinger <cg@exept.de>
parents: 915
diff changeset
  2520
                          #CursorRight #CursorDown #CursorLeft #CursorUp
e6a5e1cf9565 resource spec updated
Claus Gittinger <cg@exept.de>
parents: 915
diff changeset
  2521
                          #Return #Tab #Escape
313
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2522
                          #GotoLine #Delete #BeginOfText #EndOfText
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2523
                          #SelectLine #ExpandSelectionByLine #DeleteLine
922
e6a5e1cf9565 resource spec updated
Claus Gittinger <cg@exept.de>
parents: 915
diff changeset
  2524
                          #InsertLine
e6a5e1cf9565 resource spec updated
Claus Gittinger <cg@exept.de>
parents: 915
diff changeset
  2525
                          #SelectLineFromBeginning
e6a5e1cf9565 resource spec updated
Claus Gittinger <cg@exept.de>
parents: 915
diff changeset
  2526
                          #'F*' #'f*')>
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2527
474
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  2528
    |sensor n fKeyMacros shifted i|
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2529
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2530
    sensor := self sensor.
1287
cdda8de0af0c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1275
diff changeset
  2531
    sensor notNil ifTrue:[
cdda8de0af0c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1275
diff changeset
  2532
        shifted := sensor shiftDown.
cdda8de0af0c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1275
diff changeset
  2533
    ] ifFalse:[
cdda8de0af0c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1275
diff changeset
  2534
        shifted := device shiftDown
cdda8de0af0c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1275
diff changeset
  2535
    ].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2536
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2537
    (key isMemberOf:Character) ifTrue:[
313
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2538
        readOnly ifFalse:[
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2539
            typeOfSelection == #paste ifTrue:[
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2540
                "pasted selection will NOT be replaced by keystroke"
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2541
                self unselect
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2542
            ].
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2543
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2544
            "replace selection by what is typed in -
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2545
             if word was selected with a space, keep it"
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2546
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2547
            (selectStyle == #wordLeft) ifTrue:[
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2548
                self replaceSelectionBy:(' ' copyWith:key)
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2549
            ] ifFalse:[
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2550
                (selectStyle == #wordRight) ifTrue:[
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2551
                    self replaceSelectionBy:(key asString , ' ').
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2552
                    self cursorLeft
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2553
                ] ifFalse:[
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2554
                    self replaceSelectionBy:key
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2555
                ]
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2556
            ].
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2557
            selectStyle := nil.
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2558
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2559
            showMatchingParenthesis ifTrue:[
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2560
                "emacs style parenthesis shower"
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2561
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2562
                "claus: only do it for closing parenthesis -
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2563
                        otherwise its too anoying.
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2564
                "
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2565
"
313
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2566
                (#( $( $) $[ $] ${ $} ) includes:key) ifTrue:[
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2567
"
313
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2568
                (#( $) $] $} ) includes:key) ifTrue:[
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2569
                self searchForMatchingParenthesisFromLine:cursorLine col:(cursorCol - 1)
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2570
                                   ifFound:[:line :col |
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2571
                                                |savLine savCol|
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2572
479
fae6d1251888 fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 477
diff changeset
  2573
                                                self withCursor:Cursor eye do:[
fae6d1251888 fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 477
diff changeset
  2574
                                                    savLine := cursorLine.
fae6d1251888 fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 477
diff changeset
  2575
                                                    savCol := cursorCol.
fae6d1251888 fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 477
diff changeset
  2576
                                                    self cursorLine:line col:col.
fae6d1251888 fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 477
diff changeset
  2577
                                                    device flush.
fae6d1251888 fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 477
diff changeset
  2578
                                                    Processor activeProcess millisecondDelay:200.
fae6d1251888 fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 477
diff changeset
  2579
                                                    self cursorLine:savLine col:savCol
fae6d1251888 fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 477
diff changeset
  2580
                                                ]
313
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2581
                                           ]
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2582
                                ifNotFound:[self showNotFound]
693
8369529a2ac4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 676
diff changeset
  2583
                                   onError:[self beep]
313
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2584
                ].
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2585
            ].
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2586
        ].
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2587
        ^ self
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2588
    ].                         
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2589
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2590
    replacing := false.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2591
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2592
    "
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2593
     Fn      pastes a key-sequence (but only if not overlayed with
313
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2594
             another function in the keyboard map)
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2595
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2596
     see TextView>>:x:y
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2597
    "
1177
9d23e1241404 avoid match: if possible (to not clobber the previous matchString)
Claus Gittinger <cg@exept.de>
parents: 1108
diff changeset
  2598
    (key at:1) asLowercase == $f ifTrue:[
9d23e1241404 avoid match: if possible (to not clobber the previous matchString)
Claus Gittinger <cg@exept.de>
parents: 1108
diff changeset
  2599
        (('[fF][0-9]' match:key)
9d23e1241404 avoid match: if possible (to not clobber the previous matchString)
Claus Gittinger <cg@exept.de>
parents: 1108
diff changeset
  2600
        or:['[fF][0-9][0-9]' match:key]) ifTrue:[
9d23e1241404 avoid match: if possible (to not clobber the previous matchString)
Claus Gittinger <cg@exept.de>
parents: 1108
diff changeset
  2601
            shifted ifFalse:[
9d23e1241404 avoid match: if possible (to not clobber the previous matchString)
Claus Gittinger <cg@exept.de>
parents: 1108
diff changeset
  2602
                fKeyMacros := Smalltalk at:#FunctionKeySequences.
9d23e1241404 avoid match: if possible (to not clobber the previous matchString)
Claus Gittinger <cg@exept.de>
parents: 1108
diff changeset
  2603
                fKeyMacros notNil ifTrue:[
9d23e1241404 avoid match: if possible (to not clobber the previous matchString)
Claus Gittinger <cg@exept.de>
parents: 1108
diff changeset
  2604
                    (fKeyMacros includesKey:key) ifTrue:[
9d23e1241404 avoid match: if possible (to not clobber the previous matchString)
Claus Gittinger <cg@exept.de>
parents: 1108
diff changeset
  2605
                        self pasteOrReplace:(fKeyMacros at:key) asStringCollection.
9d23e1241404 avoid match: if possible (to not clobber the previous matchString)
Claus Gittinger <cg@exept.de>
parents: 1108
diff changeset
  2606
                        ^ self
9d23e1241404 avoid match: if possible (to not clobber the previous matchString)
Claus Gittinger <cg@exept.de>
parents: 1108
diff changeset
  2607
                    ]
313
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2608
                ]
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2609
            ]
1177
9d23e1241404 avoid match: if possible (to not clobber the previous matchString)
Claus Gittinger <cg@exept.de>
parents: 1108
diff changeset
  2610
        ].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2611
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2612
274
6df4bb990f04 handle accept where acceptAction is define (this was a historic leftover)
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
  2613
    (key == #Accept)  ifTrue:[^ self accept].
6df4bb990f04 handle accept where acceptAction is define (this was a historic leftover)
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
  2614
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2615
    ((key == #Paste) or:[key == #Insert]) ifTrue:[self pasteOrReplace. ^self].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2616
    (key == #Cut) ifTrue:[self cut. ^self].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2617
    (key == #Again) ifTrue:[self again. ^self].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2618
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2619
    (key == #Replace) ifTrue:[self replace. ^self].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2620
    (key == #SelectWord) ifTrue:[
313
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2621
        self makeCursorVisible.
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2622
        ^ self selectWordUnderCursor. 
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2623
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2624
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2625
    (key == #SearchMatchingParent) ifTrue:[^ self searchForMatchingParenthesis.].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2626
    (key == #SelectMatchingParents) ifTrue:[^ self searchForAndSelectMatchingParenthesis.].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2627
    (key == #SelectToEnd) ifTrue:[^ self selectUpToEnd.].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2628
    (key == #SelectFromBeginning) ifTrue:[^ self selectFromBeginning.].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2629
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2630
" disabled - nobody liked it ...
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2631
  and if you like it, its better done in the keymap.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2632
1304
173d00c195f9 flush pending keyboard events in cursor-up/down
Claus Gittinger <cg@exept.de>
parents: 1300
diff changeset
  2633
    (key == #Ctrlb) ifTrue:[self unselect. self cursorLeft. ^ self].
173d00c195f9 flush pending keyboard events in cursor-up/down
Claus Gittinger <cg@exept.de>
parents: 1300
diff changeset
  2634
    (key == #Ctrlf) ifTrue:[self unselect. self cursorRight. ^ self].
173d00c195f9 flush pending keyboard events in cursor-up/down
Claus Gittinger <cg@exept.de>
parents: 1300
diff changeset
  2635
    (key == #Ctrln) ifTrue:[self unselect. self cursorDown. ^ self].
173d00c195f9 flush pending keyboard events in cursor-up/down
Claus Gittinger <cg@exept.de>
parents: 1300
diff changeset
  2636
    (key == #Ctrlp) ifTrue:[self unselect. self cursorUp. ^ self].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2637
"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2638
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2639
    (key == #BeginOfLine) ifTrue:[self cursorToBeginOfLine. ^self].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2640
    (key == #EndOfLine) ifTrue:[self cursorToEndOfLine. ^self].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2641
    (key == #NextWord) ifTrue:[self cursorToNextWord. ^self].
499
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
  2642
    (key == #PreviousWord) ifTrue:[self cursorToPreviousWord. ^self].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2643
    (key == #GotoLine) ifTrue:[self gotoLine. ^self].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2644
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2645
    (key == #CursorRight) ifTrue:[
458
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2646
        (shifted and:[selectionStartLine isNil]) ifTrue:[
479
fae6d1251888 fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 477
diff changeset
  2647
            selectionStartLine := selectionEndLine := clickStartLine := cursorLine.
fae6d1251888 fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 477
diff changeset
  2648
            selectionStartCol := selectionEndCol := clickStartCol := cursorCol.
fae6d1251888 fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 477
diff changeset
  2649
            expandingTop := false.
458
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2650
            ^ self redrawLine:selectionStartLine. 
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2651
        ].
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2652
313
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2653
        selectionStartLine notNil ifTrue:[
458
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2654
            "/
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2655
            "/ treat the whole selection as cursor
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2656
            "/
313
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2657
            cursorLine := selectionEndLine.
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2658
            cursorVisibleLine := self listLineToVisibleLine:cursorLine.
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2659
            cursorCol := selectionEndCol.
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2660
            cursorCol == 0 ifTrue:[
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2661
                cursorCol := 1.
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2662
            ].
458
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2663
            shifted ifTrue:[
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2664
                self expandSelectionRight.
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2665
                ^ self
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2666
            ].
313
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2667
            self unselect; makeCursorVisible.
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2668
            cursorCol == 1 ifTrue:[^ self].
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2669
        ].
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2670
        self cursorRight. ^self
121
claus
parents: 118
diff changeset
  2671
    ].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2672
    (key == #CursorDown) ifTrue:[
458
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2673
        (shifted and:[selectionStartLine isNil]) ifTrue:[
479
fae6d1251888 fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 477
diff changeset
  2674
            selectionStartLine := clickStartLine := cursorLine. selectionEndLine := cursorLine + 1.
fae6d1251888 fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 477
diff changeset
  2675
            selectionStartCol := clickStartCol := selectionEndCol := cursorCol.
458
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2676
            self redrawLine:selectionStartLine. 
479
fae6d1251888 fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 477
diff changeset
  2677
            expandingTop := false.
458
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2678
            ^ self redrawLine:selectionEndLine. 
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2679
        ].
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2680
313
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2681
        selectionStartLine notNil ifTrue:[
458
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2682
            "/
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2683
            "/ treat the whole selection as cursor
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2684
            "/
313
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2685
            cursorLine := selectionEndLine.
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2686
            cursorVisibleLine := self listLineToVisibleLine:cursorLine.
567
a71e9e59537e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 565
diff changeset
  2687
            cursorCol := selectionStartCol.
313
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2688
            cursorCol == 0 ifTrue:[
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2689
                cursorCol := 1.
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2690
                cursorLine := cursorLine - 1.
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2691
                cursorVisibleLine := self listLineToVisibleLine:cursorLine.
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2692
            ].
458
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2693
            self makeCursorVisible.
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2694
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2695
            shifted ifTrue:[
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2696
                self expandSelectionDown.
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2697
                ^ self
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2698
            ].
503
468d4a36ed67 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 501
diff changeset
  2699
            self unselect. 
313
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2700
        ].
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2701
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2702
        sensor isNil ifTrue:[
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2703
            n := 1
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2704
        ] ifFalse:[
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2705
            n := 1 + (sensor compressKeyPressEventsWithKey:#CursorDown).
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2706
        ].
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2707
        self cursorDown:n. 
1304
173d00c195f9 flush pending keyboard events in cursor-up/down
Claus Gittinger <cg@exept.de>
parents: 1300
diff changeset
  2708
        "/
173d00c195f9 flush pending keyboard events in cursor-up/down
Claus Gittinger <cg@exept.de>
parents: 1300
diff changeset
  2709
        "/ flush keyboard to avoid runaway cursor
173d00c195f9 flush pending keyboard events in cursor-up/down
Claus Gittinger <cg@exept.de>
parents: 1300
diff changeset
  2710
        "/
1308
61d944600e3f care for nil sensors
Claus Gittinger <cg@exept.de>
parents: 1304
diff changeset
  2711
        sensor notNil ifTrue:[self sensor flushKeyboardFor:self].
313
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2712
        ^ self
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2713
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2714
    (key == #CursorLeft or:[key == #CursorUp]) ifTrue:[
479
fae6d1251888 fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 477
diff changeset
  2715
        (shifted and:[selectionStartLine isNil]) ifTrue:[
fae6d1251888 fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 477
diff changeset
  2716
            expandingTop := true.
fae6d1251888 fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 477
diff changeset
  2717
            key == #CursorLeft ifTrue:[
fae6d1251888 fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 477
diff changeset
  2718
                cursorCol > 1 ifTrue:[
fae6d1251888 fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 477
diff changeset
  2719
                    selectionStartLine := selectionEndLine := clickStartLine := cursorLine.
567
a71e9e59537e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 565
diff changeset
  2720
                    selectionEndCol := clickStartCol := cursorCol-1.
a71e9e59537e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 565
diff changeset
  2721
                    selectionStartCol := cursorCol-1.
479
fae6d1251888 fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 477
diff changeset
  2722
                    ^ self redrawLine:selectionStartLine. 
fae6d1251888 fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 477
diff changeset
  2723
                ]
fae6d1251888 fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 477
diff changeset
  2724
            ] ifFalse:[
fae6d1251888 fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 477
diff changeset
  2725
                cursorLine > 1 ifTrue:[
fae6d1251888 fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 477
diff changeset
  2726
                    selectionEndLine := clickStartLine := cursorLine.
fae6d1251888 fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 477
diff changeset
  2727
                    selectionEndCol := selectionStartCol := clickStartCol := cursorCol.
fae6d1251888 fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 477
diff changeset
  2728
                    selectionStartLine := cursorLine - 1.
fae6d1251888 fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 477
diff changeset
  2729
                    ^ self redrawFromLine:selectionStartLine to:cursorLine. 
fae6d1251888 fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 477
diff changeset
  2730
                ]
fae6d1251888 fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 477
diff changeset
  2731
            ]
fae6d1251888 fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 477
diff changeset
  2732
        ].
fae6d1251888 fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 477
diff changeset
  2733
313
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2734
        selectionStartLine notNil ifTrue:[
458
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2735
            "/
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2736
            "/ treat the whole selection as cursor
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2737
            "/
313
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2738
            cursorLine := selectionStartLine.
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2739
            cursorVisibleLine := self listLineToVisibleLine:cursorLine.
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2740
            cursorCol := selectionStartCol.
567
a71e9e59537e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 565
diff changeset
  2741
            (key == #CursorLeft) ifTrue:[    
a71e9e59537e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 565
diff changeset
  2742
                cursorCol := cursorCol+1.  "/ compensate for followup crsr-left
a71e9e59537e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 565
diff changeset
  2743
            ].
458
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2744
            self makeCursorVisible.
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2745
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2746
            shifted ifTrue:[
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2747
                (key == #CursorUp) ifTrue:[
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2748
                    ^ self expandSelectionUp.
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2749
                ].
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2750
                ^ self expandSelectionLeft.
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2751
            ].
503
468d4a36ed67 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 501
diff changeset
  2752
            self unselect. 
313
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2753
        ].
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2754
        (key == #CursorLeft) ifTrue:[
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2755
            self cursorLeft. ^self
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2756
        ].
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2757
        (key == #CursorUp)        ifTrue:[
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2758
            sensor isNil ifTrue:[
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2759
                n := 1
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2760
            ] ifFalse:[
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2761
                n := 1 + (sensor compressKeyPressEventsWithKey:#CursorUp).
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2762
            ].
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2763
            self cursorUp:n. 
1304
173d00c195f9 flush pending keyboard events in cursor-up/down
Claus Gittinger <cg@exept.de>
parents: 1300
diff changeset
  2764
            "/
173d00c195f9 flush pending keyboard events in cursor-up/down
Claus Gittinger <cg@exept.de>
parents: 1300
diff changeset
  2765
            "/ flush keyboard to avoid runaway cursor
173d00c195f9 flush pending keyboard events in cursor-up/down
Claus Gittinger <cg@exept.de>
parents: 1300
diff changeset
  2766
            "/
1308
61d944600e3f care for nil sensors
Claus Gittinger <cg@exept.de>
parents: 1304
diff changeset
  2767
            sensor notNil ifTrue:[sensor flushKeyboardFor:self].
313
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2768
            ^ self
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2769
        ].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2770
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2771
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2772
    (key == #Return)    ifTrue:[
458
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2773
        shifted ifTrue:[
313
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2774
            self unselect. self cursorReturn. ^self
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2775
        ].
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2776
        readOnly ifTrue:[
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2777
            self unselect; makeCursorVisible.
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2778
            self cursorReturn
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2779
        ] ifFalse:[
477
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  2780
            insertMode ifFalse:[
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  2781
                self cursorReturn.
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  2782
                autoIndent == true ifTrue:[
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2783
                    i := self leftIndentForLine:(cursorLine + 1).
477
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  2784
                    self cursorCol:(i+1 max:1)
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  2785
                ]
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  2786
            ] ifTrue:[
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  2787
                "/ old version just unselected ...
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  2788
                "/ self unselect; makeCursorVisible.
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  2789
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  2790
                "/ new version deletes ...
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  2791
                typeOfSelection == #paste ifTrue:[
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  2792
                    self unselect; makeCursorVisible.
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  2793
                ] ifFalse:[
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  2794
                    self copyAndDeleteSelection.            
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  2795
                ].
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  2796
                self insertCharAtCursor:(Character cr). 
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  2797
                autoIndent == true ifTrue:[
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  2798
                    i := self leftIndentForLine:cursorLine.
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  2799
                    self indentFromLine:cursorLine toLine:cursorLine.
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  2800
                    self cursorCol:(i+1 max:1)
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  2801
                ].
474
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  2802
            ].
313
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2803
        ].
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2804
        ^self
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2805
    ].
309
b5c9d68e95e1 new tabbing scheme (asking via #canTab); new focus change (passing explicit to showFocus/noFocus);
Claus Gittinger <cg@exept.de>
parents: 297
diff changeset
  2806
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2807
    (key == #Tab) ifTrue:[
324
9eec6d69e155 better Tab key handling
Claus Gittinger <cg@exept.de>
parents: 323
diff changeset
  2808
        self tabMeansNextField ifTrue:[^ super keyPress:key x:x y:y].
9eec6d69e155 better Tab key handling
Claus Gittinger <cg@exept.de>
parents: 323
diff changeset
  2809
458
14e994e20eb5 selection via shift-cursor
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2810
        shifted ifTrue:[
313
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2811
            "
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2812
             the old version used shift-tab as backtab,
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2813
             however, backtab was seldom used.
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2814
             An alternative is to make it a non-inserting tab ...
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2815
            "
324
9eec6d69e155 better Tab key handling
Claus Gittinger <cg@exept.de>
parents: 323
diff changeset
  2816
            "/ self unselect. self cursorBacktab.
9eec6d69e155 better Tab key handling
Claus Gittinger <cg@exept.de>
parents: 323
diff changeset
  2817
            self unselect. self cursorTab. 
9eec6d69e155 better Tab key handling
Claus Gittinger <cg@exept.de>
parents: 323
diff changeset
  2818
            ^self
313
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2819
        ].
324
9eec6d69e155 better Tab key handling
Claus Gittinger <cg@exept.de>
parents: 323
diff changeset
  2820
313
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2821
        "
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2822
         uncomment line below, if you like RAND/INed/MAXed editor behavior
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2823
         (where tab-key is only cursor positioning)
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2824
         this was the original behavior of the TAB key, but many people
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2825
         complained ....
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2826
        "
654
d621e63baaa5 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 641
diff changeset
  2827
        insertMode ifFalse:[
d621e63baaa5 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 641
diff changeset
  2828
            self unselect. self cursorTab. ^self
d621e63baaa5 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 641
diff changeset
  2829
        ].
324
9eec6d69e155 better Tab key handling
Claus Gittinger <cg@exept.de>
parents: 323
diff changeset
  2830
        self unselect. self insertTabAtCursor. 
9eec6d69e155 better Tab key handling
Claus Gittinger <cg@exept.de>
parents: 323
diff changeset
  2831
        ^self
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2832
    ].
309
b5c9d68e95e1 new tabbing scheme (asking via #canTab); new focus change (passing explicit to showFocus/noFocus);
Claus Gittinger <cg@exept.de>
parents: 297
diff changeset
  2833
870
c606f29db5d7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 865
diff changeset
  2834
    (key == #BackSpace
c606f29db5d7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 865
diff changeset
  2835
     or:[key == #BasicBackspace]) ifTrue:[
313
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2836
        selectionStartLine notNil ifTrue:[
870
c606f29db5d7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 865
diff changeset
  2837
            (key == #BasicBackspace) ifTrue:[
c606f29db5d7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 865
diff changeset
  2838
                ^ self deleteSelection.
c606f29db5d7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 865
diff changeset
  2839
            ] ifFalse:[
c606f29db5d7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 865
diff changeset
  2840
                ^ self copyAndDeleteSelection.
c606f29db5d7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 865
diff changeset
  2841
            ].
313
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2842
        ].
870
c606f29db5d7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 865
diff changeset
  2843
313
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2844
        self makeCursorVisible.
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2845
        self deleteCharBeforeCursor. ^self
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2846
    ].
309
b5c9d68e95e1 new tabbing scheme (asking via #canTab); new focus change (passing explicit to showFocus/noFocus);
Claus Gittinger <cg@exept.de>
parents: 297
diff changeset
  2847
870
c606f29db5d7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 865
diff changeset
  2848
    (key == #Delete
c606f29db5d7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 865
diff changeset
  2849
     or:[key == #BasicDelete]) ifTrue:[
313
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2850
        selectionStartLine notNil ifTrue:[
870
c606f29db5d7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 865
diff changeset
  2851
            (key == #BasicDelete) ifTrue:[
c606f29db5d7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 865
diff changeset
  2852
                ^ self deleteSelection.
c606f29db5d7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 865
diff changeset
  2853
            ] ifFalse:[
c606f29db5d7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 865
diff changeset
  2854
                ^ self copyAndDeleteSelection.
c606f29db5d7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 865
diff changeset
  2855
            ].
313
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2856
        ].
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2857
        self makeCursorVisible.
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2858
        self deleteCharAtCursor. ^self
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2859
    ].
309
b5c9d68e95e1 new tabbing scheme (asking via #canTab); new focus change (passing explicit to showFocus/noFocus);
Claus Gittinger <cg@exept.de>
parents: 297
diff changeset
  2860
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2861
    (key == #BeginOfText) ifTrue:[     "i.e. HOME"
313
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2862
        self unselect. 
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2863
        cursorVisibleLine == 1 ifTrue:[
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2864
            self cursorHome.
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2865
        ] ifFalse:[
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2866
            self cursorToFirstVisibleLine
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2867
        ].
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2868
        ^ self
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2869
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2870
    (key == #EndOfText) ifTrue:[       "i.e. END"
313
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2871
        self unselect.
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2872
        cursorVisibleLine == nFullLinesShown ifTrue:[
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2873
            self cursorToBottom.
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2874
        ] ifFalse:[
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2875
            self cursorToLastVisibleLine
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2876
        ].
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2877
        ^self
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2878
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2879
    ((key == #Escape)
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2880
    or:[key == #SelectLineFromBeginning])    ifTrue:[
313
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2881
        self makeCursorVisible.
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2882
        self unselect. self selectCursorLineFromBeginning. ^ self
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2883
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2884
    (key == #SelectLine)    ifTrue:[
313
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2885
        self makeCursorVisible.
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2886
        self unselect. self selectCursorLine. ^ self
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2887
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2888
    (key == #ExpandSelectionByLine)    ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2889
"/        self makeCursorVisible.
313
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2890
        self selectExpandCursorLine. ^ self
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2891
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2892
    (key == #DeleteLine)    ifTrue:[
313
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2893
        self makeCursorVisible.
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2894
        self unselect. self deleteCursorLine. ^self
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2895
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2896
    (key == #InsertLine)    ifTrue:[
313
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2897
        self makeCursorVisible.
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2898
        self unselect. self insertLine:nil before:cursorLine. ^self
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2899
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2900
    super keyPress:key x:x y:y
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2901
1308
61d944600e3f care for nil sensors
Claus Gittinger <cg@exept.de>
parents: 1304
diff changeset
  2902
    "Modified: 19.8.1997 / 17:02:21 / cg"
121
claus
parents: 118
diff changeset
  2903
!
claus
parents: 118
diff changeset
  2904
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2905
mapped
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2906
    "view was made visible"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2907
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2908
    super mapped.
915
5147640d0cf7 do not make cursor visible when mapped, but instead
Claus Gittinger <cg@exept.de>
parents: 905
diff changeset
  2909
"/    self makeCursorVisible.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2910
    cursorVisibleLine := self listLineToVisibleLine:cursorLine.
915
5147640d0cf7 do not make cursor visible when mapped, but instead
Claus Gittinger <cg@exept.de>
parents: 905
diff changeset
  2911
5147640d0cf7 do not make cursor visible when mapped, but instead
Claus Gittinger <cg@exept.de>
parents: 905
diff changeset
  2912
    "Modified: 20.12.1996 / 14:15:56 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2913
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2914
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2915
pointerEnter:state x:x y:y
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2916
    (windowGroup isNil or:[windowGroup focusView isNil]) ifTrue:[
893
33d35adb2702 share code of #hasKeyboardFocus:.
Claus Gittinger <cg@exept.de>
parents: 879
diff changeset
  2917
        self hasKeyboardFocus:true
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2918
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2919
    super pointerEnter:state x:x y:y
893
33d35adb2702 share code of #hasKeyboardFocus:.
Claus Gittinger <cg@exept.de>
parents: 879
diff changeset
  2920
33d35adb2702 share code of #hasKeyboardFocus:.
Claus Gittinger <cg@exept.de>
parents: 879
diff changeset
  2921
    "Modified: 11.12.1996 / 16:56:30 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2922
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2923
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2924
pointerLeave:state
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2925
    (windowGroup isNil or:[windowGroup focusView isNil]) ifTrue:[
893
33d35adb2702 share code of #hasKeyboardFocus:.
Claus Gittinger <cg@exept.de>
parents: 879
diff changeset
  2926
        self hasKeyboardFocus:false
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2927
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2928
    super pointerLeave:state
893
33d35adb2702 share code of #hasKeyboardFocus:.
Claus Gittinger <cg@exept.de>
parents: 879
diff changeset
  2929
33d35adb2702 share code of #hasKeyboardFocus:.
Claus Gittinger <cg@exept.de>
parents: 879
diff changeset
  2930
    "Modified: 11.12.1996 / 16:56:43 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2931
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2932
309
b5c9d68e95e1 new tabbing scheme (asking via #canTab); new focus change (passing explicit to showFocus/noFocus);
Claus Gittinger <cg@exept.de>
parents: 297
diff changeset
  2933
showFocus:explicit
893
33d35adb2702 share code of #hasKeyboardFocus:.
Claus Gittinger <cg@exept.de>
parents: 879
diff changeset
  2934
    self hasKeyboardFocus:true.
309
b5c9d68e95e1 new tabbing scheme (asking via #canTab); new focus change (passing explicit to showFocus/noFocus);
Claus Gittinger <cg@exept.de>
parents: 297
diff changeset
  2935
    super showFocus:explicit
893
33d35adb2702 share code of #hasKeyboardFocus:.
Claus Gittinger <cg@exept.de>
parents: 879
diff changeset
  2936
33d35adb2702 share code of #hasKeyboardFocus:.
Claus Gittinger <cg@exept.de>
parents: 879
diff changeset
  2937
    "Modified: 11.12.1996 / 16:56:54 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2938
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2939
309
b5c9d68e95e1 new tabbing scheme (asking via #canTab); new focus change (passing explicit to showFocus/noFocus);
Claus Gittinger <cg@exept.de>
parents: 297
diff changeset
  2940
showNoFocus:explicit
893
33d35adb2702 share code of #hasKeyboardFocus:.
Claus Gittinger <cg@exept.de>
parents: 879
diff changeset
  2941
    self hasKeyboardFocus:false.
309
b5c9d68e95e1 new tabbing scheme (asking via #canTab); new focus change (passing explicit to showFocus/noFocus);
Claus Gittinger <cg@exept.de>
parents: 297
diff changeset
  2942
    super showNoFocus:explicit
893
33d35adb2702 share code of #hasKeyboardFocus:.
Claus Gittinger <cg@exept.de>
parents: 879
diff changeset
  2943
33d35adb2702 share code of #hasKeyboardFocus:.
Claus Gittinger <cg@exept.de>
parents: 879
diff changeset
  2944
    "Modified: 11.12.1996 / 16:57:03 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2945
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2946
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2947
sizeChanged:how
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2948
    "make certain, cursor is visible after the sizechange"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2949
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2950
    |cv|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2951
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2952
    cv := cursorVisibleLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2953
    super sizeChanged:how.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2954
    cv notNil ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2955
	self makeLineVisible:cursorLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2956
    ]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2957
! !
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2958
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2959
!EditTextView methodsFor:'formatting'!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2960
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2961
indent
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2962
    "indent selected line-range"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2963
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2964
    |start end|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2965
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2966
    selectionStartLine isNil ifTrue:[^ self].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2967
    start := selectionStartLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2968
    end := selectionEndLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2969
    (selectionEndCol == 0) ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2970
	end := end - 1
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2971
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2972
    self unselect.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2973
    self indentFromLine:start toLine:end
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2974
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2975
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2976
indentFromLine:start toLine:end
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2977
    "indent a line-range - this is don by searching for the 
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2978
     last non-empty line before start, and change the indent
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2979
     of the line based on that indent."
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2980
474
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  2981
    |leftStart delta d line spaces|
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  2982
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  2983
    leftStart := self leftIndentForLine:start.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2984
    (leftStart == 0) ifTrue:[^ self].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2985
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2986
    delta := leftStart - (self leftIndentOfLine:start).
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2987
    (delta == 0) ifTrue:[^ self].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2988
    (delta > 0) ifTrue:[
474
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  2989
        spaces := String new:delta
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2990
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2991
    start to:end do:[:lineNr |
474
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  2992
        line := self listAt:lineNr.
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  2993
        line notNil ifTrue:[
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  2994
            line isBlank ifTrue:[
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  2995
                list at:lineNr put:nil
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  2996
            ] ifFalse:[
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  2997
                (delta > 0) ifTrue:[
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  2998
                    line := spaces , line.
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  2999
                    widthOfWidestLine notNil ifTrue:[
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  3000
                        widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:line).
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  3001
                    ]
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  3002
                ] ifFalse:[
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  3003
                    "check if deletion is ok"
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  3004
                    d := delta negated + 1.
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  3005
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  3006
                    line size > d ifTrue:[
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  3007
                        (line copyTo:(d - 1)) withoutSeparators isEmpty ifTrue:[
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  3008
                            line := line copyFrom:d
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  3009
                        ]
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  3010
                    ].
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  3011
                    widthOfWidestLine := nil
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  3012
                ].
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  3013
                list at:lineNr put:line.
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  3014
                self textChanged.
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  3015
            ]
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  3016
        ]
121
claus
parents: 118
diff changeset
  3017
    ].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3018
    self redrawFromLine:start to:end
474
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  3019
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  3020
    "Modified: 5.3.1996 / 14:59:18 / cg"
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  3021
!
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  3022
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  3023
leftIndentForLine:lineNr
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  3024
    "find an appropriate indent for a line.
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  3025
     this is done by searching for the last non-empty line before it
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  3026
     and returning its indent."
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  3027
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3028
    "SHOULD GO TO ListView"
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3029
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3030
    |line lnr indent|
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3031
474
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  3032
    lnr := lineNr.
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3033
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3034
    [lnr ~~ 1] whileTrue:[
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3035
        lnr  := lnr - 1.
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3036
        line := self listAt:lnr.
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3037
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3038
        line notNil ifTrue:[
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3039
            indent := line indexOfNonSeparatorStartingAt:1.
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3040
            indent ~~ 0 ifTrue:[
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3041
                ^ indent - 1
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3042
            ]
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3043
        ]
474
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  3044
    ].
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3045
    ^ 0
474
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  3046
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  3047
    "Created: 5.3.1996 / 14:58:53 / cg"
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  3048
! !
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  3049
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  3050
!EditTextView methodsFor:'initialization'!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  3051
941
f06fa4d47f26 fetch device resources early
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  3052
fetchDeviceResources
f06fa4d47f26 fetch device resources early
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  3053
    "fetch device colors, to avoid reallocation at redraw time"
f06fa4d47f26 fetch device resources early
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  3054
f06fa4d47f26 fetch device resources early
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  3055
    super fetchDeviceResources.
f06fa4d47f26 fetch device resources early
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  3056
f06fa4d47f26 fetch device resources early
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  3057
    cursorFgColor notNil ifTrue:[cursorFgColor := cursorFgColor on:device].
f06fa4d47f26 fetch device resources early
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  3058
    cursorBgColor notNil ifTrue:[cursorBgColor := cursorBgColor on:device].
1022
4362861fe15e allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents: 1018
diff changeset
  3059
    cursorNoFocusFgColor notNil ifTrue:[cursorNoFocusFgColor := cursorNoFocusFgColor on:device].
941
f06fa4d47f26 fetch device resources early
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  3060
f06fa4d47f26 fetch device resources early
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  3061
    "Created: 14.1.1997 / 00:15:24 / cg"
1022
4362861fe15e allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents: 1018
diff changeset
  3062
    "Modified: 18.2.1997 / 15:02:46 / cg"
941
f06fa4d47f26 fetch device resources early
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  3063
!
f06fa4d47f26 fetch device resources early
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  3064
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3065
initEvents
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3066
    "enable enter/leave events in addition"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3067
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3068
    super initEvents.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3069
    self enableEnterLeaveEvents
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3070
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3071
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3072
initStyle
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3073
    "initialize style specific stuff"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3074
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3075
    super initStyle.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3076
    lockUpdates := false.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3077
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3078
    cursorFgColor := DefaultCursorForegroundColor.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3079
    cursorFgColor isNil ifTrue:[cursorFgColor := bgColor].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3080
    cursorBgColor := DefaultCursorBackgroundColor.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3081
    cursorBgColor isNil ifTrue:[cursorBgColor := fgColor].
1334
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  3082
    cursorType := cursorTypeNoFocus := DefaultCursorType.
1022
4362861fe15e allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents: 1018
diff changeset
  3083
4362861fe15e allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents: 1018
diff changeset
  3084
    cursorNoFocusFgColor := DefaultCursorNoFocusForegroundColor.
4362861fe15e allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents: 1018
diff changeset
  3085
    cursorNoFocusFgColor isNil ifTrue:[
4362861fe15e allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents: 1018
diff changeset
  3086
        cursorType ~~ #block ifTrue:[
4362861fe15e allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents: 1018
diff changeset
  3087
            cursorNoFocusFgColor := cursorBgColor
4362861fe15e allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents: 1018
diff changeset
  3088
        ] ifFalse:[
4362861fe15e allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents: 1018
diff changeset
  3089
            cursorNoFocusFgColor := cursorFgColor
4362861fe15e allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents: 1018
diff changeset
  3090
        ]
4362861fe15e allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents: 1018
diff changeset
  3091
    ].
4362861fe15e allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents: 1018
diff changeset
  3092
4362861fe15e allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents: 1018
diff changeset
  3093
    "Modified: 18.2.1997 / 15:15:32 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3094
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3095
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3096
initialize
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3097
    "initialize a new EditTextView;
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3098
     setup some instance variables"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3099
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3100
    super initialize.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3101
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3102
    self level:-1.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3103
    readOnly := false.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3104
    fixedSize := false.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3105
    exceptionBlock := [:errorText | ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3106
    cursorShown := prevCursorState := true.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3107
    cursorLine := 1.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3108
    cursorVisibleLine := 1.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3109
    cursorCol := 1.
947
007a374d834c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 941
diff changeset
  3110
    modifiedChannel := ValueHolder newBoolean.
1013
391290c747b3 added an acceptChannel
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
  3111
    acceptChannel := ValueHolder newBoolean.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3112
    showMatchingParenthesis := false.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3113
    hasKeyboardFocus := false. "/ true.
323
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
  3114
    tabMeansNextField := false.
474
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  3115
    autoIndent := false.
477
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  3116
    insertMode := true.
671
f3fe0d8c604d added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents: 666
diff changeset
  3117
    trimBlankLines := true.
f3fe0d8c604d added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents: 666
diff changeset
  3118
1013
391290c747b3 added an acceptChannel
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
  3119
    "Modified: 14.2.1997 / 16:52:05 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3120
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3121
1275
849085b6b7f2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
  3122
realize
849085b6b7f2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
  3123
    "make the view visible - scroll to make the cursor visible."
849085b6b7f2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
  3124
849085b6b7f2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
  3125
    super realize.
849085b6b7f2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
  3126
915
5147640d0cf7 do not make cursor visible when mapped, but instead
Claus Gittinger <cg@exept.de>
parents: 905
diff changeset
  3127
    self makeCursorVisible.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3128
    cursorFgColor := cursorFgColor on:device.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3129
    cursorBgColor := cursorBgColor on:device.
915
5147640d0cf7 do not make cursor visible when mapped, but instead
Claus Gittinger <cg@exept.de>
parents: 905
diff changeset
  3130
5147640d0cf7 do not make cursor visible when mapped, but instead
Claus Gittinger <cg@exept.de>
parents: 905
diff changeset
  3131
    "Modified: 20.12.1996 / 14:16:05 / cg"
1275
849085b6b7f2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1269
diff changeset
  3132
    "Created: 24.7.1997 / 18:24:12 / cg"
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  3133
! !
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  3134
121
claus
parents: 118
diff changeset
  3135
!EditTextView methodsFor:'menu actions'!
claus
parents: 118
diff changeset
  3136
claus
parents: 118
diff changeset
  3137
cut
claus
parents: 118
diff changeset
  3138
    "cut selection into copybuffer"
claus
parents: 118
diff changeset
  3139
claus
parents: 118
diff changeset
  3140
    |line col history sel|
claus
parents: 118
diff changeset
  3141
claus
parents: 118
diff changeset
  3142
    sel := self selection.
claus
parents: 118
diff changeset
  3143
    sel notNil ifTrue:[
1290
d87b6c35c3ae checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1289
diff changeset
  3144
        lastString := sel asStringWithCRs.
d87b6c35c3ae checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1289
diff changeset
  3145
        line := selectionStartLine.
d87b6c35c3ae checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1289
diff changeset
  3146
        col := selectionStartCol.
d87b6c35c3ae checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1289
diff changeset
  3147
        undoAction := [self insertString:lastString atLine:line col:col].
d87b6c35c3ae checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1289
diff changeset
  3148
d87b6c35c3ae checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1289
diff changeset
  3149
        "
d87b6c35c3ae checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1289
diff changeset
  3150
         remember in CopyBuffer
d87b6c35c3ae checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1289
diff changeset
  3151
        "
d87b6c35c3ae checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1289
diff changeset
  3152
        self setTextSelection:lastString.
d87b6c35c3ae checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1289
diff changeset
  3153
d87b6c35c3ae checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1289
diff changeset
  3154
        "
d87b6c35c3ae checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1289
diff changeset
  3155
         append to DeleteHistory (if there is one)
d87b6c35c3ae checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1289
diff changeset
  3156
        "
d87b6c35c3ae checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1289
diff changeset
  3157
        history := Smalltalk at:#DeleteHistory.
d87b6c35c3ae checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1289
diff changeset
  3158
        history notNil ifTrue:[
d87b6c35c3ae checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1289
diff changeset
  3159
            history addAll:(lastString asStringCollection).
d87b6c35c3ae checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1289
diff changeset
  3160
            history size > 1000 ifTrue:[
d87b6c35c3ae checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1289
diff changeset
  3161
                history := history copyFrom:(history size - 1000)
d87b6c35c3ae checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1289
diff changeset
  3162
            ].
d87b6c35c3ae checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1289
diff changeset
  3163
        ].
d87b6c35c3ae checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1289
diff changeset
  3164
d87b6c35c3ae checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1289
diff changeset
  3165
        "
d87b6c35c3ae checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1289
diff changeset
  3166
         now, delete it
d87b6c35c3ae checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1289
diff changeset
  3167
        "
d87b6c35c3ae checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1289
diff changeset
  3168
        self deleteSelection.
d87b6c35c3ae checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1289
diff changeset
  3169
        lastReplacement := nil
121
claus
parents: 118
diff changeset
  3170
    ] ifFalse:[
1290
d87b6c35c3ae checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1289
diff changeset
  3171
        "
d87b6c35c3ae checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1289
diff changeset
  3172
         a cut without selection will search&cut again
d87b6c35c3ae checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1289
diff changeset
  3173
        "
d87b6c35c3ae checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1289
diff changeset
  3174
        self again
121
claus
parents: 118
diff changeset
  3175
    ]
1290
d87b6c35c3ae checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1289
diff changeset
  3176
d87b6c35c3ae checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1289
diff changeset
  3177
    "Modified: 31.7.1997 / 19:30:23 / cg"
121
claus
parents: 118
diff changeset
  3178
!
claus
parents: 118
diff changeset
  3179
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3180
defaultForGotoLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3181
    "return a default value to show in the gotoLine box"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3182
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3183
    cursorLine notNil ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3184
	^ cursorLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3185
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3186
    ^ super defaultForGotoLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3187
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3188
428
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  3189
editMenu
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  3190
    "return the views middleButtonMenu"
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  3191
488
d10fe3a5f0cf resources
Claus Gittinger <cg@exept.de>
parents: 479
diff changeset
  3192
    <resource: #keyboard (#Again #Copy #Cut #Paste #Accept #Find #GotoLine #SaveAs #Print)>
1261
bdb18f73205c resource flag: #menu -> #programMenu
Claus Gittinger <cg@exept.de>
parents: 1198
diff changeset
  3193
    <resource: #programMenu>
1054
d699ecd13e60 menu resource
Claus Gittinger <cg@exept.de>
parents: 1049
diff changeset
  3194
488
d10fe3a5f0cf resources
Claus Gittinger <cg@exept.de>
parents: 479
diff changeset
  3195
428
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  3196
    |labels selectors m sub shortKeys|
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  3197
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  3198
    self sensor ctrlDown ifTrue:[
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  3199
        labels := #(
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  3200
                        'again (for all)'
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  3201
                   ).
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  3202
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  3203
        selectors := #(
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  3204
                        multipleAgain
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  3205
                       ).
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  3206
    ] ifFalse:[
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  3207
        labels := #(
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  3208
"/                      'undo'
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  3209
                        'again'
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  3210
                        '-'
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  3211
                        'copy'
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  3212
                        'cut'
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  3213
                        'paste'
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  3214
                        '-'
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  3215
                        'accept'
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  3216
                        '='
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  3217
                        'others'
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  3218
                   ).
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  3219
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  3220
        selectors := #(
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  3221
"/                      undo
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  3222
                        again
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  3223
                        nil
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  3224
                        copySelection
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  3225
                        cut
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  3226
                        pasteOrReplace
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  3227
                        nil
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  3228
                        accept
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  3229
                        nil
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  3230
                        others
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  3231
                       ).
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  3232
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  3233
        shortKeys := #(
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  3234
"/                        nil
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  3235
                        #Again 
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  3236
                        nil
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  3237
                        #Copy
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  3238
                        #Cut
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  3239
                        #Paste
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  3240
                        nil
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  3241
                        #Accept 
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  3242
                        nil
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  3243
                        nil
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  3244
                      ).
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  3245
    ].
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  3246
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  3247
    m := PopUpMenu
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  3248
            labels:(resources array:labels)
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  3249
            selectors:selectors
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  3250
            accelerators:shortKeys.
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  3251
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  3252
    labels := #(
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  3253
                    'search ...'
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  3254
                    'goto ...'
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  3255
                    '-'
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  3256
                    'font ...'
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  3257
                    '-'
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  3258
                    'indent'
666
9ac9adb80415 clip at margin when drawing a caret cursor
Claus Gittinger <cg@exept.de>
parents: 662
diff changeset
  3259
                    '\c autoIndent'
9ac9adb80415 clip at margin when drawing a caret cursor
Claus Gittinger <cg@exept.de>
parents: 662
diff changeset
  3260
                    '\c insertMode'
428
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  3261
                    '-'
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  3262
                    'save as ...'
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  3263
                    'print'
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  3264
                ).
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  3265
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  3266
   selectors := #(
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  3267
                     search
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  3268
                     gotoLine
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  3269
                     nil
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  3270
                     changeFont
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  3271
                     nil
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  3272
                     indent
474
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  3273
                     autoIndent:
477
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  3274
                     insertMode:
428
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  3275
                     nil
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  3276
                     save
730
66a70c4860ea oops - doPrint was wrong
Claus Gittinger <cg@exept.de>
parents: 729
diff changeset
  3277
                     doPrint
428
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  3278
                    ).
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  3279
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  3280
    shortKeys := #(
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  3281
                      #Find
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  3282
                      #GotoLine
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  3283
                      nil
477
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  3284
                      nil         "/ changeFont
428
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  3285
                      nil
477
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  3286
                      nil         "/ indent
428
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  3287
                      nil
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  3288
                      nil
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  3289
                      nil
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  3290
                      #SaveAs
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  3291
                      #Print).
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  3292
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  3293
    sub := PopUpMenu
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  3294
                labels:(resources array:labels)
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  3295
                selectors:selectors
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  3296
                accelerators:shortKeys
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  3297
                receiver:model.
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  3298
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  3299
    m subMenuAt:#others put:sub.
474
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  3300
    sub checkToggleAt:#autoIndent: put:autoIndent.
477
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  3301
    sub checkToggleAt:#insertMode: put:insertMode.
428
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  3302
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  3303
    readOnly ifTrue:[
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  3304
        m disable:#paste
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  3305
    ].
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  3306
    self hasSelection not ifTrue:[
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  3307
        m disable:#copySelection.
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  3308
    ].
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  3309
    (self hasSelection not or:[readOnly]) ifTrue:[
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  3310
        m disable:#cut.
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  3311
        sub disable:#indent.
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  3312
    ].
1108
3d14bb6bceb7 added disableAccept
Claus Gittinger <cg@exept.de>
parents: 1082
diff changeset
  3313
    acceptEnabled == false ifTrue:[
3d14bb6bceb7 added disableAccept
Claus Gittinger <cg@exept.de>
parents: 1082
diff changeset
  3314
        m disable:#accept
3d14bb6bceb7 added disableAccept
Claus Gittinger <cg@exept.de>
parents: 1082
diff changeset
  3315
    ].
428
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  3316
    ^ m.
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  3317
1261
bdb18f73205c resource flag: #menu -> #programMenu
Claus Gittinger <cg@exept.de>
parents: 1198
diff changeset
  3318
    "Modified: 3.7.1997 / 13:54:32 / cg"
428
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  3319
!
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  3320
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3321
paste
1289
e2dcc5fe612c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1287
diff changeset
  3322
    "paste the copybuffer; if there is a selection, unselect first.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3323
     Then paste at cursor position."
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3324
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3325
    |sel|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3326
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3327
    sel := self getTextSelection.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3328
    self unselect.  
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3329
    sel notNil ifTrue:[
1289
e2dcc5fe612c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1287
diff changeset
  3330
        self paste:sel.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3331
    ]
1289
e2dcc5fe612c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1287
diff changeset
  3332
e2dcc5fe612c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1287
diff changeset
  3333
    "Modified: 31.7.1997 / 19:23:25 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3334
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3335
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3336
paste:someText
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3337
    "paste someText at cursor"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3338
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3339
    |s startLine startCol|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3340
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3341
    someText notNil ifTrue:[
362
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  3342
        s := someText.
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  3343
        s isString ifTrue:[
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  3344
            s := s asStringCollection
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  3345
        ] ifFalse:[
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  3346
            (s isKindOf:StringCollection) ifFalse:[
865
d42c7c99e67d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 840
diff changeset
  3347
                self warn:'selection (' , s class name , ') is not convertable to Text'.
362
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  3348
                ^ self
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  3349
            ]
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  3350
        ].
777
f6c040559b2c care for empty paste
Claus Gittinger <cg@exept.de>
parents: 757
diff changeset
  3351
        s size == 0 ifTrue:[^ self].
f6c040559b2c care for empty paste
Claus Gittinger <cg@exept.de>
parents: 757
diff changeset
  3352
        (s size == 1 and:[(s at:1) size == 0]) ifTrue:[^ self].
f6c040559b2c care for empty paste
Claus Gittinger <cg@exept.de>
parents: 757
diff changeset
  3353
362
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  3354
        startLine := cursorLine.
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  3355
        startCol := cursorCol.
654
d621e63baaa5 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 641
diff changeset
  3356
        self insertLines:(s withTabsExpanded) withCR:false.
362
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  3357
        self selectFromLine:startLine col:startCol
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  3358
                     toLine:cursorLine col:(cursorCol - 1).
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  3359
        typeOfSelection := #paste.
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  3360
        undoAction := [self cut].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3361
    ]
362
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  3362
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  3363
    "Modified: 14.2.1996 / 11:14:14 / stefan"
865
d42c7c99e67d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 840
diff changeset
  3364
    "Modified: 6.11.1996 / 13:27:48 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3365
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3366
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3367
pasteOrReplace
1289
e2dcc5fe612c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1287
diff changeset
  3368
    "paste the copybuffer; if there is a selection, replace it.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3369
     otherwise paste at cursor position. Replace is not done
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3370
     for originating by a paste, to allow multiple
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3371
     paste."
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3372
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3373
    |sel|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3374
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3375
    sel := self getTextSelection.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3376
    self pasteOrReplace:sel.
1289
e2dcc5fe612c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1287
diff changeset
  3377
e2dcc5fe612c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1287
diff changeset
  3378
    "Modified: 31.7.1997 / 19:23:12 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3379
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3380
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3381
pasteOrReplace:someText
1289
e2dcc5fe612c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1287
diff changeset
  3382
    "paste someText; if there is a selection, replace it.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3383
     otherwise paste at cursor position. Replace is not done
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3384
     for originating by a paste, to allow multiple
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3385
     paste."
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3386
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3387
    ((self hasSelection == true) and:[typeOfSelection ~~ #paste]) ifTrue:[
1289
e2dcc5fe612c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1287
diff changeset
  3388
        ^ self replace:someText
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3389
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3390
    self paste:someText.
1289
e2dcc5fe612c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1287
diff changeset
  3391
e2dcc5fe612c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1287
diff changeset
  3392
    "Modified: 31.7.1997 / 19:23:18 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3393
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3394
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3395
replace
1289
e2dcc5fe612c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1287
diff changeset
  3396
    "replace the selection by the contents of the copybuffer"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3397
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3398
    |sel|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3399
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3400
    sel := self getTextSelection.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3401
    sel notNil ifTrue:[
1289
e2dcc5fe612c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1287
diff changeset
  3402
        self replace:sel
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3403
    ]
1289
e2dcc5fe612c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1287
diff changeset
  3404
e2dcc5fe612c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1287
diff changeset
  3405
    "Modified: 31.7.1997 / 19:22:41 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3406
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3407
121
claus
parents: 118
diff changeset
  3408
replace:someText
1289
e2dcc5fe612c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1287
diff changeset
  3409
    "replace the selection by someText"
121
claus
parents: 118
diff changeset
  3410
362
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  3411
    |selected selectedString| 
121
claus
parents: 118
diff changeset
  3412
claus
parents: 118
diff changeset
  3413
    selected := self selection.
claus
parents: 118
diff changeset
  3414
    selected isNil ifTrue:[
362
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  3415
        ^ self paste:someText
121
claus
parents: 118
diff changeset
  3416
    ].
claus
parents: 118
diff changeset
  3417
    self deleteSelection.
claus
parents: 118
diff changeset
  3418
claus
parents: 118
diff changeset
  3419
    "take care, if we replace a selection without space by a word selected
claus
parents: 118
diff changeset
  3420
     with one - in this case we usually do not want the space.
claus
parents: 118
diff changeset
  3421
     But, if we replace a word-selected selection by something without a
claus
parents: 118
diff changeset
  3422
     space, we DO want the space added."
claus
parents: 118
diff changeset
  3423
claus
parents: 118
diff changeset
  3424
    selected size == 1 ifTrue:[
362
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  3425
        selectedString := selected at:1.
7
15a9291b9bd0 *** empty log message ***
claus
parents: 5
diff changeset
  3426
    ].
15a9291b9bd0 *** empty log message ***
claus
parents: 5
diff changeset
  3427
362
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  3428
    someText size == 1 ifTrue:[
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  3429
        |cutOffSpace addSpace replacement replacementString|
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  3430
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  3431
        cutOffSpace := false.
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  3432
        addSpace := false.
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  3433
        replacement := someText copy.
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  3434
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  3435
        selectedString notNil ifTrue:[
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  3436
            ((selectedString startsWith:' ') or:[selectedString endsWith:' ']) ifFalse:[
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  3437
               "selection has no space"
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  3438
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  3439
                ((selectStyle == #wordleft) or:[selectStyle == #wordRight]) ifTrue:[
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  3440
                    cutOffSpace := true
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  3441
                ]
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  3442
            ] ifTrue:[
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  3443
                addSpace := true
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  3444
            ]
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  3445
        ].
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  3446
        replacementString := replacement at:1.
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  3447
        cutOffSpace ifTrue:[
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  3448
            (replacementString startsWith:' ') ifTrue:[
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  3449
                replacementString := replacementString withoutSpaces
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  3450
            ].
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  3451
        ] ifFalse:[
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  3452
            selectStyle == #wordLeft ifTrue:[
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  3453
                "want a space at left"
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  3454
                (replacementString startsWith:' ') ifFalse:[
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  3455
                    replacementString := replacementString withoutSpaces.
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  3456
                    replacementString := ' ' , replacementString
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  3457
                ]
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  3458
            ].
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  3459
            selectStyle == #wordRight ifTrue:[
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  3460
                "want a space at right"
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  3461
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  3462
                (replacementString endsWith:' ') ifFalse:[
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  3463
                    replacementString := replacementString withoutSpaces.
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  3464
                    replacementString := replacementString , ' '
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  3465
                ]
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  3466
            ].
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  3467
        ].
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  3468
        replacement at:1 put: replacementString.
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  3469
        self paste:replacement.
121
claus
parents: 118
diff changeset
  3470
    ] ifFalse:[
362
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  3471
        self paste:someText
7
15a9291b9bd0 *** empty log message ***
claus
parents: 5
diff changeset
  3472
    ].
121
claus
parents: 118
diff changeset
  3473
    lastString := selectedString.
claus
parents: 118
diff changeset
  3474
    lastReplacement := someText
362
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  3475
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  3476
    "Modified: 14.2.1996 / 10:37:02 / stefan"
1289
e2dcc5fe612c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1287
diff changeset
  3477
    "Modified: 31.7.1997 / 19:22:49 / cg"
121
claus
parents: 118
diff changeset
  3478
!
claus
parents: 118
diff changeset
  3479
claus
parents: 118
diff changeset
  3480
showDeleted
claus
parents: 118
diff changeset
  3481
    "open a readonly editor on all deleted text"
claus
parents: 118
diff changeset
  3482
claus
parents: 118
diff changeset
  3483
    |v|
claus
parents: 118
diff changeset
  3484
claus
parents: 118
diff changeset
  3485
    v := EditTextView openWith:(Smalltalk at:#DeleteHistory).
claus
parents: 118
diff changeset
  3486
    v readOnly.
claus
parents: 118
diff changeset
  3487
    v topView label:'deleted text'.
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  3488
! !
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  3489
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3490
!EditTextView methodsFor:'private'!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3491
331
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
  3492
checkModificationsAllowed
1300
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  3493
    "check if the text can be modified (i.e. is not readOnly).
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  3494
     evaluate the exceptionBlock if not.
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  3495
     This block should be provided by the application or user of the textView,
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  3496
     and may show a warnBox or whatever."
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  3497
331
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
  3498
    readOnly ifTrue: [
1300
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  3499
        exceptionBlock isNil ifTrue:[
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  3500
            ^ false
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  3501
        ].
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  3502
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  3503
        (exceptionBlock value:'Text may not be modified') ~~ true ifTrue:[
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  3504
            ^ false
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  3505
        ]
331
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
  3506
    ].
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
  3507
    ^ true
1300
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  3508
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  3509
    "Modified: 13.8.1997 / 15:36:07 / cg"
331
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
  3510
!
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
  3511
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3512
textChanged
522
aa9458e4643e indent/undent did not trigger a modify
ca
parents: 503
diff changeset
  3513
    "my text was modified (internally).
aa9458e4643e indent/undent did not trigger a modify
ca
parents: 503
diff changeset
  3514
     Sent whenever text has been edited (not to confuse with
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3515
     contentsChanged, which is triggered when the size has changed, and
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3516
     is used to notify scrollers, other views etc.)"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3517
641
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  3518
    self contentsChanged.
1015
caf7265128b9 clear modified on accept.
Claus Gittinger <cg@exept.de>
parents: 1013
diff changeset
  3519
    self modified:true.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3520
    contentsWasSaved := false
641
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  3521
1015
caf7265128b9 clear modified on accept.
Claus Gittinger <cg@exept.de>
parents: 1013
diff changeset
  3522
    "Modified: 14.2.1997 / 16:58:38 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3523
! !
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3524
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3525
!EditTextView methodsFor:'queries'!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3526
997
615a5a19c5bf specClass
ca
parents: 991
diff changeset
  3527
specClass
615a5a19c5bf specClass
ca
parents: 991
diff changeset
  3528
    self class == EditTextView ifTrue:[^ TextEditorSpec].
1049
24360c8891d6 specClass query
Claus Gittinger <cg@exept.de>
parents: 1037
diff changeset
  3529
    ^ super specClass
24360c8891d6 specClass query
Claus Gittinger <cg@exept.de>
parents: 1037
diff changeset
  3530
24360c8891d6 specClass query
Claus Gittinger <cg@exept.de>
parents: 1037
diff changeset
  3531
    "Modified: 25.2.1997 / 14:54:16 / cg"
997
615a5a19c5bf specClass
ca
parents: 991
diff changeset
  3532
!
615a5a19c5bf specClass
ca
parents: 991
diff changeset
  3533
324
9eec6d69e155 better Tab key handling
Claus Gittinger <cg@exept.de>
parents: 323
diff changeset
  3534
tabMeansNextField
323
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
  3535
    "return true, if a Tab character should shift focus."
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
  3536
313
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  3537
    "if not readOnly, I want my tab keys ..."
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  3538
323
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
  3539
    ^ readOnly or:[tabMeansNextField]
324
9eec6d69e155 better Tab key handling
Claus Gittinger <cg@exept.de>
parents: 323
diff changeset
  3540
9eec6d69e155 better Tab key handling
Claus Gittinger <cg@exept.de>
parents: 323
diff changeset
  3541
    "Created: 7.2.1996 / 19:15:31 / cg"
313
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  3542
!
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  3543
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3544
widthOfContents
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3545
    "return the width of the contents in pixels
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3546
     Redefined to add the size of a space (for the cursor).
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3547
     this enables us to scroll one position further than the longest
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3548
     line (and possibly see the cursor behind the line)"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3549
697
0f258f02e8ea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 693
diff changeset
  3550
    |w dev|
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3551
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3552
    w := super widthOfContents.
697
0f258f02e8ea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 693
diff changeset
  3553
    (dev := device) isNil ifTrue:[
606
682579fa3b62 fixed #widthOfContents if no device is known
Claus Gittinger <cg@exept.de>
parents: 597
diff changeset
  3554
        "/ really dont know ...
697
0f258f02e8ea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 693
diff changeset
  3555
        dev := Screen current
606
682579fa3b62 fixed #widthOfContents if no device is known
Claus Gittinger <cg@exept.de>
parents: 597
diff changeset
  3556
    ].
697
0f258f02e8ea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 693
diff changeset
  3557
    ^ w + (font widthOn:dev)
0f258f02e8ea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 693
diff changeset
  3558
0f258f02e8ea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 693
diff changeset
  3559
    "Modified: 28.5.1996 / 19:32:25 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3560
! !
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3561
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3562
!EditTextView methodsFor:'redrawing'!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3563
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3564
redrawCursorIfBetweenVisibleLine:startVisLine and:endVisLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3565
    "redraw the cursor, if it sits in a line range"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3566
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3567
    cursorShown ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3568
	cursorVisibleLine notNil ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3569
	    (cursorVisibleLine between:startVisLine and:endVisLine) ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3570
		self drawCursorCharacter
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3571
	    ]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3572
	]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3573
    ]
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  3574
!
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  3575
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3576
redrawCursorIfInVisibleLine:visLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3577
    "redraw the cursor, if it sits in visible line"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3578
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3579
    cursorShown ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3580
	(visLine == cursorVisibleLine) ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3581
	    self drawCursorCharacter
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3582
	]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3583
    ]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3584
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3585
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3586
redrawFromVisibleLine:startVisLine to:endVisLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3587
    "redraw a visible line range"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3588
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3589
    super redrawFromVisibleLine:startVisLine to:endVisLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3590
    self redrawCursorIfBetweenVisibleLine:startVisLine and:endVisLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3591
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3592
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3593
redrawVisibleLine:visLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3594
    "redraw a visible line"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3595
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3596
    super redrawVisibleLine:visLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3597
    self redrawCursorIfInVisibleLine:visLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3598
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3599
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3600
redrawVisibleLine:visLine col:colNr
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3601
    "redraw the single character in visibleline at colNr"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3602
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3603
    cursorShown ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3604
	(visLine == cursorVisibleLine) ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3605
	    (colNr == cursorCol) ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3606
		self drawCursorCharacter.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3607
		^ self
118
claus
parents: 105
diff changeset
  3608
	    ]
claus
parents: 105
diff changeset
  3609
	]
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  3610
    ].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3611
    super redrawVisibleLine:visLine col:colNr
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3612
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3613
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3614
redrawVisibleLine:visLine from:startCol
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3615
    "redraw a visible line from startCol to the end of line"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3616
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3617
    super redrawVisibleLine:visLine from:startCol.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3618
    self redrawCursorIfInVisibleLine:visLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3619
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3620
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3621
redrawVisibleLine:visLine from:startCol to:endCol
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3622
    "redraw a visible line from startCol to endCol"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3623
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3624
    super redrawVisibleLine:visLine from:startCol to:endCol.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3625
    self redrawCursorIfInVisibleLine:visLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3626
! !
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3627
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3628
!EditTextView methodsFor:'scrolling'!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3629
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3630
halfPageDown
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3631
    "half a page down - to keep cursor on same visible line, it has to be moved
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3632
     within the real text  "
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3633
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3634
    |prevCursorLine|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3635
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3636
    prevCursorLine := cursorVisibleLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3637
    super halfPageDown.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3638
    self cursorVisibleLine:prevCursorLine col:cursorCol
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3639
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3640
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3641
halfPageUp
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3642
    "half a page up - to keep cursor on same visible line, it has to be moved
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3643
     within the real text  "
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3644
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3645
    |prevCursorLine|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3646
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3647
    prevCursorLine := cursorVisibleLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3648
    super halfPageUp.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3649
    self cursorVisibleLine:prevCursorLine col:cursorCol
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3650
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3651
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3652
originChanged:delta
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3653
    "sent after scrolling - have to show the cursor if it was on before"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3654
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3655
    super originChanged:delta.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3656
    "
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3657
     should we move the cursor with the scroll - or leave it ?
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3658
    "
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3659
    cursorVisibleLine := self listLineToVisibleLine:cursorLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3660
    prevCursorState ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3661
	self showCursor
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3662
    ]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3663
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3664
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3665
originWillChange
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3666
    "sent before scrolling - have to hide the cursor"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3667
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3668
    prevCursorState := cursorShown.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3669
    cursorShown ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3670
	self hideCursor
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3671
    ]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3672
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3673
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3674
pageDown
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3675
    "page down - to keep cursor on same visible line, it has to be moved
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3676
     within the real text  "
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3677
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3678
    |prevCursorLine|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3679
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3680
    prevCursorLine := cursorVisibleLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3681
    super pageDown.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3682
    self cursorVisibleLine:prevCursorLine col:cursorCol
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3683
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3684
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3685
pageUp
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3686
    "page up - to keep cursor on same visible line, it has to be moved
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3687
     within the real text  "
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3688
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3689
    |prevCursorLine|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3690
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3691
    prevCursorLine := cursorVisibleLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3692
    super pageUp.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3693
    self cursorVisibleLine:prevCursorLine col:cursorCol
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3694
! !
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3695
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3696
!EditTextView methodsFor:'searching'!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3697
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3698
searchBwd:pattern ifAbsent:aBlock
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3699
    "do a backward search"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3700
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3701
    |startLine startCol|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3702
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3703
    cursorLine isNil ifTrue:[^ self].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3704
    selectionStartLine notNil ifTrue:[
565
f2a0499ba3d0 preserve search pattern
Claus Gittinger <cg@exept.de>
parents: 559
diff changeset
  3705
        startLine := selectionStartLine.
f2a0499ba3d0 preserve search pattern
Claus Gittinger <cg@exept.de>
parents: 559
diff changeset
  3706
        startCol := selectionStartCol
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3707
    ] ifFalse:[
565
f2a0499ba3d0 preserve search pattern
Claus Gittinger <cg@exept.de>
parents: 559
diff changeset
  3708
        startLine := cursorLine min:list size.
f2a0499ba3d0 preserve search pattern
Claus Gittinger <cg@exept.de>
parents: 559
diff changeset
  3709
        startCol := cursorCol
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3710
    ].
1339
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  3711
    self 
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  3712
        searchBackwardFor:pattern 
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  3713
        startingAtLine:startLine col:startCol
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  3714
        ifFound:[:line :col |
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  3715
            self cursorLine:line col:col.
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  3716
            self showMatch:pattern atLine:line col:col.
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  3717
"/            self makeLineVisible:cursorLine
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  3718
            typeOfSelection := #search] 
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  3719
        ifAbsent:aBlock
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  3720
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  3721
    "Modified: 9.10.1997 / 13:02:04 / cg"
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  3722
!
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  3723
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  3724
searchBwd:pattern ignoreCase:ign ifAbsent:aBlock
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  3725
    "do a backward search"
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  3726
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  3727
    |startLine startCol|
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  3728
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  3729
    cursorLine isNil ifTrue:[^ self].
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  3730
    selectionStartLine notNil ifTrue:[
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  3731
        startLine := selectionStartLine.
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  3732
        startCol := selectionStartCol
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  3733
    ] ifFalse:[
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  3734
        startLine := cursorLine min:list size.
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  3735
        startCol := cursorCol
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  3736
    ].
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  3737
    self 
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  3738
        searchBackwardFor:pattern
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  3739
        ignoreCase:ign
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  3740
        startingAtLine:startLine col:startCol
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  3741
        ifFound:[:line :col |
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  3742
            self cursorLine:line col:col.
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  3743
            self showMatch:pattern atLine:line col:col.
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  3744
"/            self makeLineVisible:cursorLine
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  3745
            typeOfSelection := #search] 
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  3746
        ifAbsent:aBlock
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  3747
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  3748
    "Modified: 9.10.1997 / 13:02:13 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3749
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3750
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3751
searchForAndSelectMatchingParenthesis
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3752
    "select characters enclosed by matching parenthesis if one is under cusor"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3753
1339
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  3754
    self 
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  3755
        searchForMatchingParenthesisFromLine:cursorLine col:cursorCol
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  3756
        ifFound:[:line :col | 
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  3757
                  self selectFromLine:cursorLine col:cursorCol
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  3758
                               toLine:line col:col]
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  3759
        ifNotFound:[self showNotFound]
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  3760
        onError:[self beep]
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  3761
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  3762
    "Modified: 9.10.1997 / 12:57:34 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3763
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3764
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3765
searchForMatchingParenthesis
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3766
    "search for a matching parenthesis starting at cursor position. 
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3767
     Search for the corresponding character is done forward if its an opening, 
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3768
     backwards if its a closing parenthesis.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3769
     Positions the cursor if found, peeps if not"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3770
1339
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  3771
     self 
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  3772
        searchForMatchingParenthesisFromLine:cursorLine col:cursorCol
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  3773
        ifFound:[:line :col | self cursorLine:line col:col]
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  3774
        ifNotFound:[self showNotFound]
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  3775
        onError:[self beep]
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  3776
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  3777
    "Modified: 9.10.1997 / 12:56:30 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3778
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3779
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3780
searchFwd:pattern ifAbsent:aBlock
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3781
    "do a forward search"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3782
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3783
    |startCol|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3784
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3785
    "/ if there is no selection and the cursor is at the origin, 
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3786
    "/ assume its the first search and do not skip the very first match
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3787
    startCol := cursorCol.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3788
    self hasSelection ifFalse:[
1339
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  3789
        (cursorLine == 1 and:[cursorCol == 1]) ifTrue:[
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  3790
            startCol := 0
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  3791
        ]
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  3792
    ].
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  3793
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  3794
    self 
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  3795
        searchFwd:pattern 
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  3796
        startingAtLine:cursorLine col:startCol 
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  3797
        ifAbsent:aBlock
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  3798
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  3799
    "Modified: 9.10.1997 / 12:58:59 / cg"
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  3800
!
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  3801
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  3802
searchFwd:pattern ignoreCase:ign ifAbsent:aBlock
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  3803
    "do a forward search"
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  3804
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  3805
    |startCol|
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  3806
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  3807
    "/ if there is no selection and the cursor is at the origin, 
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  3808
    "/ assume its the first search and do not skip the very first match
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  3809
    startCol := cursorCol.
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  3810
    self hasSelection ifFalse:[
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  3811
        (cursorLine == 1 and:[cursorCol == 1]) ifTrue:[
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  3812
            startCol := 0
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  3813
        ]
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3814
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3815
1339
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  3816
    self 
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  3817
        searchFwd:pattern
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  3818
        ignoreCase:ign
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  3819
        startingAtLine:cursorLine col:startCol 
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  3820
        ifAbsent:aBlock
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  3821
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  3822
    "Modified: 9.10.1997 / 12:58:59 / cg"
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  3823
    "Created: 9.10.1997 / 13:04:10 / cg"
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  3824
!
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  3825
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  3826
searchFwd:pattern ignoreCase:ign startingAtLine:startLine col:startCol ifAbsent:aBlock
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  3827
    "do a forward search"
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  3828
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  3829
    cursorLine isNil ifTrue:[^ self].
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  3830
    self 
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  3831
        searchForwardFor:pattern 
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  3832
        ignoreCase:ign
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  3833
        startingAtLine:startLine col:startCol
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  3834
        ifFound:[:line :col |
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  3835
            self cursorLine:line col:col.
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  3836
            self showMatch:pattern atLine:line col:col.
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  3837
"/            self makeLineVisible:cursorLine
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  3838
            typeOfSelection := #search]
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  3839
        ifAbsent:aBlock
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  3840
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  3841
    "Modified: 9.10.1997 / 12:57:47 / cg"
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  3842
    "Created: 9.10.1997 / 13:01:12 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3843
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3844
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3845
searchFwd:pattern startingAtLine:startLine col:startCol ifAbsent:aBlock
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3846
    "do a forward search"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3847
1339
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  3848
    self 
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  3849
        searchForwardFor:pattern 
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  3850
        startingAtLine:startLine col:startCol
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  3851
        ifFound:[:line :col |
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  3852
            self cursorLine:line col:col.
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  3853
            self showMatch:pattern atLine:line col:col.
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  3854
            typeOfSelection := #search]
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  3855
        ifAbsent:aBlock
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  3856
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  3857
    "Modified: 9.10.1997 / 13:07:52 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3858
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3859
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3860
setSearchPattern
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3861
    "set the searchpattern from the selection if there is one, and position
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3862
     cursor to start of pattern"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3863
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3864
    |sel|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3865
559
3ff87e9447c6 keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents: 522
diff changeset
  3866
    "/
3ff87e9447c6 keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents: 522
diff changeset
  3867
    "/ if the last operation was a replcae, set pattern to last
3ff87e9447c6 keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents: 522
diff changeset
  3868
    "/ original string (for search after again)
3ff87e9447c6 keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents: 522
diff changeset
  3869
    "/
565
f2a0499ba3d0 preserve search pattern
Claus Gittinger <cg@exept.de>
parents: 559
diff changeset
  3870
    (lastString notNil 
f2a0499ba3d0 preserve search pattern
Claus Gittinger <cg@exept.de>
parents: 559
diff changeset
  3871
     and:[lastReplacement notNil
f2a0499ba3d0 preserve search pattern
Claus Gittinger <cg@exept.de>
parents: 559
diff changeset
  3872
     and:[typeOfSelection ~~ #search]]) ifTrue:[
1325
05bbe657902c allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1319
diff changeset
  3873
        lastSearchPattern := lastString asString withoutSeparators.
559
3ff87e9447c6 keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents: 522
diff changeset
  3874
        ^ self
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3875
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3876
559
3ff87e9447c6 keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents: 522
diff changeset
  3877
    "/
3ff87e9447c6 keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents: 522
diff changeset
  3878
    "/ if there is a selection:
3ff87e9447c6 keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents: 522
diff changeset
  3879
    "/    if there was no previous search, take it as search pattern.
3ff87e9447c6 keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents: 522
diff changeset
  3880
    "/    if there was a previous search, only take the selection if
3ff87e9447c6 keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents: 522
diff changeset
  3881
    "/    it did not result from a paste.
3ff87e9447c6 keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents: 522
diff changeset
  3882
    "/    (to allow search-paste to be repeated)
3ff87e9447c6 keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents: 522
diff changeset
  3883
    "/
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3884
    sel := self selection.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3885
    sel notNil ifTrue:[
1325
05bbe657902c allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1319
diff changeset
  3886
        (lastSearchPattern isNil
559
3ff87e9447c6 keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents: 522
diff changeset
  3887
        or:[typeOfSelection ~~ #paste]) ifTrue:[
3ff87e9447c6 keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents: 522
diff changeset
  3888
            self cursorLine:selectionStartLine col:selectionStartCol.
1325
05bbe657902c allow case-ignoring search
Claus Gittinger <cg@exept.de>
parents: 1319
diff changeset
  3889
            lastSearchPattern := sel asString withoutSeparators
559
3ff87e9447c6 keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents: 522
diff changeset
  3890
        ]
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3891
    ]
559
3ff87e9447c6 keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents: 522
diff changeset
  3892
565
f2a0499ba3d0 preserve search pattern
Claus Gittinger <cg@exept.de>
parents: 559
diff changeset
  3893
    "Modified: 20.4.1996 / 12:50:13 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3894
! !
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3895
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3896
!EditTextView methodsFor:'selections'!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3897
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3898
selectAll
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3899
    "select the whole text.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3900
     redefined to send super selectFrom... since we dont want the
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3901
     cursor to be moved in this case."
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3902
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3903
    list isNil ifTrue:[
1082
ccc3aa4268c1 better #selectAll
Claus Gittinger <cg@exept.de>
parents: 1054
diff changeset
  3904
        self unselect
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3905
    ] ifFalse:[
1082
ccc3aa4268c1 better #selectAll
Claus Gittinger <cg@exept.de>
parents: 1054
diff changeset
  3906
        super selectFromLine:1 col:1 toLine:(list size + 1) col:0.
ccc3aa4268c1 better #selectAll
Claus Gittinger <cg@exept.de>
parents: 1054
diff changeset
  3907
        typeOfSelection := nil
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3908
    ]
1082
ccc3aa4268c1 better #selectAll
Claus Gittinger <cg@exept.de>
parents: 1054
diff changeset
  3909
ccc3aa4268c1 better #selectAll
Claus Gittinger <cg@exept.de>
parents: 1054
diff changeset
  3910
    "Modified: 28.2.1997 / 19:14:54 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3911
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3912
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3913
selectCursorLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3914
    "select cursorline"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3915
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3916
    self selectFromLine:cursorLine col:1 toLine:cursorLine+1 col:0 
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3917
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3918
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3919
selectCursorLineFromBeginning
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3920
    "select cursorline up to cursor position"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3921
823
fc61564f7832 escape selects up to previous character
Claus Gittinger <cg@exept.de>
parents: 785
diff changeset
  3922
    cursorCol > 1 ifTrue:[
fc61564f7832 escape selects up to previous character
Claus Gittinger <cg@exept.de>
parents: 785
diff changeset
  3923
        self selectFromLine:cursorLine col:1
fc61564f7832 escape selects up to previous character
Claus Gittinger <cg@exept.de>
parents: 785
diff changeset
  3924
                     toLine:cursorLine col:(cursorCol-1)
fc61564f7832 escape selects up to previous character
Claus Gittinger <cg@exept.de>
parents: 785
diff changeset
  3925
    ]
fc61564f7832 escape selects up to previous character
Claus Gittinger <cg@exept.de>
parents: 785
diff changeset
  3926
fc61564f7832 escape selects up to previous character
Claus Gittinger <cg@exept.de>
parents: 785
diff changeset
  3927
    "Modified: 16.8.1996 / 19:14:14 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3928
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3929
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3930
selectExpandCursorLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3931
    "expand selection by one line or select cursorline"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3932
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3933
    selectionStartLine isNil ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3934
	self selectCursorLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3935
    ] ifFalse:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3936
	self selectFromLine:selectionStartLine col:selectionStartCol
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3937
		     toLine:cursorLine+1 col:0.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3938
	self makeLineVisible:selectionEndLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3939
    ]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3940
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3941
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3942
selectFromBeginning
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3943
    "select the text from the beginning to the current cursor position."
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3944
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3945
    |col|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3946
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3947
    list isNil ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3948
	self unselect
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3949
    ] ifFalse:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3950
	cursorCol == 0 ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3951
	    col := 0
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3952
	] ifFalse:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3953
	    col := cursorCol - 1
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3954
	].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3955
	super selectFromLine:1 col:1 toLine:cursorLine col:col.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3956
	typeOfSelection := nil
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3957
    ]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3958
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3959
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3960
selectFromLine:startLine col:startCol toLine:endLine col:endCol
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3961
    "when a range is selected, position the cursor behind the selection
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3962
     for easier editing. Also typeOfSelection is nilled here."
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3963
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3964
    super selectFromLine:startLine col:startCol toLine:endLine col:endCol.
1198
1c5390d2d3fb care for failed selection when positioning cursor.
ca
parents: 1177
diff changeset
  3965
    selectionEndLine notNil ifTrue:[
1c5390d2d3fb care for failed selection when positioning cursor.
ca
parents: 1177
diff changeset
  3966
        self cursorLine:selectionEndLine col:(selectionEndCol + 1).
1c5390d2d3fb care for failed selection when positioning cursor.
ca
parents: 1177
diff changeset
  3967
    ].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3968
    typeOfSelection := nil
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3969
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3970
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3971
selectUpToEnd
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3972
    "select the text from the current cursor position to the end."
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3973
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3974
    list isNil ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3975
	self unselect
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3976
    ] ifFalse:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3977
	super selectFromLine:cursorLine col:cursorCol toLine:(list size + 1) col:0.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3978
	typeOfSelection := nil
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3979
    ]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3980
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3981
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3982
selectWordUnderCursor
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3983
    "select the word under the cursor"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3984
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3985
    self selectWordAtLine:cursorLine col:cursorCol
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3986
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3987
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3988
unselect
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3989
    "forget and unhilight selection - must take care of cursor here"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3990
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3991
    |wasOn|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3992
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3993
    wasOn := self hideCursor.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3994
    super unselect.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3995
    wasOn ifTrue:[self showCursor]
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  3996
! !
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  3997
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  3998
!EditTextView methodsFor:'undo & again'!
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  3999
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  4000
again
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  4001
    "repeat the last action (which was a cut or replace).
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  4002
     If current selection is not last string, search forward to
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  4003
     next occurence of it before repeating the last operation."
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  4004
501
13fc7b9ce5cb fixed (?) again-replace
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  4005
    |s l c sel savedSelectStyle|
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  4006
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  4007
    lastString notNil ifTrue:[
501
13fc7b9ce5cb fixed (?) again-replace
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  4008
        s := lastString asString.
840
b0071cea13fd fixed Again when spaces are replaced
Claus Gittinger <cg@exept.de>
parents: 828
diff changeset
  4009
501
13fc7b9ce5cb fixed (?) again-replace
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  4010
        "remove final cr"
840
b0071cea13fd fixed Again when spaces are replaced
Claus Gittinger <cg@exept.de>
parents: 828
diff changeset
  4011
        s := s copyWithoutLast:1.
b0071cea13fd fixed Again when spaces are replaced
Claus Gittinger <cg@exept.de>
parents: 828
diff changeset
  4012
"/        s := s withoutSpaces.        "XXX - replacing text with spaces ..."
501
13fc7b9ce5cb fixed (?) again-replace
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  4013
        savedSelectStyle := selectStyle.
13fc7b9ce5cb fixed (?) again-replace
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  4014
        selectStyle := nil.
13fc7b9ce5cb fixed (?) again-replace
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  4015
13fc7b9ce5cb fixed (?) again-replace
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  4016
        sel := self selection.
13fc7b9ce5cb fixed (?) again-replace
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  4017
13fc7b9ce5cb fixed (?) again-replace
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  4018
        "if we are already there (after a find), ommit search"
13fc7b9ce5cb fixed (?) again-replace
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  4019
13fc7b9ce5cb fixed (?) again-replace
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  4020
        (sel notNil and:[sel asString withoutSeparators = s]) ifTrue:[
13fc7b9ce5cb fixed (?) again-replace
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  4021
            undoAction := [self insertLines:lastString atLine:cursorLine col:cursorCol].
13fc7b9ce5cb fixed (?) again-replace
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  4022
            l := selectionStartLine "cursorLine". 
13fc7b9ce5cb fixed (?) again-replace
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  4023
            c := selectionStartCol "cursorCol".
13fc7b9ce5cb fixed (?) again-replace
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  4024
            self deleteSelection.
13fc7b9ce5cb fixed (?) again-replace
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  4025
            lastReplacement notNil ifTrue:[
654
d621e63baaa5 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 641
diff changeset
  4026
                self insertLines:lastReplacement asStringCollection withCR:false.
501
13fc7b9ce5cb fixed (?) again-replace
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  4027
                self selectFromLine:l col:c toLine:cursorLine col:(cursorCol - 1).
13fc7b9ce5cb fixed (?) again-replace
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  4028
            ].
13fc7b9ce5cb fixed (?) again-replace
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  4029
            selectStyle := savedSelectStyle.
13fc7b9ce5cb fixed (?) again-replace
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  4030
            ^ true
13fc7b9ce5cb fixed (?) again-replace
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  4031
        ].
13fc7b9ce5cb fixed (?) again-replace
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  4032
13fc7b9ce5cb fixed (?) again-replace
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  4033
        self searchForwardFor:s startingAtLine:cursorLine col:cursorCol 
13fc7b9ce5cb fixed (?) again-replace
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  4034
            ifFound:
13fc7b9ce5cb fixed (?) again-replace
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  4035
                [
13fc7b9ce5cb fixed (?) again-replace
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  4036
                    :line :col |
13fc7b9ce5cb fixed (?) again-replace
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  4037
13fc7b9ce5cb fixed (?) again-replace
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  4038
                    |repl|
13fc7b9ce5cb fixed (?) again-replace
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  4039
13fc7b9ce5cb fixed (?) again-replace
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  4040
                    self selectFromLine:line col:col
13fc7b9ce5cb fixed (?) again-replace
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  4041
                                 toLine:line col:(col + s size - 1).
13fc7b9ce5cb fixed (?) again-replace
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  4042
                    self makeLineVisible:line.
13fc7b9ce5cb fixed (?) again-replace
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  4043
                    undoAction := [self insertLines:lastString atLine:line col:col].
13fc7b9ce5cb fixed (?) again-replace
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  4044
13fc7b9ce5cb fixed (?) again-replace
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  4045
                    self deleteSelection.
13fc7b9ce5cb fixed (?) again-replace
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  4046
                    lastReplacement notNil ifTrue:[
785
6384ec64a6dd checkin from browser
Claus Gittinger <cg@exept.de>
parents: 783
diff changeset
  4047
                        lastReplacement isString ifFalse:[
6384ec64a6dd checkin from browser
Claus Gittinger <cg@exept.de>
parents: 783
diff changeset
  4048
                            repl := lastReplacement asString withoutSpaces
6384ec64a6dd checkin from browser
Claus Gittinger <cg@exept.de>
parents: 783
diff changeset
  4049
                        ] ifTrue:[
6384ec64a6dd checkin from browser
Claus Gittinger <cg@exept.de>
parents: 783
diff changeset
  4050
                            repl := lastReplacement withoutSpaces.
6384ec64a6dd checkin from browser
Claus Gittinger <cg@exept.de>
parents: 783
diff changeset
  4051
                        ].
654
d621e63baaa5 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 641
diff changeset
  4052
                        self insertLines:repl asStringCollection withCR:false.
501
13fc7b9ce5cb fixed (?) again-replace
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  4053
                        self selectFromLine:line col:col toLine:cursorLine col:(cursorCol - 1).
13fc7b9ce5cb fixed (?) again-replace
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  4054
                    ].
13fc7b9ce5cb fixed (?) again-replace
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  4055
                    selectStyle := savedSelectStyle.
13fc7b9ce5cb fixed (?) again-replace
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  4056
                    ^ true
13fc7b9ce5cb fixed (?) again-replace
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  4057
                ] 
13fc7b9ce5cb fixed (?) again-replace
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  4058
           ifAbsent:
13fc7b9ce5cb fixed (?) again-replace
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  4059
                [
13fc7b9ce5cb fixed (?) again-replace
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  4060
                    self showNotFound.
13fc7b9ce5cb fixed (?) again-replace
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  4061
                    selectStyle := savedSelectStyle.
13fc7b9ce5cb fixed (?) again-replace
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  4062
                    ^ false
13fc7b9ce5cb fixed (?) again-replace
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  4063
                ]
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  4064
    ]
501
13fc7b9ce5cb fixed (?) again-replace
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  4065
840
b0071cea13fd fixed Again when spaces are replaced
Claus Gittinger <cg@exept.de>
parents: 828
diff changeset
  4066
    "Modified: 9.10.1996 / 16:14:11 / cg"
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  4067
!
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  4068
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4069
multipleAgain
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4070
    "repeat the last action (which was a cut or replace) until search fails"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4071
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4072
    [self again] whileTrue:[]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4073
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4074
121
claus
parents: 118
diff changeset
  4075
undo
claus
parents: 118
diff changeset
  4076
    "currently not implemented"
claus
parents: 118
diff changeset
  4077
claus
parents: 118
diff changeset
  4078
    undoAction notNil ifTrue:[
claus
parents: 118
diff changeset
  4079
	undoAction value
claus
parents: 118
diff changeset
  4080
    ]
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  4081
! !
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  4082
865
d42c7c99e67d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 840
diff changeset
  4083
!EditTextView class methodsFor:'documentation'!
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4084
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4085
version
1355
6725ab9cc6f5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
  4086
    ^ '$Header: /cvs/stx/stx/libwidg/Attic/ETxtView.st,v 1.139 1997-10-21 18:28:05 cg Exp $'
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  4087
! !