EditTextView.st
author Claus Gittinger <cg@exept.de>
Tue, 30 Nov 2004 12:55:50 +0100
changeset 3115 b75128334006
parent 3114 ae98b76a709e
child 3127 29767bf8a215
permissions -rw-r--r--
info string in undo
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
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
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
2184
fb634dc3e606 learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents: 2157
diff changeset
    13
"{ Package: 'stx:libwidg' }"
fb634dc3e606 learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents: 2157
diff changeset
    14
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    15
TextView subclass:#EditTextView
2724
23f4e16dc4f4 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2720
diff changeset
    16
	instanceVariableNames:'cursorLine cursorVisibleLine cursorCol cursorShown
23f4e16dc4f4 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2720
diff changeset
    17
		prevCursorState readOnly modifiedChannel fixedSize exceptionBlock
23f4e16dc4f4 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2720
diff changeset
    18
		cursorFgColor cursorBgColor cursorNoFocusFgColor cursorType
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
    19
		cursorTypeNoFocus typeOfSelection lastString lastReplacement
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
    20
		lastAction replacing showMatchingParenthesis hasKeyboardFocus
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
    21
		acceptAction lockUpdates tabMeansNextField autoIndent insertMode
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
    22
		trimBlankLines wordWrap replacementWordSelectStyle acceptChannel
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
    23
		acceptEnabled st80Mode disableIfInvisible
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
    24
		cursorMovementWhenUpdating learnMode learnedMacro
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
    25
		cursorLineHolder cursorColHolder dropTarget tabRequiresControl
2989
5dcc2912bcb6 undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents: 2984
diff changeset
    26
		undoSupport'
2724
23f4e16dc4f4 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2720
diff changeset
    27
	classVariableNames:'DefaultCursorForegroundColor DefaultCursorBackgroundColor
23f4e16dc4f4 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2720
diff changeset
    28
		DefaultCursorType DefaultCursorNoFocusForegroundColor
23f4e16dc4f4 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2720
diff changeset
    29
		DefaultCursorTypeNoFocus'
23f4e16dc4f4 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2720
diff changeset
    30
	poolDictionaries:''
23f4e16dc4f4 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2720
diff changeset
    31
	category:'Views-Text'
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    32
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    33
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
    34
Object subclass:#EditAction
3115
b75128334006 info string in undo
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
    35
	instanceVariableNames:'userFriendlyInfo'
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
    36
	classVariableNames:''
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
    37
	poolDictionaries:''
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
    38
	privateIn:EditTextView
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
    39
!
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
    40
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
    41
EditTextView::EditAction subclass:#DeleteRange
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
    42
	instanceVariableNames:'line1 col1 line2 col2'
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
    43
	classVariableNames:''
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
    44
	poolDictionaries:''
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
    45
	privateIn:EditTextView
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
    46
!
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
    47
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
    48
EditTextView::EditAction subclass:#InsertCharacter
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
    49
	instanceVariableNames:'line col character'
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
    50
	classVariableNames:''
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
    51
	poolDictionaries:''
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
    52
	privateIn:EditTextView
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
    53
!
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
    54
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
    55
EditTextView::EditAction subclass:#PasteString
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
    56
	instanceVariableNames:'line col string selected'
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
    57
	classVariableNames:''
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
    58
	poolDictionaries:''
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
    59
	privateIn:EditTextView
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
    60
!
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
    61
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
    62
EditTextView::EditAction subclass:#ReplaceCharacter
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
    63
	instanceVariableNames:'line col character'
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
    64
	classVariableNames:''
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
    65
	poolDictionaries:''
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
    66
	privateIn:EditTextView
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
    67
!
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
    68
865
d42c7c99e67d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 840
diff changeset
    69
!EditTextView class methodsFor:'documentation'!
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    70
33
5eeef3ea8ebd added access methods for cursorLine & cursorCol
claus
parents: 25
diff changeset
    71
copyright
5eeef3ea8ebd added access methods for cursorLine & cursorCol
claus
parents: 25
diff changeset
    72
"
5eeef3ea8ebd added access methods for cursorLine & cursorCol
claus
parents: 25
diff changeset
    73
 COPYRIGHT (c) 1989 by Claus Gittinger
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
    74
              All Rights Reserved
33
5eeef3ea8ebd added access methods for cursorLine & cursorCol
claus
parents: 25
diff changeset
    75
5eeef3ea8ebd added access methods for cursorLine & cursorCol
claus
parents: 25
diff changeset
    76
 This software is furnished under a license and may be used
5eeef3ea8ebd added access methods for cursorLine & cursorCol
claus
parents: 25
diff changeset
    77
 only in accordance with the terms of that license and with the
5eeef3ea8ebd added access methods for cursorLine & cursorCol
claus
parents: 25
diff changeset
    78
 inclusion of the above copyright notice.   This software may not
5eeef3ea8ebd added access methods for cursorLine & cursorCol
claus
parents: 25
diff changeset
    79
 be provided or otherwise made available to, or used by, any
5eeef3ea8ebd added access methods for cursorLine & cursorCol
claus
parents: 25
diff changeset
    80
 other person.  No title to or ownership of the software is
5eeef3ea8ebd added access methods for cursorLine & cursorCol
claus
parents: 25
diff changeset
    81
 hereby transferred.
5eeef3ea8ebd added access methods for cursorLine & cursorCol
claus
parents: 25
diff changeset
    82
"
5eeef3ea8ebd added access methods for cursorLine & cursorCol
claus
parents: 25
diff changeset
    83
!
5eeef3ea8ebd added access methods for cursorLine & cursorCol
claus
parents: 25
diff changeset
    84
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    85
documentation
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    86
"
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    87
    a view for editable text - adds editing functionality to TextView
125
claus
parents: 123
diff changeset
    88
    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
    89
    acceptAction to be performed for accept
125
claus
parents: 123
diff changeset
    90
claus
parents: 123
diff changeset
    91
    If used with a model, this is informed by sending it a changeMsg with
claus
parents: 123
diff changeset
    92
    the current contents as argument.
297
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
    93
    (however, it is possible to define both changeMsg and acceptAction)
125
claus
parents: 123
diff changeset
    94
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
    95
    Please read the historic notice in the ListView class.
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    96
586
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 567
diff changeset
    97
    [Instance variables:]
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    98
2129
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
    99
        cursorLine              <Number>        line where cursor sits (1..)
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   100
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   101
        cursorVisibleLine       <Number>        visible line where cursor sits (1..nLinesShown)
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   102
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   103
        cursorCol               <Number>        col where cursor sits (1..)
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   104
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   105
        cursorShown             <Boolean>       true, if cursor is currently shown
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   106
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   107
        readOnly                <Boolean>       true, if text may not be edited
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   108
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   109
        modifiedChannel         <ValueHolder>   holding true, if text has been modified.
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   110
                                                cleared on accept.
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   111
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   112
        acceptChannel           <ValueHolder>   holding true, if text has been accepted.
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   113
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   114
        fixedSize               <Boolean>       true, if no lines may be added/removed
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   115
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   116
        exceptionBlock          <Block>         block to be evaluated when readonly text is about to be modified
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   117
                                                if it returns true, the modification will be done anyway.
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   118
                                                if it returns anything else, the modification is not done.
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   119
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   120
        cursorFgColor           <Color>         color used for cursor drawing
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   121
        cursorBgColor           <Color>         color used for cursor drawing
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   122
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   123
        cursorType              <Symbol>        how the cursor is drawn; currently implemented
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   124
                                                are #block (solid-block cursor), #ibeam
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   125
                                                (vertical bar at insertion point) 
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   126
                                                and #caret (caret below insertion-point)
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   127
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   128
        cursorTypeNoFocus       <Symbol>        like above, if view has no focus
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   129
                                                nil means: hide the cursor.
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   130
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   131
        undoAction              <Block>         block which undoes last cut, paste or replace
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   132
                                                (not yet fully implemented)
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   133
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   134
        typeOfSelection         <Symbol>        #paste, if selection created by paste, nil otherwise
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   135
                                                this affects the next keyPress: if #paste it does not
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   136
                                                replace; otherwise it replaces the selection.
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   137
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   138
        lastCut                 <String>        last cut or replaced string
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   139
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   140
        lastReplacement         <String>        last replacement
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   141
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   142
        replacing               <Boolean>       true if entered characters replace last selection
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   143
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   144
        showMatchingParenthesis <Boolean>       if true, shows matching parenthesis
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   145
                                                when entering one; this is the default.
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   146
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   147
        hasKeyboardFocus        <Boolean>       true if this view has the focus
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   148
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   149
        acceptAction            <Block>         accept action - evaluated passing the contents as 
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   150
                                                argument 
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   151
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   152
        tabMeansNextField       <Boolean>       if true, Tab is ignored as input and shifts keyboard
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   153
                                                focus to the next field. For editTextViews, this is false
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   154
                                                by default (i.e. tabs can be entered into the text).
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   155
                                                For some subclasses (inputFields), this may be true.
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   156
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   157
        trimBlankLines          <Boolean>       if true, trailing blanks are
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   158
                                                removed when editing.
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   159
                                                Default is true.
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   160
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   161
        wordWrap                <Boolean>       Currently not used.
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   162
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   163
        lockUpdates             <Boolean>       internal, private
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   164
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   165
        prevCursorState         <Boolean>       temporary, private
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   166
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   167
        cursorMovementWhenUpdating
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   168
                                <Symbol>        defines where the cursor is to be positioned if the
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   169
                                                model changes its value by some outside activity
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   170
                                                (i.e. not by user input into the field).
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   171
                                                Can be one of:
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   172
                                                    #keep / nil     -> stay where it was
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   173
                                                    #endOfText      -> cursor to the end
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   174
                                                    #endOfLine      -> stay in the line, but move to end
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   175
                                                    #beginOfText    -> cursor to the beginning
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   176
                                                    #beginOfLine    -> stay in the line, but move to begin
2131
858209ba8509 cursor movement default
Claus Gittinger <cg@exept.de>
parents: 2129
diff changeset
   177
                                                The default is #beginOfText
323
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   178
33
5eeef3ea8ebd added access methods for cursorLine & cursorCol
claus
parents: 25
diff changeset
   179
2589
62794ae04446 support drop
ca
parents: 2580
diff changeset
   180
62794ae04446 support drop
ca
parents: 2580
diff changeset
   181
        dropTarget              <DropTarget|nil> drop operation descriptor or nil (drop disabled)
62794ae04446 support drop
ca
parents: 2580
diff changeset
   182
62794ae04446 support drop
ca
parents: 2580
diff changeset
   183
2712
e83d71c9bdec ST80Mode classVariables is now UserPreferences.st80EditMode
Claus Gittinger <cg@exept.de>
parents: 2707
diff changeset
   184
    userPreference values:
e83d71c9bdec ST80Mode classVariables is now UserPreferences.st80EditMode
Claus Gittinger <cg@exept.de>
parents: 2707
diff changeset
   185
        userPreferences.st80EditMode 
e83d71c9bdec ST80Mode classVariables is now UserPreferences.st80EditMode
Claus Gittinger <cg@exept.de>
parents: 2707
diff changeset
   186
                                <Boolean>       if true, cursor positioning is
2129
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   187
                                                done as in vi or ST80; i.e.
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   188
                                                wysiwyg mode is somewhat relaxed,
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   189
                                                in that the cursor cannot be
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   190
                                                positioned behind a lines end.
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   191
                                                This is not yet completely implemented.
33
5eeef3ea8ebd added access methods for cursorLine & cursorCol
claus
parents: 25
diff changeset
   192
    used globals:
5eeef3ea8ebd added access methods for cursorLine & cursorCol
claus
parents: 25
diff changeset
   193
2129
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   194
        DeleteHistory           <Text>          last 1000 lines of deleted text
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   195
                                                (but only if this variable exists already)
586
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 567
diff changeset
   196
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 567
diff changeset
   197
    [styleSheet parameters:]
121
claus
parents: 118
diff changeset
   198
2589
62794ae04446 support drop
ca
parents: 2580
diff changeset
   199
        textCursorForegroundColor <Color>          cursor fg color; default: text background
62794ae04446 support drop
ca
parents: 2580
diff changeset
   200
        textCursorBackgroundColor <Color>          cursor bg color; default: text foreground
2129
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   201
        textCursorNoFocusForegroundColor 
2589
62794ae04446 support drop
ca
parents: 2580
diff changeset
   202
                                  <Color>          cursor fg color if no focus; default: cursor fg color
62794ae04446 support drop
ca
parents: 2580
diff changeset
   203
        textCursorType            <Symbol>         cursor type; default:  #block
586
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 567
diff changeset
   204
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 567
diff changeset
   205
    [author:]
2129
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   206
        Claus Gittinger
586
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 567
diff changeset
   207
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 567
diff changeset
   208
    [see also:]
2129
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   209
        CodeView Workspace TextView ListView
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   210
        EditField
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   211
"
297
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   212
!
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
examples
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   215
"
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   216
  non MVC operation:
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   217
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   218
    basic setup:
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   219
                                                                        [exBegin]
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   220
        |top textView|
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   221
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   222
        top := StandardSystemView new.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   223
        top extent:300@200.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   224
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   225
        textView := EditTextView new.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   226
        textView origin:0.0 @ 0.0 corner:1.0 @ 1.0.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   227
        top addSubView:textView.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   228
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   229
        textView contents:('/etc/hosts' asFilename contentsOfEntireFile).
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   230
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   231
        top open.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   232
                                                                        [exEnd]
594
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
    with vertical scrollbar:
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   236
                                                                        [exBegin]
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   237
        |top scrollView textView|
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   238
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   239
        top := StandardSystemView new.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   240
        top extent:300@200.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   241
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   242
        scrollView := ScrollableView for:EditTextView.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   243
        textView := scrollView scrolledView.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   244
        scrollView origin:0.0 @ 0.0 corner:1.0 @ 1.0.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   245
        top addSubView:scrollView.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   246
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   247
        textView contents:('/etc/hosts' asFilename contentsOfEntireFile).
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   248
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   249
        top open.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   250
                                                                        [exEnd]
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   251
297
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   252
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   253
    with horizontal & vertical scrollbars:
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   254
                                                                        [exBegin]
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   255
        |top scrollView textView|
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   256
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   257
        top := StandardSystemView new.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   258
        top extent:300@200.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   259
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   260
        scrollView := HVScrollableView for:EditTextView.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   261
        textView := scrollView scrolledView.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   262
        scrollView origin:0.0 @ 0.0 corner:1.0 @ 1.0.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   263
        top addSubView:scrollView.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   264
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   265
        textView contents:('/etc/hosts' asFilename contentsOfEntireFile).
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   266
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   267
        top open.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   268
                                                                        [exEnd]
297
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   269
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   270
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   271
    set the action for accept:
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   272
                                                                        [exBegin]
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   273
        |top textView|
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   274
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   275
        top := StandardSystemView new.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   276
        top extent:300@200.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   277
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   278
        textView := EditTextView new.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   279
        textView origin:0.0 @ 0.0 corner:1.0 @ 1.0.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   280
        top addSubView:textView.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   281
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   282
        textView contents:('/etc/hosts' asFilename contentsOfEntireFile).
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   283
        textView acceptAction:[:contents |
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   284
                                Transcript showCR:'will not overwrite the file with:'.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   285
                                Transcript showCR:contents asString
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   286
                              ].
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   287
        top open.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   288
                                                                        [exEnd]
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   289
297
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   290
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   291
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
   292
    non-string (text) items:
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   293
                                                                        [exBegin]
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   294
        |top textView list|
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   295
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   296
        list := '/etc/hosts' asFilename contentsOfEntireFile asStringCollection.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   297
        1 to:list size by:2 do:[:nr |
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   298
            list at:nr put:(Text string:(list at:nr)
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   299
                                 emphasis:(Array with:#bold with:(#color->Color red)))
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   300
        ].
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   301
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   302
        top := StandardSystemView new.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   303
        top extent:300@200.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   304
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   305
        textView := EditTextView new.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   306
        textView origin:0.0 @ 0.0 corner:1.0 @ 1.0.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   307
        top addSubView:textView.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   308
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   309
        textView contents:list.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   310
        top open.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   311
                                                                        [exEnd]
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
   312
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
   313
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
   314
297
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   315
  MVC operation:
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   316
    (the examples model here is a plug simulating a real model;
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   317
     real world applications would not use a plug ..)
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   318
                                                                        [exBegin]
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   319
        |top textView model|
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   320
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   321
        model := Plug new.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   322
        model respondTo:#accepted:
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   323
                   with:[:newContents | 
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   324
                                Transcript showCR:'will not overwrite the file with:'.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   325
                                Transcript showCR:newContents asString
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   326
                        ].
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   327
        model respondTo:#getList
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   328
                   with:['/etc/hosts' asFilename contentsOfEntireFile].
297
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   329
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   330
        
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   331
        top := StandardSystemView new.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   332
        top extent:300@200.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   333
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   334
        textView := EditTextView new.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   335
        textView origin:0.0 @ 0.0 corner:1.0 @ 1.0.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   336
        top addSubView:textView.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   337
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   338
        textView listMessage:#getList;
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   339
                 model:model;
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   340
                 changeMessage:#accepted:;
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   341
                 aspect:#list.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   342
        top open.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   343
                                                                        [exEnd]
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   344
297
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   345
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   346
    two textViews on the same model:
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   347
                                                                        [exBegin]
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   348
        |top1 textView1 top2 textView2 model currentContents|
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   349
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   350
        model := Plug new.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   351
        model respondTo:#accepted:
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   352
                   with:[:newContents |
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   353
                                Transcript showCR:'accepted:'.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   354
                                Transcript showCR:newContents asString.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   355
                                currentContents := newContents.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   356
                                model changed:#contents
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   357
                        ].
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   358
        model respondTo:#getList
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   359
                   with:[Transcript showCR:'query'.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   360
                         currentContents].
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   361
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   362
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   363
        top1 := StandardSystemView new.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   364
        top1 extent:300@200.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   365
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   366
        textView1 := EditTextView new.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   367
        textView1 origin:0.0 @ 0.0 corner:1.0 @ 1.0.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   368
        top1 addSubView:textView1.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   369
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   370
        textView1 listMessage:#getList;
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   371
                  model:model;
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   372
                  aspect:#contents;
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   373
                  changeMessage:#accepted:.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   374
        top1 open.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   375
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   376
        top2 := StandardSystemView new.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   377
        top2 extent:300@200.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   378
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   379
        textView2 := EditTextView new.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   380
        textView2 origin:0.0 @ 0.0 corner:1.0 @ 1.0.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   381
        top2 addSubView:textView2.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   382
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   383
        textView2 listMessage:#getList;
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   384
                  model:model;
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   385
                  aspect:#contents;
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   386
                  changeMessage:#accepted:.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   387
        top2 open.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   388
                                                                        [exEnd]
297
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   389
"
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   390
! !
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   391
865
d42c7c99e67d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 840
diff changeset
   392
!EditTextView class methodsFor:'defaults'!
59
450ce95a72a4 *** empty log message ***
claus
parents: 46
diff changeset
   393
1419
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   394
st80Mode
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   395
    "return true, if the st80 editing mode is turned on.
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   396
     This setting affects the behavior of the cursor, when positioned
3023
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
   397
     beyond the end of a line or the end of the text."
1419
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   398
2647
23dca8f032c3 changed st80Mode from classVar to userPreferences value
Claus Gittinger <cg@exept.de>
parents: 2627
diff changeset
   399
    ^ UserPreferences current st80EditMode
1419
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   400
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   401
   "
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   402
    EditTextView st80Mode:true
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   403
    EditTextView st80Mode:false
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   404
   "
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   405
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   406
    "Modified: / 16.1.1998 / 22:54:57 / cg"
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   407
!
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   408
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   409
st80Mode:aBoolean
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   410
    "turns on/off st80 behavior, where the cursor cannot be positioned
2707
810c994db0b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2696
diff changeset
   411
     beyond the end of a line or the last line"
1419
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   412
2647
23dca8f032c3 changed st80Mode from classVar to userPreferences value
Claus Gittinger <cg@exept.de>
parents: 2627
diff changeset
   413
    UserPreferences current st80EditMode:aBoolean.
1419
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   414
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   415
   "
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   416
    EditTextView st80Mode:true
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   417
    EditTextView st80Mode:false
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   418
   "
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   419
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   420
    "Modified: / 16.1.1998 / 22:55:19 / cg"
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   421
!
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   422
59
450ce95a72a4 *** empty log message ***
claus
parents: 46
diff changeset
   423
updateStyleCache
440
2beb33cb0146 added style resource directive
Claus Gittinger <cg@exept.de>
parents: 428
diff changeset
   424
    "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
   425
1390
99674e1d9c85 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
   426
    <resource: #style (#'textCursor.foregroundColor' #'textCursor.backgroundColor'
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   427
                       #'textCursor.noFocusForegroundColor' 
3114
ae98b76a709e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3058
diff changeset
   428
                       #'textCursor.type' 
ae98b76a709e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3058
diff changeset
   429
                       #'textCursor.typeNoFocus'
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   430
                       #'editText.st80Mode')>
1355
6725ab9cc6f5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
   431
6725ab9cc6f5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
   432
    DefaultCursorForegroundColor := StyleSheet colorAt:'textCursor.foregroundColor'.
6725ab9cc6f5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
   433
    DefaultCursorBackgroundColor := StyleSheet colorAt:'textCursor.backgroundColor'.
6725ab9cc6f5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
   434
    DefaultCursorNoFocusForegroundColor := StyleSheet colorAt:'textCursor.noFocusForegroundColor'.
6725ab9cc6f5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
   435
    DefaultCursorType := StyleSheet at:'textCursor.type' default:#block.
1534
bcb211e1b41a read noFocus cursorStyle from styleSheet
Claus Gittinger <cg@exept.de>
parents: 1533
diff changeset
   436
    DefaultCursorTypeNoFocus := StyleSheet at:'textCursor.typeNoFocus'.
bcb211e1b41a read noFocus cursorStyle from styleSheet
Claus Gittinger <cg@exept.de>
parents: 1533
diff changeset
   437
1419
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   438
    "
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   439
     self updateStyleCache
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   440
    "
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   441
1534
bcb211e1b41a read noFocus cursorStyle from styleSheet
Claus Gittinger <cg@exept.de>
parents: 1533
diff changeset
   442
    "Modified: / 20.5.1998 / 04:27:41 / cg"
59
450ce95a72a4 *** empty log message ***
claus
parents: 46
diff changeset
   443
! !
450ce95a72a4 *** empty log message ***
claus
parents: 46
diff changeset
   444
2744
cb920467a4b4 method category rename
Claus Gittinger <cg@exept.de>
parents: 2730
diff changeset
   445
!EditTextView methodsFor:'Compatibility-ST80'!
1552
d3d4afaf4c68 dummy ST80 compatibility: #autoAccept:
Claus Gittinger <cg@exept.de>
parents: 1548
diff changeset
   446
d3d4afaf4c68 dummy ST80 compatibility: #autoAccept:
Claus Gittinger <cg@exept.de>
parents: 1548
diff changeset
   447
autoAccept:aBoolean
d3d4afaf4c68 dummy ST80 compatibility: #autoAccept:
Claus Gittinger <cg@exept.de>
parents: 1548
diff changeset
   448
    "ignored for now"
d3d4afaf4c68 dummy ST80 compatibility: #autoAccept:
Claus Gittinger <cg@exept.de>
parents: 1548
diff changeset
   449
2019
b6b078ea3bbf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2018
diff changeset
   450
    "Created: / 5.6.1998 / 15:30:32 / cg "
1585
9bf6cf249376 two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents: 1580
diff changeset
   451
!
9bf6cf249376 two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents: 1580
diff changeset
   452
9bf6cf249376 two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents: 1580
diff changeset
   453
continuousAccept:aBoolean
9bf6cf249376 two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents: 1580
diff changeset
   454
    "ignored for now"
9bf6cf249376 two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents: 1580
diff changeset
   455
9bf6cf249376 two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents: 1580
diff changeset
   456
    "Created: / 19.6.1998 / 00:03:49 / cg"
9bf6cf249376 two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents: 1580
diff changeset
   457
!
9bf6cf249376 two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents: 1580
diff changeset
   458
1390
99674e1d9c85 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
   459
cutSelection
99674e1d9c85 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
   460
    self cut
99674e1d9c85 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
   461
99674e1d9c85 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
   462
    "Created: / 31.10.1997 / 03:29:50 / cg"
99674e1d9c85 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
   463
!
99674e1d9c85 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
   464
1590
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   465
deselect
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   466
    "remove the selection"
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   467
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   468
    ^ self unselect
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   469
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   470
    "Created: / 19.6.1998 / 02:41:54 / cg"
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   471
!
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   472
2101
8f2fab818f71 category renamining
Claus Gittinger <cg@exept.de>
parents: 2088
diff changeset
   473
enabled:aBoolean
8f2fab818f71 category renamining
Claus Gittinger <cg@exept.de>
parents: 2088
diff changeset
   474
8f2fab818f71 category renamining
Claus Gittinger <cg@exept.de>
parents: 2088
diff changeset
   475
    self readOnly:aBoolean not
8f2fab818f71 category renamining
Claus Gittinger <cg@exept.de>
parents: 2088
diff changeset
   476
8f2fab818f71 category renamining
Claus Gittinger <cg@exept.de>
parents: 2088
diff changeset
   477
    "Created: / 30.3.1999 / 15:10:23 / stefan"
8f2fab818f71 category renamining
Claus Gittinger <cg@exept.de>
parents: 2088
diff changeset
   478
    "Modified: / 30.3.1999 / 15:10:53 / stefan"
8f2fab818f71 category renamining
Claus Gittinger <cg@exept.de>
parents: 2088
diff changeset
   479
!
8f2fab818f71 category renamining
Claus Gittinger <cg@exept.de>
parents: 2088
diff changeset
   480
1732
2d433e114bbc added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 1717
diff changeset
   481
find:pattern
2d433e114bbc added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 1717
diff changeset
   482
    self searchFwd:pattern ifAbsent:nil
2d433e114bbc added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 1717
diff changeset
   483
2d433e114bbc added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 1717
diff changeset
   484
    "Created: / 29.1.1999 / 19:09:42 / cg"
2d433e114bbc added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 1717
diff changeset
   485
    "Modified: / 29.1.1999 / 19:10:12 / cg"
2d433e114bbc added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 1717
diff changeset
   486
!
2d433e114bbc added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 1717
diff changeset
   487
1294
dac755d4acd3 added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   488
insert:aString at:aCharacterPosition
dac755d4acd3 added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   489
    "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
   490
dac755d4acd3 added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   491
    |line col|
dac755d4acd3 added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   492
dac755d4acd3 added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   493
    line := self lineOfCharacterPosition:aCharacterPosition.
dac755d4acd3 added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   494
    col := aCharacterPosition - (self characterPositionOfLine:line col:1) + 1.
1480
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
   495
    col < 1 ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   496
        col := 1
1480
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
   497
    ].
1294
dac755d4acd3 added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   498
    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
   499
dac755d4acd3 added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   500
    "
dac755d4acd3 added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   501
     |top v|
dac755d4acd3 added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   502
dac755d4acd3 added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   503
     top := StandardSystemView new.
dac755d4acd3 added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   504
     top extent:300@300.
dac755d4acd3 added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   505
     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
   506
     top openAndWait.
dac755d4acd3 added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   507
     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
   508
     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
   509
    "
dac755d4acd3 added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   510
1480
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
   511
    "Modified: / 5.4.1998 / 17:20:08 / cg"
1294
dac755d4acd3 added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   512
!
dac755d4acd3 added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   513
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   514
insertAndSelect:aString at:aCharacterPosition
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   515
    "insert a selected string at aCharacterPosition."
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   516
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   517
    |line col|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   518
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   519
    line := self lineOfCharacterPosition:aCharacterPosition.
2310
861ab02b13b9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2225
diff changeset
   520
    col := (aCharacterPosition - (self characterPositionOfLine:line col:1) + 1) max:1.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   521
    self insertString:aString atLine:line col:col.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   522
    self selectFromLine:line col:col toLine:line col:col + aString size - 1
125
claus
parents: 123
diff changeset
   523
    "
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   524
     |v|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   525
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   526
     v := EditTextView new openAndWait.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   527
     v contents:'1234567890\1234567890\1234567890\' withCRs.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   528
     v insertAndSelect:'<- hello there' at:5.
125
claus
parents: 123
diff changeset
   529
    "
1390
99674e1d9c85 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
   530
!
99674e1d9c85 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
   531
99674e1d9c85 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
   532
pasteSelection
99674e1d9c85 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
   533
    self paste
99674e1d9c85 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
   534
99674e1d9c85 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
   535
    "Created: / 31.10.1997 / 03:28:53 / cg"
1590
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   536
!
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   537
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   538
replaceSelectionWith:aString
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   539
    ^ self replaceSelectionBy:aString
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   540
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   541
    "Created: / 19.6.1998 / 02:42:32 / cg"
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   542
!
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   543
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   544
selectAt:pos
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   545
    "move the cursor before cursorPosition."
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   546
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   547
    self cursorToCharacterPosition:pos
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   548
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   549
    "Modified: / 19.6.1998 / 02:41:28 / cg"
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   550
    "Created: / 19.6.1998 / 02:43:39 / cg"
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   551
!
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   552
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   553
selectFrom:startPos to:endPos
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   554
    "change the selection given two aCharacterPositions."
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   555
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   556
    |line1 col1 line2 col2|
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   557
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   558
    startPos > endPos ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   559
        ^ self unselect
1590
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   560
    ].
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   561
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   562
    line1 := self lineOfCharacterPosition:startPos.
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   563
    col1 := startPos - (self characterPositionOfLine:line1 col:1) + 1.
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   564
    col1 < 1 ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   565
        col1 := 1
1590
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   566
    ].
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   567
    line2 := self lineOfCharacterPosition:endPos.
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   568
    col2 := startPos - (self characterPositionOfLine:line2 col:1) + 1.
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   569
    col2 < 1 ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   570
        col2 := 1
1590
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   571
    ].
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   572
    self selectFromLine:line1 col:col1 toLine:line2 col:col2
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   573
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   574
    "Modified: / 19.6.1998 / 02:41:28 / cg"
2101
8f2fab818f71 category renamining
Claus Gittinger <cg@exept.de>
parents: 2088
diff changeset
   575
!
8f2fab818f71 category renamining
Claus Gittinger <cg@exept.de>
parents: 2088
diff changeset
   576
8f2fab818f71 category renamining
Claus Gittinger <cg@exept.de>
parents: 2088
diff changeset
   577
textHasChanged
8f2fab818f71 category renamining
Claus Gittinger <cg@exept.de>
parents: 2088
diff changeset
   578
    ^ self modified
8f2fab818f71 category renamining
Claus Gittinger <cg@exept.de>
parents: 2088
diff changeset
   579
8f2fab818f71 category renamining
Claus Gittinger <cg@exept.de>
parents: 2088
diff changeset
   580
    "Created: / 19.6.1998 / 00:09:43 / cg"
2117
b50c6d182e28 added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 2107
diff changeset
   581
!
b50c6d182e28 added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 2107
diff changeset
   582
b50c6d182e28 added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 2107
diff changeset
   583
textHasChanged:aBoolean
b50c6d182e28 added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 2107
diff changeset
   584
    "ST-80 compatibility: set/clear the modified flag."
b50c6d182e28 added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 2107
diff changeset
   585
b50c6d182e28 added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 2107
diff changeset
   586
    self modified:aBoolean
b50c6d182e28 added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 2107
diff changeset
   587
b50c6d182e28 added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 2107
diff changeset
   588
    "Created: / 5.2.2000 / 17:07:59 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   589
! !
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   590
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   591
!EditTextView methodsFor:'accessing-behavior'!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   592
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   593
acceptAction
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   594
    "return the action to be performed on accept (or nil)"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   595
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   596
    ^ acceptAction
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   597
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   598
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   599
acceptAction:aBlock
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   600
    "set the action to be performed on accept"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   601
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   602
    acceptAction := aBlock
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   603
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   604
2792
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   605
acceptChannel
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   606
    "return the valueHolder holding true if text was accepted.
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   607
     By placing a true into this channel, an accept can also be forced."
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   608
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   609
    ^ acceptChannel
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   610
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   611
    "Modified: / 30.1.1998 / 14:17:11 / cg"
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   612
!
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   613
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   614
acceptChannel:aValueHolder
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   615
    "set the valueHolder holding true if text was accepted.
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   616
     By placing a true into this channel, an accept can also be forced."
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   617
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   618
    |prev|
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   619
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   620
    prev := acceptChannel.
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   621
    acceptChannel := aValueHolder.
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   622
    self setupChannel:aValueHolder for:nil withOld:prev
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   623
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   624
    "Created: / 30.1.1998 / 14:51:09 / cg"
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   625
!
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   626
1108
3d14bb6bceb7 added disableAccept
Claus Gittinger <cg@exept.de>
parents: 1082
diff changeset
   627
acceptEnabled:aBoolean
3d14bb6bceb7 added disableAccept
Claus Gittinger <cg@exept.de>
parents: 1082
diff changeset
   628
    "enable/disable accept. This greys the corresponding item in the menu"
3d14bb6bceb7 added disableAccept
Claus Gittinger <cg@exept.de>
parents: 1082
diff changeset
   629
3d14bb6bceb7 added disableAccept
Claus Gittinger <cg@exept.de>
parents: 1082
diff changeset
   630
    acceptEnabled := aBoolean
3d14bb6bceb7 added disableAccept
Claus Gittinger <cg@exept.de>
parents: 1082
diff changeset
   631
3d14bb6bceb7 added disableAccept
Claus Gittinger <cg@exept.de>
parents: 1082
diff changeset
   632
    "Created: 7.3.1997 / 11:04:34 / cg"
3d14bb6bceb7 added disableAccept
Claus Gittinger <cg@exept.de>
parents: 1082
diff changeset
   633
!
3d14bb6bceb7 added disableAccept
Claus Gittinger <cg@exept.de>
parents: 1082
diff changeset
   634
2792
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   635
accepted
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   636
    "return true if text was accepted"
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   637
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   638
    ^ acceptChannel value
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   639
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   640
    "Created: 14.2.1997 / 16:43:46 / cg"
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   641
!
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   642
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   643
accepted:aBoolean
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   644
    "set/clear the accepted flag.
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   645
     This may force my current contents to be placed into my model."
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   646
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   647
    acceptChannel value:aBoolean.
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   648
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   649
    "Created: / 14.2.1997 / 16:44:01 / cg"
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   650
    "Modified: / 30.1.1998 / 14:20:15 / cg"
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   651
!
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   652
474
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   653
autoIndent:aBoolean
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   654
    autoIndent := aBoolean
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   655
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   656
    "Created: 5.3.1996 / 14:37:50 / cg"
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   657
!
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   658
2774
0415ba0f8cb5 cursorMovement getter
penk
parents: 2762
diff changeset
   659
cursorMovementWhenUpdating
0415ba0f8cb5 cursorMovement getter
penk
parents: 2762
diff changeset
   660
    "return what is be done with the cursor, 
0415ba0f8cb5 cursorMovement getter
penk
parents: 2762
diff changeset
   661
     when I get a new text (via the model or the #contents/#list)
0415ba0f8cb5 cursorMovement getter
penk
parents: 2762
diff changeset
   662
     Allowed arguments are:
0415ba0f8cb5 cursorMovement getter
penk
parents: 2762
diff changeset
   663
        #keep / nil     -> stay where it was
0415ba0f8cb5 cursorMovement getter
penk
parents: 2762
diff changeset
   664
        #endOfText      -> position cursor to the end
0415ba0f8cb5 cursorMovement getter
penk
parents: 2762
diff changeset
   665
        #beginOfText    -> position cursor to the beginning
0415ba0f8cb5 cursorMovement getter
penk
parents: 2762
diff changeset
   666
        #endOfLine      -> position cursor to the current lines end
0415ba0f8cb5 cursorMovement getter
penk
parents: 2762
diff changeset
   667
        #beginOfLine    -> position cursor to the current lines start
0415ba0f8cb5 cursorMovement getter
penk
parents: 2762
diff changeset
   668
     The default is #beginOfText.
0415ba0f8cb5 cursorMovement getter
penk
parents: 2762
diff changeset
   669
     This may be useful for fields which get new values assigned from
0415ba0f8cb5 cursorMovement getter
penk
parents: 2762
diff changeset
   670
     the program (i.e. not from the user)"
0415ba0f8cb5 cursorMovement getter
penk
parents: 2762
diff changeset
   671
0415ba0f8cb5 cursorMovement getter
penk
parents: 2762
diff changeset
   672
    ^ cursorMovementWhenUpdating
0415ba0f8cb5 cursorMovement getter
penk
parents: 2762
diff changeset
   673
0415ba0f8cb5 cursorMovement getter
penk
parents: 2762
diff changeset
   674
    "Modified: 16.12.1995 / 16:27:55 / cg"
0415ba0f8cb5 cursorMovement getter
penk
parents: 2762
diff changeset
   675
!
0415ba0f8cb5 cursorMovement getter
penk
parents: 2762
diff changeset
   676
2133
47a23fdfc83f comment
Claus Gittinger <cg@exept.de>
parents: 2131
diff changeset
   677
cursorMovementWhenUpdating:aSymbolOrNil
47a23fdfc83f comment
Claus Gittinger <cg@exept.de>
parents: 2131
diff changeset
   678
    "define what should be done with the cursor, 
47a23fdfc83f comment
Claus Gittinger <cg@exept.de>
parents: 2131
diff changeset
   679
     when I get a new text (via the model or the #contents/#list)
47a23fdfc83f comment
Claus Gittinger <cg@exept.de>
parents: 2131
diff changeset
   680
     Allowed arguments are:
47a23fdfc83f comment
Claus Gittinger <cg@exept.de>
parents: 2131
diff changeset
   681
        #keep / nil     -> stay where it was
47a23fdfc83f comment
Claus Gittinger <cg@exept.de>
parents: 2131
diff changeset
   682
        #endOfText      -> position cursor to the end
47a23fdfc83f comment
Claus Gittinger <cg@exept.de>
parents: 2131
diff changeset
   683
        #beginOfText    -> position cursor to the beginning
47a23fdfc83f comment
Claus Gittinger <cg@exept.de>
parents: 2131
diff changeset
   684
        #endOfLine      -> position cursor to the current lines end
47a23fdfc83f comment
Claus Gittinger <cg@exept.de>
parents: 2131
diff changeset
   685
        #beginOfLine    -> position cursor to the current lines start
47a23fdfc83f comment
Claus Gittinger <cg@exept.de>
parents: 2131
diff changeset
   686
     The default is #beginOfText.
2129
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   687
     This may be useful for fields which get new values assigned from
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   688
     the program (i.e. not from the user)"
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   689
2133
47a23fdfc83f comment
Claus Gittinger <cg@exept.de>
parents: 2131
diff changeset
   690
    cursorMovementWhenUpdating := aSymbolOrNil
2129
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   691
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   692
    "Modified: 16.12.1995 / 16:27:55 / cg"
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   693
!
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   694
2035
6924861adf08 added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents: 2029
diff changeset
   695
disableIfInvisible:aBoolean
6924861adf08 added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents: 2029
diff changeset
   696
    disableIfInvisible := aBoolean
6924861adf08 added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents: 2029
diff changeset
   697
!
6924861adf08 added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents: 2029
diff changeset
   698
2438
6406f4444ee4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2432
diff changeset
   699
dontReplaceSelectionOnInput
6406f4444ee4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2432
diff changeset
   700
    typeOfSelection := #paste
6406f4444ee4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2432
diff changeset
   701
!
6406f4444ee4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2432
diff changeset
   702
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   703
exceptionBlock:aBlock
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   704
    "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
   705
     readonly text"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   706
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   707
    exceptionBlock := aBlock
323
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   708
!
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   709
477
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
   710
insertMode:aBoolean
2795
1f7b5f242eee learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents: 2792
diff changeset
   711
    insertMode value:aBoolean
477
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
   712
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
   713
    "Created: 6.3.1996 / 12:24:05 / cg"
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
   714
!
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
   715
2795
1f7b5f242eee learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents: 2792
diff changeset
   716
insertModeHolder
1f7b5f242eee learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents: 2792
diff changeset
   717
    ^ insertMode
1f7b5f242eee learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents: 2792
diff changeset
   718
!
1f7b5f242eee learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents: 2792
diff changeset
   719
2792
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   720
isReadOnly
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   721
    "return true, if the text is readonly."
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   722
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   723
    ^ readOnly value
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   724
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   725
    "Modified: 14.2.1997 / 17:35:56 / cg"
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   726
!
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   727
2796
481d9e54434c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2795
diff changeset
   728
modeLabelHolder
481d9e54434c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2795
diff changeset
   729
    "a valueHolder, which contains 'L' (learnMode), I (insertMode) or empty"
481d9e54434c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2795
diff changeset
   730
481d9e54434c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2795
diff changeset
   731
    ^ BlockValue 
481d9e54434c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2795
diff changeset
   732
        with:[:i :l | 
481d9e54434c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2795
diff changeset
   733
            l value 
481d9e54434c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2795
diff changeset
   734
                ifTrue:[
481d9e54434c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2795
diff changeset
   735
                    'L' asText allBold colorizeAllWith:Color red]
481d9e54434c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2795
diff changeset
   736
                ifFalse:[
481d9e54434c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2795
diff changeset
   737
                    i value 
481d9e54434c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2795
diff changeset
   738
                        ifTrue:[
481d9e54434c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2795
diff changeset
   739
                            'I']
481d9e54434c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2795
diff changeset
   740
                        ifFalse:[
481d9e54434c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2795
diff changeset
   741
                            nil]]]
481d9e54434c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2795
diff changeset
   742
        argument:(self insertModeHolder)
481d9e54434c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2795
diff changeset
   743
        argument:(self learnModeHolder).
481d9e54434c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2795
diff changeset
   744
!
481d9e54434c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2795
diff changeset
   745
2792
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   746
modified
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   747
    "return true if text was modified"
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   748
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   749
    ^ modifiedChannel value
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   750
!
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   751
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   752
modified:aBoolean
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   753
    "set/clear the modified flag"
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   754
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   755
    modifiedChannel value:aBoolean
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   756
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   757
    "Modified: 14.2.1997 / 16:44:05 / cg"
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   758
!
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   759
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   760
modifiedChannel
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   761
    "return the valueHolder holding true if text was modified"
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   762
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   763
    ^ modifiedChannel
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   764
!
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   765
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   766
modifiedChannel:aValueHolder
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   767
    "set the valueHolder holding true if text was modified"
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   768
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   769
    |prev|
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   770
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   771
    prev := modifiedChannel.
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   772
    modifiedChannel := aValueHolder.
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   773
    self setupChannel:aValueHolder for:nil withOld:prev
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   774
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   775
    "Created: / 30.1.1998 / 14:51:32 / cg"
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   776
!
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   777
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   778
readOnly
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   779
    "make the text readonly.
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   780
     Somewhat obsolete - use #readOnly:"
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   781
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   782
    <resource:#obsolete>
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   783
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   784
    self obsoleteMethodWarning:'use #readOnly:'.
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   785
    readOnly := true
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   786
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   787
    "Modified: 14.2.1997 / 17:35:56 / cg"
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   788
!
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   789
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   790
readOnly:aBoolean
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   791
    "make the text readonly (aBoolean == true) or writable (aBoolean == false).
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   792
     The argument may also be a valueHolder."
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   793
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   794
    readOnly := aBoolean
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   795
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   796
    "Created: 14.2.1997 / 17:35:39 / cg"
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   797
!
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   798
323
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   799
tabMeansNextField:aBoolean
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   800
    "set/clear tabbing to the next field.
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   801
     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
   802
     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
   803
     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
   804
     input fields."
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   805
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   806
    tabMeansNextField := aBoolean
2779
5ca530482fdd unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 2774
diff changeset
   807
!
5ca530482fdd unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 2774
diff changeset
   808
5ca530482fdd unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 2774
diff changeset
   809
tabRequiresControl
5ca530482fdd unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 2774
diff changeset
   810
    "returns true, if a focus tabbing requires a control-key to be pressed.
5ca530482fdd unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 2774
diff changeset
   811
     The default is true for editTextView, false for other widgets,
5ca530482fdd unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 2774
diff changeset
   812
     to allow for easier text entry"
5ca530482fdd unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 2774
diff changeset
   813
5ca530482fdd unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 2774
diff changeset
   814
    ^ tabRequiresControl 
5ca530482fdd unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 2774
diff changeset
   815
!
5ca530482fdd unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 2774
diff changeset
   816
5ca530482fdd unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 2774
diff changeset
   817
tabRequiresControl:aBoolean
5ca530482fdd unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 2774
diff changeset
   818
    "controls if a focus tabbing requires a control-key to be pressed.
5ca530482fdd unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 2774
diff changeset
   819
     The default is true for editTextView, false for other widgets,
5ca530482fdd unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 2774
diff changeset
   820
     to allow for easier text entry"
5ca530482fdd unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 2774
diff changeset
   821
5ca530482fdd unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 2774
diff changeset
   822
    tabRequiresControl := aBoolean
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   823
! !
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   824
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   825
!EditTextView methodsFor:'accessing-contents'!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   826
1902
302a68c2255e added #at:basicPut: to access a line without change notification.
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   827
at:lineNr basicPut:aLine
302a68c2255e added #at:basicPut: to access a line without change notification.
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   828
    "change a line without change notification"
302a68c2255e added #at:basicPut: to access a line without change notification.
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   829
302a68c2255e added #at:basicPut: to access a line without change notification.
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   830
    (self at:lineNr) = aLine ifFalse:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   831
        super at:lineNr put:aLine.
1902
302a68c2255e added #at:basicPut: to access a line without change notification.
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   832
    ].
302a68c2255e added #at:basicPut: to access a line without change notification.
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   833
!
302a68c2255e added #at:basicPut: to access a line without change notification.
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   834
522
aa9458e4643e indent/undent did not trigger a modify
ca
parents: 503
diff changeset
   835
at:lineNr put:aLine
aa9458e4643e indent/undent did not trigger a modify
ca
parents: 503
diff changeset
   836
    (self at:lineNr) = aLine ifFalse:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   837
        super at:lineNr put:aLine.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   838
        self textChanged
522
aa9458e4643e indent/undent did not trigger a modify
ca
parents: 503
diff changeset
   839
    ].
aa9458e4643e indent/undent did not trigger a modify
ca
parents: 503
diff changeset
   840
!
aa9458e4643e indent/undent did not trigger a modify
ca
parents: 503
diff changeset
   841
1577
4e487247ad33 dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents: 1568
diff changeset
   842
characterBeforeCursor
2707
810c994db0b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2696
diff changeset
   843
    "return the character under the cursor - space if beyond line.
1577
4e487247ad33 dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents: 1568
diff changeset
   844
     For non-block cursors, this is the character immediately to the right
4e487247ad33 dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents: 1568
diff changeset
   845
     of the insertion-bar or caret."
4e487247ad33 dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents: 1568
diff changeset
   846
4e487247ad33 dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents: 1568
diff changeset
   847
    cursorCol == 1 ifTrue:[^ nil].
4e487247ad33 dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents: 1568
diff changeset
   848
4e487247ad33 dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents: 1568
diff changeset
   849
    ^ self characterAtLine:cursorLine col:cursorCol-1
4e487247ad33 dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents: 1568
diff changeset
   850
4e487247ad33 dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents: 1568
diff changeset
   851
    "Created: / 17.6.1998 / 15:16:41 / cg"
4e487247ad33 dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents: 1568
diff changeset
   852
!
4e487247ad33 dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents: 1568
diff changeset
   853
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   854
characterUnderCursor
2707
810c994db0b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2696
diff changeset
   855
    "return the character under the cursor - space if beyond line.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   856
     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
   857
     of the insertion-bar or caret."
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   858
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   859
    ^ self characterAtLine:cursorLine col:cursorCol
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   860
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   861
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   862
contents
2213
6068f2786bd6 added #contentsAsString
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
   863
    "return the contents as a String or Text (i.e. with emphasis)"
259
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
    list isNil ifTrue:[^ ''].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   866
    self removeTrailingBlankLines.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   867
    ^ list asStringWithCRs
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
2213
6068f2786bd6 added #contentsAsString
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
   870
contentsAsString
6068f2786bd6 added #contentsAsString
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
   871
    "return the contents as a String (i.e. without emphasis)"
6068f2786bd6 added #contentsAsString
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
   872
6068f2786bd6 added #contentsAsString
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
   873
    list isNil ifTrue:[^ ''].
6068f2786bd6 added #contentsAsString
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
   874
    self removeTrailingBlankLines.
6068f2786bd6 added #contentsAsString
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
   875
    ^ (list collect:[:each | each isNil ifTrue:['']
6068f2786bd6 added #contentsAsString
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
   876
                                        ifFalse:[each string]
6068f2786bd6 added #contentsAsString
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
   877
                    ]) asStringWithCRs
6068f2786bd6 added #contentsAsString
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
   878
!
6068f2786bd6 added #contentsAsString
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
   879
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   880
cursorCol
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   881
    "return the cursors col (1..).
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   882
     This is the absolute col; NOT the visible col"
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
    ^ cursorCol
125
claus
parents: 123
diff changeset
   885
!
claus
parents: 123
diff changeset
   886
2422
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   887
cursorColHolder
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   888
    "return a valueHolder for the cursors column (1..)."
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   889
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   890
    ^ cursorColHolder
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   891
!
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   892
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   893
cursorLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   894
    "return the cursors line (1..). 
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   895
     This is the absolute line; NOT the visible line"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   896
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   897
    ^ cursorLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   898
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   899
2422
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   900
cursorLineHolder
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   901
    "return a valueHolder for the cursors line (1..). 
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   902
     This is the absolute line; NOT the visible line"
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   903
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   904
    ^ cursorLineHolder
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   905
!
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
   906
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   907
fixedSize
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   908
    "make the texts size fixed (no lines may be added).
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   909
     OBSOLETE: use readOnly"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   910
2363
1982139b2c0b Use <resource:#obsolete>
Stefan Vogel <sv@exept.de>
parents: 2357
diff changeset
   911
    <resource:#obsolete>
1982139b2c0b Use <resource:#obsolete>
Stefan Vogel <sv@exept.de>
parents: 2357
diff changeset
   912
1018
427190d7026f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1017
diff changeset
   913
    self obsoleteMethodWarning:'use #readOnly:'.
1733
c5139b7402f0 use self isReadonly; readOnly may now be a valueHolder.
Claus Gittinger <cg@exept.de>
parents: 1732
diff changeset
   914
    readOnly == true ifFalse:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   915
        readOnly := true.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   916
        middleButtonMenu notNil ifTrue:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   917
            middleButtonMenu disableAll:#(cut paste replace indent)
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   918
        ]
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   919
    ]
1018
427190d7026f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1017
diff changeset
   920
427190d7026f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1017
diff changeset
   921
    "Modified: 14.2.1997 / 17:35:24 / cg"
127
claus
parents: 125
diff changeset
   922
!
claus
parents: 125
diff changeset
   923
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   924
list:something
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   925
    "position cursor home when setting contents"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   926
2129
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   927
    |prevCursorLine prevCursorCol|
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   928
2989
5dcc2912bcb6 undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents: 2984
diff changeset
   929
    undoSupport resetHistories.
2955
Claus Gittinger <cg@exept.de>
parents: 2954
diff changeset
   930
2129
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   931
    prevCursorLine := cursorLine.
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   932
    prevCursorCol := cursorCol.
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   933
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   934
    super list:something.
2129
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   935
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   936
    (cursorMovementWhenUpdating == #endOfText
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   937
    or:[cursorMovementWhenUpdating == #end]) ifTrue:[
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   938
        ^ self cursorToEndOfText
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   939
    ].
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   940
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   941
    (cursorMovementWhenUpdating == #endOfLine) ifTrue:[
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   942
        ^ self cursorLine:prevCursorLine col:(self listAt:cursorLine) size + 1.
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   943
    ].    
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   944
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   945
    (cursorMovementWhenUpdating == #beginOfText
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   946
    or:[cursorMovementWhenUpdating == #begin]) ifTrue:[
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   947
        ^ self cursorHome
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   948
    ].
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   949
    (cursorMovementWhenUpdating == #beginOfLine) ifTrue:[
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   950
        ^ self cursorLine:prevCursorLine col:1.
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   951
    ].
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   952
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   953
    "/ default: stay where it was
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   954
    "/ self cursorLine:prevCursorLine col:prevCursorCol.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   955
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   956
1476
ac38c8af8585 setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents: 1449
diff changeset
   957
setContents:something
ac38c8af8585 setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents: 1449
diff changeset
   958
    |selType|
ac38c8af8585 setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents: 1449
diff changeset
   959
2989
5dcc2912bcb6 undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents: 2984
diff changeset
   960
    undoSupport resetHistories.
2955
Claus Gittinger <cg@exept.de>
parents: 2954
diff changeset
   961
1476
ac38c8af8585 setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents: 1449
diff changeset
   962
    selType := typeOfSelection.
ac38c8af8585 setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents: 1449
diff changeset
   963
    super setContents:something.
ac38c8af8585 setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents: 1449
diff changeset
   964
    typeOfSelection := selType.
ac38c8af8585 setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents: 1449
diff changeset
   965
ac38c8af8585 setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents: 1449
diff changeset
   966
    "Created: / 31.3.1998 / 23:35:06 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   967
! !
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   968
474
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   969
!EditTextView methodsFor:'accessing-look'!
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   970
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   971
cursorForegroundColor:color1 backgroundColor:color2
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   972
    "set both cursor foreground and cursor background colors"
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   973
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   974
    |wasOn|
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   975
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   976
    wasOn := self hideCursor.
1993
5ffe0b3943cd #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1967
diff changeset
   977
    cursorFgColor := color1 onDevice:device.
5ffe0b3943cd #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1967
diff changeset
   978
    cursorBgColor := color2 onDevice:device.
474
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   979
    wasOn ifTrue:[self showCursor]
1333
56af09878b96 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1325
diff changeset
   980
!
56af09878b96 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1325
diff changeset
   981
1899
c98fc612bab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
   982
cursorType
c98fc612bab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
   983
    "return the style of the text cursor.
c98fc612bab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
   984
     Currently, supported are: #block, #frame, #ibeam, #caret, #solidCaret
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   985
                               #bigCaret and #bigSolidCaret"
1899
c98fc612bab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
   986
c98fc612bab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
   987
    ^ cursorType
c98fc612bab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
   988
c98fc612bab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
   989
    "Modified: / 5.5.1999 / 14:52:33 / cg"
c98fc612bab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
   990
!
c98fc612bab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
   991
1333
56af09878b96 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1325
diff changeset
   992
cursorType:aCursorTypeSymbol
56af09878b96 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1325
diff changeset
   993
    "set the style of the text cursor.
56af09878b96 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1325
diff changeset
   994
     Currently, supported are: #block, #frame, #ibeam, #caret, #solidCaret
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
   995
                               #bigCaret and #bigSolidCaret"
1333
56af09878b96 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1325
diff changeset
   996
1334
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
   997
    cursorType := aCursorTypeSymbol.
1333
56af09878b96 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1325
diff changeset
   998
56af09878b96 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1325
diff changeset
   999
    "Created: 21.9.1997 / 13:42:23 / cg"
56af09878b96 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1325
diff changeset
  1000
    "Modified: 21.9.1997 / 13:43:35 / cg"
1334
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  1001
!
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  1002
1899
c98fc612bab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
  1003
cursorTypeNoFocus
c98fc612bab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
  1004
    "return the style of the text cursor when the view has no focus.
c98fc612bab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
  1005
     If left unspecified, this is the same as the regular cursorType."
c98fc612bab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
  1006
c98fc612bab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
  1007
    ^ cursorTypeNoFocus
c98fc612bab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
  1008
c98fc612bab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
  1009
    "Created: / 5.5.1999 / 14:52:46 / cg"
c98fc612bab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
  1010
!
c98fc612bab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
  1011
1334
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  1012
cursorTypeNoFocus:aCursorTypeSymbol
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  1013
    "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
  1014
     If left unspecified, this is the same as the regular cursorType."
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  1015
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  1016
    cursorTypeNoFocus := aCursorTypeSymbol
474
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  1017
! !
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  1018
2119
2aa585fc62a3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2117
diff changeset
  1019
!EditTextView methodsFor:'change & update'!
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1020
125
claus
parents: 123
diff changeset
  1021
accept
claus
parents: 123
diff changeset
  1022
    "accept the current contents by executing the accept-action and/or
claus
parents: 123
diff changeset
  1023
     changeMessage."
claus
parents: 123
diff changeset
  1024
1108
3d14bb6bceb7 added disableAccept
Claus Gittinger <cg@exept.de>
parents: 1082
diff changeset
  1025
    acceptEnabled == false ifTrue:[
3046
c2d66c9ba0d8 Send #beep to window instead of device
Stefan Vogel <sv@exept.de>
parents: 3044
diff changeset
  1026
        self beep.
2035
6924861adf08 added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents: 2029
diff changeset
  1027
        ^ self
6924861adf08 added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents: 2029
diff changeset
  1028
    ].
6924861adf08 added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents: 2029
diff changeset
  1029
    (disableIfInvisible == true and:[self reallyRealized not]) ifTrue:[
6924861adf08 added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents: 2029
diff changeset
  1030
        ^ self
1108
3d14bb6bceb7 added disableAccept
Claus Gittinger <cg@exept.de>
parents: 1082
diff changeset
  1031
    ].
3d14bb6bceb7 added disableAccept
Claus Gittinger <cg@exept.de>
parents: 1082
diff changeset
  1032
125
claus
parents: 123
diff changeset
  1033
    lockUpdates := true.
1013
391290c747b3 added an acceptChannel
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
  1034
391290c747b3 added an acceptChannel
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
  1035
    "/
391290c747b3 added an acceptChannel
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
  1036
    "/ ST-80 way of doing it
391290c747b3 added an acceptChannel
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
  1037
    "/
391290c747b3 added an acceptChannel
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
  1038
    model notNil ifTrue:[
2035
6924861adf08 added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents: 2029
diff changeset
  1039
        self sendChangeMessageWith:self argForChangeMessage.
1013
391290c747b3 added an acceptChannel
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
  1040
    ].
391290c747b3 added an acceptChannel
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
  1041
2999
40d3a383e8db *** empty log message ***
ca
parents: 2989
diff changeset
  1042
    model notNil ifTrue:[
40d3a383e8db *** empty log message ***
ca
parents: 2989
diff changeset
  1043
        acceptChannel value:true withoutNotifying:self.
40d3a383e8db *** empty log message ***
ca
parents: 2989
diff changeset
  1044
    ].
40d3a383e8db *** empty log message ***
ca
parents: 2989
diff changeset
  1045
757
2cc7e423f0ef only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents: 730
diff changeset
  1046
    "/
2cc7e423f0ef only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents: 730
diff changeset
  1047
    "/ ST/X way of doing things
2cc7e423f0ef only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents: 730
diff changeset
  1048
    "/ as a historic (and temporary) leftover,
2cc7e423f0ef only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents: 730
diff changeset
  1049
    "/ 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
  1050
    "/ - not with the actual string
2cc7e423f0ef only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents: 730
diff changeset
  1051
    "/
2cc7e423f0ef only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents: 730
diff changeset
  1052
    acceptAction notNil ifTrue:[
2035
6924861adf08 added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents: 2029
diff changeset
  1053
        acceptAction value:self list
757
2cc7e423f0ef only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents: 730
diff changeset
  1054
    ].
2cc7e423f0ef only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents: 730
diff changeset
  1055
125
claus
parents: 123
diff changeset
  1056
    lockUpdates := false.
757
2cc7e423f0ef only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents: 730
diff changeset
  1057
1437
ab84b08a9f9c allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
  1058
    "Modified: / 30.1.1998 / 14:19:00 / cg"
131
claus
parents: 130
diff changeset
  1059
!
claus
parents: 130
diff changeset
  1060
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1061
argForChangeMessage
597
fb42c94a042e commentary
Claus Gittinger <cg@exept.de>
parents: 594
diff changeset
  1062
    "return the argument to be passed with the change notification.
fb42c94a042e commentary
Claus Gittinger <cg@exept.de>
parents: 594
diff changeset
  1063
     Defined as separate method for easier subclassability."
fb42c94a042e commentary
Claus Gittinger <cg@exept.de>
parents: 594
diff changeset
  1064
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1065
    ^ self contents
597
fb42c94a042e commentary
Claus Gittinger <cg@exept.de>
parents: 594
diff changeset
  1066
fb42c94a042e commentary
Claus Gittinger <cg@exept.de>
parents: 594
diff changeset
  1067
    "Modified: 29.4.1996 / 12:42:14 / cg"
121
claus
parents: 118
diff changeset
  1068
!
claus
parents: 118
diff changeset
  1069
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1070
getListFromModel
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1071
    "get my contents from the model.
597
fb42c94a042e commentary
Claus Gittinger <cg@exept.de>
parents: 594
diff changeset
  1072
     Redefined to ignore updates resulting from my own changes
fb42c94a042e commentary
Claus Gittinger <cg@exept.de>
parents: 594
diff changeset
  1073
     (i.e. if lockUpdates is true)."
121
claus
parents: 118
diff changeset
  1074
claus
parents: 118
diff changeset
  1075
    "
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1076
     ignore updates from my own change
121
claus
parents: 118
diff changeset
  1077
    "
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1078
    lockUpdates ifTrue:[
2196
f8c955dd6eb9 validate the cursorLine, when updating from a changed model
Claus Gittinger <cg@exept.de>
parents: 2186
diff changeset
  1079
        lockUpdates := false.
f8c955dd6eb9 validate the cursorLine, when updating from a changed model
Claus Gittinger <cg@exept.de>
parents: 2186
diff changeset
  1080
        ^ self
121
claus
parents: 118
diff changeset
  1081
    ].
2196
f8c955dd6eb9 validate the cursorLine, when updating from a changed model
Claus Gittinger <cg@exept.de>
parents: 2186
diff changeset
  1082
    super getListFromModel.
f8c955dd6eb9 validate the cursorLine, when updating from a changed model
Claus Gittinger <cg@exept.de>
parents: 2186
diff changeset
  1083
f8c955dd6eb9 validate the cursorLine, when updating from a changed model
Claus Gittinger <cg@exept.de>
parents: 2186
diff changeset
  1084
    "/ validate the cursorLine
2310
861ab02b13b9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2225
diff changeset
  1085
    (cursorLine notNil 
861ab02b13b9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2225
diff changeset
  1086
     and:[ cursorLine > list size ]) ifTrue:[
2196
f8c955dd6eb9 validate the cursorLine, when updating from a changed model
Claus Gittinger <cg@exept.de>
parents: 2186
diff changeset
  1087
        self cursorLine:list size + 1 col:1
f8c955dd6eb9 validate the cursorLine, when updating from a changed model
Claus Gittinger <cg@exept.de>
parents: 2186
diff changeset
  1088
    ].
1437
ab84b08a9f9c allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
  1089
!
ab84b08a9f9c allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
  1090
ab84b08a9f9c allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
  1091
update:something with:aParameter from:changedObject
1438
bed1564b0640 fixed update for acceptChannel
Claus Gittinger <cg@exept.de>
parents: 1437
diff changeset
  1092
    changedObject == acceptChannel ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1093
        acceptChannel value == true ifTrue:[ 
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1094
            self accept.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1095
        ].
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1096
        ^ self.
1437
ab84b08a9f9c allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
  1097
    ].
ab84b08a9f9c allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
  1098
    super update:something with:aParameter from:changedObject
ab84b08a9f9c allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
  1099
ab84b08a9f9c allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
  1100
    "Created: / 30.1.1998 / 14:15:56 / cg"
1439
d1b3ca91ed8a fixed update for acceptChannel
Claus Gittinger <cg@exept.de>
parents: 1438
diff changeset
  1101
    "Modified: / 1.2.1998 / 13:15:55 / cg"
121
claus
parents: 118
diff changeset
  1102
! !
claus
parents: 118
diff changeset
  1103
claus
parents: 118
diff changeset
  1104
!EditTextView methodsFor:'cursor handling'!
claus
parents: 118
diff changeset
  1105
2406
aeabb4ccf07c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2404
diff changeset
  1106
characterPositionOfCursor
aeabb4ccf07c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2404
diff changeset
  1107
    ^ self characterPositionOfLine:cursorLine col:cursorCol
aeabb4ccf07c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2404
diff changeset
  1108
!
aeabb4ccf07c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2404
diff changeset
  1109
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1110
cursorBacktab
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1111
    "move cursor to prev tabstop"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1112
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1113
    self cursorCol:(self prevTabBefore:cursorCol).
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1114
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1115
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1116
cursorCol:newCol
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1117
    "move cursor to some column in the current line"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1118
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1119
    |wasOn|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1120
2822
08ceab3fc237 search refactored;
Claus Gittinger <cg@exept.de>
parents: 2819
diff changeset
  1121
    (cursorCol == newCol) ifTrue:[^ self].
08ceab3fc237 search refactored;
Claus Gittinger <cg@exept.de>
parents: 2819
diff changeset
  1122
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1123
    wasOn := self hideCursor.
2422
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1124
    self setValidatedCursorCol:newCol.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1125
    self makeCursorVisibleAndShowCursor:wasOn.
672
065750d02339 added cursorCol-validation
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  1126
065750d02339 added cursorCol-validation
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  1127
    "Modified: 22.5.1996 / 14:25:53 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1128
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1129
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1130
cursorDown
632
5af2c22002e4 dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
  1131
    "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
  1132
     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
  1133
5af2c22002e4 dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
  1134
    |wasOn|
5af2c22002e4 dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
  1135
5af2c22002e4 dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
  1136
    self cursorDown:1.
5af2c22002e4 dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
  1137
2707
810c994db0b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2696
diff changeset
  1138
    "/ cursor beyond text ?
632
5af2c22002e4 dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
  1139
    cursorLine > list size ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1140
        wasOn := self hideCursor.
2422
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1141
        self setValidatedCursorLine:(list size + 1) col:cursorCol.
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1142
        self makeCursorVisibleAndShowCursor:wasOn.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1143
        self beep.
632
5af2c22002e4 dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
  1144
    ].
5af2c22002e4 dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
  1145
1561
db5f27354172 make cursor correctly visible if in partial last line.
Claus Gittinger <cg@exept.de>
parents: 1560
diff changeset
  1146
    "Modified: / 10.6.1998 / 17:00:23 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1147
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1148
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1149
cursorDown:n
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1150
    "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
  1151
2422
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1152
    |wasOn nv nL|
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1153
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1154
    cursorVisibleLine notNil ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1155
        wasOn := self hideCursor.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1156
        nv := cursorVisibleLine + n - 1.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1157
        (nv >= nFullLinesShown) ifTrue:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1158
            self scrollDown:(nv - nFullLinesShown + 1)
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1159
        ].
2422
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1160
        self setValidatedCursorLine:(cursorLine + n) col:cursorCol.
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1161
        self makeCursorVisibleAndShowCursor:wasOn.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1162
    ] ifFalse:[
2422
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1163
        (nL := cursorLine) isNil ifTrue:[
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1164
            nL := firstLineShown
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1165
        ].
2422
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1166
        self setValidatedCursorLine:(nL + n) col:cursorCol.
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1167
        self makeCursorVisible.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1168
    ].
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  1169
1561
db5f27354172 make cursor correctly visible if in partial last line.
Claus Gittinger <cg@exept.de>
parents: 1560
diff changeset
  1170
    "Modified: / 10.6.1998 / 16:59:17 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1171
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1172
121
claus
parents: 118
diff changeset
  1173
cursorHome
597
fb42c94a042e commentary
Claus Gittinger <cg@exept.de>
parents: 594
diff changeset
  1174
    "scroll to top AND move cursor to first line of text."
121
claus
parents: 118
diff changeset
  1175
674
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  1176
    self cursorLine:1 col:1
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  1177
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  1178
"/    |wasOn|
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  1179
"/
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  1180
"/    wasOn := self hideCursor.
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  1181
"/    self scrollToTop.
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  1182
"/    cursorLine := cursorVisibleLine := 1.
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  1183
"/    cursorCol := self validateCursorCol:1 inLine:cursorLine.
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  1184
"/    self makeCursorVisibleAndShowCursor:wasOn.
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  1185
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  1186
    "Modified: 22.5.1996 / 18:26:42 / cg"
121
claus
parents: 118
diff changeset
  1187
!
claus
parents: 118
diff changeset
  1188
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1189
cursorLeft
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1190
    "move cursor to left"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1191
1300
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  1192
    (cursorCol ~~ 1) ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1193
        self cursorCol:(cursorCol - 1)
1300
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  1194
    ] ifFalse:[
3023
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  1195
        cursorLine ~~ 1 ifTrue:[
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  1196
            self st80EditMode ifTrue:[
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  1197
                self cursorUp.
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  1198
                self cursorToEndOfLine.
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  1199
           ]
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  1200
        ]
1300
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  1201
    ]
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  1202
1426
de76570ba19e crsrLeft/crsrRight does not wrap to prev/next line in st80 mode
Claus Gittinger <cg@exept.de>
parents: 1419
diff changeset
  1203
    "Modified: / 23.1.1998 / 12:37:13 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1204
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1205
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1206
cursorLine:line col:col
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1207
    "this positions onto physical - not visible - line"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1208
676
b65b82a1ffcb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
  1209
    |wasOn newCol|
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1210
2822
08ceab3fc237 search refactored;
Claus Gittinger <cg@exept.de>
parents: 2819
diff changeset
  1211
    ((line == cursorLine) and:[col == cursorCol]) ifTrue:[^ self].
08ceab3fc237 search refactored;
Claus Gittinger <cg@exept.de>
parents: 2819
diff changeset
  1212
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1213
    wasOn := self hideCursor.
2422
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1214
    self setValidatedCursorLine:line.
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1215
672
065750d02339 added cursorCol-validation
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  1216
    (col < 1) ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1217
        newCol := 1
672
065750d02339 added cursorCol-validation
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  1218
    ] ifFalse:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1219
        newCol := col.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1220
    ].
2647
23dca8f032c3 changed st80Mode from classVar to userPreferences value
Claus Gittinger <cg@exept.de>
parents: 2627
diff changeset
  1221
    self st80EditMode ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1222
        (cursorLine == list size
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1223
        and:[cursorLine ~~ line]) ifTrue:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1224
            newCol := (self listAt:(list size)) size + 1.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1225
        ]
1419
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
  1226
    ].
2422
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1227
    self setValidatedCursorCol:newCol.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1228
    self makeCursorVisibleAndShowCursor:wasOn.
672
065750d02339 added cursorCol-validation
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  1229
1596
0bbdb4e9fc43 made st80Mode also an inst-flag;
Claus Gittinger <cg@exept.de>
parents: 1591
diff changeset
  1230
    "Modified: / 20.6.1998 / 18:19:06 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1231
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1232
1580
d30e562bea15 allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
  1233
cursorMovementAllowed
d30e562bea15 allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
  1234
    "return true, if the user may move the cursor around
d30e562bea15 allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
  1235
     (via button-click, or cursor-key with selection).
d30e562bea15 allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
  1236
     By default, true is returned, but this may be redefined
d30e562bea15 allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
  1237
     in special subclasses (such as a terminal view), where
d30e562bea15 allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
  1238
     this is not wanted"
d30e562bea15 allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
  1239
d30e562bea15 allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
  1240
    ^ true
d30e562bea15 allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
  1241
d30e562bea15 allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
  1242
    "Created: / 18.6.1998 / 14:11:16 / cg"
d30e562bea15 allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
  1243
!
d30e562bea15 allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
  1244
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1245
cursorReturn
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1246
    "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
  1247
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1248
    |wasOn|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1249
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1250
    self checkForExistingLine:(cursorLine + 1).
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1251
    cursorVisibleLine notNil ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1252
        nFullLinesShown notNil ifTrue:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1253
            (cursorVisibleLine >= nFullLinesShown) ifTrue:[self scrollDown]
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1254
        ]
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1255
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1256
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1257
    wasOn := self hideCursor.
2422
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1258
    self setValidatedCursorLine:(cursorLine + 1) col:1.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1259
    self makeCursorVisibleAndShowCursor:wasOn.
672
065750d02339 added cursorCol-validation
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  1260
674
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  1261
    "Modified: 22.5.1996 / 18:27:34 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1262
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1263
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1264
cursorRight
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1265
    "move cursor to right"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1266
1300
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  1267
    |l|
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  1268
3023
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  1269
    self st80EditMode ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1270
        l := (self listAt:cursorLine).
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1271
        cursorCol >= (l size + 1) ifTrue:[
3023
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  1272
            cursorLine < list size ifTrue:[
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  1273
                self cursorReturn.
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  1274
            ].
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1275
            ^ self    
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1276
        ]
1300
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  1277
    ].    
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1278
    self cursorCol:(cursorCol + 1)
1300
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  1279
1596
0bbdb4e9fc43 made st80Mode also an inst-flag;
Claus Gittinger <cg@exept.de>
parents: 1591
diff changeset
  1280
    "Modified: / 20.6.1998 / 18:19:07 / cg"
259
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
1833
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  1283
cursorShown:aBoolean
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  1284
    "change cursor visibility
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  1285
     return true if cursor was visible before."
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  1286
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  1287
    |oldState|
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  1288
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  1289
    oldState := cursorShown.
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  1290
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  1291
    aBoolean ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1292
        self drawCursor.
1833
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  1293
    ] ifFalse:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1294
        (cursorShown and:[shown]) ifTrue: [
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1295
            self undrawCursor.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1296
        ].
1833
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  1297
    ].
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  1298
    cursorShown := aBoolean.
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  1299
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  1300
    ^ oldState
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  1301
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  1302
    "Modified: / 30.3.1999 / 15:32:43 / stefan"
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  1303
    "Created: / 30.3.1999 / 15:59:30 / stefan"
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  1304
!
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  1305
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1306
cursorTab
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1307
    "move cursor to next tabstop"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1308
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1309
    self cursorCol:(self nextTabAfter:cursorCol).
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1310
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1311
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1312
cursorToBeginOfLine
3020
68a2dfad4e5e CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents: 2999
diff changeset
  1313
    "move cursor to the start of the current line"
68a2dfad4e5e CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents: 2999
diff changeset
  1314
68a2dfad4e5e CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents: 2999
diff changeset
  1315
    |textStart l|
68a2dfad4e5e CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents: 2999
diff changeset
  1316
68a2dfad4e5e CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents: 2999
diff changeset
  1317
    l := self listAt:cursorLine.
68a2dfad4e5e CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents: 2999
diff changeset
  1318
    textStart := l isNil ifTrue:[1] ifFalse:[l indexOfNonSeparator].
68a2dfad4e5e CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents: 2999
diff changeset
  1319
    cursorCol > textStart ifTrue:[
68a2dfad4e5e CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents: 2999
diff changeset
  1320
        self cursorCol:textStart
68a2dfad4e5e CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents: 2999
diff changeset
  1321
    ] ifFalse:[
68a2dfad4e5e CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents: 2999
diff changeset
  1322
        self cursorCol:1
68a2dfad4e5e CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents: 2999
diff changeset
  1323
    ]
68a2dfad4e5e CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents: 2999
diff changeset
  1324
68a2dfad4e5e CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents: 2999
diff changeset
  1325
    "Created: / 8.8.2004 / 18:51:21 / janfrog"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1326
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1327
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1328
cursorToBottom
2129
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  1329
    "move cursor to the last line of text (col 1)"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1330
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1331
    |wasOn newTop|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1332
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1333
    wasOn := self hideCursor.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1334
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1335
    newTop := list size - nFullLinesShown.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1336
    (newTop < 1) ifTrue:[
2129
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  1337
        newTop := 1
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1338
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1339
    self scrollToLine:newTop.
2422
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1340
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1341
    self setValidatedCursorLine:(list size) col:1.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1342
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1343
    self makeCursorVisibleAndShowCursor:wasOn.
672
065750d02339 added cursorCol-validation
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  1344
674
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  1345
    "Modified: 22.5.1996 / 18:27:45 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1346
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1347
1415
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1348
cursorToCharacterPosition:pos
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1349
    "compute line/col from character position (1..)
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1350
     and move the cursor onto that char"
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1351
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1352
    |line col|
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1353
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1354
    line := self lineOfCharacterPosition:pos.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1355
    col := pos - (self characterPositionOfLine:line col:1) + 1.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1356
    self cursorLine:line col:col
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1357
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1358
    "Created: / 15.1.1998 / 21:55:33 / cg"
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1359
!
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1360
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1361
cursorToEnd
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1362
    "move cursor down below last line of text"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1363
2422
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1364
    |wasOn newTop lineNr line|
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1365
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1366
    lineNr := list size.
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1367
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1368
    cursorLine >= lineNr ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1369
        line := self listAt:cursorLine.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1370
        (line isNil or:[line isEmpty]) ifTrue:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1371
            ^ self
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1372
        ]
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1373
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1374
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1375
    wasOn := self hideCursor.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1376
2422
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1377
    lineNr := lineNr + 1.
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1378
    newTop :=  lineNr - nFullLinesShown.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1379
    (newTop < 1) ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1380
        newTop := 1
259
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
    self scrollToLine:newTop.
2422
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1383
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1384
    self setValidatedCursorLine:lineNr col:1.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1385
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1386
    self makeCursorVisibleAndShowCursor:wasOn.
672
065750d02339 added cursorCol-validation
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  1387
674
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  1388
    "Modified: 22.5.1996 / 18:27:53 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1389
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1390
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1391
cursorToEndOfLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1392
    "move cursor to end of current line"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1393
1300
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  1394
    |line|
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  1395
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  1396
    line := (self listAt:cursorLine).
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  1397
    self cursorCol:(line size + 1)
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  1398
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  1399
    "Modified: 13.8.1997 / 15:34:02 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1400
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1401
2129
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  1402
cursorToEndOfText
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  1403
    "move cursor to the end of the text (behinf last character in last line)"
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  1404
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  1405
    |wasOn newTop|
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  1406
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  1407
    wasOn := self hideCursor.
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  1408
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  1409
    newTop := list size - nFullLinesShown.
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  1410
    (newTop < 1) ifTrue:[
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  1411
        newTop := 1
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  1412
    ].
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  1413
    self scrollToLine:newTop.
2422
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1414
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1415
    self setValidatedCursorLine:list size.
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1416
    self setCursorCol:(self validateCursorCol:(self listAt:cursorLine) size inLine:cursorLine).
2129
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  1417
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  1418
    self makeCursorVisibleAndShowCursor:wasOn.
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  1419
!
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  1420
131
claus
parents: 130
diff changeset
  1421
cursorToFirstVisibleLine
claus
parents: 130
diff changeset
  1422
    "place cursor into the first visible line; do not scroll."
claus
parents: 130
diff changeset
  1423
claus
parents: 130
diff changeset
  1424
    self cursorLine:(self visibleLineToAbsoluteLine:1) col:1
claus
parents: 130
diff changeset
  1425
!
claus
parents: 130
diff changeset
  1426
claus
parents: 130
diff changeset
  1427
cursorToLastVisibleLine
claus
parents: 130
diff changeset
  1428
    "place cursor into the first visible line; do not scroll."
claus
parents: 130
diff changeset
  1429
claus
parents: 130
diff changeset
  1430
    self cursorLine:(self visibleLineToAbsoluteLine:nFullLinesShown) col:1
claus
parents: 130
diff changeset
  1431
!
claus
parents: 130
diff changeset
  1432
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1433
cursorToNextWord
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1434
    "move the cursor to the beginning of the next word"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1435
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1436
    |col line searching|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1437
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1438
    (cursorLine > list size) ifTrue:[^ self].
2422
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1439
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1440
    self wordAtLine:cursorLine col:cursorCol do:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1441
        :beginLine :beginCol :endLine :endCol :style | 
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1442
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1443
        line := endLine.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1444
        col := endCol + 1.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1445
        searching := true.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1446
        [searching 
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1447
         and:[(self characterAtLine:line col:col) isSeparator]] whileTrue:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1448
            self wordAtLine:line col:col do:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1449
                :beginLine :beginCol :endLine :endCol :style |
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1450
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1451
                (line > list size) ifTrue:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1452
                    "break out"
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1453
                    searching := false
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1454
                ] ifFalse:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1455
                    line := endLine.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1456
                    col := endCol + 1.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1457
                ]
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1458
            ]
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1459
        ].
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1460
        self cursorLine:line col:col
121
claus
parents: 118
diff changeset
  1461
    ]
claus
parents: 118
diff changeset
  1462
!
claus
parents: 118
diff changeset
  1463
499
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
  1464
cursorToPreviousWord
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
  1465
    "move the cursor to the beginning of this or the previous word"
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
  1466
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
  1467
    |col line searching l|
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
  1468
2422
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1469
    (cursorLine > list size) ifTrue:[^ self].      "/ this is rubbish
499
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
  1470
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
  1471
    self wordAtLine:cursorLine col:cursorCol do:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1472
        :beginLine :beginCol :endLine :endCol :style | 
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1473
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1474
        line := beginLine.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1475
        col := beginCol.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1476
        style == #wordLeft ifTrue:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1477
            col := col + 1
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1478
        ].
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1479
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1480
        (cursorLine == line
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1481
        and:[cursorCol == col]) ifTrue:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1482
            searching := true.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1483
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1484
            col > 1 ifTrue:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1485
                col := col - 1.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1486
            ].
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1487
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1488
            [searching] whileTrue:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1489
                (col == 1) ifTrue:[    
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1490
                    line == 1 ifTrue:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1491
                        searching := false
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1492
                    ] ifFalse:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1493
                        line := line - 1.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1494
                        l := list at:line.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1495
                        col := l size + 1.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1496
                    ]
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1497
                ] ifFalse:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1498
                    (self characterAtLine:line col:col) isSeparator ifFalse:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1499
                        self wordAtLine:line col:col do:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1500
                            :beginLine :beginCol :endLine :endCol :style |
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1501
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1502
                            line := beginLine.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1503
                            col := beginCol.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1504
                            style == #wordLeft ifTrue:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1505
                                col := col + 1
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1506
                            ].
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1507
                            searching := false.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1508
                        ]
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1509
                    ] ifTrue:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1510
                        col := col - 1
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1511
                    ]
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1512
                ]
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1513
            ]
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1514
        ].
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1515
        self cursorLine:line col:col
499
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
  1516
    ]
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
  1517
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
  1518
    "Created: 8.3.1996 / 21:52:48 / cg"
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
  1519
    "Modified: 8.3.1996 / 22:12:45 / cg"
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
  1520
!
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
  1521
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1522
cursorToTop
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1523
    "move cursor to absolute home"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1524
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1525
    self cursorLine:1 col:1
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1526
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1527
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1528
cursorUp
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1529
    "move cursor up; scroll if at start of visible text"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1530
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1531
    self cursorUp:1
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1532
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1533
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1534
cursorUp:n
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1535
    "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
  1536
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1537
    |wasOn nv nl|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1538
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1539
    cursorLine isNil ifTrue:[
2422
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1540
        self setCursorLine:(firstLineShown + nFullLinesShown - 1).
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1541
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1542
    nl := cursorLine - n.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1543
    nl < 1 ifTrue:[nl := 1].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1544
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1545
    (nl ~~ cursorLine) ifTrue: [
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1546
        wasOn := self hideCursor.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1547
        cursorVisibleLine notNil ifTrue:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1548
            nv := cursorVisibleLine - n.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1549
            nv < 1 ifTrue:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1550
                self scrollUp:(nv negated + 1)
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1551
            ].
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1552
        ].
2422
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1553
        self setValidatedCursorLine:nl col:cursorCol.
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1554
        wasOn ifTrue:[self showCursor].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1555
    ]
672
065750d02339 added cursorCol-validation
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  1556
674
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  1557
    "Modified: 22.5.1996 / 18:28:11 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1558
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1559
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1560
cursorVisibleLine:visibleLineNr col:colNr
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1561
    "put cursor to visibleline/col"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1562
2422
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1563
    |wasOn newCol listLine|
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1564
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1565
    wasOn := self hideCursor.
2422
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1566
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1567
    listLine := self visibleLineToAbsoluteLine:visibleLineNr.
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1568
    self setValidatedCursorLine:listLine.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1569
    cursorVisibleLine := visibleLineNr.
2422
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1570
676
b65b82a1ffcb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
  1571
    newCol := colNr.
b65b82a1ffcb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
  1572
    (newCol < 1) ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1573
        newCol := 1
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1574
    ].
2422
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1575
    self setValidatedCursorCol:newCol.
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1576
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1577
    self makeCursorVisibleAndShowCursor:wasOn.
672
065750d02339 added cursorCol-validation
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  1578
1597
5fdcfcedb91c fixed cursor positioning after replaceStringAtCursor.
Claus Gittinger <cg@exept.de>
parents: 1596
diff changeset
  1579
    "Modified: / 20.6.1998 / 18:40:28 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1580
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1581
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1582
cursorX:x y:y
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1583
    "put cursor to position next to x/y coordinate in view"
121
claus
parents: 118
diff changeset
  1584
claus
parents: 118
diff changeset
  1585
    |line col|
claus
parents: 118
diff changeset
  1586
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1587
    line := self visibleLineOfY:y.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1588
    col := self colOfX:x inVisibleLine:line.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1589
    self cursorVisibleLine:line col:col.
121
claus
parents: 118
diff changeset
  1590
!
claus
parents: 118
diff changeset
  1591
claus
parents: 118
diff changeset
  1592
drawCursor
claus
parents: 118
diff changeset
  1593
    "draw the cursor if shown and cursor is visible.
claus
parents: 118
diff changeset
  1594
     (but not, if there is a selection - to avoid confusion)"
claus
parents: 118
diff changeset
  1595
claus
parents: 118
diff changeset
  1596
    shown ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1597
        cursorVisibleLine notNil ifTrue:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1598
            self hasSelection ifFalse:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1599
                self drawCursorCharacter
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1600
            ]
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1601
        ]
121
claus
parents: 118
diff changeset
  1602
    ]
claus
parents: 118
diff changeset
  1603
!
claus
parents: 118
diff changeset
  1604
claus
parents: 118
diff changeset
  1605
drawCursor:cursorType with:fgColor and:bgColor
claus
parents: 118
diff changeset
  1606
    "draw a cursor; the argument cursorType specifies what type
125
claus
parents: 123
diff changeset
  1607
     of cursor should be drawn.
728
3ef81000ee8c new cursorTypes: #bigCaret and #bigSolidCaret
Claus Gittinger <cg@exept.de>
parents: 698
diff changeset
  1608
     Currently, supported are: #block, #frame, #ibeam, #caret, #solidCaret
2085
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1609
                               #bigCaret and #bigSolidCaret"
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1610
2570
590956e81610 Remove unused method vars.
Stefan Vogel <sv@exept.de>
parents: 2569
diff changeset
  1611
    |x y w char y2 x1 x2 oldPaint oldClip|
121
claus
parents: 118
diff changeset
  1612
claus
parents: 118
diff changeset
  1613
    self hasSelection ifTrue:[
2085
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1614
        "
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1615
         hide cursor, if there is a selection
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1616
        "
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1617
        ^ super redrawVisibleLine:cursorVisibleLine col:cursorCol.
121
claus
parents: 118
diff changeset
  1618
    ].
claus
parents: 118
diff changeset
  1619
1334
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  1620
    cursorType == #none ifTrue:[
2085
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1621
        ^ self
1334
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  1622
    ].
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  1623
121
claus
parents: 118
diff changeset
  1624
    cursorType == #block ifTrue:[
2085
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1625
        super drawVisibleLine:cursorVisibleLine 
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1626
                          col:cursorCol 
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1627
                         with:fgColor
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1628
                          and:bgColor.
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1629
        ^ self
121
claus
parents: 118
diff changeset
  1630
    ].
2429
eed79a96e43b eliminated accesses to leftOffset
Claus Gittinger <cg@exept.de>
parents: 2427
diff changeset
  1631
    x := (self xOfCol:cursorCol inVisibleLine:cursorVisibleLine) - viewOrigin x.
121
claus
parents: 118
diff changeset
  1632
    y := self yOfVisibleLine:cursorVisibleLine.
claus
parents: 118
diff changeset
  1633
1449
2a54bdfff203 eliminated direct refs to paint instvar
Claus Gittinger <cg@exept.de>
parents: 1446
diff changeset
  1634
    oldPaint := self paint. "/ do not clobber GC
121
claus
parents: 118
diff changeset
  1635
    cursorType == #frame ifTrue:[
2085
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1636
        super redrawVisibleLine:cursorVisibleLine col:cursorCol.
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1637
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1638
        char := self characterUnderCursor asString.
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1639
        self paint:bgColor.
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1640
        self displayRectangleX:x y:y 
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1641
                         width:(font widthOf:char) height:fontHeight.
133
claus
parents: 132
diff changeset
  1642
    ] ifFalse:[
2085
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1643
        self paint:bgColor.
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1644
        cursorType == #ibeam ifTrue:[
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1645
            x1 := x - 1.
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1646
            y2 := y + fontHeight - 1.
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1647
            self displayLineFromX:x1 y:y toX:x1 y:y2. 
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1648
            self displayLineFromX:x y:y toX:x y:y2. 
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1649
            ^ self
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1650
        ].
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1651
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1652
        cursorType == #Ibeam ifTrue:[
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1653
            x1 := x - 1.
2088
b2beb67b1a98 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2085
diff changeset
  1654
            y := y + 1.
2085
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1655
            y2 := y + fontHeight - 1.
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1656
            self displayLineFromX:x1 y:y toX:x1 y:y2. 
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1657
            self displayLineFromX:x y:y toX:x y:y2. 
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1658
            self displayLineFromX:x1-2 y:y toX:x+2 y:y. 
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1659
            self displayLineFromX:x1-2 y:y2 toX:x+2 y:y2. 
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1660
            ^ self
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1661
        ].
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1662
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1663
        y := y + fontHeight - 3.
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1664
        ((cursorType == #bigCaret) or:[cursorType == #bigSolidCaret]) ifTrue:[
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1665
            w := (fontWidth * 2 // 3) max:4.
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1666
            y2 := y + w + (w//2).
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1667
        ] ifFalse:[
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1668
            w := (fontWidth // 2) max:4.
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1669
            y2 := y + w.
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1670
        ].
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1671
        x1 := x - w.
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1672
        x2 := x + w.
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1673
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1674
        oldClip := self clippingRectangleOrNil.
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1675
        self clippingRectangle:(margin@margin extent:(width-margin) @ (height-margin)).
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1676
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1677
        cursorType == #caret ifTrue:[
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1678
            self lineWidth:2.
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1679
            self displayLineFromX:x1 y:y2 toX:x y:y. 
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1680
            self displayLineFromX:x y:y toX:x2 y:y2. 
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1681
        ] ifFalse:[
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1682
            "anything else: solidCaret"
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1683
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1684
            self fillPolygon:(Array with:(x1 @ y2)
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1685
                                    with:(x @ y)
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1686
                                    with:(x2 @ y2))
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1687
        ].
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1688
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1689
        self clippingRectangle:oldClip
121
claus
parents: 118
diff changeset
  1690
    ].
133
claus
parents: 132
diff changeset
  1691
    self paint:oldPaint.
662
4bcdf0cce3a7 dont let caret cursor become too small (with small fonts)
Claus Gittinger <cg@exept.de>
parents: 655
diff changeset
  1692
2088
b2beb67b1a98 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2085
diff changeset
  1693
    "Modified: / 15.12.1999 / 22:24:17 / cg"
121
claus
parents: 118
diff changeset
  1694
!
claus
parents: 118
diff changeset
  1695
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1696
drawCursorCharacter
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1697
    "draw the cursor. 
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1698
     (i.e. the cursor if no selection)
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1699
     - helper for many cursor methods"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1700
1817
1a9e22f755c8 show non-focus cursor when disabled or readOnly
Claus Gittinger <cg@exept.de>
parents: 1816
diff changeset
  1701
    (hasKeyboardFocus 
1a9e22f755c8 show non-focus cursor when disabled or readOnly
Claus Gittinger <cg@exept.de>
parents: 1816
diff changeset
  1702
    and:[self enabled
1a9e22f755c8 show non-focus cursor when disabled or readOnly
Claus Gittinger <cg@exept.de>
parents: 1816
diff changeset
  1703
    and:[readOnly not]]) ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1704
        self drawFocusCursor
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1705
    ] ifFalse:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1706
        self drawNoFocusCursor
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1707
    ]
1817
1a9e22f755c8 show non-focus cursor when disabled or readOnly
Claus Gittinger <cg@exept.de>
parents: 1816
diff changeset
  1708
1a9e22f755c8 show non-focus cursor when disabled or readOnly
Claus Gittinger <cg@exept.de>
parents: 1816
diff changeset
  1709
    "Modified: / 23.3.1999 / 13:52:48 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1710
!
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
drawFocusCursor
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1713
    "draw the cursor when the focus is in the view."
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1714
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1715
    self hasSelection ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1716
        ^ super redrawVisibleLine:cursorVisibleLine col:cursorCol.
1334
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  1717
    ].
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  1718
    cursorType == #none ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1719
        ^ self undrawCursor
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1720
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1721
    self drawCursor:cursorType with:cursorFgColor and:cursorBgColor.
1334
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  1722
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  1723
    "Modified: 22.9.1997 / 00:16:38 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1724
!
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
drawNoFocusCursor
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1727
    "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
  1728
1334
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  1729
    |cType|
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  1730
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1731
    self hasSelection ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1732
        ^ super redrawVisibleLine:cursorVisibleLine col:cursorCol.
121
claus
parents: 118
diff changeset
  1733
    ].
1022
4362861fe15e allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents: 1018
diff changeset
  1734
1334
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  1735
    cType := cursorTypeNoFocus ? cursorType.
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  1736
    cType == #none ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1737
        ^ self undrawCursor
1334
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  1738
    ].
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  1739
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  1740
    cType == #block ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1741
        ^ self drawCursor:#frame with:cursorNoFocusFgColor and:cursorBgColor
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1742
    ].
1022
4362861fe15e allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents: 1018
diff changeset
  1743
1334
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  1744
    ^ self drawCursor:cType with:cursorNoFocusFgColor and:cursorNoFocusFgColor.
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  1745
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  1746
    "Modified: 22.9.1997 / 00:16:13 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1747
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1748
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1749
gotoLine:aLineNumber
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1750
    "position cursor onto line, aLineNumber.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1751
     Make certain that this line is visible"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1752
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1753
    self makeLineVisible:aLineNumber.
2951
eb820ef25acf unselect before gotoLine
Claus Gittinger <cg@exept.de>
parents: 2950
diff changeset
  1754
    self unselect.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1755
    self cursorLine:aLineNumber col:1
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1756
!
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
hideCursor
1833
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  1759
    "make cursor invisible if currently invisible"
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  1760
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  1761
    ^ self cursorShown:false
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  1762
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  1763
    "Modified: / 30.3.1999 / 16:02:28 / stefan"
121
claus
parents: 118
diff changeset
  1764
!
claus
parents: 118
diff changeset
  1765
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1766
makeCursorVisible
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1767
    "scroll text to make cursorline visible 
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1768
     (i.e. to have cursorLine in visible area)"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1769
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1770
    |line col|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1771
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1772
    cursorLine notNil ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1773
        line := cursorLine.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1774
        col := cursorCol.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1775
        "
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1776
         if there is a selection, its better to
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1777
         have its start being visible, instead of the end
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1778
        "
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1779
        (selectionStartLine notNil 
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1780
        and:[selectionEndLine notNil]) ifTrue:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1781
            expandingTop ~~ false ifTrue:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1782
                line := selectionStartLine.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1783
                col := selectionStartCol.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1784
            ] ifFalse:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1785
                line := selectionEndLine.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1786
                col := selectionEndCol
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1787
            ]
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1788
        ].
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1789
        self makeLineVisible:line.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1790
        self makeColVisible:col inLine:line 
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1791
    ]
479
fae6d1251888 fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 477
diff changeset
  1792
fae6d1251888 fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 477
diff changeset
  1793
    "Modified: 6.3.1996 / 13:46:46 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1794
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1795
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1796
makeCursorVisibleAndShowCursor:flag
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1797
    "scroll to make cursorLine visible;
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1798
     if flag is true, draw the cursor"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1799
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1800
    self makeCursorVisible.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1801
    flag ifTrue:[self showCursor]
121
claus
parents: 118
diff changeset
  1802
!
claus
parents: 118
diff changeset
  1803
2422
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1804
setCursorCol:colNr
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1805
    "strictly private: set the cursorCol"
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1806
2815
d71f43d7de3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2796
diff changeset
  1807
    cursorCol := (colNr max:1).
2422
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1808
    cursorColHolder value:cursorCol.
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1809
!
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1810
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1811
setCursorLine:lineNr
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1812
    "strictly private: set the cursorLine"
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1813
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1814
    cursorLine := lineNr.
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1815
    cursorLineHolder value:cursorLine.
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1816
    self updateCursorVisibleLine.
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1817
!
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1818
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1819
setCursorLine:lineNr col:colNr
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1820
    "strictly private: set the cursorLine, col and update the visibleLine"
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1821
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1822
    self setCursorLine:lineNr.
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1823
    self setCursorCol:colNr.
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1824
!
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1825
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1826
setValidatedCursorCol:colNr
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1827
    "strictly private: set the cursorCol"
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1828
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1829
    self setCursorCol:(self validateCursorCol:colNr inLine:cursorLine).
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1830
!
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1831
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1832
setValidatedCursorLine:lineNr
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1833
    "strictly private: set the cursorLine and update the visibleLine"
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1834
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1835
    self setCursorLine:(self validateCursorLine:lineNr).
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1836
!
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1837
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1838
setValidatedCursorLine:lineNr col:colNr
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1839
    "strictly private: set the cursorLine, col and update the visibleLine"
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1840
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1841
    self setValidatedCursorLine:lineNr.
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1842
    self setValidatedCursorCol:colNr.
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1843
!
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1844
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1845
showCursor
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1846
    "make cursor visible if currently invisible"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1847
1833
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  1848
    ^ self cursorShown:true
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  1849
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  1850
    "Modified: / 30.3.1999 / 16:02:34 / stefan"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1851
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1852
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1853
undrawCursor
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1854
    "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
  1855
2085
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1856
    |prevCol line oldClip x y e1 e2 e3|
1022
4362861fe15e allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents: 1018
diff changeset
  1857
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1858
    cursorVisibleLine notNil ifTrue:[
2085
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1859
        prevCol := cursorCol - 1.
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1860
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1861
        "/ if there is any italic stuff in the cursor line,
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1862
        "/ redraw it completely (because characters overlap).
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1863
        cursorCol > 1 ifTrue:[
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1864
            (line := self listAt:cursorLine) notNil ifTrue:[
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1865
                line hasChangeOfEmphasis ifTrue:[
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1866
                    line size >= (cursorCol-1) ifTrue:[
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1867
                        e1 := Text extractEmphasis:#italic from:(line emphasisAt:cursorCol-1).
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1868
                        line size >= (cursorCol) ifTrue:[
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1869
                            e2 := Text extractEmphasis:#italic from:(line emphasisAt:cursorCol).
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1870
                            line size >= (cursorCol+1) ifTrue:[
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1871
                                e3 := Text extractEmphasis:#italic from:(line emphasisAt:cursorCol+1)
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1872
                            ].
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1873
                        ].
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1874
                    ].
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1875
                    (e1 notNil or:[e2 notNil or:[e3 notNil]]) ifTrue:[
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1876
                        ^ super redrawVisibleLine:cursorVisibleLine 
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1877
                    ]
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1878
                ]
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1879
            ]
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1880
        ].
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1881
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1882
        ((cursorType == #caret)
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1883
         or:[cursorType == #solidCaret
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1884
         or:[cursorType == #bigSolidCaret
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1885
         or:[cursorType == #bigCaret
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1886
         or:[cursorType == #Ibeam]]]]) ifTrue:[
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1887
            "caret-cursor touches 4 characters"
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1888
            ((cursorCol > 1) and:[fontIsFixedWidth]) ifTrue:[
2088
b2beb67b1a98 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2085
diff changeset
  1889
                super redrawVisibleLine:cursorVisibleLine-1 from:prevCol to:cursorCol.
2085
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1890
                super redrawVisibleLine:cursorVisibleLine from:prevCol to:cursorCol.
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1891
                super redrawVisibleLine:cursorVisibleLine+1 from:prevCol to:cursorCol.
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1892
            ] ifFalse:[
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1893
                "care for left margin"
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1894
                super redrawVisibleLine:cursorVisibleLine; redrawVisibleLine:cursorVisibleLine+1.
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1895
            ].
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1896
            ^ self
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1897
        ].
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1898
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1899
        cursorType == #ibeam ifTrue:[
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1900
            "ibeam-cursor touches 2 characters"
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1901
            cursorCol > 1 ifTrue:[
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1902
                super redrawVisibleLine:cursorVisibleLine from:prevCol to:cursorCol.
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1903
            ] ifFalse:[
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1904
                "care for left margin"
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1905
                super redrawVisibleLine:cursorVisibleLine.
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1906
            ].
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1907
            ^ self
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1908
        ].
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1909
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1910
        "block cursor is simple - just one character under cursor"
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1911
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1912
        "/ however, if italic characters are involved, we must care
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1913
        "/ for the chars before/after the cursor.
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1914
        "/ We redraw the part of the previous character which got
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1915
        "/ detroyed by the block cursor.
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1916
        "/ (must change the clip, to avoid destroying the prev-prev character) 
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1917
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1918
        line := self visibleAt:cursorVisibleLine.
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1919
        (line notNil and:[line isText]) ifTrue:[
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1920
            cursorCol > 1 ifTrue:[
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1921
                oldClip := self clippingRectangleOrNil.
2429
eed79a96e43b eliminated accesses to leftOffset
Claus Gittinger <cg@exept.de>
parents: 2427
diff changeset
  1922
                x := (self xOfCol:cursorCol inVisibleLine:cursorVisibleLine) - viewOrigin x.
2085
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1923
                y := self yOfVisibleLine:cursorVisibleLine.
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1924
                self clippingRectangle:(x@y extent:((font width * 2) @ fontHeight)).
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1925
                super redrawVisibleLine:cursorVisibleLine from:cursorCol-1 to:cursorCol.
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1926
                self clippingRectangle:oldClip.
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1927
                ^ self.
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1928
            ].
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1929
        ].
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1930
        super redrawVisibleLine:cursorVisibleLine col:cursorCol
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1931
    ]
728
3ef81000ee8c new cursorTypes: #bigCaret and #bigSolidCaret
Claus Gittinger <cg@exept.de>
parents: 698
diff changeset
  1932
2088
b2beb67b1a98 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2085
diff changeset
  1933
    "Modified: / 15.12.1999 / 22:25:59 / cg"
121
claus
parents: 118
diff changeset
  1934
!
claus
parents: 118
diff changeset
  1935
2422
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1936
updateCursorVisibleLine
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1937
    "strictly private: set the visibleLine from the cursorLine.
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1938
     notice: visibleLine will be set to nil if the cursor is not visible"
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1939
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1940
    cursorVisibleLine := self listLineToVisibleLine:cursorLine.
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1941
!
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1942
672
065750d02339 added cursorCol-validation
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  1943
validateCursorCol:col inLine:line
674
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  1944
    "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
  1945
     Here, no limits are enforced (and col is returned), 
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  1946
     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
  1947
     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
  1948
1300
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  1949
    |l max|
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  1950
1419
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
  1951
    "/ in ST80 mode,
2707
810c994db0b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2696
diff changeset
  1952
    "/ the cursor may not be positioned beyond the
810c994db0b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2696
diff changeset
  1953
    "/ end of a line or beyond the last line of the text
3023
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  1954
    
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  1955
    self st80EditMode ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1956
        l := (self listAt:line).
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1957
        max := l size + 1.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1958
        col > max ifTrue:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1959
            ^ max
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1960
        ]
1300
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  1961
    ].
672
065750d02339 added cursorCol-validation
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  1962
    ^ col
065750d02339 added cursorCol-validation
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  1963
1419
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
  1964
    "Created: / 22.5.1996 / 14:25:30 / cg"
1596
0bbdb4e9fc43 made st80Mode also an inst-flag;
Claus Gittinger <cg@exept.de>
parents: 1591
diff changeset
  1965
    "Modified: / 20.6.1998 / 18:19:24 / cg"
674
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  1966
!
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  1967
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  1968
validateCursorLine:line
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  1969
    "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
  1970
     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
  1971
     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
  1972
     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
  1973
     skip reserved regions"
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  1974
1419
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
  1975
    "/
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
  1976
    "/ in st80Mode, the cursor may not be positioned
2707
810c994db0b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2696
diff changeset
  1977
    "/ beyond the last line
1419
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
  1978
    "/
3023
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  1979
    self st80EditMode ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1980
        ^ (line min:(list size)) max:1
1419
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
  1981
    ].
674
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  1982
    ^ line
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  1983
1419
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
  1984
    "Created: / 22.5.1996 / 18:22:23 / cg"
1596
0bbdb4e9fc43 made st80Mode also an inst-flag;
Claus Gittinger <cg@exept.de>
parents: 1591
diff changeset
  1985
    "Modified: / 20.6.1998 / 18:19:26 / cg"
672
065750d02339 added cursorCol-validation
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  1986
!
065750d02339 added cursorCol-validation
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  1987
121
claus
parents: 118
diff changeset
  1988
withCursorOffDo:aBlock
claus
parents: 118
diff changeset
  1989
    "evaluate aBlock with cursor off; turn it on afterwards."
claus
parents: 118
diff changeset
  1990
claus
parents: 118
diff changeset
  1991
    (shown not or:[cursorShown not]) ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1992
        ^ aBlock value
121
claus
parents: 118
diff changeset
  1993
    ].
claus
parents: 118
diff changeset
  1994
    self hideCursor.
2522
d80496af7eaf #valueNowOrOnUnwindDo: -> #ensure:
Claus Gittinger <cg@exept.de>
parents: 2506
diff changeset
  1995
    aBlock ensure:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  1996
        self showCursor
121
claus
parents: 118
diff changeset
  1997
    ]
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1998
! !
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1999
2589
62794ae04446 support drop
ca
parents: 2580
diff changeset
  2000
!EditTextView methodsFor:'drag & drop'!
62794ae04446 support drop
ca
parents: 2580
diff changeset
  2001
62794ae04446 support drop
ca
parents: 2580
diff changeset
  2002
allowDrop:aBoolean
62794ae04446 support drop
ca
parents: 2580
diff changeset
  2003
    "enable/disable drop support
62794ae04446 support drop
ca
parents: 2580
diff changeset
  2004
    "
62794ae04446 support drop
ca
parents: 2580
diff changeset
  2005
    aBoolean ifFalse:[
62794ae04446 support drop
ca
parents: 2580
diff changeset
  2006
        dropTarget := nil.
62794ae04446 support drop
ca
parents: 2580
diff changeset
  2007
    ] ifTrue:[
62794ae04446 support drop
ca
parents: 2580
diff changeset
  2008
        dropTarget ifNil:[
62794ae04446 support drop
ca
parents: 2580
diff changeset
  2009
            dropTarget := DropTarget receiver:self
62794ae04446 support drop
ca
parents: 2580
diff changeset
  2010
                              argument:nil
62794ae04446 support drop
ca
parents: 2580
diff changeset
  2011
                          dropSelector:#'drop:'
62794ae04446 support drop
ca
parents: 2580
diff changeset
  2012
                       canDropSelector:#'canDrop:'
62794ae04446 support drop
ca
parents: 2580
diff changeset
  2013
        ]
62794ae04446 support drop
ca
parents: 2580
diff changeset
  2014
    ].
62794ae04446 support drop
ca
parents: 2580
diff changeset
  2015
!
62794ae04446 support drop
ca
parents: 2580
diff changeset
  2016
62794ae04446 support drop
ca
parents: 2580
diff changeset
  2017
canDrop:aContext
62794ae04446 support drop
ca
parents: 2580
diff changeset
  2018
    "I accept textObjects and fileObjects only
62794ae04446 support drop
ca
parents: 2580
diff changeset
  2019
    "
62794ae04446 support drop
ca
parents: 2580
diff changeset
  2020
    |objects|
62794ae04446 support drop
ca
parents: 2580
diff changeset
  2021
62794ae04446 support drop
ca
parents: 2580
diff changeset
  2022
    aContext sourceWidget == self ifTrue:[
62794ae04446 support drop
ca
parents: 2580
diff changeset
  2023
        ^ false
62794ae04446 support drop
ca
parents: 2580
diff changeset
  2024
    ].
62794ae04446 support drop
ca
parents: 2580
diff changeset
  2025
    self checkModificationsAllowed ifFalse:[^ false].
62794ae04446 support drop
ca
parents: 2580
diff changeset
  2026
62794ae04446 support drop
ca
parents: 2580
diff changeset
  2027
    objects := aContext dropObjects.
62794ae04446 support drop
ca
parents: 2580
diff changeset
  2028
    objects isEmpty ifTrue:[ ^ false ].
62794ae04446 support drop
ca
parents: 2580
diff changeset
  2029
62794ae04446 support drop
ca
parents: 2580
diff changeset
  2030
    objects do:[:el|
62794ae04446 support drop
ca
parents: 2580
diff changeset
  2031
        (el isTextObject or:[el isFileObject]) ifFalse:[^ false].
62794ae04446 support drop
ca
parents: 2580
diff changeset
  2032
    ].
62794ae04446 support drop
ca
parents: 2580
diff changeset
  2033
    ^ true
62794ae04446 support drop
ca
parents: 2580
diff changeset
  2034
!
62794ae04446 support drop
ca
parents: 2580
diff changeset
  2035
62794ae04446 support drop
ca
parents: 2580
diff changeset
  2036
drop:aContext
62794ae04446 support drop
ca
parents: 2580
diff changeset
  2037
    "drop objects
62794ae04446 support drop
ca
parents: 2580
diff changeset
  2038
    "
62794ae04446 support drop
ca
parents: 2580
diff changeset
  2039
    |text|
62794ae04446 support drop
ca
parents: 2580
diff changeset
  2040
62794ae04446 support drop
ca
parents: 2580
diff changeset
  2041
    (self canDrop:aContext) ifFalse:[^ false].
62794ae04446 support drop
ca
parents: 2580
diff changeset
  2042
62794ae04446 support drop
ca
parents: 2580
diff changeset
  2043
    text := StringCollection new.
62794ae04446 support drop
ca
parents: 2580
diff changeset
  2044
62794ae04446 support drop
ca
parents: 2580
diff changeset
  2045
    aContext dropObjects do:[:el| |obj|
62794ae04446 support drop
ca
parents: 2580
diff changeset
  2046
        obj := el theObject.
62794ae04446 support drop
ca
parents: 2580
diff changeset
  2047
        el isTextObject ifTrue:[ text addAll:obj ]
62794ae04446 support drop
ca
parents: 2580
diff changeset
  2048
                       ifFalse:[ text add:(obj asString) ]
62794ae04446 support drop
ca
parents: 2580
diff changeset
  2049
    ].
62794ae04446 support drop
ca
parents: 2580
diff changeset
  2050
    self pasteOrReplace:text.
62794ae04446 support drop
ca
parents: 2580
diff changeset
  2051
  ^ true
62794ae04446 support drop
ca
parents: 2580
diff changeset
  2052
!
62794ae04446 support drop
ca
parents: 2580
diff changeset
  2053
62794ae04446 support drop
ca
parents: 2580
diff changeset
  2054
dropTarget
62794ae04446 support drop
ca
parents: 2580
diff changeset
  2055
    "returns the dropTarget or nil
62794ae04446 support drop
ca
parents: 2580
diff changeset
  2056
    "
62794ae04446 support drop
ca
parents: 2580
diff changeset
  2057
    ^ dropTarget
62794ae04446 support drop
ca
parents: 2580
diff changeset
  2058
!
62794ae04446 support drop
ca
parents: 2580
diff changeset
  2059
62794ae04446 support drop
ca
parents: 2580
diff changeset
  2060
dropTarget:aDropTragetOrNil
62794ae04446 support drop
ca
parents: 2580
diff changeset
  2061
    "set the dropTarget or nil
62794ae04446 support drop
ca
parents: 2580
diff changeset
  2062
    "
62794ae04446 support drop
ca
parents: 2580
diff changeset
  2063
    dropTarget := aDropTragetOrNil.
62794ae04446 support drop
ca
parents: 2580
diff changeset
  2064
! !
62794ae04446 support drop
ca
parents: 2580
diff changeset
  2065
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2066
!EditTextView methodsFor:'editing'!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2067
313
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2068
copyAndDeleteSelection
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2069
    "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
  2070
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2071
    selectionStartLine notNil ifTrue:[
3043
06df889187a4 set selection interface changed
ca
parents: 3038
diff changeset
  2072
        self setClipboardText:(self selection).
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2073
        self deleteSelection.
313
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2074
    ].
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2075
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2076
    "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
  2077
!
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2078
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2079
deleteCharAtCursor
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2080
    "delete single character under cursor; does not merge lines"
121
claus
parents: 118
diff changeset
  2081
claus
parents: 118
diff changeset
  2082
    |wasOn|
claus
parents: 118
diff changeset
  2083
claus
parents: 118
diff changeset
  2084
    wasOn := self hideCursor.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2085
    self deleteCharAtLine:cursorLine col:cursorCol.
121
claus
parents: 118
diff changeset
  2086
    wasOn ifTrue:[self showCursor]
claus
parents: 118
diff changeset
  2087
!
claus
parents: 118
diff changeset
  2088
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2089
deleteCharAtLine:lineNr col:colNr
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2090
    "delete a single character at colNr in line lineNr"
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2091
3023
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  2092
    self st80EditMode ifTrue:[
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  2093
        (self listAt:cursorLine) size + 1 = colNr ifTrue:[
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  2094
            | wasOn |
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  2095
            wasOn := self hideCursor.
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  2096
            self 
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  2097
                cursorReturn;
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  2098
                cursorCol:1;
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  2099
                deleteCharBeforeCursor.        
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  2100
            wasOn ifTrue:[ self showCursor].
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  2101
            ^ self.
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  2102
        ].
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  2103
    ].
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  2104
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2105
    self deleteCharsAtLine:lineNr fromCol:colNr toCol:colNr
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2106
!
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2107
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2108
deleteCharBeforeCursor
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2109
    "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
  2110
2491
f3e207ae5156 auto indent fix
Claus Gittinger <cg@exept.de>
parents: 2461
diff changeset
  2111
    |soCol wasOn lineNrAboveCursor ln prevTab|
121
claus
parents: 118
diff changeset
  2112
claus
parents: 118
diff changeset
  2113
    wasOn := self hideCursor.
2491
f3e207ae5156 auto indent fix
Claus Gittinger <cg@exept.de>
parents: 2461
diff changeset
  2114
    autoIndent ifTrue:[
f3e207ae5156 auto indent fix
Claus Gittinger <cg@exept.de>
parents: 2461
diff changeset
  2115
        prevTab := (self prevTabBefore:cursorCol) max:1.
f3e207ae5156 auto indent fix
Claus Gittinger <cg@exept.de>
parents: 2461
diff changeset
  2116
        ln := (list at:cursorLine) ? ''.
f3e207ae5156 auto indent fix
Claus Gittinger <cg@exept.de>
parents: 2461
diff changeset
  2117
        ln size < prevTab ifTrue:[
f3e207ae5156 auto indent fix
Claus Gittinger <cg@exept.de>
parents: 2461
diff changeset
  2118
            ln := ln , (String new:prevTab withAll:Character space).
f3e207ae5156 auto indent fix
Claus Gittinger <cg@exept.de>
parents: 2461
diff changeset
  2119
        ].
f3e207ae5156 auto indent fix
Claus Gittinger <cg@exept.de>
parents: 2461
diff changeset
  2120
        (ln copyTo:prevTab) isBlank ifTrue:[
f3e207ae5156 auto indent fix
Claus Gittinger <cg@exept.de>
parents: 2461
diff changeset
  2121
            (ln copyFrom:prevTab+1) isBlank ifTrue:[
f3e207ae5156 auto indent fix
Claus Gittinger <cg@exept.de>
parents: 2461
diff changeset
  2122
                cursorCol > prevTab ifTrue:[
f3e207ae5156 auto indent fix
Claus Gittinger <cg@exept.de>
parents: 2461
diff changeset
  2123
                    self cursorLine:cursorLine col:prevTab.
f3e207ae5156 auto indent fix
Claus Gittinger <cg@exept.de>
parents: 2461
diff changeset
  2124
                    wasOn ifTrue:[ self showCursor ].
f3e207ae5156 auto indent fix
Claus Gittinger <cg@exept.de>
parents: 2461
diff changeset
  2125
                    ^  self
f3e207ae5156 auto indent fix
Claus Gittinger <cg@exept.de>
parents: 2461
diff changeset
  2126
                ].
f3e207ae5156 auto indent fix
Claus Gittinger <cg@exept.de>
parents: 2461
diff changeset
  2127
            ] ifFalse:[
f3e207ae5156 auto indent fix
Claus Gittinger <cg@exept.de>
parents: 2461
diff changeset
  2128
                self deleteFromLine:cursorLine col:prevTab toLine:cursorLine col:cursorCol-1.
f3e207ae5156 auto indent fix
Claus Gittinger <cg@exept.de>
parents: 2461
diff changeset
  2129
                self cursorLine:cursorLine col:prevTab.
f3e207ae5156 auto indent fix
Claus Gittinger <cg@exept.de>
parents: 2461
diff changeset
  2130
                wasOn ifTrue:[ self showCursor ].
f3e207ae5156 auto indent fix
Claus Gittinger <cg@exept.de>
parents: 2461
diff changeset
  2131
                ^  self.
2356
6416beb0f23a backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents: 2350
diff changeset
  2132
            ]
2491
f3e207ae5156 auto indent fix
Claus Gittinger <cg@exept.de>
parents: 2461
diff changeset
  2133
        ].
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2134
    ].
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2135
2491
f3e207ae5156 auto indent fix
Claus Gittinger <cg@exept.de>
parents: 2461
diff changeset
  2136
"/        (autoIndent
f3e207ae5156 auto indent fix
Claus Gittinger <cg@exept.de>
parents: 2461
diff changeset
  2137
"/    and:[cursorCol  ~~ 1
f3e207ae5156 auto indent fix
Claus Gittinger <cg@exept.de>
parents: 2461
diff changeset
  2138
"/    and:[cursorLine <= (list size)]]) 
f3e207ae5156 auto indent fix
Claus Gittinger <cg@exept.de>
parents: 2461
diff changeset
  2139
"/     ifTrue:[
f3e207ae5156 auto indent fix
Claus Gittinger <cg@exept.de>
parents: 2461
diff changeset
  2140
"/        soCol := (self leftIndentForLine:cursorLine) + 1.
f3e207ae5156 auto indent fix
Claus Gittinger <cg@exept.de>
parents: 2461
diff changeset
  2141
"/
f3e207ae5156 auto indent fix
Claus Gittinger <cg@exept.de>
parents: 2461
diff changeset
  2142
"/        (cursorCol == soCol and:[soCol > 1]) ifTrue:[
f3e207ae5156 auto indent fix
Claus Gittinger <cg@exept.de>
parents: 2461
diff changeset
  2143
"/            ln := list at:cursorLine.
f3e207ae5156 auto indent fix
Claus Gittinger <cg@exept.de>
parents: 2461
diff changeset
  2144
"/            (ln notNil and:[(ln indexOfNonSeparatorStartingAt:1) < soCol]) ifTrue:[
f3e207ae5156 auto indent fix
Claus Gittinger <cg@exept.de>
parents: 2461
diff changeset
  2145
"/                soCol := 1
f3e207ae5156 auto indent fix
Claus Gittinger <cg@exept.de>
parents: 2461
diff changeset
  2146
"/            ]
f3e207ae5156 auto indent fix
Claus Gittinger <cg@exept.de>
parents: 2461
diff changeset
  2147
"/        ]
f3e207ae5156 auto indent fix
Claus Gittinger <cg@exept.de>
parents: 2461
diff changeset
  2148
"/    ] ifFalse:[
f3e207ae5156 auto indent fix
Claus Gittinger <cg@exept.de>
parents: 2461
diff changeset
  2149
        soCol := 1.
f3e207ae5156 auto indent fix
Claus Gittinger <cg@exept.de>
parents: 2461
diff changeset
  2150
"/    ].
f3e207ae5156 auto indent fix
Claus Gittinger <cg@exept.de>
parents: 2461
diff changeset
  2151
1419
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
  2152
    (cursorCol ~~ soCol and:[cursorCol ~~ 1]) ifTrue:[
2356
6416beb0f23a backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents: 2350
diff changeset
  2153
        "
6416beb0f23a backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents: 2350
diff changeset
  2154
         somewhere in the middle of a line
6416beb0f23a backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents: 2350
diff changeset
  2155
        "
6416beb0f23a backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents: 2350
diff changeset
  2156
        self cursorLeft.
6416beb0f23a backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents: 2350
diff changeset
  2157
        self deleteCharAtLine:cursorLine col:cursorCol.
1419
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
  2158
    ] ifFalse:[
2356
6416beb0f23a backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents: 2350
diff changeset
  2159
        "
6416beb0f23a backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents: 2350
diff changeset
  2160
         at begin of line - merge with previous line;
6416beb0f23a backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents: 2350
diff changeset
  2161
         except for the very first line.
6416beb0f23a backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents: 2350
diff changeset
  2162
        "
6416beb0f23a backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents: 2350
diff changeset
  2163
        (cursorLine == 1) ifFalse:[
6416beb0f23a backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents: 2350
diff changeset
  2164
            lineNrAboveCursor := self validateCursorLine:(cursorLine - 1).
6416beb0f23a backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents: 2350
diff changeset
  2165
            lineNrAboveCursor < cursorLine ifTrue:[
6416beb0f23a backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents: 2350
diff changeset
  2166
                (lineNrAboveCursor > 0 and:[lineNrAboveCursor > list size]) ifTrue:[
2707
810c994db0b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2696
diff changeset
  2167
                    "/ we are beyond the end of the text.
2356
6416beb0f23a backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents: 2350
diff changeset
  2168
                    "/ move the cursor to the previous line.
6416beb0f23a backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents: 2350
diff changeset
  2169
                    self cursorLine:lineNrAboveCursor col:1.
6416beb0f23a backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents: 2350
diff changeset
  2170
                ] ifFalse:[
6416beb0f23a backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents: 2350
diff changeset
  2171
                    self mergeLine:lineNrAboveCursor removeBlanks:false.
6416beb0f23a backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents: 2350
diff changeset
  2172
                ]
6416beb0f23a backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents: 2350
diff changeset
  2173
            ]
6416beb0f23a backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents: 2350
diff changeset
  2174
        ]
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2175
    ].
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2176
    wasOn ifTrue:[ self showCursor ]
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2177
1419
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
  2178
    "Modified: / 16.1.1998 / 22:33:04 / cg"
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2179
!
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2180
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2181
deleteCharsAtLine:lineNr fromCol:colNr
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2182
    "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
  2183
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2184
    |line|
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2185
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2186
    (line := self listAt:lineNr) notNil ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2187
        self deleteCharsAtLine:lineNr fromCol:colNr toCol:(line size)
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2188
    ]
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2189
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2190
!
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2191
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2192
deleteCharsAtLine:lineNr toCol:colNr
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2193
    "delete characters from start up to colNr in line lineNr"
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2194
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2195
    self deleteCharsAtLine:lineNr fromCol:1 toCol:colNr
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2196
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2197
121
claus
parents: 118
diff changeset
  2198
!
claus
parents: 118
diff changeset
  2199
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2200
deleteCursorLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2201
    "delete the line where the cursor sits"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2202
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2203
    self deleteLine:cursorLine
121
claus
parents: 118
diff changeset
  2204
!
claus
parents: 118
diff changeset
  2205
2385
357e8a1cb2b2 added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents: 2373
diff changeset
  2206
deleteFromCharacterPosition:charPos1 to:charPos2
357e8a1cb2b2 added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents: 2373
diff changeset
  2207
    "delete a substring at a character position"
357e8a1cb2b2 added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents: 2373
diff changeset
  2208
357e8a1cb2b2 added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents: 2373
diff changeset
  2209
    |line1 col1 line2 col2|
357e8a1cb2b2 added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents: 2373
diff changeset
  2210
357e8a1cb2b2 added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents: 2373
diff changeset
  2211
    line1 := self lineOfCharacterPosition:charPos1.
357e8a1cb2b2 added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents: 2373
diff changeset
  2212
    col1 := charPos1 - (self characterPositionOfLine:line1 col:1) + 1.
2725
eccf283b2efb deleteFromCharacterPos - fixed
Claus Gittinger <cg@exept.de>
parents: 2724
diff changeset
  2213
    col1 == 0 ifTrue:[
eccf283b2efb deleteFromCharacterPos - fixed
Claus Gittinger <cg@exept.de>
parents: 2724
diff changeset
  2214
        line1 := line1 - 1.
eccf283b2efb deleteFromCharacterPos - fixed
Claus Gittinger <cg@exept.de>
parents: 2724
diff changeset
  2215
        col1 := (self listAt:line1) size + 1.
eccf283b2efb deleteFromCharacterPos - fixed
Claus Gittinger <cg@exept.de>
parents: 2724
diff changeset
  2216
    ].
2385
357e8a1cb2b2 added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents: 2373
diff changeset
  2217
357e8a1cb2b2 added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents: 2373
diff changeset
  2218
    line2 := self lineOfCharacterPosition:charPos2.
357e8a1cb2b2 added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents: 2373
diff changeset
  2219
    col2 := charPos2 - (self characterPositionOfLine:line2 col:1) + 1.
357e8a1cb2b2 added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents: 2373
diff changeset
  2220
357e8a1cb2b2 added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents: 2373
diff changeset
  2221
    self deleteFromLine:line1 col:col1 toLine:line2 col:col2.
357e8a1cb2b2 added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents: 2373
diff changeset
  2222
!
357e8a1cb2b2 added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents: 2373
diff changeset
  2223
2954
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  2224
deleteFromLine:startLine col:startCol toLine:endLine col:endCol
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  2225
    "delete all text from startLine/startCol to endLine/endCol -
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  2226
     joining lines if nescessary"
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  2227
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  2228
    |line newLine lineSize nMore|
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  2229
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  2230
    self checkModificationsAllowed ifFalse:[ ^ self].
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  2231
    list isNil ifTrue:[^ self].
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  2232
    startLine > list size ifTrue:[ ^ self]. "/ deleted space below text
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  2233
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  2234
    (startLine == endLine) ifTrue:[
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  2235
        "/ delete chars within a line
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  2236
        self deleteCharsAtLine:startLine fromCol:startCol toCol:endCol.
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  2237
        ^ self
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  2238
    ].
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  2239
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  2240
    ((startCol == 1) and:[endCol == 0]) ifTrue:[
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  2241
        "/ delete full lines only
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  2242
        endLine > startLine ifTrue:[
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  2243
            self deleteFromLine:startLine toLine:(endLine - 1)
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  2244
        ].
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  2245
        ^ self
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  2246
    ].
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  2247
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  2248
    "/ delete right rest of 1st line
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  2249
    self deleteCharsAtLine:startLine fromCol:startCol.
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  2250
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  2251
    "/ delete the inner lines ...
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  2252
    endLine > (startLine + 1) ifTrue:[
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  2253
        self deleteFromLine:(startLine + 1) toLine:(endLine - 1)
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  2254
    ].
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  2255
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  2256
    (endCol ~~ 0) ifTrue:[
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  2257
        "/ delete the left rest of the last line
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  2258
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  2259
        self deleteCharsAtLine:(startLine + 1) toCol:endCol.
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  2260
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  2261
        "/ must add blanks, if startCol lies beyond end of startLine
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  2262
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  2263
        line := list at:startLine.
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  2264
        lineSize := line size.
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  2265
        (startCol > lineSize) ifTrue:[
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  2266
            newLine := line.
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  2267
            line isNil ifTrue:[
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  2268
                newLine := String new:(startCol - 1)
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  2269
            ] ifFalse:[
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  2270
                nMore := startCol - 1 - lineSize.
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  2271
                nMore > 0 ifTrue:[
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  2272
                    newLine := line , (line species new:nMore)
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  2273
                ]
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  2274
            ].
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  2275
            newLine ~~ line ifTrue:[
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  2276
                list at:startLine put:newLine.
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  2277
            ].
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  2278
            "/ TODO: remember old maxwidth of linerange,
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  2279
            "/ only clear widthOfWidestLine, if this max
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  2280
            "/ length was (one of) the longest.
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  2281
            "/ avoids slow delete with huge texts.
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  2282
            widthOfWidestLine := nil. "/ i.e. unknown
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  2283
            self textChanged.
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  2284
        ]
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  2285
    ].
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  2286
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  2287
    "/ merge the left rest of 1st line with right rest of last line into one
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  2288
    self mergeLine:startLine removeBlanks:false
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  2289
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  2290
    "Modified: / 10.11.1998 / 23:52:59 / cg"
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  2291
!
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  2292
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2293
deleteLine:lineNr
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2294
    "delete line"
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2295
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2296
    self deleteFromLine:lineNr toLine:lineNr
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2297
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2298
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2299
!
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2300
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2301
deleteLinesWithoutRedrawFrom:startLine to:endLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2302
    "delete lines - no redraw;
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2303
     return true, if something was really deleted"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2304
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2305
    |lastLine|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2306
331
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
  2307
    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
  2308
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2309
    (list isNil or:[startLine > list size]) ifTrue:[^ false].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2310
    (endLine > list size) ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2311
        lastLine := list size
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2312
    ] ifFalse:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2313
        lastLine := endLine
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2314
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2315
    list removeFromIndex:startLine toIndex:lastLine.
1717
83203096a851 dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  2316
    "/ TODO: remember old maxwidth of linerange,
83203096a851 dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  2317
    "/ only clear widthOfWidestLine, if this max
83203096a851 dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  2318
    "/ length was (one of) the longest.
83203096a851 dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  2319
    "/ avoids slow delete with huge texts.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2320
    widthOfWidestLine := nil. "/ i.e. unknown
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2321
    self textChanged.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2322
    ^ true
1717
83203096a851 dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  2323
83203096a851 dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  2324
    "Modified: / 10.11.1998 / 23:55:29 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2325
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2326
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2327
deleteSelection
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2328
    "delete the selection"
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
    |wasOn startLine startCol endLine endCol|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2331
331
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
  2332
    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
  2333
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2334
    selectionStartLine notNil ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2335
        wasOn := self hideCursor.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2336
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2337
        startLine := selectionStartLine.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2338
        startCol := selectionStartCol.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2339
        endLine := selectionEndLine.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2340
        endCol := selectionEndCol.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2341
        self unselectWithoutRedraw.
2422
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2342
        self deleteFromLine:startLine col:startCol toLine:endLine col:endCol.
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2343
        self setCursorLine:startLine col:startCol.
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2344
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2345
        self makeCursorVisibleAndShowCursor:wasOn
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2346
    ]
121
claus
parents: 118
diff changeset
  2347
!
claus
parents: 118
diff changeset
  2348
2157
ba22c3cc278b added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
  2349
deleteWordBeforeCursor
ba22c3cc278b added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
  2350
    "delete the word to the left of cursor and move cursor to left"
ba22c3cc278b added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
  2351
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  2352
    |wasOn beginCol beginLine endCol endLine|
2157
ba22c3cc278b added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
  2353
ba22c3cc278b added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
  2354
    wasOn := self hideCursor.
ba22c3cc278b added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
  2355
    endCol := cursorCol-1.
ba22c3cc278b added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
  2356
    endLine := cursorLine.
ba22c3cc278b added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
  2357
    self cursorToPreviousWord.
ba22c3cc278b added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
  2358
    beginCol := cursorCol.
ba22c3cc278b added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
  2359
    beginLine := cursorLine.
ba22c3cc278b added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
  2360
    self deleteFromLine:beginLine col:beginCol toLine:endLine col:endCol.
ba22c3cc278b added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
  2361
    wasOn ifTrue:[ self showCursor ].
ba22c3cc278b added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
  2362
ba22c3cc278b added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
  2363
    "Modified: / 22.2.2000 / 23:59:04 / cg"
ba22c3cc278b added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
  2364
!
ba22c3cc278b added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
  2365
121
claus
parents: 118
diff changeset
  2366
insertCharAtCursor:aCharacter
1566
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  2367
    "insert a single character at cursor-position - advance cursor."
121
claus
parents: 118
diff changeset
  2368
claus
parents: 118
diff changeset
  2369
    |wasOn|
claus
parents: 118
diff changeset
  2370
claus
parents: 118
diff changeset
  2371
    wasOn := self hideCursor.
1566
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  2372
    aCharacter == Character tab ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2373
        "/ needs special care to advance cursor correctly
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2374
        self insertTabAtCursor
121
claus
parents: 118
diff changeset
  2375
    ] ifFalse:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2376
        self insert:aCharacter atLine:cursorLine col:cursorCol.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2377
        aCharacter == (Character cr) ifTrue:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2378
            self cursorReturn
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2379
        ] ifFalse:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2380
            self cursorRight.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2381
        ].
121
claus
parents: 118
diff changeset
  2382
    ].
claus
parents: 118
diff changeset
  2383
    self makeCursorVisibleAndShowCursor:wasOn.
1566
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  2384
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  2385
    "Modified: / 12.6.1998 / 21:50:20 / cg"
121
claus
parents: 118
diff changeset
  2386
!
claus
parents: 118
diff changeset
  2387
641
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  2388
insertLine:aString before:lineNr
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  2389
    "insert the line aString before line lineNr"
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  2390
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  2391
    ^ self insertLines:(Array with:aString) from:1 to:1  before:lineNr.
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  2392
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  2393
    "Modified: 14.5.1996 / 13:42:54 / cg"
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  2394
!
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  2395
155
claus
parents: 133
diff changeset
  2396
insertLines:aStringCollection before:lineNr
claus
parents: 133
diff changeset
  2397
    "insert a bunch before line lineNr"
claus
parents: 133
diff changeset
  2398
claus
parents: 133
diff changeset
  2399
    self insertLines:aStringCollection from:1 to:aStringCollection size before:lineNr
claus
parents: 133
diff changeset
  2400
claus
parents: 133
diff changeset
  2401
    "Modified: 6.9.1995 / 20:51:03 / claus"
claus
parents: 133
diff changeset
  2402
!
claus
parents: 133
diff changeset
  2403
654
d621e63baaa5 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 641
diff changeset
  2404
insertLines:lines withCR:withCr
1566
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  2405
    "insert a bunch of lines at cursor position. 
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  2406
     Cursor is moved behind insertion.
641
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  2407
     If withCr is true, append cr after last line"
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  2408
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  2409
    |start end nLines wasOn|
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  2410
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  2411
    lines notNil ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2412
        nLines := lines size.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2413
        (nLines == 1) ifTrue:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2414
            self insertStringAtCursor:(lines at:1).
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2415
            withCr ifTrue:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2416
                self insertCharAtCursor:(Character cr)
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2417
            ] 
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2418
        ] ifFalse:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2419
            (cursorCol ~~ 1) ifTrue:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2420
                self insertStringAtCursor:(lines at:1).
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2421
                self insertCharAtCursor:(Character cr).
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2422
                start := 2
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2423
            ] ifFalse:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2424
                start := 1
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2425
            ].
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2426
            withCr ifTrue:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2427
                end := nLines
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2428
            ] ifFalse:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2429
                end := nLines - 1
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2430
            ].
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2431
            (start < nLines) ifTrue:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2432
                (end >= start) ifTrue:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2433
                    wasOn := self hideCursor.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2434
                    self insertLines:lines from:start to:end before:cursorLine.
2422
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2435
                    self setCursorLine:(cursorLine + (end - start + 1)).
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2436
                    wasOn ifTrue:[self showCursor].
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2437
                ]
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2438
            ].
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2439
            withCr ifFalse:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2440
                "last line without cr"
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2441
                self insertStringAtCursor:(lines at:nLines)
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2442
            ]
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2443
        ]
641
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  2444
    ]
654
d621e63baaa5 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 641
diff changeset
  2445
1566
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  2446
    "Created: / 18.5.1996 / 15:32:06 / cg"
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  2447
    "Modified: / 12.6.1998 / 21:51:16 / cg"
654
d621e63baaa5 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 641
diff changeset
  2448
!
d621e63baaa5 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 641
diff changeset
  2449
d621e63baaa5 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 641
diff changeset
  2450
insertLines:lines withCr:withCr
d621e63baaa5 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 641
diff changeset
  2451
    "insert a bunch of lines at cursor position. Cursor
d621e63baaa5 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 641
diff changeset
  2452
     is moved behind insertion.
d621e63baaa5 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 641
diff changeset
  2453
     If withCr is true, append cr after last line"
d621e63baaa5 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 641
diff changeset
  2454
2363
1982139b2c0b Use <resource:#obsolete>
Stefan Vogel <sv@exept.de>
parents: 2357
diff changeset
  2455
    <resource:#obsolete>
1982139b2c0b Use <resource:#obsolete>
Stefan Vogel <sv@exept.de>
parents: 2357
diff changeset
  2456
1292
ca4c9a957a32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1290
diff changeset
  2457
    self obsoleteMethodWarning:'use #insertLines:withCR:'.
ca4c9a957a32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1290
diff changeset
  2458
    self insertLines:lines withCR:withCr.
ca4c9a957a32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1290
diff changeset
  2459
ca4c9a957a32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1290
diff changeset
  2460
    "Modified: 31.7.1997 / 23:07:22 / cg"
641
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  2461
!
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  2462
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2463
insertSelectedStringAtCursor:aString
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2464
    "insert the argument, aString at cursor position and select it"
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
    |startLine startCol|
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
    startLine := cursorLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2469
    startCol := cursorCol.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2470
    self insertStringAtCursor:aString.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2471
    self selectFromLine:startLine col:startCol
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2472
                 toLine:cursorLine col:(cursorCol - 1)
259
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
1935
b59ff4681762 added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
  2475
insertString:aString atCharacterPosition:charPos
b59ff4681762 added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
  2476
    "insert the argument, aString at a character position"
b59ff4681762 added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
  2477
b59ff4681762 added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
  2478
    |line col|
b59ff4681762 added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
  2479
b59ff4681762 added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
  2480
    line := self lineOfCharacterPosition:charPos.
b59ff4681762 added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
  2481
    col := charPos - (self characterPositionOfLine:line col:1) + 1.
b59ff4681762 added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
  2482
    self insertString:aString atLine:line col:col
b59ff4681762 added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
  2483
!
b59ff4681762 added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
  2484
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2485
insertString:aString atLine:lineNr col:colNr
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2486
    "insert the string, aString at line/col;
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2487
     handle cr's correctly"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2488
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2489
    |start           "{ Class: SmallInteger }"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2490
     stop            "{ Class: SmallInteger }"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2491
     end             "{ Class: SmallInteger }"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2492
     subString c
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2493
     l               "{ Class: SmallInteger }" |
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2494
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2495
    aString isNil ifTrue:[^ self].
1560
43d0f7c2143f use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents: 1559
diff changeset
  2496
    (aString includes:(Character cr)) ifFalse:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2497
        ^ self insertStringWithoutCRs:aString atLine:lineNr col:colNr
121
claus
parents: 118
diff changeset
  2498
    ].
1560
43d0f7c2143f use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents: 1559
diff changeset
  2499
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2500
    l := lineNr.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2501
    c := colNr.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2502
    start := 1.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2503
    end := aString size.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2504
    [start <= end] whileTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2505
        stop := aString indexOf:(Character cr) startingAt:start.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2506
        stop == 0 ifTrue:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2507
            stop := end + 1
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2508
        ].
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2509
        subString := aString copyFrom:start to:(stop - 1).
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2510
        self insertStringWithoutCRs:subString atLine:l col:c.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2511
        (stop <= end) ifTrue:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2512
            c := c + subString size.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2513
            self insert:(Character cr) atLine:l col:c.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2514
            l := l + 1.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2515
            c := 1
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2516
        ].
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2517
        start := stop + 1
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2518
    ]
1480
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  2519
1560
43d0f7c2143f use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents: 1559
diff changeset
  2520
    "Modified: / 10.6.1998 / 19:03:59 / cg"
121
claus
parents: 118
diff changeset
  2521
!
claus
parents: 118
diff changeset
  2522
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2523
insertStringAtCursor:aString
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2524
    "insert the argument, aString at cursor position
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2525
     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
  2526
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2527
    aString isNil ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2528
        "new:"
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2529
        self insertCharAtCursor:(Character cr).
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2530
        ^ self
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  2531
    ].
1560
43d0f7c2143f use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents: 1559
diff changeset
  2532
    (aString includes:(Character cr)) ifFalse:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2533
        ^ self insertStringWithoutCRsAtCursor:aString
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  2534
    ].
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  2535
654
d621e63baaa5 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 641
diff changeset
  2536
    self insertLines:aString asStringCollection withCR:false.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2537
1560
43d0f7c2143f use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents: 1559
diff changeset
  2538
    "Modified: / 10.6.1998 / 19:03:21 / cg"
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  2539
!
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  2540
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2541
insertStringWithoutCRs:aString atLine:lineNr col:colNr
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2542
    "insert aString (which has no crs) at lineNr/colNr"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2543
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2544
    self withoutRedrawInsertStringWithoutCRs:aString atLine:lineNr col:colNr.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2545
    shown ifTrue:[self redrawLine:lineNr from:colNr]
1480
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  2546
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  2547
    "Modified: / 5.4.1998 / 16:51:14 / cg"
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  2548
!
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  2549
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2550
insertStringWithoutCRsAtCursor:aString
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2551
    "insert a string (which has no crs) at cursor position
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2552
     - advance cursor"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2553
2422
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2554
    |wasOn oldLen newLen deltaLen|
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2555
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2556
    aString size > 0 ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2557
        wasOn := self hideCursor.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2558
        (aString includes:Character tab) ifTrue:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2559
            self checkForExistingLine:cursorLine.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2560
            oldLen := (list at:cursorLine) size.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2561
            self insertString:aString atLine:cursorLine col:cursorCol.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2562
            newLen := (list at:cursorLine) size.
2422
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2563
            deltaLen := newLen - oldLen.    
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2564
        ] ifFalse:[
2574
e79598f1627b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2570
diff changeset
  2565
            self insertString:aString atLine:(cursorLine ? 1) col:cursorCol.
2422
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2566
            deltaLen := aString size.
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2567
        ].
2422
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2568
        self setCursorCol:(cursorCol + deltaLen).
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2569
        wasOn ifTrue:[self showCursor]
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2570
    ]
1563
b4eb49efdfcd fixed cursor positioning if inserting a string with tabs.
Claus Gittinger <cg@exept.de>
parents: 1561
diff changeset
  2571
b4eb49efdfcd fixed cursor positioning if inserting a string with tabs.
Claus Gittinger <cg@exept.de>
parents: 1561
diff changeset
  2572
    "Modified: / 10.6.1998 / 20:43:52 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2573
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2574
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2575
insertTabAtCursor
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2576
    "insert spaces to next tab"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2577
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2578
    |wasOn nextTab|
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  2579
121
claus
parents: 118
diff changeset
  2580
    wasOn := self hideCursor.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2581
    nextTab := self nextTabAfter:cursorCol.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2582
    self insertStringAtCursor:(String new:(nextTab - cursorCol)).
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2583
    self makeCursorVisibleAndShowCursor:wasOn.
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  2584
!
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  2585
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  2586
mergeLine:lineNr
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  2587
    "merge line lineNr with line lineNr+1"
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  2588
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  2589
    self mergeLine:lineNr removeBlanks:true
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  2590
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  2591
    "Modified: 9.9.1997 / 09:28:03 / cg"
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  2592
!
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  2593
2506
5568d67dbddd Ctrl-8 / Ctrl-9,
Claus Gittinger <cg@exept.de>
parents: 2505
diff changeset
  2594
parenthizeSelectionWith:openingCharacter and:closingCharacter
2505
9204d5313979 Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents: 2491
diff changeset
  2595
    |newSelectionEnd|
9204d5313979 Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents: 2491
diff changeset
  2596
9204d5313979 Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents: 2491
diff changeset
  2597
    self hasSelection ifFalse:[^ self].
9204d5313979 Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents: 2491
diff changeset
  2598
9204d5313979 Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents: 2491
diff changeset
  2599
    newSelectionEnd := selectionEndCol.
9204d5313979 Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents: 2491
diff changeset
  2600
2506
5568d67dbddd Ctrl-8 / Ctrl-9,
Claus Gittinger <cg@exept.de>
parents: 2505
diff changeset
  2601
    (self characterAtLine:selectionStartLine col:selectionStartCol) == openingCharacter ifTrue:[
5568d67dbddd Ctrl-8 / Ctrl-9,
Claus Gittinger <cg@exept.de>
parents: 2505
diff changeset
  2602
        (self characterAtLine:selectionEndLine col:selectionEndCol) == closingCharacter ifTrue:[
2505
9204d5313979 Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents: 2491
diff changeset
  2603
            self deleteCharAtLine:selectionEndLine col:selectionEndCol.
9204d5313979 Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents: 2491
diff changeset
  2604
            newSelectionEnd := newSelectionEnd-1.
9204d5313979 Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents: 2491
diff changeset
  2605
        ].
9204d5313979 Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents: 2491
diff changeset
  2606
        self deleteCharAtLine:selectionStartLine col:selectionStartCol.
9204d5313979 Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents: 2491
diff changeset
  2607
        selectionStartLine == selectionEndLine ifTrue:[
9204d5313979 Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents: 2491
diff changeset
  2608
            newSelectionEnd := newSelectionEnd-1.
9204d5313979 Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents: 2491
diff changeset
  2609
        ]
9204d5313979 Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents: 2491
diff changeset
  2610
    ] ifFalse:[
2506
5568d67dbddd Ctrl-8 / Ctrl-9,
Claus Gittinger <cg@exept.de>
parents: 2505
diff changeset
  2611
        self insert:closingCharacter atLine:selectionEndLine col:selectionEndCol+1.
2505
9204d5313979 Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents: 2491
diff changeset
  2612
        newSelectionEnd := newSelectionEnd+1.
2506
5568d67dbddd Ctrl-8 / Ctrl-9,
Claus Gittinger <cg@exept.de>
parents: 2505
diff changeset
  2613
        self insert:openingCharacter atLine:selectionStartLine col:selectionStartCol.
2505
9204d5313979 Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents: 2491
diff changeset
  2614
        selectionStartLine == selectionEndLine ifTrue:[
9204d5313979 Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents: 2491
diff changeset
  2615
            newSelectionEnd := newSelectionEnd+1.
9204d5313979 Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents: 2491
diff changeset
  2616
        ]
9204d5313979 Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents: 2491
diff changeset
  2617
    ].
9204d5313979 Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents: 2491
diff changeset
  2618
    self 
9204d5313979 Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents: 2491
diff changeset
  2619
        selectFromLine:selectionStartLine col:selectionStartCol
9204d5313979 Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents: 2491
diff changeset
  2620
        toLine:selectionEndLine col:newSelectionEnd.
9204d5313979 Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents: 2491
diff changeset
  2621
!
9204d5313979 Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents: 2491
diff changeset
  2622
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2623
removeTrailingBlankLines
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2624
    "remove all blank lines at end of text"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2625
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2626
    |lastLine "{ Class: SmallInteger }"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2627
     line finished|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2628
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2629
    lastLine := list size.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2630
    finished := false.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2631
    [finished] whileFalse:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2632
        (lastLine <= 1) ifTrue:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2633
            finished := true
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2634
        ] ifFalse:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2635
            line := list at:lastLine.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2636
            line notNil ifTrue:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2637
                line isBlank ifTrue:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2638
                    list at:lastLine put:nil.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2639
                    line := nil
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2640
                ]
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2641
            ].
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2642
            line notNil ifTrue:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2643
                finished := true
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2644
            ] ifFalse:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2645
                lastLine := lastLine - 1
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2646
            ]
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2647
        ]
118
claus
parents: 105
diff changeset
  2648
    ].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2649
    (lastLine ~~ list size) ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2650
        list grow:lastLine.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2651
"/        self textChanged
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2652
    ]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2653
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2654
477
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  2655
replaceCharAtCursor:aCharacter
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  2656
    "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
  2657
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  2658
    |wasOn|
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  2659
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  2660
    wasOn := self hideCursor.
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  2661
    aCharacter == (Character cr) ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2662
        self cursorReturn
477
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  2663
    ] ifFalse:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2664
        self replace:aCharacter atLine:cursorLine col:cursorCol.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2665
        self cursorRight.
477
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  2666
    ].
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  2667
    self makeCursorVisibleAndShowCursor:wasOn.
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  2668
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  2669
    "Created: 6.3.1996 / 12:27:42 / cg"
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  2670
!
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  2671
2427
43cc7ea39bac more editing stuff (xxx-characterPosition)
Claus Gittinger <cg@exept.de>
parents: 2422
diff changeset
  2672
replaceFromCharacterPosition:charPos1 to:charPos2 with:newString
43cc7ea39bac more editing stuff (xxx-characterPosition)
Claus Gittinger <cg@exept.de>
parents: 2422
diff changeset
  2673
    "replace a substring at a character position"
43cc7ea39bac more editing stuff (xxx-characterPosition)
Claus Gittinger <cg@exept.de>
parents: 2422
diff changeset
  2674
43cc7ea39bac more editing stuff (xxx-characterPosition)
Claus Gittinger <cg@exept.de>
parents: 2422
diff changeset
  2675
    self insertString:newString atCharacterPosition:charPos1.
43cc7ea39bac more editing stuff (xxx-characterPosition)
Claus Gittinger <cg@exept.de>
parents: 2422
diff changeset
  2676
    self deleteFromCharacterPosition:charPos1+newString size to:charPos2+newString size.
43cc7ea39bac more editing stuff (xxx-characterPosition)
Claus Gittinger <cg@exept.de>
parents: 2422
diff changeset
  2677
!
43cc7ea39bac more editing stuff (xxx-characterPosition)
Claus Gittinger <cg@exept.de>
parents: 2422
diff changeset
  2678
1564
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  2679
replaceLines:lines withCR:withCr
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  2680
    "replace a bunch of lines at cursor position. Cursor
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  2681
     is moved behind replacement.
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  2682
     If withCr is true, move to the beginning of the next line
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  2683
     after the last line"
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  2684
1809
111f603c0a1c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1807
diff changeset
  2685
    |line col nLines wasOn|
1564
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  2686
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  2687
    lines notNil ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2688
        wasOn := self hideCursor.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2689
        nLines := lines size.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2690
        line := cursorLine.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2691
        col := cursorCol.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2692
        lines keysAndValuesDo:[:i :l |
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2693
            self replaceString:l atLine:line col:col.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2694
            (i ~~ nLines or:[withCr]) ifTrue:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2695
                line := line + 1.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2696
                col := 1.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2697
            ] ifFalse:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2698
                col := col + (l size).
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2699
            ]
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2700
        ].
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2701
        self cursorLine:line col:col.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2702
        self makeCursorVisibleAndShowCursor:wasOn.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2703
        "/ wasOn ifTrue:[self showCursor].
1564
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  2704
    ]
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  2705
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  2706
    "Created: / 18.5.1996 / 15:32:06 / cg"
1567
0eff7ca88e89 much faster multi-line replace (avoid scroll)
Claus Gittinger <cg@exept.de>
parents: 1566
diff changeset
  2707
    "Modified: / 12.6.1998 / 22:05:51 / cg"
1564
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  2708
!
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  2709
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2710
replaceSelectionBy:something
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2711
    "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
  2712
     leave cursor after insertion"
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
    self replaceSelectionBy:something keepCursor:false
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  2715
!
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  2716
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  2717
replaceSelectionBy:something keepCursor:keep
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  2718
    "delete the selection (if any) and insert something, a character or string;
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  2719
     leave cursor after insertion or leave it, depending on keep"
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  2720
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  2721
    |sel l c|
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  2722
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  2723
    l := cursorLine.
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  2724
    c := cursorCol.
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  2725
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  2726
    sel := self selection.
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  2727
    sel notNil ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2728
        lastString := sel.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2729
        self deleteSelection.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2730
        replacing := true.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2731
        lastReplacement := ''
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  2732
    ].
840
b0071cea13fd fixed Again when spaces are replaced
Claus Gittinger <cg@exept.de>
parents: 828
diff changeset
  2733
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  2734
    (something isMemberOf:Character) ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2735
        lastReplacement notNil ifTrue:[
840
b0071cea13fd fixed Again when spaces are replaced
Claus Gittinger <cg@exept.de>
parents: 828
diff changeset
  2736
"/ "XXX - replacing text with spaces ..."
b0071cea13fd fixed Again when spaces are replaced
Claus Gittinger <cg@exept.de>
parents: 828
diff changeset
  2737
"/            (lastReplacement endsWith:Character space) ifTrue:[
b0071cea13fd fixed Again when spaces are replaced
Claus Gittinger <cg@exept.de>
parents: 828
diff changeset
  2738
"/                lastReplacement := lastReplacement copyWithoutLast:1 "copyTo:(lastReplacement size - 1)".
b0071cea13fd fixed Again when spaces are replaced
Claus Gittinger <cg@exept.de>
parents: 828
diff changeset
  2739
"/                lastReplacement := lastReplacement copyWith:something.
b0071cea13fd fixed Again when spaces are replaced
Claus Gittinger <cg@exept.de>
parents: 828
diff changeset
  2740
"/                lastReplacement := lastReplacement copyWith:Character space
b0071cea13fd fixed Again when spaces are replaced
Claus Gittinger <cg@exept.de>
parents: 828
diff changeset
  2741
"/            ] ifFalse:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2742
                lastReplacement := lastReplacement copyWith:something.
840
b0071cea13fd fixed Again when spaces are replaced
Claus Gittinger <cg@exept.de>
parents: 828
diff changeset
  2743
"/            ]
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2744
        ].
2795
1f7b5f242eee learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents: 2792
diff changeset
  2745
        insertMode value ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2746
            self insertCharAtCursor:something
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2747
        ] ifFalse:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2748
            self replaceCharAtCursor:something
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2749
        ]
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  2750
    ] ifFalse:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2751
        lastReplacement := something.
2795
1f7b5f242eee learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents: 2792
diff changeset
  2752
        insertMode value ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2753
            self insertStringAtCursor:something
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2754
        ] ifFalse:[
2912
b302a46fc21e oops - replace-by-keyboard-entry got corrupted by
Claus Gittinger <cg@exept.de>
parents: 2910
diff changeset
  2755
            self replaceStringAtCursor:something
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2756
        ]
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  2757
    ].
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  2758
    keep ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2759
        self cursorLine:l col:c
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  2760
    ]
477
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  2761
840
b0071cea13fd fixed Again when spaces are replaced
Claus Gittinger <cg@exept.de>
parents: 828
diff changeset
  2762
    "Modified: 9.10.1996 / 16:14:35 / cg"
1564
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  2763
!
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  2764
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  2765
replaceStringAtCursor:aString
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  2766
    "replace multiple characters at cursor-position - advance cursor"
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  2767
1566
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  2768
    |wasOn i1 i2|
1564
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  2769
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  2770
    wasOn := self hideCursor.
1566
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  2771
    (aString includes:Character tab) ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2772
        "/ need special care for TAB (to move cursor correctly)
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2773
        i1 := 1.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2774
        [i1 ~~ 0] whileTrue:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2775
            i2 := aString indexOf:Character tab startingAt:i1.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2776
            i2 ~~ 0 ifTrue:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2777
                i1 ~~ i2 ifTrue:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2778
                    self replaceString:(aString copyFrom:i1 to:i2-1) atLine:cursorLine col:cursorCol.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2779
                    self cursorCol:(cursorCol + (i2 - i1)).
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2780
                ].
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2781
                self replaceTABAtCursor.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2782
                i2 := i2 + 1.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2783
            ] ifFalse:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2784
                self replaceString:(aString copyFrom:i1) atLine:cursorLine col:cursorCol.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2785
                self cursorCol:(cursorCol + (aString size - i1 + 1)).
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2786
            ].
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2787
            i1 := i2.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2788
        ]
1566
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  2789
    ] ifFalse:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2790
        self replaceString:aString atLine:cursorLine col:cursorCol.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2791
        self cursorCol:(cursorCol + aString size).
1566
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  2792
    ].
1564
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  2793
    self makeCursorVisibleAndShowCursor:wasOn.
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  2794
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  2795
    "Created: / 9.6.1998 / 20:33:20 / cg"
1597
5fdcfcedb91c fixed cursor positioning after replaceStringAtCursor.
Claus Gittinger <cg@exept.de>
parents: 1596
diff changeset
  2796
    "Modified: / 20.6.1998 / 19:41:02 / cg"
1566
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  2797
!
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  2798
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  2799
replaceTABAtCursor
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  2800
    "replace a single character at cursor-position by a TAB character"
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  2801
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  2802
    |wasOn nextTab|
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  2803
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  2804
    wasOn := self hideCursor.
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  2805
    nextTab := self nextTabAfter:cursorCol.
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  2806
    self replaceStringAtCursor:(String new:(nextTab - cursorCol)).
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  2807
    self makeCursorVisibleAndShowCursor:wasOn.
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  2808
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  2809
    "Created: / 12.6.1998 / 21:53:23 / cg"
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2810
! !
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2811
2752
5650a9ab5935 method category rename
Claus Gittinger <cg@exept.de>
parents: 2744
diff changeset
  2812
!EditTextView methodsFor:'editing-basic'!
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2813
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  2814
basicDeleteCharsAtLine:lineNr fromCol:startCol toCol:endCol
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2815
    "delete characters from startCol to endCol in line lineNr
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2816
    "
1803
ac7cc1b99407 scroll left as required, if deleting characters of the longest line,
Claus Gittinger <cg@exept.de>
parents: 1796
diff changeset
  2817
    |line lineSize newLine start stop prevWidth newWidth|
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2818
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2819
    line := self listAt:lineNr.
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2820
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2821
    (self checkModificationsAllowed and:[line notNil]) ifTrue:[ 
2207
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  2822
        lineSize := line size.
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  2823
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  2824
        startCol == 0     ifFalse:[ start := startCol ]
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  2825
                           ifTrue:[ start := 1 ]. 
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  2826
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  2827
        endCol > lineSize ifFalse:[ stop  := endCol ]
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  2828
                           ifTrue:[ stop  := lineSize ].
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  2829
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  2830
        stop >= start ifTrue:[
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  2831
            start ~~ 1 ifTrue:[ newLine := line copyFrom:1 to:(start-1) ]
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  2832
                      ifFalse:[ newLine := '' ].
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  2833
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  2834
            stop == lineSize ifFalse:[
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  2835
                line bitsPerCharacter > newLine bitsPerCharacter ifTrue:[
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  2836
                    newLine := line string species fromString:newLine.
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  2837
                ].
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  2838
                newLine := newLine, (line copyFrom:(stop + 1) to:lineSize)
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  2839
            ].
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  2840
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  2841
            (trimBlankLines and:[newLine isBlank]) ifTrue:[
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  2842
                newLine := nil
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  2843
            ].
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  2844
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  2845
            prevWidth := self widthOfLine:lineNr.
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  2846
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  2847
            list at:lineNr put:newLine.
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  2848
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  2849
            (prevWidth = widthOfWidestLine) ifTrue:[
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  2850
                "/ remember old width of this line,
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  2851
                "/ only clear widthOfWidestLine, if this lines
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  2852
                "/ length was (one of) the longest.
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  2853
                "/ avoids slow delete with huge texts.
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  2854
                widthOfWidestLine := nil.   "i.e. unknown"
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  2855
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  2856
                "/ scroll left if reqiured
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  2857
                viewOrigin x > 0 ifTrue:[
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  2858
                    newWidth := self widthOfLine:lineNr.
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  2859
                    newWidth < (viewOrigin x + width) ifTrue:[
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  2860
                        self scrollHorizontalTo:(newWidth 
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  2861
                                                 - width 
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  2862
                                                 + margin + margin 
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  2863
                                                 + (font widthOf:'  '))
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  2864
                    ]
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  2865
                ].
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  2866
                self textChanged.
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  2867
            ] ifFalse:[
2617
a9b1af787406 typo on method name
Claus Gittinger <cg@exept.de>
parents: 2606
diff changeset
  2868
                self textChanged "/ textChangedButNoSizeChange
2207
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  2869
            ].
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  2870
            self redrawLine:lineNr from:start.
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  2871
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  2872
        ]
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2873
    ]
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2874
1717
83203096a851 dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  2875
    "Modified: / 11.11.1998 / 00:01:09 / cg"
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2876
!
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2877
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  2878
basicDeleteFromLine:startLineNr toLine:endLineNr
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2879
    "delete some lines"
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2880
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2881
    |wasOn nLines|
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2882
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2883
    self checkModificationsAllowed ifFalse:[ ^ self].
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2884
    list isNil ifTrue:[^ self].
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2885
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2886
    wasOn := self hideCursor.
1717
83203096a851 dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  2887
83203096a851 dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  2888
    "/ isnt this the same as:
83203096a851 dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  2889
    "/ self deleteLinesWithoutRedrawFrom:startLineNr to:endLineNr.
83203096a851 dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  2890
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2891
    list removeFromIndex:startLineNr toIndex:(endLineNr min:list size).
1717
83203096a851 dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  2892
    "/ TODO: remember old maxwidth of linerange,
83203096a851 dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  2893
    "/ only clear widthOfWidestLine, if this max
83203096a851 dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  2894
    "/ length was (one of) the longest.
83203096a851 dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  2895
    "/ avoids slow delete with huge texts.
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2896
    widthOfWidestLine := nil. "/ i.e. unknown
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2897
    self textChanged.
1717
83203096a851 dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  2898
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2899
    self redrawFromLine:startLineNr.
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2900
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2901
    nLines := list size.
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2902
    (firstLineShown >= nLines) ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  2903
        self makeLineVisible:nLines
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2904
    ].
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2905
    wasOn ifTrue:[self showCursor].
1717
83203096a851 dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  2906
83203096a851 dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  2907
    "Modified: / 10.11.1998 / 23:55:05 / cg"
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2908
!
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2909
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  2910
basicDeleteLineWithoutRedraw:lineNr
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2911
    "delete line - no redraw;
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2912
     return true, if something was really deleted"
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2913
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  2914
    self checkModificationsAllowed ifFalse:[ ^ false].
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2915
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2916
    (list isNil or:[lineNr > list size]) ifTrue:[^ false].
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2917
    list removeIndex:lineNr.
1717
83203096a851 dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  2918
    "/ TODO: remember old maxwidth of linerange,
83203096a851 dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  2919
    "/ only clear widthOfWidestLine, if this max
83203096a851 dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  2920
    "/ length was (one of) the longest.
83203096a851 dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  2921
    "/ avoids slow delete with huge texts.
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2922
    widthOfWidestLine := nil. "/ i.e. unknown
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2923
    self textChanged.
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2924
    ^ true
1717
83203096a851 dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  2925
83203096a851 dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  2926
    "Modified: / 10.11.1998 / 23:53:24 / cg"
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2927
!
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2928
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  2929
basicInsert:aCharacter atLine:lineNr col:colNr
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2930
    "insert a single character at lineNr/colNr; 
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2931
     set emphasis to character at current position"
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2932
1929
8e70fb7c9701 fixed handling of italic text when inserting
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  2933
    |line lineSize newLine drawCharacterOnly attribute oldClip x y|
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2934
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2935
    self checkModificationsAllowed ifFalse:[ ^ self].
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2936
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2937
    aCharacter == (Character cr) ifTrue:[
2029
22629607c6eb care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents: 2022
diff changeset
  2938
        self splitLine:lineNr before:colNr.
22629607c6eb care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents: 2022
diff changeset
  2939
        ^ self
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2940
    ].
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2941
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2942
    drawCharacterOnly := false.
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2943
    self checkForExistingLine:lineNr.
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2944
    line := list at:lineNr.
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2945
    lineSize := line size.
671
f3fe0d8c604d added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents: 666
diff changeset
  2946
3023
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  2947
    self st80EditMode ifFalse:[
2029
22629607c6eb care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents: 2022
diff changeset
  2948
        (trimBlankLines 
22629607c6eb care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents: 2022
diff changeset
  2949
        and:[colNr > lineSize
22629607c6eb care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents: 2022
diff changeset
  2950
        and:[aCharacter == Character space]]) ifTrue:[
22629607c6eb care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents: 2022
diff changeset
  2951
            ^ self
22629607c6eb care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents: 2022
diff changeset
  2952
        ]
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2953
    ].
671
f3fe0d8c604d added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents: 666
diff changeset
  2954
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2955
    (lineSize == 0) ifTrue:[
2029
22629607c6eb care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents: 2022
diff changeset
  2956
        newLine := aCharacter asString species new:colNr.
22629607c6eb care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents: 2022
diff changeset
  2957
        drawCharacterOnly := true
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2958
    ] ifFalse: [
2029
22629607c6eb care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents: 2022
diff changeset
  2959
        (colNr > lineSize) ifTrue: [
22629607c6eb care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents: 2022
diff changeset
  2960
            colNr == (lineSize +1) ifTrue:[
22629607c6eb care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents: 2022
diff changeset
  2961
                attribute := line emphasisAt:lineSize
22629607c6eb care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents: 2022
diff changeset
  2962
            ].
22629607c6eb care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents: 2022
diff changeset
  2963
            newLine := line species new:colNr.
2210
94f6ffcb06ac *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2207
diff changeset
  2964
            newLine replaceFrom:1 to:lineSize with:line startingAt:1.
2029
22629607c6eb care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents: 2022
diff changeset
  2965
            drawCharacterOnly := true
22629607c6eb care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents: 2022
diff changeset
  2966
        ] ifFalse: [
22629607c6eb care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents: 2022
diff changeset
  2967
            attribute := line emphasisAt:colNr.
22629607c6eb care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents: 2022
diff changeset
  2968
            newLine   := line species new:(lineSize + 1).
22629607c6eb care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents: 2022
diff changeset
  2969
2210
94f6ffcb06ac *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2207
diff changeset
  2970
            newLine replaceFrom:1 to:(colNr - 1) with:line startingAt:1.
94f6ffcb06ac *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2207
diff changeset
  2971
            newLine replaceFrom:(colNr + 1) to:(lineSize + 1) with:line startingAt:colNr
2029
22629607c6eb care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents: 2022
diff changeset
  2972
        ]
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2973
    ].
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2974
2869
48d830f0aea5 insertCharacter: care for wide chars
Claus Gittinger <cg@exept.de>
parents: 2866
diff changeset
  2975
    aCharacter asString bitsPerCharacter > newLine bitsPerCharacter ifTrue:[
2940
22b1345e22dd care for 16bit chars
ca
parents: 2931
diff changeset
  2976
        newLine := aCharacter asString species fromString:newLine.
22b1345e22dd care for 16bit chars
ca
parents: 2931
diff changeset
  2977
        line isText ifTrue:[
22b1345e22dd care for 16bit chars
ca
parents: 2931
diff changeset
  2978
            newLine := newLine asText
22b1345e22dd care for 16bit chars
ca
parents: 2931
diff changeset
  2979
        ]
2869
48d830f0aea5 insertCharacter: care for wide chars
Claus Gittinger <cg@exept.de>
parents: 2866
diff changeset
  2980
    ].
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2981
    newLine at:colNr put:aCharacter.
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2982
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2983
    attribute notNil ifTrue:[
2029
22629607c6eb care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents: 2022
diff changeset
  2984
        newLine emphasisAt:colNr put:attribute
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2985
    ].
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2986
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2987
    aCharacter == (Character tab) ifTrue:[
2029
22629607c6eb care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents: 2022
diff changeset
  2988
        newLine := self withTabsExpanded:newLine.
22629607c6eb care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents: 2022
diff changeset
  2989
        drawCharacterOnly := false
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2990
    ].
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2991
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2992
    list at:lineNr put:newLine.
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2993
    widthOfWidestLine notNil ifTrue:[
2029
22629607c6eb care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents: 2022
diff changeset
  2994
        widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:line).
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2995
    ].
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2996
    self textChanged.
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2997
    shown ifTrue:[
2029
22629607c6eb care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents: 2022
diff changeset
  2998
        "/ care for italic text - in this case, we must also
22629607c6eb care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents: 2022
diff changeset
  2999
        "/ redraw the character before the insertion in order
22629607c6eb care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents: 2022
diff changeset
  3000
        "/ to fix the slanted piece of the character.
22629607c6eb care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents: 2022
diff changeset
  3001
        "/ (but we must clip, to avoid destoying the character before)
22629607c6eb care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents: 2022
diff changeset
  3002
        (newLine notNil and:[newLine isText]) ifTrue:[
22629607c6eb care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents: 2022
diff changeset
  3003
            colNr > 1 ifTrue:[
22629607c6eb care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents: 2022
diff changeset
  3004
                cursorVisibleLine notNil ifTrue:[
22629607c6eb care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents: 2022
diff changeset
  3005
                    oldClip := self clippingRectangleOrNil.
2429
eed79a96e43b eliminated accesses to leftOffset
Claus Gittinger <cg@exept.de>
parents: 2427
diff changeset
  3006
                    x := (self xOfCol:colNr inVisibleLine:cursorVisibleLine) - viewOrigin x.
2029
22629607c6eb care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents: 2022
diff changeset
  3007
                    y := self yOfVisibleLine:cursorVisibleLine.
22629607c6eb care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents: 2022
diff changeset
  3008
                    drawCharacterOnly ifTrue:[
22629607c6eb care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents: 2022
diff changeset
  3009
                        self clippingRectangle:(x@y extent:((font width * 2) @ fontHeight)).
22629607c6eb care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents: 2022
diff changeset
  3010
                        self redrawLine:lineNr from:colNr-1 to:colNr
22629607c6eb care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents: 2022
diff changeset
  3011
                    ] ifFalse:[
22629607c6eb care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents: 2022
diff changeset
  3012
                        self clippingRectangle:(x@y extent:((width - x) @ fontHeight)).
22629607c6eb care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents: 2022
diff changeset
  3013
                        self redrawLine:lineNr from:colNr-1
22629607c6eb care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents: 2022
diff changeset
  3014
                    ].
22629607c6eb care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents: 2022
diff changeset
  3015
                    self clippingRectangle:oldClip.
22629607c6eb care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents: 2022
diff changeset
  3016
                ].
22629607c6eb care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents: 2022
diff changeset
  3017
                ^ self.
22629607c6eb care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents: 2022
diff changeset
  3018
            ].
22629607c6eb care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents: 2022
diff changeset
  3019
        ].
22629607c6eb care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents: 2022
diff changeset
  3020
        drawCharacterOnly ifTrue:[
22629607c6eb care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents: 2022
diff changeset
  3021
            self redrawLine:lineNr col:colNr
22629607c6eb care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents: 2022
diff changeset
  3022
        ] ifFalse:[
22629607c6eb care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents: 2022
diff changeset
  3023
            self redrawLine:lineNr from:colNr
22629607c6eb care for invisible cursor when redrawing italic area
Claus Gittinger <cg@exept.de>
parents: 2022
diff changeset
  3024
        ]
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  3025
    ]
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  3026
1596
0bbdb4e9fc43 made st80Mode also an inst-flag;
Claus Gittinger <cg@exept.de>
parents: 1591
diff changeset
  3027
    "Modified: / 20.6.1998 / 18:19:22 / cg"
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  3028
!
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  3029
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3030
basicMergeLine:lineNr removeBlanks:removeBlanks
1319
2739903e7a80 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  3031
    "merge line lineNr with line lineNr+1"
2739903e7a80 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  3032
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3033
    |leftPart rightPart bothParts nextLineNr i|
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3034
2356
6416beb0f23a backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents: 2350
diff changeset
  3035
    (list notNil and:[(list size) >= lineNr]) ifFalse:[
2707
810c994db0b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2696
diff changeset
  3036
        "/ empty list or beyond end of text
2356
6416beb0f23a backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents: 2350
diff changeset
  3037
        ^ self
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3038
    ].
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3039
    leftPart := self listAt:lineNr.
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3040
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3041
    leftPart isNil ifTrue:[
2356
6416beb0f23a backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents: 2350
diff changeset
  3042
        leftPart := ''.
6416beb0f23a backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents: 2350
diff changeset
  3043
        autoIndent ifTrue:[
6416beb0f23a backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents: 2350
diff changeset
  3044
            (i := self leftIndentForLine:cursorLine) == 0 ifFalse:[
6416beb0f23a backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents: 2350
diff changeset
  3045
                leftPart := String new:i
6416beb0f23a backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents: 2350
diff changeset
  3046
            ]
6416beb0f23a backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents: 2350
diff changeset
  3047
        ]
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3048
    ].
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3049
    self cursorLine:lineNr col:((leftPart size) + 1).
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3050
    nextLineNr := self validateCursorLine:(lineNr + 1).
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3051
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3052
    nextLineNr > (list size) ifFalse:[
2356
6416beb0f23a backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents: 2350
diff changeset
  3053
        (rightPart := self listAt:nextLineNr) isNil ifTrue:[
6416beb0f23a backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents: 2350
diff changeset
  3054
            rightPart := ''
6416beb0f23a backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents: 2350
diff changeset
  3055
        ] ifFalse:[
6416beb0f23a backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents: 2350
diff changeset
  3056
            removeBlanks ifTrue:[
6416beb0f23a backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents: 2350
diff changeset
  3057
                rightPart := rightPart withoutLeadingSeparators.
6416beb0f23a backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents: 2350
diff changeset
  3058
            ]
6416beb0f23a backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents: 2350
diff changeset
  3059
        ].
6416beb0f23a backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents: 2350
diff changeset
  3060
6416beb0f23a backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents: 2350
diff changeset
  3061
        bothParts := leftPart , rightPart.
6416beb0f23a backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents: 2350
diff changeset
  3062
        (trimBlankLines and:[bothParts isBlank]) ifTrue:[bothParts := nil].
6416beb0f23a backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents: 2350
diff changeset
  3063
        list at:lineNr put:bothParts.
6416beb0f23a backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents: 2350
diff changeset
  3064
        self redrawLine:lineNr.
6416beb0f23a backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents: 2350
diff changeset
  3065
        self deleteLine:nextLineNr
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  3066
    ]
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  3067
1319
2739903e7a80 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  3068
    "Created: 9.9.1997 / 09:27:38 / cg"
2739903e7a80 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  3069
    "Modified: 9.9.1997 / 09:28:27 / cg"
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  3070
!
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  3071
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3072
basicReplace:aCharacter atLine:lineNr col:colNr
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  3073
    "replace a single character at lineNr/colNr"
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  3074
1558
abf35cc39757 minimize redraw in overwrite-replace;
Claus Gittinger <cg@exept.de>
parents: 1557
diff changeset
  3075
    |line lineSize newLine drawCharacterOnly|
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  3076
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  3077
    self checkModificationsAllowed ifFalse:[ ^ self].
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  3078
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  3079
    aCharacter == (Character cr) ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3080
        ^ self
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  3081
    ].
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  3082
1558
abf35cc39757 minimize redraw in overwrite-replace;
Claus Gittinger <cg@exept.de>
parents: 1557
diff changeset
  3083
    drawCharacterOnly := true.
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  3084
    self checkForExistingLine:lineNr.
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  3085
    line := list at:lineNr.
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  3086
    lineSize := line size.
671
f3fe0d8c604d added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents: 666
diff changeset
  3087
f3fe0d8c604d added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents: 666
diff changeset
  3088
    (trimBlankLines
f3fe0d8c604d added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents: 666
diff changeset
  3089
    and:[colNr > lineSize
f3fe0d8c604d added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents: 666
diff changeset
  3090
    and:[aCharacter == Character space]]) ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3091
        ^ self
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  3092
    ].
671
f3fe0d8c604d added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents: 666
diff changeset
  3093
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  3094
    (lineSize == 0) ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3095
        newLine := aCharacter asString species new:colNr.
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  3096
    ] ifFalse: [
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3097
        (colNr > lineSize) ifTrue: [
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3098
            newLine := line species new:colNr.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3099
            newLine replaceFrom:1 to:lineSize with:line startingAt:1.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3100
        ] ifFalse: [
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3101
            newLine := line copy.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3102
        ]
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  3103
    ].
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  3104
    newLine at:colNr put:aCharacter.
1558
abf35cc39757 minimize redraw in overwrite-replace;
Claus Gittinger <cg@exept.de>
parents: 1557
diff changeset
  3105
    aCharacter == (Character tab) ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3106
        newLine := self withTabsExpanded:newLine.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3107
        drawCharacterOnly := false
1558
abf35cc39757 minimize redraw in overwrite-replace;
Claus Gittinger <cg@exept.de>
parents: 1557
diff changeset
  3108
    ].
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  3109
    list at:lineNr put:newLine.
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  3110
    widthOfWidestLine notNil ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3111
        widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:line).
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  3112
    ].
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  3113
    self textChanged.
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  3114
    shown ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3115
        drawCharacterOnly ifTrue:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3116
            self redrawLine:lineNr col:colNr
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3117
        ] ifFalse:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3118
            self redrawLine:lineNr from:colNr
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3119
        ]
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  3120
    ]
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  3121
1558
abf35cc39757 minimize redraw in overwrite-replace;
Claus Gittinger <cg@exept.de>
parents: 1557
diff changeset
  3122
    "Created: / 6.3.1996 / 12:29:20 / cg"
1559
cecf77805bff expand tabs in #replaceAll:...
Claus Gittinger <cg@exept.de>
parents: 1558
diff changeset
  3123
    "Modified: / 10.6.1998 / 18:50:18 / cg"
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  3124
!
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  3125
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3126
basicSplitLine:lineNr before:colNr
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3127
    "split the line linNr before colNr; the right part (from colNr)
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3128
     is cut off and inserted after lineNr; the view is redrawn"
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3129
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3130
    |line lineSize leftRest rightRest visLine w h mustWait    
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3131
     srcY    "{ Class: SmallInteger }" |
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3132
3027
0dd9657b8033 *** empty log message ***
ca
parents: 3024
diff changeset
  3133
    list isNil ifTrue:[ ^ self ].
0dd9657b8033 *** empty log message ***
ca
parents: 3024
diff changeset
  3134
    lineNr > (list size) ifTrue:[ ^ self ].
0dd9657b8033 *** empty log message ***
ca
parents: 3024
diff changeset
  3135
0dd9657b8033 *** empty log message ***
ca
parents: 3024
diff changeset
  3136
    (colNr == 1) ifTrue:[
0dd9657b8033 *** empty log message ***
ca
parents: 3024
diff changeset
  3137
        self nonUndoableDo:[
0dd9657b8033 *** empty log message ***
ca
parents: 3024
diff changeset
  3138
            self insertLine:nil before:lineNr.
0dd9657b8033 *** empty log message ***
ca
parents: 3024
diff changeset
  3139
        ].
0dd9657b8033 *** empty log message ***
ca
parents: 3024
diff changeset
  3140
        ^ self
0dd9657b8033 *** empty log message ***
ca
parents: 3024
diff changeset
  3141
    ].
0dd9657b8033 *** empty log message ***
ca
parents: 3024
diff changeset
  3142
0dd9657b8033 *** empty log message ***
ca
parents: 3024
diff changeset
  3143
    line := list at:lineNr.
0dd9657b8033 *** empty log message ***
ca
parents: 3024
diff changeset
  3144
    line isNil ifFalse:[
0dd9657b8033 *** empty log message ***
ca
parents: 3024
diff changeset
  3145
        lineSize := line size.
0dd9657b8033 *** empty log message ***
ca
parents: 3024
diff changeset
  3146
        (colNr <= lineSize) ifTrue:[
0dd9657b8033 *** empty log message ***
ca
parents: 3024
diff changeset
  3147
            rightRest := line copyFrom:colNr to:lineSize.
0dd9657b8033 *** empty log message ***
ca
parents: 3024
diff changeset
  3148
            (colNr > 1) ifTrue:[
0dd9657b8033 *** empty log message ***
ca
parents: 3024
diff changeset
  3149
                leftRest := line copyTo:(colNr - 1)
0dd9657b8033 *** empty log message ***
ca
parents: 3024
diff changeset
  3150
            ]
0dd9657b8033 *** empty log message ***
ca
parents: 3024
diff changeset
  3151
        ] ifFalse:[
0dd9657b8033 *** empty log message ***
ca
parents: 3024
diff changeset
  3152
            leftRest := line
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3153
        ]
3027
0dd9657b8033 *** empty log message ***
ca
parents: 3024
diff changeset
  3154
    ].
0dd9657b8033 *** empty log message ***
ca
parents: 3024
diff changeset
  3155
    leftRest notNil ifTrue:[
0dd9657b8033 *** empty log message ***
ca
parents: 3024
diff changeset
  3156
        (trimBlankLines and:[leftRest isBlank]) ifTrue:[leftRest := nil]
0dd9657b8033 *** empty log message ***
ca
parents: 3024
diff changeset
  3157
    ].
0dd9657b8033 *** empty log message ***
ca
parents: 3024
diff changeset
  3158
    list at:lineNr put:leftRest.
0dd9657b8033 *** empty log message ***
ca
parents: 3024
diff changeset
  3159
    self nonUndoableDo:[
0dd9657b8033 *** empty log message ***
ca
parents: 3024
diff changeset
  3160
        self withoutRedrawInsertLine:rightRest before:(lineNr + 1).
0dd9657b8033 *** empty log message ***
ca
parents: 3024
diff changeset
  3161
    ].
0dd9657b8033 *** empty log message ***
ca
parents: 3024
diff changeset
  3162
    visLine := self listLineToVisibleLine:(lineNr).
0dd9657b8033 *** empty log message ***
ca
parents: 3024
diff changeset
  3163
    visLine notNil ifTrue:[
0dd9657b8033 *** empty log message ***
ca
parents: 3024
diff changeset
  3164
        w := self widthForScrollBetween:lineNr
0dd9657b8033 *** empty log message ***
ca
parents: 3024
diff changeset
  3165
                                    and:(firstLineShown + nLinesShown).
0dd9657b8033 *** empty log message ***
ca
parents: 3024
diff changeset
  3166
        srcY := topMargin + (visLine * fontHeight).
0dd9657b8033 *** empty log message ***
ca
parents: 3024
diff changeset
  3167
        h := ((nLinesShown - visLine - 1) * fontHeight).
0dd9657b8033 *** empty log message ***
ca
parents: 3024
diff changeset
  3168
        (mustWait := (w > 0 and:[h > 0])) ifTrue:[
0dd9657b8033 *** empty log message ***
ca
parents: 3024
diff changeset
  3169
            self catchExpose.
0dd9657b8033 *** empty log message ***
ca
parents: 3024
diff changeset
  3170
            self 
0dd9657b8033 *** empty log message ***
ca
parents: 3024
diff changeset
  3171
                copyFrom:self 
0dd9657b8033 *** empty log message ***
ca
parents: 3024
diff changeset
  3172
                x:textStartLeft y:srcY
0dd9657b8033 *** empty log message ***
ca
parents: 3024
diff changeset
  3173
                toX:textStartLeft y:(srcY + fontHeight)
0dd9657b8033 *** empty log message ***
ca
parents: 3024
diff changeset
  3174
                width:w
0dd9657b8033 *** empty log message ***
ca
parents: 3024
diff changeset
  3175
                height:((nLinesShown - visLine - 1) * fontHeight)
0dd9657b8033 *** empty log message ***
ca
parents: 3024
diff changeset
  3176
                async:true.
0dd9657b8033 *** empty log message ***
ca
parents: 3024
diff changeset
  3177
        ].
0dd9657b8033 *** empty log message ***
ca
parents: 3024
diff changeset
  3178
        self redrawLine:lineNr.
0dd9657b8033 *** empty log message ***
ca
parents: 3024
diff changeset
  3179
        self redrawLine:(lineNr + 1).
0dd9657b8033 *** empty log message ***
ca
parents: 3024
diff changeset
  3180
        mustWait ifTrue:[self waitForExpose]
0dd9657b8033 *** empty log message ***
ca
parents: 3024
diff changeset
  3181
    ].
0dd9657b8033 *** empty log message ***
ca
parents: 3024
diff changeset
  3182
    widthOfWidestLine := nil. "/ unknown
0dd9657b8033 *** empty log message ***
ca
parents: 3024
diff changeset
  3183
    self textChanged.
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3184
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3185
    "Modified: 29.1.1997 / 13:03:22 / cg"
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3186
!
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3187
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3188
basicWithoutRedrawInsertLine:aString before:lineNr
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3189
    "insert the argument, aString before line lineNr; the string
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3190
     becomes line nileNr; everything else is moved down; the view
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3191
     is not redrawn"
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3192
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3193
    |line|
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3194
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3195
    self checkModificationsAllowed ifFalse:[ ^ self].
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3196
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3197
    line := aString.
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3198
    line notNil ifTrue:[
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3199
        line isString ifTrue:[
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3200
            line isBlank ifTrue:[
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3201
                line := nil
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3202
            ] ifFalse:[
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3203
                (line includes:(Character tab)) ifTrue:[
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3204
                    line := self withTabsExpanded:line
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3205
                ]
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3206
            ]
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3207
        ]
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3208
    ].
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3209
    list isNil ifTrue: [
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3210
        list := StringCollection new:lineNr
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3211
    ] ifFalse: [
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3212
        list grow:((list size + 1) max:lineNr)
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3213
    ].
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3214
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3215
    "I have changed 'replaceFrom:to:with:startingAt:' to correctly handle 
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3216
     overlapping copy - if it didn't, we had to use:"
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3217
"
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3218
    index := list size.
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3219
    [index > lineNr] whileTrue: [
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3220
        pIndex := index - 1.
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3221
        list at:index put:(list at:pIndex).
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3222
        index := pIndex
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3223
    ].
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3224
"
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3225
    list replaceFrom:(lineNr + 1) to:(list size) with:list startingAt:lineNr.
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3226
    list at:lineNr put:line.
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3227
    self contentsChanged
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3228
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3229
    "Modified: / 10.6.1998 / 19:00:56 / cg"
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3230
!
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3231
2954
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3232
basicWithoutRedrawInsertLines:lines from:start to:end before:lineNr
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3233
    "insert a bunch of lines before line lineNr; the view is not redrawn"
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3234
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3235
    |newLine newLines nLines|
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3236
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3237
    self checkModificationsAllowed ifFalse:[ ^ self].
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3238
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3239
    nLines := end - start + 1.
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3240
    newLines := Array new:(lines size).
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3241
    start to:end do:[:index |
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3242
        newLine := lines at:index.
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3243
        newLine notNil ifTrue:[
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3244
            newLine isString ifTrue:[
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3245
                newLine isBlank ifTrue:[
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3246
                    newLine := nil
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3247
                ] ifFalse:[
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3248
                    (newLine includes:(Character tab)) ifTrue:[
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3249
                        newLine := self withTabsExpanded:newLine
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3250
                    ]
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3251
                ]
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3252
            ]
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3253
        ].
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3254
        newLines at:index put:newLine
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3255
    ].
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3256
    list isNil ifTrue: [
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3257
        list := StringCollection new:(lineNr + nLines + 1)
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3258
    ] ifFalse: [
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3259
        list grow:((list size + nLines) max:(lineNr + nLines - 1))
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3260
    ].
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3261
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3262
    "I have changed 'replaceFrom:to:with:startingAt:' to correctly handle 
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3263
     overlapping copy - if it didn't, we had to use:"
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3264
"
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3265
    index := list size.
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3266
    [index > lineNr] whileTrue: [
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3267
        pIndex := index - 1.
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3268
        list at:index put:(list at:pIndex).
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3269
        index := pIndex
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3270
    ].
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3271
"
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3272
    list replaceFrom:(lineNr + nLines) to:(list size) with:list startingAt:lineNr.
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3273
    list replaceFrom:lineNr to:(lineNr + nLines - 1) with:newLines startingAt:start.
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3274
    self contentsChanged
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3275
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3276
    "Modified: / 10.6.1998 / 19:01:16 / cg"
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3277
!
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3278
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3279
basicWithoutRedrawInsertStringWithoutCRs:aString atLine:lineNr col:colNr
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3280
    "insert aString (which has no crs) at lineNr/colNr"
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3281
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3282
    |isText strLen line lineSize newLine stringType sz|
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3283
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3284
    (aString notNil) ifFalse:[ ^ self].
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3285
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3286
    strLen := aString size.
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3287
    self checkForExistingLine:lineNr.
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3288
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3289
    stringType := aString string species.
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3290
    isText     := aString isText.
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3291
    line       := list at:lineNr.
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3292
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3293
    line notNil ifTrue:[
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3294
        lineSize := line size.
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3295
        line isString ifFalse:[
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3296
            stringType := line species
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3297
        ] ifTrue:[
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3298
            line bitsPerCharacter > aString bitsPerCharacter ifTrue:[
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3299
                stringType := line string species
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3300
            ].
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3301
            line isText ifTrue:[ isText := true ]
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3302
        ].
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3303
    ] ifFalse:[
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3304
        lineSize := 0
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3305
    ].
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3306
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3307
    ((colNr == 1) and:[lineSize == 0]) ifTrue: [
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3308
        newLine := aString
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3309
    ] ifFalse:[
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3310
        (lineSize == 0 or:[colNr > lineSize]) ifTrue: [
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3311
            sz := colNr + strLen - 1
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3312
        ] ifFalse:[
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3313
            sz := lineSize + strLen
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3314
        ].
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3315
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3316
        isText ifFalse:[
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3317
            newLine := stringType new:sz
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3318
        ] ifTrue:[
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3319
            newLine := Text string:(stringType new:sz)
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3320
        ].
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3321
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3322
        (lineSize ~~ 0) ifTrue: [
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3323
            (colNr > lineSize) ifTrue: [
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3324
                newLine replaceFrom:1 to:lineSize
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3325
                               with:line startingAt:1
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3326
            ] ifFalse: [
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3327
                newLine replaceFrom:1 to:(colNr - 1)
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3328
                               with:line startingAt:1.
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3329
                newLine replaceFrom:(colNr + strLen) to:(lineSize + strLen)
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3330
                               with:line startingAt:colNr
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3331
            ]
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3332
        ].
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3333
        newLine replaceFrom:colNr to:(colNr + strLen - 1) with:aString startingAt:1
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3334
    ].
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3335
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3336
    (aString includes:(Character tab)) ifTrue:[
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3337
        newLine := self withTabsExpanded:newLine
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3338
    ].
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3339
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3340
    list at:lineNr put:newLine.
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3341
    widthOfWidestLine notNil ifTrue:[
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3342
        widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:newLine).
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3343
    ].
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3344
    self textChanged.
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3345
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3346
    "Modified: / 10.6.1998 / 19:01:52 / cg"
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3347
!
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3348
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3349
deleteCharsAtLine:lineNr fromCol:startCol toCol:endCol
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3350
    "delete characters from startCol to endCol in line lineNr
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3351
    "
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3352
    |deleted|
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3353
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3354
    deleted := self textFromLine:lineNr col:startCol toLine:lineNr col:endCol.
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3355
    self basicDeleteCharsAtLine:lineNr fromCol:startCol toCol:endCol.
3115
b75128334006 info string in undo
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
  3356
    self addUndo:(PasteString line:lineNr col:startCol string:deleted info:'delete').
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3357
!
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3358
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3359
deleteFromLine:startLineNr toLine:endLineNr
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3360
    "delete some lines"
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3361
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3362
    |deleted|
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3363
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3364
    deleted := self textFromLine:startLineNr col:1 toLine:endLineNr+1 col:0.
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3365
    self basicDeleteFromLine:startLineNr toLine:endLineNr.
3115
b75128334006 info string in undo
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
  3366
    self addUndo:(PasteString line:startLineNr col:1 string:deleted info:'delete').
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3367
!
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3368
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3369
deleteLineWithoutRedraw:lineNr
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3370
    "delete line - no redraw;
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3371
     return true, if something was really deleted"
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3372
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3373
    |deleted ret|
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3374
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3375
    deleted := self textFromLine:lineNr col:1 toLine:lineNr+1 col:0.
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3376
    ret := self basicDeleteLineWithoutRedraw:lineNr.
3115
b75128334006 info string in undo
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
  3377
    self addUndo:(PasteString line:lineNr col:1 string:deleted info:'delete').
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3378
    ^ ret.
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3379
!
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3380
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3381
insert:aCharacter atLine:lineNr col:colNr
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3382
    "insert a single character at lineNr/colNr; 
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3383
     set emphasis to character at current position"
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3384
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3385
    self basicInsert:aCharacter atLine:lineNr col:colNr.
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3386
    aCharacter ~~ Character cr ifTrue:[
3115
b75128334006 info string in undo
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
  3387
        self addUndo:(DeleteRange line1:lineNr col1:colNr line2:lineNr col2:colNr info:'insert').
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3388
    ]
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3389
!
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3390
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3391
insertLines:someText from:start to:end before:lineNr
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3392
    "insert a bunch of lines before line lineNr"
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3393
2954
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3394
    |text indent visLine w nLines "{ Class: SmallInteger }"
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3395
     srcY "{ Class: SmallInteger }"
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3396
     dstY "{ Class: SmallInteger }" |
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3397
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3398
    self isReadOnly ifTrue:[
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3399
        ^ self
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3400
    ].
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3401
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3402
    autoIndent ifTrue:[
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3403
        indent := self leftIndentForLine:lineNr.
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3404
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3405
        text := someText collect:[:ln||line|
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3406
            ln notNil ifTrue:[
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3407
                line := ln withoutLeadingSeparators.
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3408
                (line isEmpty or:[indent == 0]) ifFalse:[
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3409
                    line := (String new:indent), line
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3410
                ].
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3411
                line
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3412
            ] ifFalse:[
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3413
                nil
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3414
            ]
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3415
        ].
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3416
    ] ifFalse:[
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3417
        text := someText
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3418
    ].
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3419
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3420
    visLine := self listLineToVisibleLine:lineNr.
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3421
    (shown not or:[visLine isNil]) ifTrue:[
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3422
        self withoutRedrawInsertLines:text
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3423
             from:start to:end
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3424
             before:lineNr.
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3425
    ] ifFalse:[
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3426
        nLines := end - start + 1.
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3427
        ((visLine + nLines) >= nLinesShown) ifTrue:[
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3428
            self withoutRedrawInsertLines:text
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3429
                 from:start to:end
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3430
                 before:lineNr.
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3431
            self redrawFromVisibleLine:visLine to:nLinesShown
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3432
        ] ifFalse:[
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3433
            w := self widthForScrollBetween:(lineNr + nLines)
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3434
                                        and:(firstLineShown + nLines + nLinesShown).
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3435
            srcY := topMargin + ((visLine - 1) * fontHeight).
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3436
            dstY := srcY + (nLines * fontHeight).
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3437
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3438
            "/
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3439
            "/ scroll ...
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3440
            "/
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3441
            "
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3442
             stupid: must catchExpose before inserting new
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3443
             stuff - since catchExpose may perform redraws
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3444
            "
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3445
            self catchExpose.
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3446
            self withoutRedrawInsertLines:text
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3447
                 from:start to:end
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3448
                 before:lineNr.
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3449
            self 
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3450
                copyFrom:self 
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3451
                x:textStartLeft y:srcY
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3452
                toX:textStartLeft y:dstY
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3453
                width:w
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3454
                height:(height - dstY)
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3455
                async:true.
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3456
            self redrawFromVisibleLine:visLine to:(visLine + nLines - 1).
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3457
            self waitForExpose
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3458
        ].
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3459
    ].
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3460
    widthOfWidestLine notNil ifTrue:[
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3461
        text do:[:line |
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3462
            widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:line).
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3463
        ]
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3464
    ].
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3465
    self textChanged.
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3466
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3467
    "Modified: 29.1.1997 / 13:02:39 / cg"
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3468
!
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3469
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3470
mergeLine:lineNr removeBlanks:removeBlanks
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3471
    "merge line lineNr with line lineNr+1"
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3472
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3473
    |len|
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3474
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3475
    len := (self listAt:lineNr) size.
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3476
    self nonUndoableDo:[
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3477
        self basicMergeLine:lineNr removeBlanks:removeBlanks.
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3478
    ].
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3479
    self addUndo:(PasteString new line:lineNr col:len+1 string:(Character cr asString) selected:false).
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3480
!
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3481
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3482
replace:aCharacter atLine:lineNr col:colNr
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3483
    "replace a single character at lineNr/colNr"
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3484
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3485
    |originalChar|
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3486
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3487
    originalChar := self characterAtLine:lineNr col:colNr.
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3488
    self basicReplace:aCharacter atLine:lineNr col:colNr.
3115
b75128334006 info string in undo
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
  3489
    self addUndo:(ReplaceCharacter line:lineNr col:colNr character:originalChar info:'replace').
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3490
!
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3491
1564
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  3492
replaceString:aString atLine:lineNr col:colNr
1557
b88c7410311f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1552
diff changeset
  3493
    "replace multiple characters starting at lineNr/colNr.
1567
0eff7ca88e89 much faster multi-line replace (avoid scroll)
Claus Gittinger <cg@exept.de>
parents: 1566
diff changeset
  3494
     This is not prepared to encounter special chars (except TAB)
0eff7ca88e89 much faster multi-line replace (avoid scroll)
Claus Gittinger <cg@exept.de>
parents: 1566
diff changeset
  3495
     in the string."
1557
b88c7410311f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1552
diff changeset
  3496
b88c7410311f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1552
diff changeset
  3497
    |line lineSize newLine endCol|
b88c7410311f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1552
diff changeset
  3498
b88c7410311f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1552
diff changeset
  3499
    self checkModificationsAllowed ifFalse:[ ^ self].
b88c7410311f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1552
diff changeset
  3500
b88c7410311f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1552
diff changeset
  3501
    self checkForExistingLine:lineNr.
b88c7410311f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1552
diff changeset
  3502
    line := list at:lineNr.
b88c7410311f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1552
diff changeset
  3503
    lineSize := line size.
b88c7410311f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1552
diff changeset
  3504
b88c7410311f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1552
diff changeset
  3505
    endCol := colNr + aString size - 1.
b88c7410311f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1552
diff changeset
  3506
    (lineSize == 0) ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3507
        newLine := aString species new:endCol.
1557
b88c7410311f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1552
diff changeset
  3508
    ] ifFalse: [
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3509
        (endCol > lineSize) ifTrue: [
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3510
            aString isText ifTrue:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3511
                newLine := aString species new:endCol.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3512
            ] ifFalse:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3513
                newLine := line species new:endCol.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3514
            ].
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3515
            newLine replaceFrom:1 to:lineSize with:line startingAt:1.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3516
        ] ifFalse: [
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3517
            aString isText ifTrue:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3518
                newLine := aString species new:line size.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3519
                newLine replaceFrom:1 to:lineSize with:line startingAt:1.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3520
            ] ifFalse:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3521
                newLine := line copy.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3522
            ]
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3523
        ]
1557
b88c7410311f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1552
diff changeset
  3524
    ].
b88c7410311f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1552
diff changeset
  3525
    newLine replaceFrom:colNr with:aString.
1559
cecf77805bff expand tabs in #replaceAll:...
Claus Gittinger <cg@exept.de>
parents: 1558
diff changeset
  3526
    (aString includes:(Character tab)) ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3527
        newLine := self withTabsExpanded:newLine.
1559
cecf77805bff expand tabs in #replaceAll:...
Claus Gittinger <cg@exept.de>
parents: 1558
diff changeset
  3528
    ].
1557
b88c7410311f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1552
diff changeset
  3529
    list at:lineNr put:newLine.
b88c7410311f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1552
diff changeset
  3530
    widthOfWidestLine notNil ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3531
        widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:line).
1557
b88c7410311f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1552
diff changeset
  3532
    ].
b88c7410311f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1552
diff changeset
  3533
    self textChanged.
b88c7410311f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1552
diff changeset
  3534
    shown ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3535
        self redrawLine:lineNr from:colNr
1557
b88c7410311f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1552
diff changeset
  3536
    ]
b88c7410311f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1552
diff changeset
  3537
1564
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  3538
    "Created: / 11.6.1998 / 10:38:32 / cg"
1599
63636b356b1f care for emphasis when replacing.
Claus Gittinger <cg@exept.de>
parents: 1597
diff changeset
  3539
    "Modified: / 20.6.1998 / 20:23:50 / cg"
1557
b88c7410311f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1552
diff changeset
  3540
!
b88c7410311f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1552
diff changeset
  3541
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3542
splitLine:lineNr before:colNr
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3543
    "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
  3544
     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
  3545
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3546
    self basicSplitLine:lineNr before:colNr.
3115
b75128334006 info string in undo
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
  3547
    self addUndo:(DeleteRange line1:lineNr col1:colNr line2:lineNr+1 col2:0 info:'split').
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3548
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3549
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3550
withoutRedrawInsertLine:aString before:lineNr
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3551
    "insert the argument, aString before line lineNr; the string
2954
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3552
     becomes line lineNr; everything else is moved down; the view
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3553
     is not redrawn"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3554
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3555
    self basicWithoutRedrawInsertLine:aString before:lineNr.
3115
b75128334006 info string in undo
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
  3556
    self addUndo:(DeleteRange line1:lineNr col1:1 line2:lineNr+1 col2:0 info:'insert').
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3557
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3558
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3559
withoutRedrawInsertLines:lines from:start to:end before:lineNr
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3560
    "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
  3561
2954
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3562
    self basicWithoutRedrawInsertLines:lines from:start to:end before:lineNr.
3115
b75128334006 info string in undo
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
  3563
    self addUndo:(DeleteRange line1:lineNr col1:1 line2:lineNr+end-start+1 col2:0 info:'insert').
121
claus
parents: 118
diff changeset
  3564
!
claus
parents: 118
diff changeset
  3565
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3566
withoutRedrawInsertStringWithoutCRs:aString atLine:lineNr col:colNr
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3567
    "insert aString (which has no crs) at lineNr/colNr"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3568
2954
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3569
    self basicWithoutRedrawInsertStringWithoutCRs:aString atLine:lineNr col:colNr.
3115
b75128334006 info string in undo
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
  3570
    self addUndo:(DeleteRange line1:lineNr col1:colNr line2:lineNr col2:colNr+aString size-1 info:'insert').
259
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
2752
5650a9ab5935 method category rename
Claus Gittinger <cg@exept.de>
parents: 2744
diff changeset
  3573
!EditTextView methodsFor:'event handling'!
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3574
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3575
buttonPress:button x:x y:y
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3576
    "hide the cursor when button is activated"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3577
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3578
    hasKeyboardFocus := true.
2589
62794ae04446 support drop
ca
parents: 2580
diff changeset
  3579
    dragIsActive := false.
62794ae04446 support drop
ca
parents: 2580
diff changeset
  3580
1817
1a9e22f755c8 show non-focus cursor when disabled or readOnly
Claus Gittinger <cg@exept.de>
parents: 1816
diff changeset
  3581
    cursorShown ifTrue: [
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3582
        self drawCursor
1817
1a9e22f755c8 show non-focus cursor when disabled or readOnly
Claus Gittinger <cg@exept.de>
parents: 1816
diff changeset
  3583
    ].
259
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
    ((button == 1) or:[button == #select]) ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3586
        self hideCursor
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3587
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3588
    (button == #paste) ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3589
        self pasteOrReplace.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3590
        ^ self
259
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
    super buttonPress:button x:x y:y
1817
1a9e22f755c8 show non-focus cursor when disabled or readOnly
Claus Gittinger <cg@exept.de>
parents: 1816
diff changeset
  3593
1a9e22f755c8 show non-focus cursor when disabled or readOnly
Claus Gittinger <cg@exept.de>
parents: 1816
diff changeset
  3594
    "Modified: / 23.3.1999 / 13:51:40 / cg"
121
claus
parents: 118
diff changeset
  3595
!
claus
parents: 118
diff changeset
  3596
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3597
buttonRelease:button x:x y:y
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3598
    "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
  3599
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3600
    ((button == 1) or:[button == #select]) ifTrue:[
2589
62794ae04446 support drop
ca
parents: 2580
diff changeset
  3601
        typeOfSelection := nil.
62794ae04446 support drop
ca
parents: 2580
diff changeset
  3602
62794ae04446 support drop
ca
parents: 2580
diff changeset
  3603
        dragIsActive ifTrue:[
62794ae04446 support drop
ca
parents: 2580
diff changeset
  3604
            self unselect
62794ae04446 support drop
ca
parents: 2580
diff changeset
  3605
        ].
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3606
        selectionStartLine isNil ifTrue:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3607
            clickCol notNil ifTrue:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3608
                self cursorMovementAllowed ifTrue:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3609
                    self cursorLine:clickLine col:clickCol
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3610
                ]
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3611
            ]
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3612
        ] ifFalse:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3613
            lastString := nil. "new selection invalidates remembered string"
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3614
        ].
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  3615
        self showCursor
259
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 buttonRelease:button x:x y:y
1580
d30e562bea15 allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
  3618
d30e562bea15 allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
  3619
    "Modified: / 18.6.1998 / 14:14:05 / cg"
259
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
2580
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  3622
cursorKeyPress:key shifted:shifted
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  3623
2730
61a2f1981ac6 Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents: 2725
diff changeset
  3624
    |n|
61a2f1981ac6 Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents: 2725
diff changeset
  3625
2606
6a3ab90d339f redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents: 2599
diff changeset
  3626
    self changeTypeOfSelectionTo:nil.
2580
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  3627
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  3628
    (key == #CursorRight) ifTrue:[
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  3629
        (shifted and:[selectionStartLine isNil]) ifTrue:[
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  3630
            selectionStartLine := selectionEndLine := clickStartLine := cursorLine.
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  3631
            selectionStartCol := selectionEndCol := clickStartCol := cursorCol.
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  3632
            expandingTop := false.
2660
1352e7b3ac67 always validate selection (SHIFT-cursor-keys)
Claus Gittinger <cg@exept.de>
parents: 2647
diff changeset
  3633
            self validateNewSelection.
2580
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  3634
            self redrawLine:selectionStartLine.
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  3635
            ^ self.
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  3636
        ].
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  3637
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  3638
        selectionStartLine notNil ifTrue:[
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  3639
            self cursorMovementAllowed ifTrue:[
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  3640
                "/
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  3641
                "/ treat the whole selection as cursor
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  3642
                "/
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  3643
                self setCursorLine:selectionEndLine.
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  3644
                selectionEndCol == 0 ifTrue:[
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  3645
                    selectionEndCol := 1.
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  3646
                ].
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  3647
                self setCursorCol:selectionEndCol.
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  3648
                shifted ifTrue:[
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  3649
                    self expandSelectionRight.
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  3650
                    ^ self
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  3651
                ].
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  3652
                self unselect; makeCursorVisible.
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  3653
                cursorCol == 1 ifTrue:[^ self].
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  3654
            ].
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  3655
        ].
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  3656
        self cursorRight. 
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  3657
        ^ self
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  3658
    ].
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  3659
    (key == #CursorDown) ifTrue:[
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  3660
        (shifted and:[selectionStartLine isNil]) ifTrue:[
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  3661
            selectionStartLine := clickStartLine := cursorLine. selectionEndLine := cursorLine + 1.
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  3662
            selectionStartCol := clickStartCol := selectionEndCol := cursorCol.
2660
1352e7b3ac67 always validate selection (SHIFT-cursor-keys)
Claus Gittinger <cg@exept.de>
parents: 2647
diff changeset
  3663
            self validateNewSelection.
2580
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  3664
            self redrawLine:selectionStartLine. 
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  3665
            expandingTop := false.
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  3666
            self redrawLine:selectionEndLine.
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  3667
            ^ self 
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  3668
        ].
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  3669
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  3670
        selectionStartLine notNil ifTrue:[
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  3671
            self cursorMovementAllowed ifTrue:[
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  3672
                "/
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  3673
                "/ treat the whole selection as cursor
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  3674
                "/
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  3675
                self setCursorLine:selectionEndLine.
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  3676
                self setCursorCol:selectionStartCol.
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  3677
                cursorCol == 0 ifTrue:[
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  3678
                    self setCursorCol:1.
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  3679
                    self setCursorLine:(cursorLine - 1).
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  3680
                ].
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  3681
                self makeCursorVisible.
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  3682
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  3683
                shifted ifTrue:[
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  3684
                    clickLine := cursorLine.
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  3685
                    clickCol := cursorCol.
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  3686
                    self expandSelectionDown.
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  3687
                    ^ self
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  3688
                ].
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  3689
                self unselect. 
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  3690
            ].
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  3691
        ].
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  3692
2730
61a2f1981ac6 Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents: 2725
diff changeset
  3693
        n := 1 + (self sensor compressKeyPressEventsWithKey:#CursorDown).
2580
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  3694
        self cursorDown:n. 
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  3695
        "/
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  3696
        "/ flush keyboard to avoid runaway cursor
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  3697
        "/
2730
61a2f1981ac6 Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents: 2725
diff changeset
  3698
        self sensor flushKeyboardFor:self.
2580
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  3699
        ^ self
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  3700
    ].
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  3701
    (key == #CursorLeft or:[key == #CursorUp]) ifTrue:[
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  3702
        (shifted and:[selectionStartLine isNil]) ifTrue:[
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  3703
            expandingTop := true.
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  3704
            key == #CursorLeft ifTrue:[
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  3705
                cursorCol > 1 ifTrue:[
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  3706
                    selectionStartLine := selectionEndLine := clickStartLine := cursorLine.
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  3707
                    selectionEndCol := clickStartCol := cursorCol-1.
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  3708
                    selectionStartCol := cursorCol-1.
2660
1352e7b3ac67 always validate selection (SHIFT-cursor-keys)
Claus Gittinger <cg@exept.de>
parents: 2647
diff changeset
  3709
                    self validateNewSelection.
2580
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  3710
                    self redrawLine:selectionStartLine.
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  3711
                    ^ self 
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  3712
                ]
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  3713
            ] ifFalse:[
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  3714
                cursorLine > 1 ifTrue:[
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  3715
                    selectionEndLine := clickStartLine := cursorLine.
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  3716
                    selectionEndCol := selectionStartCol := clickStartCol := cursorCol.
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  3717
                    selectionStartLine := cursorLine - 1.
2660
1352e7b3ac67 always validate selection (SHIFT-cursor-keys)
Claus Gittinger <cg@exept.de>
parents: 2647
diff changeset
  3718
                    self validateNewSelection.
2580
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  3719
                    self redrawFromLine:selectionStartLine to:cursorLine.
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  3720
                    ^ self 
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  3721
                ]
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  3722
            ]
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  3723
        ].
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  3724
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  3725
        selectionStartLine notNil ifTrue:[
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  3726
            self cursorMovementAllowed ifTrue:[
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  3727
                "/
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  3728
                "/ treat the whole selection as cursor
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  3729
                "/
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  3730
                self setCursorLine:selectionStartLine.
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  3731
                self setCursorCol:selectionStartCol.
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  3732
                (key == #CursorLeft) ifTrue:[    
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  3733
                    self setCursorCol:(cursorCol+1).  "/ compensate for followup crsr-left
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  3734
                ].
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  3735
                self makeCursorVisible.
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  3736
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  3737
                shifted ifTrue:[
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  3738
                    (key == #CursorUp) ifTrue:[
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  3739
                        clickLine := cursorLine.
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  3740
                        self expandSelectionUp.
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  3741
                    ] ifFalse:[
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  3742
                        self expandSelectionLeft.
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  3743
                    ].
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  3744
                    ^ self 
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  3745
                ].
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  3746
                self unselect. 
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  3747
            ].
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  3748
        ].
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  3749
        (key == #CursorLeft) ifTrue:[
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  3750
            self cursorLeft. ^self
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  3751
        ].
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  3752
        (key == #CursorUp)        ifTrue:[
2730
61a2f1981ac6 Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents: 2725
diff changeset
  3753
            n := 1 + (self sensor compressKeyPressEventsWithKey:#CursorUp).
2580
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  3754
            self cursorUp:n. 
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  3755
            "/
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  3756
            "/ flush keyboard to avoid runaway cursor
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  3757
            "/
2730
61a2f1981ac6 Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents: 2725
diff changeset
  3758
            self sensor flushKeyboardFor:self.
2580
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  3759
            ^ self
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  3760
        ].
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  3761
    ].
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  3762
!
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  3763
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3764
doKeyPress:key x:x y:y
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3765
    "handle keyboard input"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3766
2978
b5b3527cbb6b undo key
Claus Gittinger <cg@exept.de>
parents: 2965
diff changeset
  3767
    <resource: #keyboard (#Paste #Insert #Cut #Again #Replace #Undo #Accept
2017
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3768
                          #Delete #BasicDelete #BackSpace #BasicBackspace
2883
6cdb4a5a7b5e shift-delete - delete whiteSpace
Claus Gittinger <cg@exept.de>
parents: 2880
diff changeset
  3769
                          #SelectWord #DeleteSpaces
2017
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3770
                          #SearchMatchingParent #SelectMatchingParents 
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3771
                          #SelectToEnd #SelectFromBeginning
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3772
                          #BeginOfLine #EndOfLine #NextWord #PreviousWord
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3773
                          #CursorRight #CursorDown #CursorLeft #CursorUp
2819
a7a41dfb9df7 BackTab / NonInsertingTab modifiers now defined in keyboard.rc
ca
parents: 2817
diff changeset
  3774
                          #Return #Tab #BackTab #NonInsertingTab #Escape
2017
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3775
                          #GotoLine #Delete #BeginOfText #EndOfText
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3776
                          #SelectLine #ExpandSelectionByLine #DeleteLine
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3777
                          #InsertLine
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3778
                          #SelectLineFromBeginning
2184
fb634dc3e606 learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents: 2157
diff changeset
  3779
                          #LearnKeyboardMacro #ExecuteKeyboardMacro
2017
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3780
                          #'F*' #'f*')>
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3781
3023
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  3782
    |fKeyMacros shiftPressed ctrlPressed i event cmdMacro|
2184
fb634dc3e606 learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents: 2157
diff changeset
  3783
fb634dc3e606 learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents: 2157
diff changeset
  3784
    event := WindowGroup lastEventQuerySignal query.
3023
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  3785
    shiftPressed := event hasShift.
3024
e2d7e40e6481 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3023
diff changeset
  3786
    ctrlPressed := event hasCtrl and:[(event rawKey startsWith:'Ctrl') not].
2205
230cf9cef6c3 searchPatter, if from selection (escape meta characters)
Claus Gittinger <cg@exept.de>
parents: 2196
diff changeset
  3787
2416
56acdd9e31b5 lifted mkeyboardMacro handling from Workspace to EditTextView
Claus Gittinger <cg@exept.de>
parents: 2406
diff changeset
  3788
    cmdMacro := UserPreferences current functionKeySequences at:key ifAbsent:nil.
56acdd9e31b5 lifted mkeyboardMacro handling from Workspace to EditTextView
Claus Gittinger <cg@exept.de>
parents: 2406
diff changeset
  3789
    cmdMacro notNil ifTrue:[
2720
0358840e2be6 some code refactoring
Claus Gittinger <cg@exept.de>
parents: 2719
diff changeset
  3790
        self executeKeyboardMacro:cmdMacro.
2416
56acdd9e31b5 lifted mkeyboardMacro handling from Workspace to EditTextView
Claus Gittinger <cg@exept.de>
parents: 2406
diff changeset
  3791
        ^ self
56acdd9e31b5 lifted mkeyboardMacro handling from Workspace to EditTextView
Claus Gittinger <cg@exept.de>
parents: 2406
diff changeset
  3792
    ].
56acdd9e31b5 lifted mkeyboardMacro handling from Workspace to EditTextView
Claus Gittinger <cg@exept.de>
parents: 2406
diff changeset
  3793
2205
230cf9cef6c3 searchPatter, if from selection (escape meta characters)
Claus Gittinger <cg@exept.de>
parents: 2196
diff changeset
  3794
    (key == #BackSpace
230cf9cef6c3 searchPatter, if from selection (escape meta characters)
Claus Gittinger <cg@exept.de>
parents: 2196
diff changeset
  3795
     or:[key == #BasicBackspace]) ifTrue:[
230cf9cef6c3 searchPatter, if from selection (escape meta characters)
Claus Gittinger <cg@exept.de>
parents: 2196
diff changeset
  3796
        selectionStartLine notNil ifTrue:[
230cf9cef6c3 searchPatter, if from selection (escape meta characters)
Claus Gittinger <cg@exept.de>
parents: 2196
diff changeset
  3797
            (key == #BasicBackspace) ifTrue:[
2505
9204d5313979 Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents: 2491
diff changeset
  3798
                self deleteSelection.
9204d5313979 Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents: 2491
diff changeset
  3799
            ] ifFalse: [
9204d5313979 Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents: 2491
diff changeset
  3800
                self copyAndDeleteSelection.
2205
230cf9cef6c3 searchPatter, if from selection (escape meta characters)
Claus Gittinger <cg@exept.de>
parents: 2196
diff changeset
  3801
            ].
2505
9204d5313979 Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents: 2491
diff changeset
  3802
            ^ self
2205
230cf9cef6c3 searchPatter, if from selection (escape meta characters)
Claus Gittinger <cg@exept.de>
parents: 2196
diff changeset
  3803
        ].
230cf9cef6c3 searchPatter, if from selection (escape meta characters)
Claus Gittinger <cg@exept.de>
parents: 2196
diff changeset
  3804
230cf9cef6c3 searchPatter, if from selection (escape meta characters)
Claus Gittinger <cg@exept.de>
parents: 2196
diff changeset
  3805
        self makeCursorVisible.
3023
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  3806
        shiftPressed ifTrue:[
2205
230cf9cef6c3 searchPatter, if from selection (escape meta characters)
Claus Gittinger <cg@exept.de>
parents: 2196
diff changeset
  3807
            self deleteWordBeforeCursor.
230cf9cef6c3 searchPatter, if from selection (escape meta characters)
Claus Gittinger <cg@exept.de>
parents: 2196
diff changeset
  3808
        ] ifFalse:[
230cf9cef6c3 searchPatter, if from selection (escape meta characters)
Claus Gittinger <cg@exept.de>
parents: 2196
diff changeset
  3809
            self deleteCharBeforeCursor. 
230cf9cef6c3 searchPatter, if from selection (escape meta characters)
Claus Gittinger <cg@exept.de>
parents: 2196
diff changeset
  3810
        ].
2207
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  3811
2205
230cf9cef6c3 searchPatter, if from selection (escape meta characters)
Claus Gittinger <cg@exept.de>
parents: 2196
diff changeset
  3812
        ^ self
230cf9cef6c3 searchPatter, if from selection (escape meta characters)
Claus Gittinger <cg@exept.de>
parents: 2196
diff changeset
  3813
    ].
2184
fb634dc3e606 learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents: 2157
diff changeset
  3814
fb634dc3e606 learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents: 2157
diff changeset
  3815
    (key == #LearnKeyboardMacro) ifTrue:[
2580
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  3816
        self toggleLearnMode.
2184
fb634dc3e606 learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents: 2157
diff changeset
  3817
        ^ self
fb634dc3e606 learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents: 2157
diff changeset
  3818
    ].
fb634dc3e606 learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents: 2157
diff changeset
  3819
    (key == #ExecuteKeyboardMacro) ifTrue:[
2580
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  3820
        self executeLearnedKeyboardMacro.
2184
fb634dc3e606 learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents: 2157
diff changeset
  3821
        ^ self.
fb634dc3e606 learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents: 2157
diff changeset
  3822
    ].
2795
1f7b5f242eee learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents: 2792
diff changeset
  3823
    self learnMode ifTrue:[
2184
fb634dc3e606 learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents: 2157
diff changeset
  3824
        learnedMacro add:event.
fb634dc3e606 learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents: 2157
diff changeset
  3825
    ].
fb634dc3e606 learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents: 2157
diff changeset
  3826
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3827
    (key isMemberOf:Character) ifTrue:[
2720
0358840e2be6 some code refactoring
Claus Gittinger <cg@exept.de>
parents: 2719
diff changeset
  3828
        self handleNonCommandKey:key.
2017
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3829
        ^ self
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3830
    ].                         
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3831
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3832
    replacing := false.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3833
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3834
    "
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3835
     Fn      pastes a key-sequence (but only if not overlayed with
2017
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3836
             another function in the keyboard map)
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3837
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3838
     see TextView>>:x:y
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3839
    "
1177
9d23e1241404 avoid match: if possible (to not clobber the previous matchString)
Claus Gittinger <cg@exept.de>
parents: 1108
diff changeset
  3840
    (key at:1) asLowercase == $f ifTrue:[
2017
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3841
        (('[fF][0-9]' match:key)
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3842
        or:['[fF][0-9][0-9]' match:key]) ifTrue:[
3023
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  3843
            shiftPressed ifFalse:[
2017
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3844
                fKeyMacros := UserPreferences current functionKeySequences.
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3845
                fKeyMacros notNil ifTrue:[
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3846
                    (fKeyMacros includesKey:key) ifTrue:[
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3847
                        self pasteOrReplace:(fKeyMacros at:key) asStringCollection.
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3848
                        ^ self
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3849
                    ]
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3850
                ]
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3851
            ]
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3852
        ].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3853
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3854
2506
5568d67dbddd Ctrl-8 / Ctrl-9,
Claus Gittinger <cg@exept.de>
parents: 2505
diff changeset
  3855
    (key == #'Ctrl8' or:[key == #'Ctrl9']) ifTrue:[
5568d67dbddd Ctrl-8 / Ctrl-9,
Claus Gittinger <cg@exept.de>
parents: 2505
diff changeset
  3856
        self parenthizeSelectionWith:$( and:$).
5568d67dbddd Ctrl-8 / Ctrl-9,
Claus Gittinger <cg@exept.de>
parents: 2505
diff changeset
  3857
        ^ self.
5568d67dbddd Ctrl-8 / Ctrl-9,
Claus Gittinger <cg@exept.de>
parents: 2505
diff changeset
  3858
    ].
5568d67dbddd Ctrl-8 / Ctrl-9,
Claus Gittinger <cg@exept.de>
parents: 2505
diff changeset
  3859
    (key == #'Ctrl2') ifTrue:[
5568d67dbddd Ctrl-8 / Ctrl-9,
Claus Gittinger <cg@exept.de>
parents: 2505
diff changeset
  3860
        self parenthizeSelectionWith:$" and:$".
5568d67dbddd Ctrl-8 / Ctrl-9,
Claus Gittinger <cg@exept.de>
parents: 2505
diff changeset
  3861
        ^ self.
5568d67dbddd Ctrl-8 / Ctrl-9,
Claus Gittinger <cg@exept.de>
parents: 2505
diff changeset
  3862
    ].
5568d67dbddd Ctrl-8 / Ctrl-9,
Claus Gittinger <cg@exept.de>
parents: 2505
diff changeset
  3863
    (key == #'Ctrl#') ifTrue:[
5568d67dbddd Ctrl-8 / Ctrl-9,
Claus Gittinger <cg@exept.de>
parents: 2505
diff changeset
  3864
        self parenthizeSelectionWith:$' and:$'.
2505
9204d5313979 Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents: 2491
diff changeset
  3865
        ^ self.
9204d5313979 Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents: 2491
diff changeset
  3866
    ].
9204d5313979 Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents: 2491
diff changeset
  3867
274
6df4bb990f04 handle accept where acceptAction is define (this was a historic leftover)
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
  3868
    (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
  3869
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3870
    ((key == #Paste) or:[key == #Insert]) ifTrue:[self pasteOrReplace. ^self].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3871
    (key == #Cut) ifTrue:[self cut. ^self].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3872
    (key == #Again) ifTrue:[self again. ^self].
2978
b5b3527cbb6b undo key
Claus Gittinger <cg@exept.de>
parents: 2965
diff changeset
  3873
    (key == #Undo) ifTrue:[self undo. ^self].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3874
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3875
    (key == #Replace) ifTrue:[self replace. ^self].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3876
    (key == #SelectWord) ifTrue:[
2017
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3877
        self makeCursorVisible.
2505
9204d5313979 Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents: 2491
diff changeset
  3878
        self selectWordUnderCursor.
9204d5313979 Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents: 2491
diff changeset
  3879
        ^ self
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3880
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3881
2505
9204d5313979 Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents: 2491
diff changeset
  3882
    (key == #SearchMatchingParent) ifTrue:[self searchForMatchingParenthesis. ^ self].
9204d5313979 Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents: 2491
diff changeset
  3883
    (key == #SelectMatchingParents) ifTrue:[self searchForAndSelectMatchingParenthesis. ^ self].
9204d5313979 Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents: 2491
diff changeset
  3884
    (key == #SelectToEnd) ifTrue:[self selectUpToEnd. ^ self].
9204d5313979 Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents: 2491
diff changeset
  3885
    (key == #SelectFromBeginning) ifTrue:[self selectFromBeginning. ^ self].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3886
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3887
" disabled - nobody liked it ...
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3888
  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
  3889
1304
173d00c195f9 flush pending keyboard events in cursor-up/down
Claus Gittinger <cg@exept.de>
parents: 1300
diff changeset
  3890
    (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
  3891
    (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
  3892
    (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
  3893
    (key == #Ctrlp) ifTrue:[self unselect. self cursorUp. ^ self].
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
1675
b1cba2341f95 EndOfLine / BeginOfLine unselect first.
Claus Gittinger <cg@exept.de>
parents: 1601
diff changeset
  3896
    (key == #BeginOfLine) ifTrue:[
3023
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  3897
        shiftPressed ifTrue: [       
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  3898
            "/ "Original St/X code - now use Ctrl modifier"
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  3899
            "/ self unselect.
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  3900
            "/ self cursorHome.
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  3901
            "Jan's modification"        
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  3902
            self addToSelectionAfter:[ self cursorToBeginOfLine ].
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  3903
        ] ifFalse: [
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  3904
            self unselect.
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  3905
            ctrlPressed ifTrue:[
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  3906
                self cursorHome.
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  3907
            ] ifFalse:[
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  3908
                self cursorToBeginOfLine.
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  3909
            ]
2017
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3910
        ].
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3911
        ^ self
1675
b1cba2341f95 EndOfLine / BeginOfLine unselect first.
Claus Gittinger <cg@exept.de>
parents: 1601
diff changeset
  3912
    ].
b1cba2341f95 EndOfLine / BeginOfLine unselect first.
Claus Gittinger <cg@exept.de>
parents: 1601
diff changeset
  3913
    (key == #EndOfLine) ifTrue:[
3023
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  3914
        shiftPressed ifTrue:[
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  3915
            "/ "Original St/X code - now use Ctrl modifier"
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  3916
            "/ self unselect.
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  3917
            "/ self cursorToBottom
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  3918
            "Jan's modification"        
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  3919
            self addToSelectionAfter:[ self cursorToEndOfLine ] .
2017
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3920
        ] ifFalse:[
3023
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  3921
            self unselect.
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  3922
            ctrlPressed ifTrue:[
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  3923
                self cursorToBottom
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  3924
            ] ifFalse:[
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  3925
                self cursorToEndOfLine. 
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  3926
            ]
2017
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3927
        ].
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3928
        ^ self
1675
b1cba2341f95 EndOfLine / BeginOfLine unselect first.
Claus Gittinger <cg@exept.de>
parents: 1601
diff changeset
  3929
    ].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3930
    (key == #NextWord) ifTrue:[self cursorToNextWord. ^self].
499
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
  3931
    (key == #PreviousWord) ifTrue:[self cursorToPreviousWord. ^self].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3932
    (key == #GotoLine) ifTrue:[self gotoLine. ^self].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3933
2580
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  3934
    (key == #CursorRight
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  3935
    or:[key == #CursorDown
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  3936
    or:[key == #CursorLeft
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  3937
    or:[key == #CursorUp]]]) ifTrue:[
3023
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  3938
        self cursorKeyPress:key shifted:shiftPressed.
2580
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  3939
        ^ self.
259
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
    (key == #Return)    ifTrue:[
3023
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  3943
        shiftPressed ifTrue:[
2505
9204d5313979 Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents: 2491
diff changeset
  3944
            self unselect. self cursorReturn. 
9204d5313979 Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents: 2491
diff changeset
  3945
            ^ self
2017
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3946
        ].
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3947
        self isReadOnly ifTrue:[
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3948
            self unselect; makeCursorVisible.
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3949
            self cursorReturn
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3950
        ] ifFalse:[
2795
1f7b5f242eee learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents: 2792
diff changeset
  3951
            insertMode value ifFalse:[
2017
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3952
                self cursorReturn.
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3953
                autoIndent == true ifTrue:[
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3954
                    i := self leftIndentForLine:(cursorLine + 1).
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3955
                    self cursorCol:(i+1 max:1)
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3956
                ]
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3957
            ] ifTrue:[
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3958
                "/ old version just unselected ...
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3959
                "/ self unselect; makeCursorVisible.
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3960
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3961
                "/ new version deletes ...
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3962
                typeOfSelection == #paste ifTrue:[
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3963
                    self unselect; makeCursorVisible.
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3964
                ] ifFalse:[
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3965
                    self copyAndDeleteSelection.            
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3966
                ].
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3967
                self insertCharAtCursor:(Character cr). 
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3968
                autoIndent == true ifTrue:[
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3969
                    i := self leftIndentForLine:cursorLine.
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3970
                    self indentFromLine:cursorLine toLine:cursorLine.
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3971
                    self cursorCol:(i+1 max:1)
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3972
                ].
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3973
            ].
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3974
        ].
2505
9204d5313979 Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents: 2491
diff changeset
  3975
        ^ self
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3976
    ].
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
  3977
2819
a7a41dfb9df7 BackTab / NonInsertingTab modifiers now defined in keyboard.rc
ca
parents: 2817
diff changeset
  3978
    (key == #NonInsertingTab) ifTrue:[
a7a41dfb9df7 BackTab / NonInsertingTab modifiers now defined in keyboard.rc
ca
parents: 2817
diff changeset
  3979
        self unselect. self cursorTab. 
a7a41dfb9df7 BackTab / NonInsertingTab modifiers now defined in keyboard.rc
ca
parents: 2817
diff changeset
  3980
        ^ self
a7a41dfb9df7 BackTab / NonInsertingTab modifiers now defined in keyboard.rc
ca
parents: 2817
diff changeset
  3981
    ].
a7a41dfb9df7 BackTab / NonInsertingTab modifiers now defined in keyboard.rc
ca
parents: 2817
diff changeset
  3982
    (key == #BackTab) ifTrue:[
a7a41dfb9df7 BackTab / NonInsertingTab modifiers now defined in keyboard.rc
ca
parents: 2817
diff changeset
  3983
        self tabMeansNextField ifTrue:[^ super keyPress:key x:x y:y].
a7a41dfb9df7 BackTab / NonInsertingTab modifiers now defined in keyboard.rc
ca
parents: 2817
diff changeset
  3984
        self unselect. self cursorBacktab.
a7a41dfb9df7 BackTab / NonInsertingTab modifiers now defined in keyboard.rc
ca
parents: 2817
diff changeset
  3985
        ^ self
a7a41dfb9df7 BackTab / NonInsertingTab modifiers now defined in keyboard.rc
ca
parents: 2817
diff changeset
  3986
    ].
a7a41dfb9df7 BackTab / NonInsertingTab modifiers now defined in keyboard.rc
ca
parents: 2817
diff changeset
  3987
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3988
    (key == #Tab) ifTrue:[
2017
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3989
        self tabMeansNextField ifTrue:[^ super keyPress:key x:x y:y].
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3990
2795
1f7b5f242eee learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents: 2792
diff changeset
  3991
        insertMode value ifFalse:[
2017
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3992
            self unselect. self cursorTab. ^self
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3993
        ].
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  3994
        self unselect. self insertTabAtCursor. 
2505
9204d5313979 Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents: 2491
diff changeset
  3995
        ^ self
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3996
    ].
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
  3997
2883
6cdb4a5a7b5e shift-delete - delete whiteSpace
Claus Gittinger <cg@exept.de>
parents: 2880
diff changeset
  3998
    "/ key == #DeleteSpaces ifTrue:[
6cdb4a5a7b5e shift-delete - delete whiteSpace
Claus Gittinger <cg@exept.de>
parents: 2880
diff changeset
  3999
    (key == #Delete) ifTrue:[
3023
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  4000
        shiftPressed ifTrue:[
2883
6cdb4a5a7b5e shift-delete - delete whiteSpace
Claus Gittinger <cg@exept.de>
parents: 2880
diff changeset
  4001
            [(cursorCol <= (self listAt:cursorLine) size)
6cdb4a5a7b5e shift-delete - delete whiteSpace
Claus Gittinger <cg@exept.de>
parents: 2880
diff changeset
  4002
             and:[self characterUnderCursor isSeparator]] whileTrue:[
6cdb4a5a7b5e shift-delete - delete whiteSpace
Claus Gittinger <cg@exept.de>
parents: 2880
diff changeset
  4003
                self makeCursorVisible.
6cdb4a5a7b5e shift-delete - delete whiteSpace
Claus Gittinger <cg@exept.de>
parents: 2880
diff changeset
  4004
                self deleteCharAtCursor. 
6cdb4a5a7b5e shift-delete - delete whiteSpace
Claus Gittinger <cg@exept.de>
parents: 2880
diff changeset
  4005
            ].
6cdb4a5a7b5e shift-delete - delete whiteSpace
Claus Gittinger <cg@exept.de>
parents: 2880
diff changeset
  4006
            ^ self
6cdb4a5a7b5e shift-delete - delete whiteSpace
Claus Gittinger <cg@exept.de>
parents: 2880
diff changeset
  4007
        ]
6cdb4a5a7b5e shift-delete - delete whiteSpace
Claus Gittinger <cg@exept.de>
parents: 2880
diff changeset
  4008
    ].
6cdb4a5a7b5e shift-delete - delete whiteSpace
Claus Gittinger <cg@exept.de>
parents: 2880
diff changeset
  4009
870
c606f29db5d7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 865
diff changeset
  4010
    (key == #Delete
c606f29db5d7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 865
diff changeset
  4011
     or:[key == #BasicDelete]) ifTrue:[
2017
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4012
        selectionStartLine notNil ifTrue:[
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4013
            (key == #BasicDelete) ifTrue:[
2505
9204d5313979 Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents: 2491
diff changeset
  4014
                self deleteSelection.
2017
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4015
            ] ifFalse:[
2505
9204d5313979 Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents: 2491
diff changeset
  4016
                self copyAndDeleteSelection.
2017
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4017
            ].
2505
9204d5313979 Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents: 2491
diff changeset
  4018
            ^ self
2017
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4019
        ].
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4020
        self makeCursorVisible.
2505
9204d5313979 Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents: 2491
diff changeset
  4021
        self deleteCharAtCursor. 
9204d5313979 Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents: 2491
diff changeset
  4022
        ^ self
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4023
    ].
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
  4024
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4025
    (key == #BeginOfText) ifTrue:[     "i.e. HOME"
2017
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4026
        self unselect. 
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4027
        cursorVisibleLine == 1 ifTrue:[
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4028
            self cursorHome.
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4029
        ] ifFalse:[
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4030
            self cursorToFirstVisibleLine
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4031
        ].
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4032
        ^ self
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4033
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4034
    (key == #EndOfText) ifTrue:[       "i.e. END"
2017
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4035
        self unselect.
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4036
        cursorVisibleLine == nFullLinesShown ifTrue:[
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4037
            self cursorToBottom.
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4038
        ] ifFalse:[
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4039
            self cursorToLastVisibleLine
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4040
        ].
2505
9204d5313979 Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents: 2491
diff changeset
  4041
        ^ self
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4042
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4043
    ((key == #Escape)
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4044
    or:[key == #SelectLineFromBeginning])    ifTrue:[
2017
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4045
        self makeCursorVisible.
2505
9204d5313979 Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents: 2491
diff changeset
  4046
        self unselect. self selectCursorLineFromBeginning. 
9204d5313979 Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents: 2491
diff changeset
  4047
        ^ self
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4048
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4049
    (key == #SelectLine)    ifTrue:[
2017
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4050
        self makeCursorVisible.
2505
9204d5313979 Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents: 2491
diff changeset
  4051
        self unselect. self selectCursorLine. 
9204d5313979 Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents: 2491
diff changeset
  4052
        ^ self
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4053
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4054
    (key == #ExpandSelectionByLine)    ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4055
"/        self makeCursorVisible.
2505
9204d5313979 Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents: 2491
diff changeset
  4056
        self selectExpandCursorLine. 
9204d5313979 Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents: 2491
diff changeset
  4057
        ^ self
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4058
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4059
    (key == #DeleteLine)    ifTrue:[
2017
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4060
        self makeCursorVisible.
3024
e2d7e40e6481 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3023
diff changeset
  4061
        self unselect. self deleteCursorLine.
2505
9204d5313979 Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents: 2491
diff changeset
  4062
        ^ self
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4063
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4064
    (key == #InsertLine)    ifTrue:[
2017
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4065
        self makeCursorVisible.
2505
9204d5313979 Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents: 2491
diff changeset
  4066
        self unselect. self insertLine:nil before:cursorLine. 
9204d5313979 Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents: 2491
diff changeset
  4067
        ^ self
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4068
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4069
    super keyPress:key x:x y:y
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4070
1446
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  4071
    "Modified: / 6.2.1998 / 11:59:59 / stefan"
2157
ba22c3cc278b added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
  4072
    "Modified: / 22.2.2000 / 23:01:23 / cg"
121
claus
parents: 118
diff changeset
  4073
!
claus
parents: 118
diff changeset
  4074
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4075
executeKeyboardMacro:cmdMacro
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4076
    Error handle:[:ex |
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4077
        self warn:'Error in keyboard macro: ' , ex description.
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4078
        ex return.
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4079
    ] do:[
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4080
        AbortSignal handle:[:ex |
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4081
            self warn:'Keyboard macro aborted'.
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4082
            ex return.
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4083
        ] do:[
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4084
            Parser 
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4085
                evaluate:cmdMacro asString
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4086
                receiver:self
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4087
                notifying:nil
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4088
                compile:false.
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4089
        ].
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4090
    ].
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4091
!
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4092
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4093
handleNonCommandKey:keyArg
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4094
    |selStartLine selStartCol selEndLine selEndCol sel key|
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4095
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4096
    self isReadOnly ifTrue:[
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4097
        self flash.
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4098
        ^ self.
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4099
    ].
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4100
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4101
    key := keyArg.
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4102
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4103
    typeOfSelection == #paste ifTrue:[
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4104
        "pasted selection will NOT be replaced by keystroke"
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4105
        self unselect
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4106
    ].
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4107
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4108
    selStartLine := selectionStartLine.
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4109
    selStartCol := self selectionStartCol.
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4110
    selEndLine := selectionEndLine.
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4111
    selEndCol := self selectionEndCol.
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4112
    sel := self selection.
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4113
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4114
    (characterEncoding ? #'iso10646-1') ~~ #'iso10646-1' ifTrue:[
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4115
        key := CharacterEncoder encode:key from:#'iso10646-1' into:characterEncoding.
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4116
    ].
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4117
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4118
    "replace selection by what is typed in -
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4119
     if word was selected with a space, keep it"
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4120
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4121
    (selectStyle == #wordLeft) ifTrue:[
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4122
        self replaceSelectionBy:(' ' , key asString)
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4123
    ] ifFalse:[
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4124
        (selectStyle == #wordRight) ifTrue:[
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4125
            self replaceSelectionBy:(key asString , ' ').
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4126
            self cursorLeft
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4127
        ] ifFalse:[
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4128
            self replaceSelectionBy:key
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4129
        ]
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4130
    ].                                       
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4131
    selectStyle := nil.
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4132
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4133
    showMatchingParenthesis ifTrue:[
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4134
        "emacs style parenthesis shower"
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4135
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4136
        "claus: only do it for closing parenthesis -
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4137
                otherwise its too anoying.
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4138
        "
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4139
"
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4140
        (#( $( $) $[ $] ${ $} ) includes:key) ifTrue:[
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4141
"
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4142
        (#( $) $] $} ) includes:key) ifTrue:[
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4143
        self 
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4144
            searchForMatchingParenthesisFromLine:cursorLine col:(cursorCol - 1)
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4145
            ifFound:[:line :col |
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4146
                         |savLine savCol sensor|
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4147
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4148
                         self withCursor:Cursor eye do:[
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4149
                             savLine := cursorLine.
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4150
                             savCol := cursorCol.
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4151
                             self cursorLine:line col:col.
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4152
                             device flush.
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4153
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4154
                             "/ want to wait 200ms, but not if another keyPress
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4155
                             "/ arrives in the meantime ...
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4156
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4157
                             sensor := self sensor.
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4158
                             5 timesRepeat:[
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4159
                                 (sensor hasKeyPressEventFor:self) ifFalse:[
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4160
                                     Processor activeProcess millisecondDelay:40.
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4161
                                 ]
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4162
                             ].
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4163
                             self cursorLine:savLine col:savCol
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4164
                         ]
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4165
                    ]
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4166
            ifNotFound:[self showNotFound]
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4167
            onError:[self beep]
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4168
        ].
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4169
    ].
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4170
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4171
"/    true "autoExpandWhileTyping" ifTrue:[
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4172
"/        self wordAtLine:cursorLine col:cursorCol-1 do:[
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4173
"/            :beginLine :beginCol :endLine :endCol :style |
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4174
"/
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4175
"/            self selectFromLine:beginLine col:beginCol toLine:endLine col:endCol.
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4176
"/            self selection.
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4177
"/            typeOfSelection := #paste.
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4178
"/        ].                                 
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4179
"/    ].                       
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4180
!
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4181
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4182
keyPress:key x:x y:y
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4183
    "handle keyboard input"
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4184
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4185
    self undoableDo:[
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4186
        self doKeyPress:key x:x y:y
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4187
    ].
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4188
!
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4189
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4190
mapped
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4191
    "view was made visible"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4192
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4193
    super mapped.
2422
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  4194
    self updateCursorVisibleLine.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4195
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4196
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4197
sizeChanged:how
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4198
    "make certain, cursor is visible after the sizechange"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4199
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4200
    |cv|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4201
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4202
    cv := cursorVisibleLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4203
    super sizeChanged:how.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4204
    cv notNil ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4205
        self makeLineVisible:cursorLine
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4206
    ]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4207
! !
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4208
1807
30526cb1acfc category and comment
Claus Gittinger <cg@exept.de>
parents: 1804
diff changeset
  4209
!EditTextView methodsFor:'focus handling'!
30526cb1acfc category and comment
Claus Gittinger <cg@exept.de>
parents: 1804
diff changeset
  4210
30526cb1acfc category and comment
Claus Gittinger <cg@exept.de>
parents: 1804
diff changeset
  4211
hasKeyboardFocus:aBoolean
30526cb1acfc category and comment
Claus Gittinger <cg@exept.de>
parents: 1804
diff changeset
  4212
    "sent by the windowGroup, a delegate or myself to make me show a block cursor
30526cb1acfc category and comment
Claus Gittinger <cg@exept.de>
parents: 1804
diff changeset
  4213
     (otherwise, I would not know about this)"
30526cb1acfc category and comment
Claus Gittinger <cg@exept.de>
parents: 1804
diff changeset
  4214
30526cb1acfc category and comment
Claus Gittinger <cg@exept.de>
parents: 1804
diff changeset
  4215
    hasKeyboardFocus := aBoolean.
1816
0b9380a0cc7e only take keyboardFocus (and show cursor)
Claus Gittinger <cg@exept.de>
parents: 1811
diff changeset
  4216
    (cursorShown 
0b9380a0cc7e only take keyboardFocus (and show cursor)
Claus Gittinger <cg@exept.de>
parents: 1811
diff changeset
  4217
    and:[self enabled 
2129
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  4218
    and:[readOnly value not]]) ifTrue:[
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  4219
        self drawCursor
1816
0b9380a0cc7e only take keyboardFocus (and show cursor)
Claus Gittinger <cg@exept.de>
parents: 1811
diff changeset
  4220
    ].
0b9380a0cc7e only take keyboardFocus (and show cursor)
Claus Gittinger <cg@exept.de>
parents: 1811
diff changeset
  4221
0b9380a0cc7e only take keyboardFocus (and show cursor)
Claus Gittinger <cg@exept.de>
parents: 1811
diff changeset
  4222
    "Modified: / 23.3.1999 / 13:49:35 / cg"
1807
30526cb1acfc category and comment
Claus Gittinger <cg@exept.de>
parents: 1804
diff changeset
  4223
!
30526cb1acfc category and comment
Claus Gittinger <cg@exept.de>
parents: 1804
diff changeset
  4224
30526cb1acfc category and comment
Claus Gittinger <cg@exept.de>
parents: 1804
diff changeset
  4225
showFocus:explicit
30526cb1acfc category and comment
Claus Gittinger <cg@exept.de>
parents: 1804
diff changeset
  4226
    "in addition to however my superclass thinks how a focusView is to be
30526cb1acfc category and comment
Claus Gittinger <cg@exept.de>
parents: 1804
diff changeset
  4227
     displayed, show the cursor when I got the focus"
30526cb1acfc category and comment
Claus Gittinger <cg@exept.de>
parents: 1804
diff changeset
  4228
30526cb1acfc category and comment
Claus Gittinger <cg@exept.de>
parents: 1804
diff changeset
  4229
    self showCursor.
30526cb1acfc category and comment
Claus Gittinger <cg@exept.de>
parents: 1804
diff changeset
  4230
    self hasKeyboardFocus:true.
30526cb1acfc category and comment
Claus Gittinger <cg@exept.de>
parents: 1804
diff changeset
  4231
    super showFocus:explicit
30526cb1acfc category and comment
Claus Gittinger <cg@exept.de>
parents: 1804
diff changeset
  4232
30526cb1acfc category and comment
Claus Gittinger <cg@exept.de>
parents: 1804
diff changeset
  4233
    "Modified: 11.12.1996 / 16:56:54 / cg"
1918
3ac07b97b4f7 use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents: 1902
diff changeset
  4234
!
3ac07b97b4f7 use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents: 1902
diff changeset
  4235
3ac07b97b4f7 use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents: 1902
diff changeset
  4236
wantsFocusWithPointerEnter
3ac07b97b4f7 use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents: 1902
diff changeset
  4237
    "return true, if I want the focus when
3ac07b97b4f7 use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents: 1902
diff changeset
  4238
     the mouse pointer enters"
3ac07b97b4f7 use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents: 1902
diff changeset
  4239
3ac07b97b4f7 use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents: 1902
diff changeset
  4240
    |pref|
3ac07b97b4f7 use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents: 1902
diff changeset
  4241
3ac07b97b4f7 use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents: 1902
diff changeset
  4242
    pref := UserPreferences current focusFollowsMouse.
3ac07b97b4f7 use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents: 1902
diff changeset
  4243
    (pref ~~ false
3ac07b97b4f7 use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents: 1902
diff changeset
  4244
    and:[(styleSheet at:#'editText.requestFocusOnPointerEnter' default:true)
3ac07b97b4f7 use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents: 1902
diff changeset
  4245
    and:[self enabled 
3ac07b97b4f7 use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents: 1902
diff changeset
  4246
    and:[readOnly not]]]) ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4247
        ^ true
1918
3ac07b97b4f7 use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents: 1902
diff changeset
  4248
    ].
3ac07b97b4f7 use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents: 1902
diff changeset
  4249
3ac07b97b4f7 use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents: 1902
diff changeset
  4250
    ^ false
3ac07b97b4f7 use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents: 1902
diff changeset
  4251
3ac07b97b4f7 use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents: 1902
diff changeset
  4252
3ac07b97b4f7 use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents: 1902
diff changeset
  4253
1807
30526cb1acfc category and comment
Claus Gittinger <cg@exept.de>
parents: 1804
diff changeset
  4254
! !
30526cb1acfc category and comment
Claus Gittinger <cg@exept.de>
parents: 1804
diff changeset
  4255
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4256
!EditTextView methodsFor:'formatting'!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4257
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4258
indent
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4259
    "indent selected line-range"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4260
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4261
    |start end|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4262
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4263
    selectionStartLine isNil ifTrue:[^ self].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4264
    start := selectionStartLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4265
    end := selectionEndLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4266
    (selectionEndCol == 0) ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4267
        end := end - 1
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4268
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4269
    self unselect.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4270
    self indentFromLine:start toLine:end
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4271
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4272
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4273
indentFromLine:start toLine:end
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4274
    "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
  4275
     last non-empty line before start, and change the indent
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4276
     of the line based on that indent."
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4277
474
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  4278
    |leftStart delta d line spaces|
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  4279
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  4280
    leftStart := self leftIndentForLine:start.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4281
    (leftStart == 0) ifTrue:[^ self].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4282
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4283
    delta := leftStart - (self leftIndentOfLine:start).
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4284
    (delta == 0) ifTrue:[^ self].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4285
    (delta > 0) ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4286
        spaces := String new:delta
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4287
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4288
    start to:end do:[:lineNr |
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4289
        line := self listAt:lineNr.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4290
        line notNil ifTrue:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4291
            line isBlank ifTrue:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4292
                list at:lineNr put:nil
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4293
            ] ifFalse:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4294
                (delta > 0) ifTrue:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4295
                    line := spaces , line.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4296
                    widthOfWidestLine notNil ifTrue:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4297
                        widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:line).
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4298
                    ]
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4299
                ] ifFalse:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4300
                    "check if deletion is ok"
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4301
                    d := delta negated + 1.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4302
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4303
                    line size > d ifTrue:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4304
                        (line copyTo:(d - 1)) withoutSeparators isEmpty ifTrue:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4305
                            line := line copyFrom:d
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4306
                        ]
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4307
                    ].
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4308
                    widthOfWidestLine := nil
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4309
                ].
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4310
                list at:lineNr put:line.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4311
                self textChanged.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4312
            ]
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4313
        ]
121
claus
parents: 118
diff changeset
  4314
    ].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4315
    self redrawFromLine:start to:end
474
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  4316
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  4317
    "Modified: 5.3.1996 / 14:59:18 / cg"
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  4318
!
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  4319
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  4320
leftIndentForLine:lineNr
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  4321
    "find an appropriate indent for a line.
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  4322
     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
  4323
     and returning its indent."
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  4324
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  4325
    "SHOULD GO TO ListView"
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  4326
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  4327
    |line lnr indent|
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  4328
474
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  4329
    lnr := lineNr.
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  4330
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  4331
    [lnr ~~ 1] whileTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4332
        lnr  := lnr - 1.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4333
        line := self listAt:lnr.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4334
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4335
        line notNil ifTrue:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4336
            indent := line indexOfNonSeparatorStartingAt:1.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4337
            indent ~~ 0 ifTrue:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4338
                ^ indent - 1
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4339
            ]
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4340
        ]
474
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  4341
    ].
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  4342
    ^ 0
474
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  4343
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  4344
    "Created: 5.3.1996 / 14:58:53 / cg"
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  4345
! !
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  4346
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  4347
!EditTextView methodsFor:'initialization'!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  4348
941
f06fa4d47f26 fetch device resources early
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  4349
fetchDeviceResources
f06fa4d47f26 fetch device resources early
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  4350
    "fetch device colors, to avoid reallocation at redraw time"
f06fa4d47f26 fetch device resources early
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  4351
f06fa4d47f26 fetch device resources early
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  4352
    super fetchDeviceResources.
f06fa4d47f26 fetch device resources early
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  4353
1993
5ffe0b3943cd #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1967
diff changeset
  4354
    cursorFgColor notNil ifTrue:[cursorFgColor := cursorFgColor onDevice:device].
5ffe0b3943cd #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1967
diff changeset
  4355
    cursorBgColor notNil ifTrue:[cursorBgColor := cursorBgColor onDevice:device].
5ffe0b3943cd #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1967
diff changeset
  4356
    cursorNoFocusFgColor notNil ifTrue:[cursorNoFocusFgColor := cursorNoFocusFgColor onDevice:device].
941
f06fa4d47f26 fetch device resources early
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  4357
f06fa4d47f26 fetch device resources early
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  4358
    "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
  4359
    "Modified: 18.2.1997 / 15:02:46 / cg"
941
f06fa4d47f26 fetch device resources early
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  4360
!
f06fa4d47f26 fetch device resources early
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  4361
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4362
initEvents
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4363
    "enable enter/leave events in addition"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4364
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4365
    super initEvents.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4366
    self enableEnterLeaveEvents
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4367
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4368
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4369
initStyle
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4370
    "initialize style specific stuff"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4371
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4372
    super initStyle.
2088
b2beb67b1a98 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2085
diff changeset
  4373
    lineSpacing := 1.       "/ for underwave - also looks better
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4374
    lockUpdates := false.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4375
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4376
    cursorFgColor := DefaultCursorForegroundColor.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4377
    cursorFgColor isNil ifTrue:[cursorFgColor := bgColor].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4378
    cursorBgColor := DefaultCursorBackgroundColor.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4379
    cursorBgColor isNil ifTrue:[cursorBgColor := fgColor].
1334
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  4380
    cursorType := cursorTypeNoFocus := DefaultCursorType.
1534
bcb211e1b41a read noFocus cursorStyle from styleSheet
Claus Gittinger <cg@exept.de>
parents: 1533
diff changeset
  4381
    DefaultCursorTypeNoFocus notNil ifTrue:[
2088
b2beb67b1a98 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2085
diff changeset
  4382
        cursorTypeNoFocus := DefaultCursorTypeNoFocus.
1534
bcb211e1b41a read noFocus cursorStyle from styleSheet
Claus Gittinger <cg@exept.de>
parents: 1533
diff changeset
  4383
    ].
1022
4362861fe15e allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents: 1018
diff changeset
  4384
    cursorNoFocusFgColor := DefaultCursorNoFocusForegroundColor.
4362861fe15e allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents: 1018
diff changeset
  4385
    cursorNoFocusFgColor isNil ifTrue:[
2088
b2beb67b1a98 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2085
diff changeset
  4386
        cursorType ~~ #block ifTrue:[
b2beb67b1a98 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2085
diff changeset
  4387
            cursorNoFocusFgColor := cursorBgColor
b2beb67b1a98 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2085
diff changeset
  4388
        ] ifFalse:[
b2beb67b1a98 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2085
diff changeset
  4389
            cursorNoFocusFgColor := cursorFgColor
b2beb67b1a98 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2085
diff changeset
  4390
        ]
1022
4362861fe15e allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents: 1018
diff changeset
  4391
    ].
4362861fe15e allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents: 1018
diff changeset
  4392
2088
b2beb67b1a98 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2085
diff changeset
  4393
    "Modified: / 15.12.1999 / 22:27:45 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4394
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4395
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4396
initialize
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4397
    "initialize a new EditTextView;
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4398
     setup some instance variables"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4399
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4400
    super initialize.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4401
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4402
    self level:-1.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4403
    readOnly := false.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4404
    fixedSize := false.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4405
    exceptionBlock := [:errorText | ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4406
    cursorShown := prevCursorState := true.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4407
    cursorLine := 1.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4408
    cursorVisibleLine := 1.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4409
    cursorCol := 1.
2815
d71f43d7de3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2796
diff changeset
  4410
    cursorLineHolder := 1 asValue.
d71f43d7de3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2796
diff changeset
  4411
    cursorColHolder := 1 asValue.
2119
2aa585fc62a3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2117
diff changeset
  4412
    modifiedChannel := ValueHolder with:false.
2aa585fc62a3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2117
diff changeset
  4413
    acceptChannel := ValueHolder with:false.
1437
ab84b08a9f9c allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
  4414
    acceptChannel addDependent:self.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4415
    showMatchingParenthesis := false.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4416
    hasKeyboardFocus := false. "/ true.
323
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
  4417
    tabMeansNextField := false.
474
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  4418
    autoIndent := false.
2795
1f7b5f242eee learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents: 2792
diff changeset
  4419
    insertMode := true asValue.
1f7b5f242eee learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents: 2792
diff changeset
  4420
    learnMode := false asValue.
2647
23dca8f032c3 changed st80Mode from classVar to userPreferences value
Claus Gittinger <cg@exept.de>
parents: 2627
diff changeset
  4421
    "/ trimBlankLines := st80Mode not. "true."
23dca8f032c3 changed st80Mode from classVar to userPreferences value
Claus Gittinger <cg@exept.de>
parents: 2627
diff changeset
  4422
    trimBlankLines := self st80EditMode not. "true."
2131
858209ba8509 cursor movement default
Claus Gittinger <cg@exept.de>
parents: 2129
diff changeset
  4423
    cursorMovementWhenUpdating := #beginOfText.
1596
0bbdb4e9fc43 made st80Mode also an inst-flag;
Claus Gittinger <cg@exept.de>
parents: 1591
diff changeset
  4424
2589
62794ae04446 support drop
ca
parents: 2580
diff changeset
  4425
    "/ on default enable drop
62794ae04446 support drop
ca
parents: 2580
diff changeset
  4426
    self allowDrop:true.        "/ readOnly tested in #canDrop:
2989
5dcc2912bcb6 undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents: 2984
diff changeset
  4427
5dcc2912bcb6 undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents: 2984
diff changeset
  4428
    undoSupport := UndoSupport for:self.
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  4429
! !
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  4430
2580
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  4431
!EditTextView methodsFor:'macros'!
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  4432
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  4433
executeLearnedKeyboardMacro
2795
1f7b5f242eee learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents: 2792
diff changeset
  4434
    (self learnMode not and:[learnedMacro size > 0]) ifTrue:[
2580
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  4435
        learnedMacro do:[:event |
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  4436
                            WindowGroup lastEventQuerySignal answer:event
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  4437
                            do:[
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  4438
                                self 
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  4439
                                    dispatchEvent:event
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  4440
                                    withFocusOn:nil
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  4441
                                    delegate:false
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  4442
                            ]
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  4443
                        ].
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  4444
    ] ifFalse:[
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  4445
        self flash.
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  4446
    ].
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  4447
!
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  4448
2795
1f7b5f242eee learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents: 2792
diff changeset
  4449
learnMode
1f7b5f242eee learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents: 2792
diff changeset
  4450
    ^ (learnMode value ? false).
1f7b5f242eee learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents: 2792
diff changeset
  4451
!
1f7b5f242eee learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents: 2792
diff changeset
  4452
2580
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  4453
learnMode:aBoolean
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  4454
    |fg bg|
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  4455
2795
1f7b5f242eee learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents: 2792
diff changeset
  4456
    self learnModeHolder value:aBoolean.
1f7b5f242eee learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents: 2792
diff changeset
  4457
1f7b5f242eee learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents: 2792
diff changeset
  4458
    aBoolean ifTrue:[
2580
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  4459
        learnedMacro := OrderedCollection new.
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  4460
        fg := Color white.
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  4461
        bg := Color black.
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  4462
    ] ifFalse:[
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  4463
        cursorFgColor := fg := DefaultCursorForegroundColor ? bgColor.
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  4464
        cursorBgColor := bg := DefaultCursorBackgroundColor ? fgColor.
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  4465
    ].
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  4466
    self cursorForegroundColor:fg backgroundColor:bg.
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  4467
!
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  4468
2795
1f7b5f242eee learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents: 2792
diff changeset
  4469
learnModeHolder
1f7b5f242eee learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents: 2792
diff changeset
  4470
    learnMode isNil ifTrue:[
1f7b5f242eee learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents: 2792
diff changeset
  4471
        learnMode := false asValue
1f7b5f242eee learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents: 2792
diff changeset
  4472
    ].
1f7b5f242eee learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents: 2792
diff changeset
  4473
    ^ learnMode
1f7b5f242eee learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents: 2792
diff changeset
  4474
!
1f7b5f242eee learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents: 2792
diff changeset
  4475
2580
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  4476
toggleLearnMode
2795
1f7b5f242eee learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents: 2792
diff changeset
  4477
    self learnMode: self learnMode not.
2580
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  4478
! !
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  4479
121
claus
parents: 118
diff changeset
  4480
!EditTextView methodsFor:'menu actions'!
claus
parents: 118
diff changeset
  4481
2680
208d99c47d7c babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents: 2677
diff changeset
  4482
babelFishTranslate:fromToModeString
208d99c47d7c babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents: 2677
diff changeset
  4483
    "translate the selected text and paste it after the selection"
208d99c47d7c babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents: 2677
diff changeset
  4484
208d99c47d7c babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents: 2677
diff changeset
  4485
    |original translated|
208d99c47d7c babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents: 2677
diff changeset
  4486
208d99c47d7c babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents: 2677
diff changeset
  4487
    original := self selectionAsString.
208d99c47d7c babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents: 2677
diff changeset
  4488
    original size == 0 ifTrue:[^ self].
208d99c47d7c babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents: 2677
diff changeset
  4489
208d99c47d7c babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents: 2677
diff changeset
  4490
    self withWaitCursorDo:[
208d99c47d7c babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents: 2677
diff changeset
  4491
        SOAP::SoapImplError handle:[:ex |
2682
1b5aeb99f26a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2681
diff changeset
  4492
            Dialog warn:('Translation failed - WEB Service error:\\%1.' bindWith:ex description allBold) withCRs
2680
208d99c47d7c babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents: 2677
diff changeset
  4493
        ] do:[
208d99c47d7c babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents: 2677
diff changeset
  4494
            translated := SOAP::BabelFishClient new translate:original mode:fromToModeString.
208d99c47d7c babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents: 2677
diff changeset
  4495
        ]
208d99c47d7c babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents: 2677
diff changeset
  4496
    ].
208d99c47d7c babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents: 2677
diff changeset
  4497
208d99c47d7c babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents: 2677
diff changeset
  4498
    "/ v pasteOrReplace:translated
208d99c47d7c babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents: 2677
diff changeset
  4499
    self cursorLine:(self selectionEndLine) col:(self selectionEndCol + 1).
208d99c47d7c babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents: 2677
diff changeset
  4500
    self unselect.
2989
5dcc2912bcb6 undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents: 2984
diff changeset
  4501
    self undoablePaste:translated
2680
208d99c47d7c babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents: 2677
diff changeset
  4502
!
208d99c47d7c babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents: 2677
diff changeset
  4503
121
claus
parents: 118
diff changeset
  4504
cut
claus
parents: 118
diff changeset
  4505
    "cut selection into copybuffer"
claus
parents: 118
diff changeset
  4506
1818
aa16d9b96e40 fixed cut to not compress multiple blanks.
Claus Gittinger <cg@exept.de>
parents: 1817
diff changeset
  4507
    |line col history sel s|
121
claus
parents: 118
diff changeset
  4508
1548
d4a3d61388dc flash view in readonly mode, when modification is attempted.
Claus Gittinger <cg@exept.de>
parents: 1546
diff changeset
  4509
    (self checkModificationsAllowed) ifFalse:[
2121
a408dd807d99 cut - last newline fix
Claus Gittinger <cg@exept.de>
parents: 2119
diff changeset
  4510
        self flash.
a408dd807d99 cut - last newline fix
Claus Gittinger <cg@exept.de>
parents: 2119
diff changeset
  4511
        ^ self
1548
d4a3d61388dc flash view in readonly mode, when modification is attempted.
Claus Gittinger <cg@exept.de>
parents: 1546
diff changeset
  4512
    ].
1480
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  4513
121
claus
parents: 118
diff changeset
  4514
    sel := self selection.
claus
parents: 118
diff changeset
  4515
    sel notNil ifTrue:[
2121
a408dd807d99 cut - last newline fix
Claus Gittinger <cg@exept.de>
parents: 2119
diff changeset
  4516
        lastString := s := sel asStringWithCRs.
a408dd807d99 cut - last newline fix
Claus Gittinger <cg@exept.de>
parents: 2119
diff changeset
  4517
        line := selectionStartLine.
a408dd807d99 cut - last newline fix
Claus Gittinger <cg@exept.de>
parents: 2119
diff changeset
  4518
        col := selectionStartCol.
a408dd807d99 cut - last newline fix
Claus Gittinger <cg@exept.de>
parents: 2119
diff changeset
  4519
a408dd807d99 cut - last newline fix
Claus Gittinger <cg@exept.de>
parents: 2119
diff changeset
  4520
        "
a408dd807d99 cut - last newline fix
Claus Gittinger <cg@exept.de>
parents: 2119
diff changeset
  4521
         remember in CopyBuffer
a408dd807d99 cut - last newline fix
Claus Gittinger <cg@exept.de>
parents: 2119
diff changeset
  4522
        "
3043
06df889187a4 set selection interface changed
ca
parents: 3038
diff changeset
  4523
        self setClipboardText:sel. "/ lastString.
2121
a408dd807d99 cut - last newline fix
Claus Gittinger <cg@exept.de>
parents: 2119
diff changeset
  4524
a408dd807d99 cut - last newline fix
Claus Gittinger <cg@exept.de>
parents: 2119
diff changeset
  4525
        "
a408dd807d99 cut - last newline fix
Claus Gittinger <cg@exept.de>
parents: 2119
diff changeset
  4526
         append to DeleteHistory (if there is one)
a408dd807d99 cut - last newline fix
Claus Gittinger <cg@exept.de>
parents: 2119
diff changeset
  4527
        "
a408dd807d99 cut - last newline fix
Claus Gittinger <cg@exept.de>
parents: 2119
diff changeset
  4528
        history := Smalltalk at:#DeleteHistory.
a408dd807d99 cut - last newline fix
Claus Gittinger <cg@exept.de>
parents: 2119
diff changeset
  4529
        history notNil ifTrue:[
a408dd807d99 cut - last newline fix
Claus Gittinger <cg@exept.de>
parents: 2119
diff changeset
  4530
            history addAll:(sel asStringCollection).
a408dd807d99 cut - last newline fix
Claus Gittinger <cg@exept.de>
parents: 2119
diff changeset
  4531
            history size > 1000 ifTrue:[
a408dd807d99 cut - last newline fix
Claus Gittinger <cg@exept.de>
parents: 2119
diff changeset
  4532
                history := history copyFrom:(history size - 1000)
a408dd807d99 cut - last newline fix
Claus Gittinger <cg@exept.de>
parents: 2119
diff changeset
  4533
            ].
a408dd807d99 cut - last newline fix
Claus Gittinger <cg@exept.de>
parents: 2119
diff changeset
  4534
        ].
a408dd807d99 cut - last newline fix
Claus Gittinger <cg@exept.de>
parents: 2119
diff changeset
  4535
a408dd807d99 cut - last newline fix
Claus Gittinger <cg@exept.de>
parents: 2119
diff changeset
  4536
        "
a408dd807d99 cut - last newline fix
Claus Gittinger <cg@exept.de>
parents: 2119
diff changeset
  4537
         now, delete it
a408dd807d99 cut - last newline fix
Claus Gittinger <cg@exept.de>
parents: 2119
diff changeset
  4538
        "
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4539
        self undoableDo:[
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4540
            self deleteSelection.
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4541
        ].
2121
a408dd807d99 cut - last newline fix
Claus Gittinger <cg@exept.de>
parents: 2119
diff changeset
  4542
        lastReplacement := nil
121
claus
parents: 118
diff changeset
  4543
    ] ifFalse:[
2121
a408dd807d99 cut - last newline fix
Claus Gittinger <cg@exept.de>
parents: 2119
diff changeset
  4544
        "
a408dd807d99 cut - last newline fix
Claus Gittinger <cg@exept.de>
parents: 2119
diff changeset
  4545
         a cut without selection will search&cut again
a408dd807d99 cut - last newline fix
Claus Gittinger <cg@exept.de>
parents: 2119
diff changeset
  4546
        "
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4547
        self undoableDo:[
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4548
            self again
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4549
        ]
121
claus
parents: 118
diff changeset
  4550
    ]
1290
d87b6c35c3ae checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1289
diff changeset
  4551
1480
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  4552
    "Modified: / 5.4.1998 / 16:51:53 / cg"
121
claus
parents: 118
diff changeset
  4553
!
claus
parents: 118
diff changeset
  4554
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4555
defaultForGotoLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4556
    "return a default value to show in the gotoLine box"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4557
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4558
    cursorLine notNil ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  4559
        ^ cursorLine
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4560
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4561
    ^ super defaultForGotoLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4562
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4563
428
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  4564
editMenu
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  4565
    "return the views middleButtonMenu"
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  4566
488
d10fe3a5f0cf resources
Claus Gittinger <cg@exept.de>
parents: 479
diff changeset
  4567
    <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
  4568
    <resource: #programMenu>
1054
d699ecd13e60 menu resource
Claus Gittinger <cg@exept.de>
parents: 1049
diff changeset
  4569
3115
b75128334006 info string in undo
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
  4570
    |items m sub translateItems miscItems toolItems subSub toolSub what undoIdx|
1515
9e9b65bd6efb care for nil sensor
Claus Gittinger <cg@exept.de>
parents: 1495
diff changeset
  4571
2460
Claus Gittinger <cg@exept.de>
parents: 2438
diff changeset
  4572
    items := #(
2989
5dcc2912bcb6 undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents: 2984
diff changeset
  4573
                    ('Redo'             redo                    )  
2540
56b92c7a787c menu texts: standard headline case
Claus Gittinger <cg@exept.de>
parents: 2528
diff changeset
  4574
                    ('Again (for All)'  multipleAgain           )  
2460
Claus Gittinger <cg@exept.de>
parents: 2438
diff changeset
  4575
                    ('-'                                        )
Claus Gittinger <cg@exept.de>
parents: 2438
diff changeset
  4576
                    ('Search...'        search         Find     )
2944
86d6808c0b4a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2940
diff changeset
  4577
                    ('Goto Line...'     gotoLine       GotoLine )
2460
Claus Gittinger <cg@exept.de>
parents: 2438
diff changeset
  4578
                    ('-'                                        )
2866
9dd71df46f73 specialCharacters menu item
Claus Gittinger <cg@exept.de>
parents: 2857
diff changeset
  4579
                    ('Tools'            tools                   )
9dd71df46f73 specialCharacters menu item
Claus Gittinger <cg@exept.de>
parents: 2857
diff changeset
  4580
                    ('Misc'             misc                    )
2580
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  4581
                    ('-'                                        )
2676
cc61fa88a3fb google spelling;
Claus Gittinger <cg@exept.de>
parents: 2660
diff changeset
  4582
                    ('Insert File...'   insertFile              )
cc61fa88a3fb google spelling;
Claus Gittinger <cg@exept.de>
parents: 2660
diff changeset
  4583
                    ('-'                                        )
2540
56b92c7a787c menu texts: standard headline case
Claus Gittinger <cg@exept.de>
parents: 2528
diff changeset
  4584
                    ('Save As...'       save           SaveAs   )
2460
Claus Gittinger <cg@exept.de>
parents: 2438
diff changeset
  4585
                    ('Print'            doPrint        Print    )
Claus Gittinger <cg@exept.de>
parents: 2438
diff changeset
  4586
              ).
Claus Gittinger <cg@exept.de>
parents: 2438
diff changeset
  4587
2866
9dd71df46f73 specialCharacters menu item
Claus Gittinger <cg@exept.de>
parents: 2857
diff changeset
  4588
    miscItems := #(
9dd71df46f73 specialCharacters menu item
Claus Gittinger <cg@exept.de>
parents: 2857
diff changeset
  4589
                    ('AutoIndent \c'    autoIndent:             )
9dd71df46f73 specialCharacters menu item
Claus Gittinger <cg@exept.de>
parents: 2857
diff changeset
  4590
                    ('InsertMode \c'    insertMode:             )
9dd71df46f73 specialCharacters menu item
Claus Gittinger <cg@exept.de>
parents: 2857
diff changeset
  4591
                    ('-'                                        )
9dd71df46f73 specialCharacters menu item
Claus Gittinger <cg@exept.de>
parents: 2857
diff changeset
  4592
                    ('Learn Macro \c'     learnMode:                  LearnKeyboardMacro)
9dd71df46f73 specialCharacters menu item
Claus Gittinger <cg@exept.de>
parents: 2857
diff changeset
  4593
                    ('Execute Macro'    executeLearnedKeyboardMacro ExecuteKeyboardMacro )
2870
994a3a44c526 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  4594
                    ('-'                                        )
994a3a44c526 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  4595
                    ('Font...'          changeFont              )
994a3a44c526 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  4596
"/                    ('Encoding...'      changeEncoding          )
2866
9dd71df46f73 specialCharacters menu item
Claus Gittinger <cg@exept.de>
parents: 2857
diff changeset
  4597
            ).
9dd71df46f73 specialCharacters menu item
Claus Gittinger <cg@exept.de>
parents: 2857
diff changeset
  4598
2680
208d99c47d7c babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents: 2677
diff changeset
  4599
    translateItems := #(
208d99c47d7c babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents: 2677
diff changeset
  4600
                    ('English -> German'      (babelFishTranslate: 'en_de')   )  
208d99c47d7c babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents: 2677
diff changeset
  4601
                    ('English -> French'      (babelFishTranslate: 'en_fr')   )  
208d99c47d7c babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents: 2677
diff changeset
  4602
                    ('English -> Italian'     (babelFishTranslate: 'en_it')   )  
208d99c47d7c babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents: 2677
diff changeset
  4603
                    ('English -> Spanish'     (babelFishTranslate: 'en_es')   )  
208d99c47d7c babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents: 2677
diff changeset
  4604
                    ('English -> Portuguese'  (babelFishTranslate: 'en_pt')   )  
208d99c47d7c babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents: 2677
diff changeset
  4605
                    ('-'                                        )
208d99c47d7c babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents: 2677
diff changeset
  4606
                    ('German -> English'      (babelFishTranslate: 'de_en')   )  
208d99c47d7c babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents: 2677
diff changeset
  4607
                    ('French -> English'      (babelFishTranslate: 'fr_en')   )  
208d99c47d7c babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents: 2677
diff changeset
  4608
                    ('Italian -> English'     (babelFishTranslate: 'it_en')   )  
208d99c47d7c babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents: 2677
diff changeset
  4609
                    ('Spanish -> English'     (babelFishTranslate: 'es_en')   )  
208d99c47d7c babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents: 2677
diff changeset
  4610
                    ('Portuguese -> English'  (babelFishTranslate: 'pt_en')   )  
208d99c47d7c babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents: 2677
diff changeset
  4611
              ).
208d99c47d7c babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents: 2677
diff changeset
  4612
2762
e29673db4ddb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2757
diff changeset
  4613
    toolItems := #(
2866
9dd71df46f73 specialCharacters menu item
Claus Gittinger <cg@exept.de>
parents: 2857
diff changeset
  4614
                    ('Indent'                      indent                     )
9dd71df46f73 specialCharacters menu item
Claus Gittinger <cg@exept.de>
parents: 2857
diff changeset
  4615
                    ('-'                                                      )
9dd71df46f73 specialCharacters menu item
Claus Gittinger <cg@exept.de>
parents: 2857
diff changeset
  4616
                    ('Google Spell'                googleSpellingSuggestion   )
9dd71df46f73 specialCharacters menu item
Claus Gittinger <cg@exept.de>
parents: 2857
diff changeset
  4617
                    ('Translate'                   babelFishTranslate         )
9dd71df46f73 specialCharacters menu item
Claus Gittinger <cg@exept.de>
parents: 2857
diff changeset
  4618
                    ('-'                                                      )
2870
994a3a44c526 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  4619
                    ('Special Characters...'       specialCharacters          )
994a3a44c526 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  4620
                    ('-'                                                      )
2866
9dd71df46f73 specialCharacters menu item
Claus Gittinger <cg@exept.de>
parents: 2857
diff changeset
  4621
                    ('Open FileBrowser on It'      openFileBrowserOnIt        )  
2762
e29673db4ddb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2757
diff changeset
  4622
              ).
e29673db4ddb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2757
diff changeset
  4623
2460
Claus Gittinger <cg@exept.de>
parents: 2438
diff changeset
  4624
    sub := PopUpMenu itemList:items resources:resources performer:model.
2461
54d220735048 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2460
diff changeset
  4625
    sub receiver:self.
2460
Claus Gittinger <cg@exept.de>
parents: 2438
diff changeset
  4626
2919
Claus Gittinger <cg@exept.de>
parents: 2916
diff changeset
  4627
    toolSub := PopUpMenu itemList:toolItems resources:resources performer:model.
Claus Gittinger <cg@exept.de>
parents: 2916
diff changeset
  4628
    toolSub receiver:self.
Claus Gittinger <cg@exept.de>
parents: 2916
diff changeset
  4629
    sub subMenuAt:#tools put:toolSub.
Claus Gittinger <cg@exept.de>
parents: 2916
diff changeset
  4630
2680
208d99c47d7c babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents: 2677
diff changeset
  4631
    subSub := PopUpMenu itemList:translateItems resources:resources performer:model.
208d99c47d7c babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents: 2677
diff changeset
  4632
    subSub receiver:self.
2919
Claus Gittinger <cg@exept.de>
parents: 2916
diff changeset
  4633
    toolSub subMenuAt:#babelFishTranslate put:subSub.
2762
e29673db4ddb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2757
diff changeset
  4634
2866
9dd71df46f73 specialCharacters menu item
Claus Gittinger <cg@exept.de>
parents: 2857
diff changeset
  4635
    subSub := PopUpMenu itemList:miscItems resources:resources performer:model.
9dd71df46f73 specialCharacters menu item
Claus Gittinger <cg@exept.de>
parents: 2857
diff changeset
  4636
    subSub receiver:self.
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4637
    subSub checkToggleAt:#autoIndent: put:autoIndent.
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4638
    subSub checkToggleAt:#insertMode: put:(self insertModeHolder value).
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4639
    subSub checkToggleAt:#learnMode: put:(self learnModeHolder value).
2866
9dd71df46f73 specialCharacters menu item
Claus Gittinger <cg@exept.de>
parents: 2857
diff changeset
  4640
    sub subMenuAt:#misc put:subSub.
9dd71df46f73 specialCharacters menu item
Claus Gittinger <cg@exept.de>
parents: 2857
diff changeset
  4641
2730
61a2f1981ac6 Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents: 2725
diff changeset
  4642
    self sensor ctrlDown ifTrue:[
2460
Claus Gittinger <cg@exept.de>
parents: 2438
diff changeset
  4643
        m := sub
428
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  4644
    ] ifFalse:[
2017
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4645
        items := #(
2979
a15f8b2fbf90 undo key in menu
Claus Gittinger <cg@exept.de>
parents: 2978
diff changeset
  4646
                        ('Undo'    undo             Undo   )
2403
c24da3c0a57b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2385
diff changeset
  4647
                        ('Again'   again            Again  )
2017
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4648
                        ('-'                               )
2688
e32c9f26c9e4 editMenu: order is cut-copy-paste (as in windows)
Claus Gittinger <cg@exept.de>
parents: 2682
diff changeset
  4649
                        ('Cut'     cut              Cut    )
2403
c24da3c0a57b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2385
diff changeset
  4650
                        ('Copy'    copySelection    Copy   )
c24da3c0a57b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2385
diff changeset
  4651
                        ('Paste'   pasteOrReplace   Paste  )
2017
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4652
                        ('-'                               )
2403
c24da3c0a57b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2385
diff changeset
  4653
                        ('Accept'  accept           Accept )
2017
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4654
                        ('='                               )
2919
Claus Gittinger <cg@exept.de>
parents: 2916
diff changeset
  4655
                        ('More'    others           Ctrl   )
2017
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4656
                  ).
2460
Claus Gittinger <cg@exept.de>
parents: 2438
diff changeset
  4657
        m := PopUpMenu itemList:items resources:resources.
Claus Gittinger <cg@exept.de>
parents: 2438
diff changeset
  4658
Claus Gittinger <cg@exept.de>
parents: 2438
diff changeset
  4659
        m subMenuAt:#others put:sub.
428
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  4660
    ].
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  4661
2676
cc61fa88a3fb google spelling;
Claus Gittinger <cg@exept.de>
parents: 2660
diff changeset
  4662
    SOAP::GoogleClient isNil ifTrue:[
cc61fa88a3fb google spelling;
Claus Gittinger <cg@exept.de>
parents: 2660
diff changeset
  4663
        "/ GoogleClient new spellingSuggestionOf: 'Smmalltlaak and Soaap'.
cc61fa88a3fb google spelling;
Claus Gittinger <cg@exept.de>
parents: 2660
diff changeset
  4664
        m disable:#googleSpellingSuggestion
cc61fa88a3fb google spelling;
Claus Gittinger <cg@exept.de>
parents: 2660
diff changeset
  4665
    ].
cc61fa88a3fb google spelling;
Claus Gittinger <cg@exept.de>
parents: 2660
diff changeset
  4666
1733
c5139b7402f0 use self isReadonly; readOnly may now be a valueHolder.
Claus Gittinger <cg@exept.de>
parents: 1732
diff changeset
  4667
    self isReadOnly ifTrue:[
2823
d1dea3c01332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2822
diff changeset
  4668
        m disableAll:#(paste pasteOrReplace cut indent autoIndent: insertMode: 
d1dea3c01332 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2822
diff changeset
  4669
                       insertFile babelFishTranslate googleSpellingSuggestion)
428
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  4670
    ].
2817
7c82a9535b96 not ifTrue -> ifFalse
Claus Gittinger <cg@exept.de>
parents: 2815
diff changeset
  4671
    self hasSelectionForCopy ifFalse:[
2017
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4672
        m disable:#copySelection.
428
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  4673
    ].
2416
56acdd9e31b5 lifted mkeyboardMacro handling from Workspace to EditTextView
Claus Gittinger <cg@exept.de>
parents: 2406
diff changeset
  4674
    self hasSelection ifFalse:[
2762
e29673db4ddb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2757
diff changeset
  4675
        m disableAll:#(cut googleSpellingSuggestion babelFishTranslate openFileBrowserOnIt).
e29673db4ddb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2757
diff changeset
  4676
    ] ifTrue:[
2879
727a8664a834 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2870
diff changeset
  4677
        (Error handle:[:ex |
727a8664a834 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2870
diff changeset
  4678
            ex return:false
727a8664a834 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2870
diff changeset
  4679
        ] do:[
727a8664a834 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2870
diff changeset
  4680
            self selectionAsString asSingleByteString asFilename exists
727a8664a834 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2870
diff changeset
  4681
        ]) ifFalse:[
2762
e29673db4ddb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2757
diff changeset
  4682
            m disableAll:#(openFileBrowserOnIt).
e29673db4ddb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2757
diff changeset
  4683
        ]
428
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  4684
    ].
2569
b499c81c58ae added hasUndoAction query.
Claus Gittinger <cg@exept.de>
parents: 2560
diff changeset
  4685
    self hasUndoAction ifFalse:[
2017
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4686
        m disable:#undo.
3115
b75128334006 info string in undo
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
  4687
    ] ifTrue:[
b75128334006 info string in undo
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
  4688
        what := undoSupport undoActionInfo.
b75128334006 info string in undo
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
  4689
        what notNil ifTrue:[
b75128334006 info string in undo
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
  4690
            undoIdx := m indexOf:#undo.
b75128334006 info string in undo
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
  4691
            m labelAt:undoIdx put:(resources string:'Undo (%1)' with:what).
b75128334006 info string in undo
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
  4692
        ]
1818
aa16d9b96e40 fixed cut to not compress multiple blanks.
Claus Gittinger <cg@exept.de>
parents: 1817
diff changeset
  4693
    ].
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4694
    self hasRedoAction ifFalse:[
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4695
        m disable:#redo.
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4696
    ].
1108
3d14bb6bceb7 added disableAccept
Claus Gittinger <cg@exept.de>
parents: 1082
diff changeset
  4697
    acceptEnabled == false ifTrue:[
2017
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4698
        m disable:#accept
1108
3d14bb6bceb7 added disableAccept
Claus Gittinger <cg@exept.de>
parents: 1082
diff changeset
  4699
    ].
428
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  4700
    ^ m.
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  4701
2461
54d220735048 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2460
diff changeset
  4702
    "Modified: / 13.11.2001 / 10:39:16 / cg"
428
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  4703
!
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  4704
2544
48ab4ed67816 shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  4705
getTextSelectionFromHistory
48ab4ed67816 shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  4706
    |sel list box history|
48ab4ed67816 shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  4707
48ab4ed67816 shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  4708
    history := device getCopyBufferHistory copy.
3038
acfc94ec4309 Fix #getTextSelectionFromHistory
Stefan Vogel <sv@exept.de>
parents: 3027
diff changeset
  4709
    list := history collect:[:entry | 
acfc94ec4309 Fix #getTextSelectionFromHistory
Stefan Vogel <sv@exept.de>
parents: 3027
diff changeset
  4710
                entry asString string asCollectionOfLines 
acfc94ec4309 Fix #getTextSelectionFromHistory
Stefan Vogel <sv@exept.de>
parents: 3027
diff changeset
  4711
                    detect:[:line| line notEmptyOrNil] 
acfc94ec4309 Fix #getTextSelectionFromHistory
Stefan Vogel <sv@exept.de>
parents: 3027
diff changeset
  4712
                    ifNone:['      ']
acfc94ec4309 Fix #getTextSelectionFromHistory
Stefan Vogel <sv@exept.de>
parents: 3027
diff changeset
  4713
            ].
2544
48ab4ed67816 shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  4714
    box := ListSelectionBox
48ab4ed67816 shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  4715
                title:'CopyBuffer History' 
48ab4ed67816 shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  4716
                okText:'Paste'
48ab4ed67816 shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  4717
                abortText:'Cancel'
48ab4ed67816 shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  4718
                list:list 
2730
61a2f1981ac6 Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents: 2725
diff changeset
  4719
                action:[:idx | idx notNil ifTrue:[sel := history at:idx]].
2544
48ab4ed67816 shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  4720
    box useIndex:true.
48ab4ed67816 shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  4721
    box show.
2730
61a2f1981ac6 Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents: 2725
diff changeset
  4722
    ^ sel.                                 
2544
48ab4ed67816 shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  4723
!
48ab4ed67816 shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  4724
48ab4ed67816 shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  4725
getTextSelectionOrTextSelectionFromHistory
2730
61a2f1981ac6 Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents: 2725
diff changeset
  4726
61a2f1981ac6 Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents: 2725
diff changeset
  4727
    self sensor shiftDown ifTrue:[
2544
48ab4ed67816 shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  4728
        ^ self getTextSelectionFromHistory
48ab4ed67816 shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  4729
    ].
2724
23f4e16dc4f4 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2720
diff changeset
  4730
23f4e16dc4f4 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2720
diff changeset
  4731
    "/ return either the (xterm-) selection or the clipBoard
23f4e16dc4f4 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2720
diff changeset
  4732
    ^ self 
3044
f8419843f748 get selection interface changed
ca
parents: 3043
diff changeset
  4733
        getClipboardText:(self sensor ctrlDown 
2724
23f4e16dc4f4 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2720
diff changeset
  4734
                            ifTrue:#selection
23f4e16dc4f4 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2720
diff changeset
  4735
                            ifFalse:#clipboard)
2544
48ab4ed67816 shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  4736
!
48ab4ed67816 shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  4737
2676
cc61fa88a3fb google spelling;
Claus Gittinger <cg@exept.de>
parents: 2660
diff changeset
  4738
googleSpellingSuggestion
cc61fa88a3fb google spelling;
Claus Gittinger <cg@exept.de>
parents: 2660
diff changeset
  4739
    "insert the google-spelling suggestion for the selected text.
cc61fa88a3fb google spelling;
Claus Gittinger <cg@exept.de>
parents: 2660
diff changeset
  4740
     Requires that the SOAP stuff is loaded and working."
cc61fa88a3fb google spelling;
Claus Gittinger <cg@exept.de>
parents: 2660
diff changeset
  4741
2677
afb234f8b822 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2676
diff changeset
  4742
    |text suggestion|
2676
cc61fa88a3fb google spelling;
Claus Gittinger <cg@exept.de>
parents: 2660
diff changeset
  4743
cc61fa88a3fb google spelling;
Claus Gittinger <cg@exept.de>
parents: 2660
diff changeset
  4744
    self withWaitCursorDo:[
2677
afb234f8b822 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2676
diff changeset
  4745
        text := self selection asString string withoutSeparators.
afb234f8b822 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2676
diff changeset
  4746
        text size == 0 ifTrue:[^ self].
afb234f8b822 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2676
diff changeset
  4747
2680
208d99c47d7c babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents: 2677
diff changeset
  4748
        SOAP::SoapImplError handle:[:ex |
2682
1b5aeb99f26a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2681
diff changeset
  4749
            Dialog warn:('Spelling correction failed - WEB Service error:\\%1.' bindWith:ex description allBold) withCRs.
2680
208d99c47d7c babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents: 2677
diff changeset
  4750
            ^ self.
208d99c47d7c babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents: 2677
diff changeset
  4751
        ] do:[
208d99c47d7c babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents: 2677
diff changeset
  4752
            suggestion := SOAP::GoogleClient new spellingSuggestionOf:text.
208d99c47d7c babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents: 2677
diff changeset
  4753
        ].
2677
afb234f8b822 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2676
diff changeset
  4754
        suggestion size == 0 ifTrue:[
afb234f8b822 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2676
diff changeset
  4755
            Transcript showCR:'No SpellingSuggestion from Google for: ' , text.
afb234f8b822 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2676
diff changeset
  4756
            ^ self.
afb234f8b822 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2676
diff changeset
  4757
        ].
2676
cc61fa88a3fb google spelling;
Claus Gittinger <cg@exept.de>
parents: 2660
diff changeset
  4758
    ].
2989
5dcc2912bcb6 undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents: 2984
diff changeset
  4759
    self undoablePaste:suggestion.
2676
cc61fa88a3fb google spelling;
Claus Gittinger <cg@exept.de>
parents: 2660
diff changeset
  4760
!
cc61fa88a3fb google spelling;
Claus Gittinger <cg@exept.de>
parents: 2660
diff changeset
  4761
cc61fa88a3fb google spelling;
Claus Gittinger <cg@exept.de>
parents: 2660
diff changeset
  4762
insertFile
cc61fa88a3fb google spelling;
Claus Gittinger <cg@exept.de>
parents: 2660
diff changeset
  4763
    "insert contents of a file 
cc61fa88a3fb google spelling;
Claus Gittinger <cg@exept.de>
parents: 2660
diff changeset
  4764
     - ask user for filename using a fileSelectionBox."
cc61fa88a3fb google spelling;
Claus Gittinger <cg@exept.de>
parents: 2660
diff changeset
  4765
2909
a43e1343718f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2901
diff changeset
  4766
    |file text ok|
2757
b98097eaf8dc Stc cannot handle thisContext restart in true-Block.
Stefan Vogel <sv@exept.de>
parents: 2756
diff changeset
  4767
b98097eaf8dc Stc cannot handle thisContext restart in true-Block.
Stefan Vogel <sv@exept.de>
parents: 2756
diff changeset
  4768
    [
2909
a43e1343718f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2901
diff changeset
  4769
        |why|
a43e1343718f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2901
diff changeset
  4770
2757
b98097eaf8dc Stc cannot handle thisContext restart in true-Block.
Stefan Vogel <sv@exept.de>
parents: 2756
diff changeset
  4771
        file := Dialog 
b98097eaf8dc Stc cannot handle thisContext restart in true-Block.
Stefan Vogel <sv@exept.de>
parents: 2756
diff changeset
  4772
            requestFileName:(resources string:'Insert contents of:') 
b98097eaf8dc Stc cannot handle thisContext restart in true-Block.
Stefan Vogel <sv@exept.de>
parents: 2756
diff changeset
  4773
            default:nil
b98097eaf8dc Stc cannot handle thisContext restart in true-Block.
Stefan Vogel <sv@exept.de>
parents: 2756
diff changeset
  4774
            ok:(resources string:'Insert') 
b98097eaf8dc Stc cannot handle thisContext restart in true-Block.
Stefan Vogel <sv@exept.de>
parents: 2756
diff changeset
  4775
            abort:(resources string:'Cancel') 
b98097eaf8dc Stc cannot handle thisContext restart in true-Block.
Stefan Vogel <sv@exept.de>
parents: 2756
diff changeset
  4776
            pattern:nil
b98097eaf8dc Stc cannot handle thisContext restart in true-Block.
Stefan Vogel <sv@exept.de>
parents: 2756
diff changeset
  4777
            fromDirectory:directoryForFileDialog.
b98097eaf8dc Stc cannot handle thisContext restart in true-Block.
Stefan Vogel <sv@exept.de>
parents: 2756
diff changeset
  4778
        file isNil ifTrue:[
b98097eaf8dc Stc cannot handle thisContext restart in true-Block.
Stefan Vogel <sv@exept.de>
parents: 2756
diff changeset
  4779
            "cancel"
b98097eaf8dc Stc cannot handle thisContext restart in true-Block.
Stefan Vogel <sv@exept.de>
parents: 2756
diff changeset
  4780
            ^ self.
b98097eaf8dc Stc cannot handle thisContext restart in true-Block.
Stefan Vogel <sv@exept.de>
parents: 2756
diff changeset
  4781
        ].
b98097eaf8dc Stc cannot handle thisContext restart in true-Block.
Stefan Vogel <sv@exept.de>
parents: 2756
diff changeset
  4782
        file := file asFilename.
b98097eaf8dc Stc cannot handle thisContext restart in true-Block.
Stefan Vogel <sv@exept.de>
parents: 2756
diff changeset
  4783
        directoryForFileDialog := file.
2909
a43e1343718f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2901
diff changeset
  4784
a43e1343718f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2901
diff changeset
  4785
        ok := file isReadable and:[file isDirectory not].
a43e1343718f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2901
diff changeset
  4786
        ok ifFalse:[
a43e1343718f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2901
diff changeset
  4787
            file isReadable ifFalse:[
a43e1343718f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2901
diff changeset
  4788
                why := '%1 is unreadable.\\Please try again.'
a43e1343718f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2901
diff changeset
  4789
            ] ifTrue:[
a43e1343718f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2901
diff changeset
  4790
                why := '%1 is a directory.\\Please try again.'
a43e1343718f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2901
diff changeset
  4791
            ].
a43e1343718f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2901
diff changeset
  4792
            Dialog warn:((resources string:why) withCRs bindWith:file pathName).
a43e1343718f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2901
diff changeset
  4793
        ].
a43e1343718f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2901
diff changeset
  4794
    ] doUntil:[ok].
2757
b98097eaf8dc Stc cannot handle thisContext restart in true-Block.
Stefan Vogel <sv@exept.de>
parents: 2756
diff changeset
  4795
b98097eaf8dc Stc cannot handle thisContext restart in true-Block.
Stefan Vogel <sv@exept.de>
parents: 2756
diff changeset
  4796
    text := file contentsOfEntireFile.
2989
5dcc2912bcb6 undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents: 2984
diff changeset
  4797
    self undoablePaste:text.
2676
cc61fa88a3fb google spelling;
Claus Gittinger <cg@exept.de>
parents: 2660
diff changeset
  4798
!
cc61fa88a3fb google spelling;
Claus Gittinger <cg@exept.de>
parents: 2660
diff changeset
  4799
2762
e29673db4ddb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2757
diff changeset
  4800
openFileBrowserOnIt
e29673db4ddb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2757
diff changeset
  4801
    "open a fileBrowser on the selected fileName"
e29673db4ddb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2757
diff changeset
  4802
e29673db4ddb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2757
diff changeset
  4803
    |fn dir|
e29673db4ddb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2757
diff changeset
  4804
e29673db4ddb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2757
diff changeset
  4805
    fn := self selectionAsString asFilename.
e29673db4ddb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2757
diff changeset
  4806
    fn exists ifFalse:[
e29673db4ddb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2757
diff changeset
  4807
        ^ self warn:'Oops - file is gone'.
e29673db4ddb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2757
diff changeset
  4808
    ].
e29673db4ddb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2757
diff changeset
  4809
    (dir := fn) isDirectory ifFalse:[
e29673db4ddb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2757
diff changeset
  4810
        dir := fn directory
e29673db4ddb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2757
diff changeset
  4811
    ].
e29673db4ddb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2757
diff changeset
  4812
    UserPreferences fileBrowserClass openOn:dir
e29673db4ddb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2757
diff changeset
  4813
!
e29673db4ddb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2757
diff changeset
  4814
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4815
paste
1289
e2dcc5fe612c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1287
diff changeset
  4816
    "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
  4817
     Then paste at cursor position."
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4818
2989
5dcc2912bcb6 undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents: 2984
diff changeset
  4819
    self checkModificationsAllowed ifTrue:[
5dcc2912bcb6 undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents: 2984
diff changeset
  4820
        self withSelfAndTextForPasteDo:[:me :text | 
5dcc2912bcb6 undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents: 2984
diff changeset
  4821
            me unselect. 
5dcc2912bcb6 undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents: 2984
diff changeset
  4822
            me undoablePaste:text
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4823
        ]
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4824
    ]
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4825
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4826
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4827
paste:someText
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4828
    "paste someText at cursor"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4829
2856
bc6bb86d4d2e character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents: 2854
diff changeset
  4830
    |s nLines startLine startCol l1 l2 c1 c2 codingErrorReported|
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4831
1480
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  4832
    self checkModificationsAllowed ifFalse:[^ self].
2853
f8c1d3963b49 preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents: 2846
diff changeset
  4833
    someText isNil ifTrue:[^ self].
f8c1d3963b49 preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents: 2846
diff changeset
  4834
f8c1d3963b49 preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents: 2846
diff changeset
  4835
    s := someText.
2856
bc6bb86d4d2e character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents: 2854
diff changeset
  4836
    codingErrorReported := false.
bc6bb86d4d2e character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents: 2854
diff changeset
  4837
    CharacterEncoderError handle:[:ex |
2857
9e50a255069e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2856
diff changeset
  4838
        |code msg|
9e50a255069e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2856
diff changeset
  4839
9e50a255069e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2856
diff changeset
  4840
        code := ex parameter.
2856
bc6bb86d4d2e character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents: 2854
diff changeset
  4841
        codingErrorReported ifFalse:[
2857
9e50a255069e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2856
diff changeset
  4842
            msg := 'Cannot represent pasted string in this Views encoding (',characterEncoding,').'.
9e50a255069e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2856
diff changeset
  4843
            code notNil ifTrue:[
9e50a255069e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2856
diff changeset
  4844
                msg := msg , '\\Reason: No representation for ' , (code radixPrintStringRadix:16).
9e50a255069e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2856
diff changeset
  4845
            ].
9e50a255069e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2856
diff changeset
  4846
            Dialog warn:(resources string:msg) withCRs.
2856
bc6bb86d4d2e character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents: 2854
diff changeset
  4847
            codingErrorReported := true.
2853
f8c1d3963b49 preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents: 2846
diff changeset
  4848
        ].
2931
dcbb4ed67115 Use #codePoint instead of deprecated #asciiValue
Stefan Vogel <sv@exept.de>
parents: 2919
diff changeset
  4849
        ex proceedWith:($? codePoint)
2856
bc6bb86d4d2e character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents: 2854
diff changeset
  4850
    ] do:[
bc6bb86d4d2e character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents: 2854
diff changeset
  4851
        s isString ifTrue:[
bc6bb86d4d2e character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents: 2854
diff changeset
  4852
            s encoding ~~ characterEncoding ifTrue:[
bc6bb86d4d2e character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents: 2854
diff changeset
  4853
                s := s encodeFrom:(s encoding) into:characterEncoding.    
bc6bb86d4d2e character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents: 2854
diff changeset
  4854
            ].
bc6bb86d4d2e character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents: 2854
diff changeset
  4855
bc6bb86d4d2e character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents: 2854
diff changeset
  4856
            s := s asStringCollection.
bc6bb86d4d2e character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents: 2854
diff changeset
  4857
            (someText endsWith:Character cr) ifTrue:[    
2880
77a60674feb5 bugfix: paste string with ending newline
ca
parents: 2879
diff changeset
  4858
                "/ s := s copyWith:nil.
77a60674feb5 bugfix: paste string with ending newline
ca
parents: 2879
diff changeset
  4859
                s := s copyWith:'' "/ an empty line at the end
77a60674feb5 bugfix: paste string with ending newline
ca
parents: 2879
diff changeset
  4860
2856
bc6bb86d4d2e character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents: 2854
diff changeset
  4861
            ]            
bc6bb86d4d2e character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents: 2854
diff changeset
  4862
        ] ifFalse:[
3058
4d3b96f8ba11 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3046
diff changeset
  4863
            s isStringCollection ifTrue:[
4d3b96f8ba11 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3046
diff changeset
  4864
                s := s encodeFrom:(s encoding) into:characterEncoding.
4d3b96f8ba11 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3046
diff changeset
  4865
            ] ifFalse:[
4d3b96f8ba11 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3046
diff changeset
  4866
                (self 
4d3b96f8ba11 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3046
diff changeset
  4867
                    confirm:(resources 
4d3b96f8ba11 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3046
diff changeset
  4868
                        stringWithCRs:'Selection (%1) is not convertable to Text.\\Paste storeString ?'
4d3b96f8ba11 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3046
diff changeset
  4869
                        with:s class name)) ifFalse:[^ self].
4d3b96f8ba11 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3046
diff changeset
  4870
                s := StringCollection with:s storeString .
4d3b96f8ba11 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3046
diff changeset
  4871
                "/ ^ self
2856
bc6bb86d4d2e character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents: 2854
diff changeset
  4872
            ].
2017
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4873
        ].
2856
bc6bb86d4d2e character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents: 2854
diff changeset
  4874
    ].
bc6bb86d4d2e character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents: 2854
diff changeset
  4875
2853
f8c1d3963b49 preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents: 2846
diff changeset
  4876
    (nLines := s size) == 0 ifTrue:[^ self].
f8c1d3963b49 preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents: 2846
diff changeset
  4877
    (nLines == 1 and:[(s at:1) size == 0]) ifTrue:[^ self].
f8c1d3963b49 preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents: 2846
diff changeset
  4878
f8c1d3963b49 preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents: 2846
diff changeset
  4879
    typeOfSelection := #paste.
f8c1d3963b49 preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents: 2846
diff changeset
  4880
f8c1d3963b49 preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents: 2846
diff changeset
  4881
    startLine := l1 := cursorLine.
f8c1d3963b49 preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents: 2846
diff changeset
  4882
    startCol := c1 := cursorCol.
f8c1d3963b49 preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents: 2846
diff changeset
  4883
    self insertLines:(s withTabsExpanded) withCR:false.
f8c1d3963b49 preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents: 2846
diff changeset
  4884
    l2 := cursorLine.
f8c1d3963b49 preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents: 2846
diff changeset
  4885
    c2 := (cursorCol - 1).
f8c1d3963b49 preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents: 2846
diff changeset
  4886
    self selectFromLine:l1 col:c1 toLine:l2 col:c2.
f8c1d3963b49 preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents: 2846
diff changeset
  4887
    typeOfSelection := #paste. "/ sigh - cleared by #selectFromLine:
f8c1d3963b49 preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents: 2846
diff changeset
  4888
1480
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  4889
    "Modified: / 14.2.1996 / 11:14:14 / stefan"
2107
9d44232af0a0 textSelection fixes (added newLine) for MSDOS;
Claus Gittinger <cg@exept.de>
parents: 2101
diff changeset
  4890
    "Modified: / 30.1.2000 / 02:32:42 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4891
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4892
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4893
pasteOrReplace
1289
e2dcc5fe612c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1287
diff changeset
  4894
    "paste the copybuffer; if there is a selection, replace it.
2010
ca8dcc8723dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1993
diff changeset
  4895
     otherwise paste at cursor position. 
ca8dcc8723dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1993
diff changeset
  4896
     Replace is not done for selections which were created by a paste, 
ca8dcc8723dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1993
diff changeset
  4897
     to allow multiple paste operations in a row."
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4898
2724
23f4e16dc4f4 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2720
diff changeset
  4899
    self withSelfAndTextForPasteDo:[:me :text | me pasteOrReplace:text]
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4900
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4901
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4902
pasteOrReplace:someText
1289
e2dcc5fe612c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1287
diff changeset
  4903
    "paste someText; if there is a selection, replace it.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4904
     otherwise paste at cursor position. Replace is not done
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4905
     for originating by a paste, to allow multiple
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4906
     paste."
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4907
1480
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  4908
    self checkModificationsAllowed ifFalse:[^ self].
2989
5dcc2912bcb6 undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents: 2984
diff changeset
  4909
5dcc2912bcb6 undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents: 2984
diff changeset
  4910
    self undoableDo:[
5dcc2912bcb6 undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents: 2984
diff changeset
  4911
        ((self hasSelection == true) and:[typeOfSelection ~~ #paste]) ifTrue:[
5dcc2912bcb6 undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents: 2984
diff changeset
  4912
            self replace:someText
5dcc2912bcb6 undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents: 2984
diff changeset
  4913
        ] ifFalse:[
5dcc2912bcb6 undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents: 2984
diff changeset
  4914
            self paste:someText.
5dcc2912bcb6 undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents: 2984
diff changeset
  4915
        ]
5dcc2912bcb6 undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents: 2984
diff changeset
  4916
    ].
1289
e2dcc5fe612c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1287
diff changeset
  4917
2107
9d44232af0a0 textSelection fixes (added newLine) for MSDOS;
Claus Gittinger <cg@exept.de>
parents: 2101
diff changeset
  4918
    "Modified: / 30.1.2000 / 02:33:00 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4919
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4920
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4921
replace
1289
e2dcc5fe612c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1287
diff changeset
  4922
    "replace the selection by the contents of the copybuffer"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4923
2989
5dcc2912bcb6 undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents: 2984
diff changeset
  4924
    self checkModificationsAllowed ifTrue:[
5dcc2912bcb6 undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents: 2984
diff changeset
  4925
        self withSelfAndTextForPasteDo:[:me :text | 
5dcc2912bcb6 undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents: 2984
diff changeset
  4926
            me undoableDo:[
5dcc2912bcb6 undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents: 2984
diff changeset
  4927
                me replace:text
5dcc2912bcb6 undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents: 2984
diff changeset
  4928
            ]
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4929
        ]
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4930
    ]
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4931
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4932
121
claus
parents: 118
diff changeset
  4933
replace:someText
1289
e2dcc5fe612c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1287
diff changeset
  4934
    "replace the selection by someText"
121
claus
parents: 118
diff changeset
  4935
2017
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4936
    |selected selectedString 
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4937
     selStartLine selStartCol selEndLine selEndCol| 
121
claus
parents: 118
diff changeset
  4938
1480
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  4939
    self checkModificationsAllowed ifFalse:[^ self].
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  4940
121
claus
parents: 118
diff changeset
  4941
    selected := self selection.
claus
parents: 118
diff changeset
  4942
    selected isNil ifTrue:[
2017
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4943
        ^ self paste:someText
121
claus
parents: 118
diff changeset
  4944
    ].
2017
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4945
121
claus
parents: 118
diff changeset
  4946
    self deleteSelection.
claus
parents: 118
diff changeset
  4947
claus
parents: 118
diff changeset
  4948
    "take care, if we replace a selection without space by a word selected
claus
parents: 118
diff changeset
  4949
     with one - in this case we usually do not want the space.
claus
parents: 118
diff changeset
  4950
     But, if we replace a word-selected selection by something without a
claus
parents: 118
diff changeset
  4951
     space, we DO want the space added."
claus
parents: 118
diff changeset
  4952
claus
parents: 118
diff changeset
  4953
    selected size == 1 ifTrue:[
2017
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4954
        selectedString := selected at:1.
7
15a9291b9bd0 *** empty log message ***
claus
parents: 5
diff changeset
  4955
    ].
15a9291b9bd0 *** empty log message ***
claus
parents: 5
diff changeset
  4956
362
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  4957
    someText size == 1 ifTrue:[
2017
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4958
        |cutOffSpace addSpace replacement replacementString|
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4959
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4960
        cutOffSpace := false.
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4961
        addSpace := false.
2432
af5d3ff6204b be careful if replacing a symbol (which cannot be changed)
Claus Gittinger <cg@exept.de>
parents: 2429
diff changeset
  4962
        replacement := someText copyFrom:1.
2017
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4963
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4964
        selectedString notNil ifTrue:[
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4965
            ((selectedString startsWith:' ') or:[selectedString endsWith:' ']) ifFalse:[
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4966
               "selection has no space"
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4967
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4968
                ((selectStyle == #wordleft) or:[selectStyle == #wordRight]) ifTrue:[
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4969
                    cutOffSpace := true
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4970
                ]
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4971
            ] ifTrue:[
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4972
                addSpace := true
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4973
            ]
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4974
        ].
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4975
        replacementString := replacement at:1.
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4976
        cutOffSpace ifTrue:[
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4977
            (replacementString startsWith:' ') ifTrue:[
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4978
                replacementString := replacementString withoutSpaces
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4979
            ].
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4980
        ] ifFalse:[
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4981
            selectStyle == #wordLeft ifTrue:[
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4982
                "want a space at left"
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4983
                (replacementString startsWith:' ') ifFalse:[
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4984
                    replacementString := replacementString withoutSpaces.
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4985
                    replacementString := ' ' , replacementString
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4986
                ]
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4987
            ].
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4988
            selectStyle == #wordRight ifTrue:[
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4989
                "want a space at right"
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4990
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4991
                (replacementString endsWith:' ') ifFalse:[
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4992
                    replacementString := replacementString withoutSpaces.
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4993
                    replacementString := replacementString , ' '
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4994
                ]
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4995
            ].
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4996
        ].
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4997
        replacement at:1 put: replacementString.
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4998
        self paste:replacement.
121
claus
parents: 118
diff changeset
  4999
    ] ifFalse:[
2017
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  5000
        self paste:someText
7
15a9291b9bd0 *** empty log message ***
claus
parents: 5
diff changeset
  5001
    ].
121
claus
parents: 118
diff changeset
  5002
    lastString := selectedString.
2017
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  5003
    lastReplacement := someText.
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  5004
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  5005
    selStartLine := selectionStartLine.
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  5006
    selStartCol := self selectionStartCol.
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  5007
    selEndLine := selectionEndLine.
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  5008
    selEndCol := self selectionEndCol.
362
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  5009
1480
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  5010
    "Modified: / 14.2.1996 / 10:37:02 / stefan"
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  5011
    "Modified: / 5.4.1998 / 16:55:28 / cg"
121
claus
parents: 118
diff changeset
  5012
!
claus
parents: 118
diff changeset
  5013
claus
parents: 118
diff changeset
  5014
showDeleted
claus
parents: 118
diff changeset
  5015
    "open a readonly editor on all deleted text"
claus
parents: 118
diff changeset
  5016
claus
parents: 118
diff changeset
  5017
    |v|
claus
parents: 118
diff changeset
  5018
claus
parents: 118
diff changeset
  5019
    v := EditTextView openWith:(Smalltalk at:#DeleteHistory).
1733
c5139b7402f0 use self isReadonly; readOnly may now be a valueHolder.
Claus Gittinger <cg@exept.de>
parents: 1732
diff changeset
  5020
    v readOnly:true.
121
claus
parents: 118
diff changeset
  5021
    v topView label:'deleted text'.
2624
22d352e56c27 preps for special characters
Claus Gittinger <cg@exept.de>
parents: 2617
diff changeset
  5022
!
22d352e56c27 preps for special characters
Claus Gittinger <cg@exept.de>
parents: 2617
diff changeset
  5023
22d352e56c27 preps for special characters
Claus Gittinger <cg@exept.de>
parents: 2617
diff changeset
  5024
specialCharacters
2915
8db67a5d1ccb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2912
diff changeset
  5025
    CharacterSetView
8db67a5d1ccb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2912
diff changeset
  5026
        openAsInputFor:self
8db67a5d1ccb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2912
diff changeset
  5027
        label:'Special Character Input' 
8db67a5d1ccb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2912
diff changeset
  5028
        clickLabel:'Click to Insert Character'.
2866
9dd71df46f73 specialCharacters menu item
Claus Gittinger <cg@exept.de>
parents: 2857
diff changeset
  5029
!
9dd71df46f73 specialCharacters menu item
Claus Gittinger <cg@exept.de>
parents: 2857
diff changeset
  5030
2989
5dcc2912bcb6 undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents: 2984
diff changeset
  5031
undoablePaste:someText
5dcc2912bcb6 undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents: 2984
diff changeset
  5032
    self undoableDo:[
5dcc2912bcb6 undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents: 2984
diff changeset
  5033
        self paste:someText.
5dcc2912bcb6 undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents: 2984
diff changeset
  5034
    ].
5dcc2912bcb6 undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents: 2984
diff changeset
  5035
!
5dcc2912bcb6 undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents: 2984
diff changeset
  5036
2724
23f4e16dc4f4 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2720
diff changeset
  5037
withSelfAndTextForPasteDo:aBlock
23f4e16dc4f4 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2720
diff changeset
  5038
    "common code for paste/replace of the copybuffer"
23f4e16dc4f4 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2720
diff changeset
  5039
23f4e16dc4f4 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2720
diff changeset
  5040
    |sel|
23f4e16dc4f4 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2720
diff changeset
  5041
23f4e16dc4f4 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2720
diff changeset
  5042
    self checkModificationsAllowed ifFalse:[
23f4e16dc4f4 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2720
diff changeset
  5043
        self flash.
23f4e16dc4f4 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2720
diff changeset
  5044
        ^ self
23f4e16dc4f4 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2720
diff changeset
  5045
    ].
23f4e16dc4f4 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2720
diff changeset
  5046
23f4e16dc4f4 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2720
diff changeset
  5047
    sel := self getTextSelectionOrTextSelectionFromHistory.
23f4e16dc4f4 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2720
diff changeset
  5048
    sel notNil ifTrue:[
23f4e16dc4f4 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2720
diff changeset
  5049
        aBlock value:self value:sel.
23f4e16dc4f4 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2720
diff changeset
  5050
    ]
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  5051
! !
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  5052
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5053
!EditTextView methodsFor:'private'!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5054
331
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
  5055
checkModificationsAllowed
1300
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  5056
    "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
  5057
     evaluate the exceptionBlock if not.
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  5058
     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
  5059
     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
  5060
1733
c5139b7402f0 use self isReadonly; readOnly may now be a valueHolder.
Claus Gittinger <cg@exept.de>
parents: 1732
diff changeset
  5061
    self isReadOnly ifTrue: [
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  5062
        exceptionBlock isNil ifTrue:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  5063
            ^ false
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  5064
        ].
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  5065
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  5066
        (exceptionBlock value:'Text may not be modified') ~~ true ifTrue:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  5067
            ^ false
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  5068
        ]
331
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
  5069
    ].
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
  5070
    ^ true
1300
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  5071
1577
4e487247ad33 dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents: 1568
diff changeset
  5072
    "Modified: / 17.6.1998 / 15:51:10 / cg"
331
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
  5073
!
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
  5074
2596
933689d5bd9c alternative selection color
Claus Gittinger <cg@exept.de>
parents: 2589
diff changeset
  5075
currentSelectionBgColor
933689d5bd9c alternative selection color
Claus Gittinger <cg@exept.de>
parents: 2589
diff changeset
  5076
    typeOfSelection == #paste ifTrue:[
933689d5bd9c alternative selection color
Claus Gittinger <cg@exept.de>
parents: 2589
diff changeset
  5077
        ^ DefaultAlternativeSelectionBackgroundColor ? selectionBgColor
933689d5bd9c alternative selection color
Claus Gittinger <cg@exept.de>
parents: 2589
diff changeset
  5078
    ].
933689d5bd9c alternative selection color
Claus Gittinger <cg@exept.de>
parents: 2589
diff changeset
  5079
    ^ super currentSelectionBgColor
933689d5bd9c alternative selection color
Claus Gittinger <cg@exept.de>
parents: 2589
diff changeset
  5080
933689d5bd9c alternative selection color
Claus Gittinger <cg@exept.de>
parents: 2589
diff changeset
  5081
    "
933689d5bd9c alternative selection color
Claus Gittinger <cg@exept.de>
parents: 2589
diff changeset
  5082
     DefaultAlternativeSelectionBackgroundColor := Color yellow blendWith:Color green
933689d5bd9c alternative selection color
Claus Gittinger <cg@exept.de>
parents: 2589
diff changeset
  5083
    "
933689d5bd9c alternative selection color
Claus Gittinger <cg@exept.de>
parents: 2589
diff changeset
  5084
!
933689d5bd9c alternative selection color
Claus Gittinger <cg@exept.de>
parents: 2589
diff changeset
  5085
933689d5bd9c alternative selection color
Claus Gittinger <cg@exept.de>
parents: 2589
diff changeset
  5086
currentSelectionFgColor
933689d5bd9c alternative selection color
Claus Gittinger <cg@exept.de>
parents: 2589
diff changeset
  5087
    typeOfSelection == #paste ifTrue:[
933689d5bd9c alternative selection color
Claus Gittinger <cg@exept.de>
parents: 2589
diff changeset
  5088
        ^ DefaultAlternativeSelectionForegroundColor ? selectionFgColor
933689d5bd9c alternative selection color
Claus Gittinger <cg@exept.de>
parents: 2589
diff changeset
  5089
    ].
933689d5bd9c alternative selection color
Claus Gittinger <cg@exept.de>
parents: 2589
diff changeset
  5090
    ^ super currentSelectionFgColor
933689d5bd9c alternative selection color
Claus Gittinger <cg@exept.de>
parents: 2589
diff changeset
  5091
!
933689d5bd9c alternative selection color
Claus Gittinger <cg@exept.de>
parents: 2589
diff changeset
  5092
2647
23dca8f032c3 changed st80Mode from classVar to userPreferences value
Claus Gittinger <cg@exept.de>
parents: 2627
diff changeset
  5093
st80EditMode
23dca8f032c3 changed st80Mode from classVar to userPreferences value
Claus Gittinger <cg@exept.de>
parents: 2627
diff changeset
  5094
    ^ st80Mode ? (UserPreferences current st80EditMode)
23dca8f032c3 changed st80Mode from classVar to userPreferences value
Claus Gittinger <cg@exept.de>
parents: 2627
diff changeset
  5095
!
23dca8f032c3 changed st80Mode from classVar to userPreferences value
Claus Gittinger <cg@exept.de>
parents: 2627
diff changeset
  5096
2225
65ac7cbffc60 added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents: 2213
diff changeset
  5097
suppressEmphasisInSelection
65ac7cbffc60 added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents: 2213
diff changeset
  5098
    "selection is shown without emphasis"
65ac7cbffc60 added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents: 2213
diff changeset
  5099
65ac7cbffc60 added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents: 2213
diff changeset
  5100
    ^ true
65ac7cbffc60 added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents: 2213
diff changeset
  5101
!
65ac7cbffc60 added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents: 2213
diff changeset
  5102
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5103
textChanged
522
aa9458e4643e indent/undent did not trigger a modify
ca
parents: 503
diff changeset
  5104
    "my text was modified (internally).
aa9458e4643e indent/undent did not trigger a modify
ca
parents: 503
diff changeset
  5105
     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
  5106
     contentsChanged, which is triggered when the size has changed, and
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5107
     is used to notify scrollers, other views etc.)"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5108
641
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  5109
    self contentsChanged.
1015
caf7265128b9 clear modified on accept.
Claus Gittinger <cg@exept.de>
parents: 1013
diff changeset
  5110
    self modified:true.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5111
    contentsWasSaved := false
641
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  5112
1015
caf7265128b9 clear modified on accept.
Claus Gittinger <cg@exept.de>
parents: 1013
diff changeset
  5113
    "Modified: 14.2.1997 / 16:58:38 / cg"
2207
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  5114
!
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  5115
2617
a9b1af787406 typo on method name
Claus Gittinger <cg@exept.de>
parents: 2606
diff changeset
  5116
textChangedButNoSizeChange
2207
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  5117
    "my text was modified (internally).
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  5118
     Sent whenever text has been edited (not to confuse with
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  5119
     contentsChanged, which is triggered when the size has changed, and
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  5120
     is used to notify scrollers, other views etc.)"
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  5121
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  5122
    self modified:true.
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  5123
    contentsWasSaved := false
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  5124
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  5125
    "Modified: 14.2.1997 / 16:58:38 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5126
! !
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5127
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5128
!EditTextView methodsFor:'queries'!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5129
1526
7676f301bb8f added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents: 1515
diff changeset
  5130
currentLine
7676f301bb8f added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents: 1515
diff changeset
  5131
    "the current line (for relative gotos)"
7676f301bb8f added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents: 1515
diff changeset
  5132
7676f301bb8f added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents: 1515
diff changeset
  5133
    ^ cursorLine
7676f301bb8f added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents: 1515
diff changeset
  5134
7676f301bb8f added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents: 1515
diff changeset
  5135
    "Created: / 17.5.1998 / 20:07:52 / cg"
7676f301bb8f added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents: 1515
diff changeset
  5136
!
7676f301bb8f added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents: 1515
diff changeset
  5137
1878
d93809bda6c8 added #isKeyboardConsumer
Claus Gittinger <cg@exept.de>
parents: 1850
diff changeset
  5138
isKeyboardConsumer
d93809bda6c8 added #isKeyboardConsumer
Claus Gittinger <cg@exept.de>
parents: 1850
diff changeset
  5139
    "return true, if the receiver is a keyboard consumer;
d93809bda6c8 added #isKeyboardConsumer
Claus Gittinger <cg@exept.de>
parents: 1850
diff changeset
  5140
     Return true here, redefined from SimpleView."
d93809bda6c8 added #isKeyboardConsumer
Claus Gittinger <cg@exept.de>
parents: 1850
diff changeset
  5141
d93809bda6c8 added #isKeyboardConsumer
Claus Gittinger <cg@exept.de>
parents: 1850
diff changeset
  5142
    ^ true
d93809bda6c8 added #isKeyboardConsumer
Claus Gittinger <cg@exept.de>
parents: 1850
diff changeset
  5143
d93809bda6c8 added #isKeyboardConsumer
Claus Gittinger <cg@exept.de>
parents: 1850
diff changeset
  5144
!
d93809bda6c8 added #isKeyboardConsumer
Claus Gittinger <cg@exept.de>
parents: 1850
diff changeset
  5145
997
615a5a19c5bf specClass
ca
parents: 991
diff changeset
  5146
specClass
1390
99674e1d9c85 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
  5147
    "redefined, since the name of my specClass is nonStandard (i.e. not EditTextSpec)"
99674e1d9c85 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
  5148
997
615a5a19c5bf specClass
ca
parents: 991
diff changeset
  5149
    self class == EditTextView ifTrue:[^ TextEditorSpec].
1049
24360c8891d6 specClass query
Claus Gittinger <cg@exept.de>
parents: 1037
diff changeset
  5150
    ^ super specClass
24360c8891d6 specClass query
Claus Gittinger <cg@exept.de>
parents: 1037
diff changeset
  5151
1390
99674e1d9c85 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
  5152
    "Modified: / 31.10.1997 / 19:48:19 / cg"
997
615a5a19c5bf specClass
ca
parents: 991
diff changeset
  5153
!
615a5a19c5bf specClass
ca
parents: 991
diff changeset
  5154
324
9eec6d69e155 better Tab key handling
Claus Gittinger <cg@exept.de>
parents: 323
diff changeset
  5155
tabMeansNextField
323
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
  5156
    "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
  5157
313
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  5158
    "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
  5159
1733
c5139b7402f0 use self isReadonly; readOnly may now be a valueHolder.
Claus Gittinger <cg@exept.de>
parents: 1732
diff changeset
  5160
    ^ self isReadOnly or:[tabMeansNextField]
324
9eec6d69e155 better Tab key handling
Claus Gittinger <cg@exept.de>
parents: 323
diff changeset
  5161
9eec6d69e155 better Tab key handling
Claus Gittinger <cg@exept.de>
parents: 323
diff changeset
  5162
    "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
  5163
!
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  5164
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5165
widthOfContents
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5166
    "return the width of the contents in pixels
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5167
     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
  5168
     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
  5169
     line (and possibly see the cursor behind the line)"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5170
697
0f258f02e8ea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 693
diff changeset
  5171
    |w dev|
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5172
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5173
    w := super widthOfContents.
697
0f258f02e8ea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 693
diff changeset
  5174
    (dev := device) isNil ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  5175
        "/ really dont know ...
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  5176
        dev := Screen current
606
682579fa3b62 fixed #widthOfContents if no device is known
Claus Gittinger <cg@exept.de>
parents: 597
diff changeset
  5177
    ].
697
0f258f02e8ea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 693
diff changeset
  5178
    ^ w + (font widthOn:dev)
0f258f02e8ea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 693
diff changeset
  5179
0f258f02e8ea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 693
diff changeset
  5180
    "Modified: 28.5.1996 / 19:32:25 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5181
! !
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5182
1588
e2e4ceeed3da category change
Claus Gittinger <cg@exept.de>
parents: 1585
diff changeset
  5183
!EditTextView methodsFor:'realization'!
e2e4ceeed3da category change
Claus Gittinger <cg@exept.de>
parents: 1585
diff changeset
  5184
e2e4ceeed3da category change
Claus Gittinger <cg@exept.de>
parents: 1585
diff changeset
  5185
realize
e2e4ceeed3da category change
Claus Gittinger <cg@exept.de>
parents: 1585
diff changeset
  5186
    "make the view visible - scroll to make the cursor visible."
e2e4ceeed3da category change
Claus Gittinger <cg@exept.de>
parents: 1585
diff changeset
  5187
e2e4ceeed3da category change
Claus Gittinger <cg@exept.de>
parents: 1585
diff changeset
  5188
    super realize.
e2e4ceeed3da category change
Claus Gittinger <cg@exept.de>
parents: 1585
diff changeset
  5189
e2e4ceeed3da category change
Claus Gittinger <cg@exept.de>
parents: 1585
diff changeset
  5190
    self makeCursorVisible.
1993
5ffe0b3943cd #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1967
diff changeset
  5191
    cursorFgColor := cursorFgColor onDevice:device.
5ffe0b3943cd #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1967
diff changeset
  5192
    cursorBgColor := cursorBgColor onDevice:device.
1588
e2e4ceeed3da category change
Claus Gittinger <cg@exept.de>
parents: 1585
diff changeset
  5193
e2e4ceeed3da category change
Claus Gittinger <cg@exept.de>
parents: 1585
diff changeset
  5194
    "Modified: 20.12.1996 / 14:16:05 / cg"
e2e4ceeed3da category change
Claus Gittinger <cg@exept.de>
parents: 1585
diff changeset
  5195
    "Created: 24.7.1997 / 18:24:12 / cg"
e2e4ceeed3da category change
Claus Gittinger <cg@exept.de>
parents: 1585
diff changeset
  5196
! !
e2e4ceeed3da category change
Claus Gittinger <cg@exept.de>
parents: 1585
diff changeset
  5197
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5198
!EditTextView methodsFor:'redrawing'!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5199
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5200
redrawCursorIfBetweenVisibleLine:startVisLine and:endVisLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5201
    "redraw the cursor, if it sits in a line range"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5202
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5203
    cursorShown ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  5204
        cursorVisibleLine notNil ifTrue:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  5205
            (cursorVisibleLine between:startVisLine and:endVisLine) ifTrue:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  5206
                self drawCursorCharacter
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  5207
            ]
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  5208
        ]
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5209
    ]
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  5210
!
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  5211
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5212
redrawCursorIfInVisibleLine:visLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5213
    "redraw the cursor, if it sits in visible line"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5214
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5215
    cursorShown ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  5216
        (visLine == cursorVisibleLine) ifTrue:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  5217
            self drawCursorCharacter
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  5218
        ]
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5219
    ]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5220
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5221
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5222
redrawFromVisibleLine:startVisLine to:endVisLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5223
    "redraw a visible line range"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5224
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5225
    super redrawFromVisibleLine:startVisLine to:endVisLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5226
    self redrawCursorIfBetweenVisibleLine:startVisLine and:endVisLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5227
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5228
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5229
redrawVisibleLine:visLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5230
    "redraw a visible line"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5231
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5232
    super redrawVisibleLine:visLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5233
    self redrawCursorIfInVisibleLine:visLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5234
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5235
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5236
redrawVisibleLine:visLine col:colNr
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5237
    "redraw the single character in visibleline at colNr"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5238
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5239
    cursorShown ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  5240
        (visLine == cursorVisibleLine) ifTrue:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  5241
            (colNr == cursorCol) ifTrue:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  5242
                self drawCursorCharacter.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  5243
                ^ self
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  5244
            ]
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  5245
        ]
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  5246
    ].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5247
    super redrawVisibleLine:visLine col:colNr
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5248
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5249
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5250
redrawVisibleLine:visLine from:startCol
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5251
    "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
  5252
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5253
    super redrawVisibleLine:visLine from:startCol.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5254
    self redrawCursorIfInVisibleLine:visLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5255
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5256
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5257
redrawVisibleLine:visLine from:startCol to:endCol
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5258
    "redraw a visible line from startCol to endCol"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5260
    super redrawVisibleLine:visLine from:startCol to:endCol.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5261
    self redrawCursorIfInVisibleLine:visLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5262
! !
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5263
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5264
!EditTextView methodsFor:'scrolling'!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5265
2331
218a017dc1f3 additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents: 2323
diff changeset
  5266
additionalMarginForHorizontalScroll
218a017dc1f3 additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents: 2323
diff changeset
  5267
    "return the number of pixels by which we may scroll more than the actual
218a017dc1f3 additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents: 2323
diff changeset
  5268
     width of the document would allow.
218a017dc1f3 additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents: 2323
diff changeset
  5269
     This is redefined by editable textViews, to allo for the cursor
218a017dc1f3 additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents: 2323
diff changeset
  5270
     to be visible if it is positioned right behind the longest line of text.
218a017dc1f3 additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents: 2323
diff changeset
  5271
     The default returned here is 10 pixels, which should be ok for most cursors"
218a017dc1f3 additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents: 2323
diff changeset
  5272
218a017dc1f3 additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents: 2323
diff changeset
  5273
    ^ 10 max:font width
218a017dc1f3 additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents: 2323
diff changeset
  5274
!
218a017dc1f3 additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents: 2323
diff changeset
  5275
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5276
halfPageDown
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5277
    "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
  5278
     within the real text  "
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5279
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5280
    |prevCursorLine|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5281
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5282
    prevCursorLine := cursorVisibleLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5283
    super halfPageDown.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5284
    self cursorVisibleLine:prevCursorLine col:cursorCol
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5285
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5286
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5287
halfPageUp
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5288
    "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
  5289
     within the real text  "
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5290
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5291
    |prevCursorLine|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5292
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5293
    prevCursorLine := cursorVisibleLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5294
    super halfPageUp.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5295
    self cursorVisibleLine:prevCursorLine col:cursorCol
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5296
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5297
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5298
originChanged:delta
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5299
    "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
  5300
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5301
    super originChanged:delta.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5302
    "
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5303
     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
  5304
    "
2422
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  5305
    self updateCursorVisibleLine.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5306
    prevCursorState ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  5307
        self showCursor
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5308
    ]
1577
4e487247ad33 dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents: 1568
diff changeset
  5309
4e487247ad33 dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents: 1568
diff changeset
  5310
    "Modified: / 17.6.1998 / 16:13:24 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5311
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5312
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5313
originWillChange
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5314
    "sent before scrolling - have to hide the cursor"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5315
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5316
    prevCursorState := cursorShown.
1601
57dde4dfee7e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  5317
    "/ cursorShown := false.
1591
d84c117e71cc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1590
diff changeset
  5318
    cursorShown ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  5319
        self hideCursor
1591
d84c117e71cc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1590
diff changeset
  5320
    ]
d84c117e71cc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1590
diff changeset
  5321
1601
57dde4dfee7e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  5322
    "Modified: / 6.7.1998 / 13:07:23 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5323
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5324
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5325
pageDown
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5326
    "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
  5327
     within the real text  "
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5328
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5329
    |prevCursorLine|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5330
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5331
    prevCursorLine := cursorVisibleLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5332
    super pageDown.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5333
    self cursorVisibleLine:prevCursorLine col:cursorCol
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5334
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5335
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5336
pageUp
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5337
    "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
  5338
     within the real text  "
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5339
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5340
    |prevCursorLine|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5341
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5342
    prevCursorLine := cursorVisibleLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5343
    super pageUp.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5344
    self cursorVisibleLine:prevCursorLine col:cursorCol
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5345
! !
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5346
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5347
!EditTextView methodsFor:'searching'!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5348
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5349
searchBwd:pattern ifAbsent:aBlock
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5350
    "do a backward search"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5351
2822
08ceab3fc237 search refactored;
Claus Gittinger <cg@exept.de>
parents: 2819
diff changeset
  5352
    self searchBwd:pattern ignoreCase:false ifAbsent:aBlock
1339
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  5353
!
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  5354
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  5355
searchBwd:pattern ignoreCase:ign ifAbsent:aBlock
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  5356
    "do a backward search"
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  5357
2756
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
  5358
    |pos startLine startCol|
1339
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  5359
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  5360
    cursorLine isNil ifTrue:[^ self].
2756
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
  5361
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
  5362
    pos := self startPositionForSearchBackward.
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
  5363
    startLine := pos y.
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
  5364
    startCol := pos x.
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
  5365
1339
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  5366
    self 
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  5367
        searchBackwardFor:pattern
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  5368
        ignoreCase:ign
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  5369
        startingAtLine:startLine col:startCol
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  5370
        ifFound:[:line :col |
2822
08ceab3fc237 search refactored;
Claus Gittinger <cg@exept.de>
parents: 2819
diff changeset
  5371
            self cursorMovementAllowed ifTrue:[
08ceab3fc237 search refactored;
Claus Gittinger <cg@exept.de>
parents: 2819
diff changeset
  5372
                self cursorLine:line col:col.
08ceab3fc237 search refactored;
Claus Gittinger <cg@exept.de>
parents: 2819
diff changeset
  5373
            ].
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  5374
            self showMatch:pattern atLine:line col:col.
1339
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  5375
"/            self makeLineVisible:cursorLine
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  5376
            typeOfSelection := #search] 
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  5377
        ifAbsent:aBlock
1339
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  5378
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  5379
    "Modified: 9.10.1997 / 13:02:13 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5380
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5381
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5382
searchForAndSelectMatchingParenthesis
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5383
    "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
  5384
2554
ec6aca20825f refactored
Claus Gittinger <cg@exept.de>
parents: 2544
diff changeset
  5385
    self searchForAndSelectMatchingParenthesisFromLine:cursorLine col:cursorCol
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5386
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5387
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5388
searchForMatchingParenthesis
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5389
    "search for a matching parenthesis starting at cursor position. 
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5390
     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
  5391
     backwards if its a closing parenthesis.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5392
     Positions the cursor if found, peeps if not"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5393
2822
08ceab3fc237 search refactored;
Claus Gittinger <cg@exept.de>
parents: 2819
diff changeset
  5394
    self cursorMovementAllowed ifFalse:[^ self].
08ceab3fc237 search refactored;
Claus Gittinger <cg@exept.de>
parents: 2819
diff changeset
  5395
08ceab3fc237 search refactored;
Claus Gittinger <cg@exept.de>
parents: 2819
diff changeset
  5396
    self 
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  5397
        searchForMatchingParenthesisFromLine:cursorLine col:cursorCol
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  5398
        ifFound:[:line :col | self cursorLine:line col:col]
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  5399
        ifNotFound:[self showNotFound]
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  5400
        onError:[self beep]
1339
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  5401
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  5402
    "Modified: 9.10.1997 / 12:56:30 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5403
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5404
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5405
searchFwd:pattern ifAbsent:aBlock
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5406
    "do a forward search"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5407
2756
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
  5408
    |pos startLine startCol|
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
  5409
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
  5410
    pos := self startPositionForSearchForward.
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
  5411
    startLine := pos y.
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
  5412
    startCol := pos x.
1339
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  5413
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  5414
    self 
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  5415
        searchFwd:pattern 
2756
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
  5416
        startingAtLine:startLine col:startCol 
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  5417
        ifAbsent:aBlock
1339
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  5418
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  5419
    "Modified: 9.10.1997 / 12:58:59 / cg"
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  5420
!
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  5421
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  5422
searchFwd:pattern ignoreCase:ign ifAbsent:aBlock
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  5423
    "do a forward search"
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  5424
2756
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
  5425
    |pos startLine startCol|
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
  5426
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
  5427
    pos := self startPositionForSearchForward.
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
  5428
    startLine := pos y.
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
  5429
    startCol := pos x.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5430
1339
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  5431
    self 
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  5432
        searchFwd:pattern
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  5433
        ignoreCase:ign
2756
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
  5434
        startingAtLine:startLine col:startCol 
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  5435
        ifAbsent:aBlock
1339
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  5436
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  5437
    "Modified: 9.10.1997 / 12:58:59 / cg"
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  5438
    "Created: 9.10.1997 / 13:04:10 / cg"
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  5439
!
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  5440
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  5441
searchFwd:pattern ignoreCase:ign startingAtLine:startLine col:startCol ifAbsent:aBlock
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  5442
    "do a forward search"
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  5443
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  5444
    cursorLine isNil ifTrue:[^ self].
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  5445
    self 
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  5446
        searchForwardFor:pattern 
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  5447
        ignoreCase:ign
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  5448
        startingAtLine:startLine col:startCol
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  5449
        ifFound:[:line :col |
2822
08ceab3fc237 search refactored;
Claus Gittinger <cg@exept.de>
parents: 2819
diff changeset
  5450
            self cursorMovementAllowed ifTrue:[
08ceab3fc237 search refactored;
Claus Gittinger <cg@exept.de>
parents: 2819
diff changeset
  5451
                self cursorLine:line col:col.
08ceab3fc237 search refactored;
Claus Gittinger <cg@exept.de>
parents: 2819
diff changeset
  5452
            ].
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  5453
            self showMatch:pattern atLine:line col:col.
1339
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  5454
"/            self makeLineVisible:cursorLine
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  5455
            typeOfSelection := #search]
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  5456
        ifAbsent:aBlock
1339
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  5457
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  5458
    "Modified: 9.10.1997 / 12:57:47 / cg"
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  5459
    "Created: 9.10.1997 / 13:01:12 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5460
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5461
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5462
searchFwd:pattern startingAtLine:startLine col:startCol ifAbsent:aBlock
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5463
    "do a forward search"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5464
2822
08ceab3fc237 search refactored;
Claus Gittinger <cg@exept.de>
parents: 2819
diff changeset
  5465
    self searchFwd:pattern ignoreCase:false startingAtLine:startLine col:startCol ifAbsent:aBlock
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5466
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5467
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5468
setSearchPattern
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5469
    "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
  5470
     cursor to start of pattern"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5471
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5472
    |sel|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5473
559
3ff87e9447c6 keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents: 522
diff changeset
  5474
    "/
3ff87e9447c6 keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents: 522
diff changeset
  5475
    "/ 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
  5476
    "/ original string (for search after again)
3ff87e9447c6 keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents: 522
diff changeset
  5477
    "/
565
f2a0499ba3d0 preserve search pattern
Claus Gittinger <cg@exept.de>
parents: 559
diff changeset
  5478
    (lastString notNil 
f2a0499ba3d0 preserve search pattern
Claus Gittinger <cg@exept.de>
parents: 559
diff changeset
  5479
     and:[lastReplacement notNil
f2a0499ba3d0 preserve search pattern
Claus Gittinger <cg@exept.de>
parents: 559
diff changeset
  5480
     and:[typeOfSelection ~~ #search]]) ifTrue:[
2950
778d8e4f80c1 searchString
Claus Gittinger <cg@exept.de>
parents: 2949
diff changeset
  5481
        lastString isString ifTrue:[
778d8e4f80c1 searchString
Claus Gittinger <cg@exept.de>
parents: 2949
diff changeset
  5482
            lastSearchPattern := lastString.
778d8e4f80c1 searchString
Claus Gittinger <cg@exept.de>
parents: 2949
diff changeset
  5483
        ] ifFalse:[
778d8e4f80c1 searchString
Claus Gittinger <cg@exept.de>
parents: 2949
diff changeset
  5484
            lastSearchPattern := lastString asStringWithoutFinalCR.
778d8e4f80c1 searchString
Claus Gittinger <cg@exept.de>
parents: 2949
diff changeset
  5485
        ].
2205
230cf9cef6c3 searchPatter, if from selection (escape meta characters)
Claus Gittinger <cg@exept.de>
parents: 2196
diff changeset
  5486
        ^ self
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5487
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5488
559
3ff87e9447c6 keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents: 522
diff changeset
  5489
    "/
3ff87e9447c6 keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents: 522
diff changeset
  5490
    "/ if there is a selection:
3ff87e9447c6 keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents: 522
diff changeset
  5491
    "/    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
  5492
    "/    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
  5493
    "/    it did not result from a paste.
3ff87e9447c6 keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents: 522
diff changeset
  5494
    "/    (to allow search-paste to be repeated)
3ff87e9447c6 keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents: 522
diff changeset
  5495
    "/
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5496
    sel := self selection.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5497
    sel notNil ifTrue:[
2205
230cf9cef6c3 searchPatter, if from selection (escape meta characters)
Claus Gittinger <cg@exept.de>
parents: 2196
diff changeset
  5498
        (lastSearchPattern isNil
230cf9cef6c3 searchPatter, if from selection (escape meta characters)
Claus Gittinger <cg@exept.de>
parents: 2196
diff changeset
  5499
        or:[typeOfSelection ~~ #paste]) ifTrue:[
230cf9cef6c3 searchPatter, if from selection (escape meta characters)
Claus Gittinger <cg@exept.de>
parents: 2196
diff changeset
  5500
            self cursorLine:selectionStartLine col:selectionStartCol.
2835
efe44fb65536 allow search for strings with whiteSpace
Claus Gittinger <cg@exept.de>
parents: 2823
diff changeset
  5501
            lastSearchPattern := sel asStringWithoutFinalCR withMatchEscapes
2205
230cf9cef6c3 searchPatter, if from selection (escape meta characters)
Claus Gittinger <cg@exept.de>
parents: 2196
diff changeset
  5502
        ]
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5503
    ]
559
3ff87e9447c6 keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents: 522
diff changeset
  5504
565
f2a0499ba3d0 preserve search pattern
Claus Gittinger <cg@exept.de>
parents: 559
diff changeset
  5505
    "Modified: 20.4.1996 / 12:50:13 / cg"
2756
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
  5506
!
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
  5507
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
  5508
startPositionForSearchBackward
2822
08ceab3fc237 search refactored;
Claus Gittinger <cg@exept.de>
parents: 2819
diff changeset
  5509
    ^ self startPositionForSearchBackwardBasedOnCursorOrSelection
08ceab3fc237 search refactored;
Claus Gittinger <cg@exept.de>
parents: 2819
diff changeset
  5510
!
08ceab3fc237 search refactored;
Claus Gittinger <cg@exept.de>
parents: 2819
diff changeset
  5511
08ceab3fc237 search refactored;
Claus Gittinger <cg@exept.de>
parents: 2819
diff changeset
  5512
startPositionForSearchBackwardBasedOnCursorOrSelection
2756
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
  5513
    |startLine startCol|
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
  5514
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
  5515
    selectionStartLine notNil ifTrue:[
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
  5516
        startLine := selectionStartLine.
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
  5517
        startCol := selectionStartCol
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
  5518
    ] ifFalse:[
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
  5519
        cursorLine isNil ifTrue:[
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
  5520
            startLine := list size.
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
  5521
            startCol := self listAt:startLine size.
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
  5522
        ] ifFalse:[
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
  5523
            startLine := cursorLine min:list size.
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
  5524
            startCol := cursorCol
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
  5525
        ]
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
  5526
    ].
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
  5527
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
  5528
    ^ startCol @ cursorLine
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
  5529
!
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
  5530
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
  5531
startPositionForSearchForward
2822
08ceab3fc237 search refactored;
Claus Gittinger <cg@exept.de>
parents: 2819
diff changeset
  5532
    ^ self startPositionForSearchForwardBasedOnCursorOrSelection
08ceab3fc237 search refactored;
Claus Gittinger <cg@exept.de>
parents: 2819
diff changeset
  5533
!
08ceab3fc237 search refactored;
Claus Gittinger <cg@exept.de>
parents: 2819
diff changeset
  5534
08ceab3fc237 search refactored;
Claus Gittinger <cg@exept.de>
parents: 2819
diff changeset
  5535
startPositionForSearchForwardBasedOnCursorOrSelection
2756
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
  5536
    |startCol|
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
  5537
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
  5538
    "/ if there is no selection and the cursor is at the origin, 
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
  5539
    "/ assume its the first search and do not skip the very first match
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
  5540
    startCol := cursorCol.
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
  5541
    self hasSelection ifFalse:[
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
  5542
        (cursorLine == 1 and:[cursorCol == 1]) ifTrue:[
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
  5543
            startCol := 0
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
  5544
        ]
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
  5545
    ].
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
  5546
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
  5547
    ^ startCol @ cursorLine
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5548
! !
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5549
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5550
!EditTextView methodsFor:'selections'!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5551
3023
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  5552
addToSelectionAfter:aBlock
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  5553
    "Pokud existuje selekce, upravi ji
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  5554
     podle aktualni pozice kurzoru a pozice
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  5555
     po provedeni blocku.
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  5556
     Urceno k implementaci Shift-Home a Shift-End
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  5557
     Nejak nevim, jak to presneji popsat :-)"
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  5558
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  5559
    |startLine startCol endLine endCol |
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  5560
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  5561
    self hasSelection ifTrue: [
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  5562
        startLine := selectionStartLine .
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  5563
        startCol := selectionStartCol .
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  5564
        endLine := selectionEndLine .
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  5565
        endCol := selectionEndCol .
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  5566
    ] ifFalse: [
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  5567
        startLine := endLine :=  cursorLine .
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  5568
        startCol := endCol := cursorCol .
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  5569
    ].
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  5570
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  5571
    "deselectim a provedu presun kurzoru..."
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  5572
    self unselect .
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  5573
    aBlock value .
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  5574
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  5575
    "funguje dost mizerne, jen na jednom radku..."
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  5576
    (startCol - cursorCol) abs <= (endCol - cursorCol) abs
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  5577
        ifTrue: [
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  5578
            startCol := cursorCol.
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  5579
        ] ifFalse: [
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  5580
            endCol := cursorCol - 1.
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  5581
        ].
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  5582
    self selectFromLine:startLine col:startCol toLine: endLine col:endCol .
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  5583
!
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  5584
1850
82516928e791 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1849
diff changeset
  5585
autoMoveCursorToEndOfSelection
82516928e791 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1849
diff changeset
  5586
    "return true, if the cursor should be automatically moved to the
82516928e791 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1849
diff changeset
  5587
     end of a selection.
82516928e791 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1849
diff changeset
  5588
     Redefined to return false in terminaViews, where the cursor should
82516928e791 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1849
diff changeset
  5589
     not be affected by selecting"
82516928e791 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1849
diff changeset
  5590
82516928e791 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1849
diff changeset
  5591
    ^ true
82516928e791 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1849
diff changeset
  5592
!
82516928e791 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1849
diff changeset
  5593
2606
6a3ab90d339f redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents: 2599
diff changeset
  5594
changeTypeOfSelectionTo:newType
6a3ab90d339f redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents: 2599
diff changeset
  5595
    typeOfSelection ~~ newType ifTrue:[
6a3ab90d339f redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents: 2599
diff changeset
  5596
        typeOfSelection := newType.
6a3ab90d339f redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents: 2599
diff changeset
  5597
        selectionStartLine notNil ifTrue:[
6a3ab90d339f redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents: 2599
diff changeset
  5598
            self 
6a3ab90d339f redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents: 2599
diff changeset
  5599
                redrawFromLine:selectionStartLine col:selectionStartCol
6a3ab90d339f redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents: 2599
diff changeset
  5600
                toLine:selectionEndLine col:selectionEndCol
6a3ab90d339f redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents: 2599
diff changeset
  5601
        ].
6a3ab90d339f redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents: 2599
diff changeset
  5602
    ].
6a3ab90d339f redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents: 2599
diff changeset
  5603
!
6a3ab90d339f redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents: 2599
diff changeset
  5604
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5605
selectAll
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5606
    "select the whole text.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5607
     redefined to send super selectFrom... since we dont want the
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5608
     cursor to be moved in this case."
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5609
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5610
    list isNil ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  5611
        self unselect
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5612
    ] ifFalse:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  5613
        super selectFromLine:1 col:1 toLine:(list size + 1) col:0.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  5614
        typeOfSelection := nil
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5615
    ]
1082
ccc3aa4268c1 better #selectAll
Claus Gittinger <cg@exept.de>
parents: 1054
diff changeset
  5616
ccc3aa4268c1 better #selectAll
Claus Gittinger <cg@exept.de>
parents: 1054
diff changeset
  5617
    "Modified: 28.2.1997 / 19:14:54 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5618
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5619
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5620
selectCursorLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5621
    "select cursorline"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5622
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5623
    self selectFromLine:cursorLine col:1 toLine:cursorLine+1 col:0 
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5624
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5625
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5626
selectCursorLineFromBeginning
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5627
    "select cursorline up to cursor position"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5628
823
fc61564f7832 escape selects up to previous character
Claus Gittinger <cg@exept.de>
parents: 785
diff changeset
  5629
    cursorCol > 1 ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  5630
        self selectFromLine:cursorLine col:1
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  5631
                     toLine:cursorLine col:(cursorCol-1)
823
fc61564f7832 escape selects up to previous character
Claus Gittinger <cg@exept.de>
parents: 785
diff changeset
  5632
    ]
fc61564f7832 escape selects up to previous character
Claus Gittinger <cg@exept.de>
parents: 785
diff changeset
  5633
fc61564f7832 escape selects up to previous character
Claus Gittinger <cg@exept.de>
parents: 785
diff changeset
  5634
    "Modified: 16.8.1996 / 19:14:14 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5635
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5636
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5637
selectExpandCursorLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5638
    "expand selection by one line or select cursorline"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5639
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5640
    selectionStartLine isNil ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  5641
        self selectCursorLine
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5642
    ] ifFalse:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  5643
        self selectFromLine:selectionStartLine col:selectionStartCol
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  5644
                     toLine:cursorLine+1 col:0.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  5645
        self makeLineVisible:selectionEndLine
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5646
    ]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5647
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5648
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5649
selectFromBeginning
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5650
    "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
  5651
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5652
    |col|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5653
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5654
    list isNil ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  5655
        self unselect
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5656
    ] ifFalse:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  5657
        cursorCol == 0 ifTrue:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  5658
            col := 0
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  5659
        ] ifFalse:[
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  5660
            col := cursorCol - 1
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  5661
        ].
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  5662
        super selectFromLine:1 col:1 toLine:cursorLine col:col.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  5663
        typeOfSelection := nil
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5664
    ]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5665
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5666
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5667
selectFromLine:startLine col:startCol toLine:endLine col:endCol
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5668
    "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
  5669
     for easier editing. Also typeOfSelection is nilled here."
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5670
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5671
    super selectFromLine:startLine col:startCol toLine:endLine col:endCol.
1850
82516928e791 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1849
diff changeset
  5672
    (selectionEndLine notNil and:[self autoMoveCursorToEndOfSelection]) ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  5673
        self cursorLine:selectionEndLine col:(selectionEndCol + 1).
1198
1c5390d2d3fb care for failed selection when positioning cursor.
ca
parents: 1177
diff changeset
  5674
    ].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5675
    typeOfSelection := nil
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5676
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5677
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5678
selectUpToEnd
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5679
    "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
  5680
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5681
    list isNil ifTrue:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  5682
        self unselect
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5683
    ] ifFalse:[
2357
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  5684
        super selectFromLine:cursorLine col:cursorCol toLine:(list size + 1) col:0.
527d93ed293a letfOver halt removed
Claus Gittinger <cg@exept.de>
parents: 2356
diff changeset
  5685
        typeOfSelection := nil
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5686
    ]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5687
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5688
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5689
selectWordUnderCursor
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5690
    "select the word under the cursor"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5691
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5692
    self selectWordAtLine:cursorLine col:cursorCol
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5693
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5694
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5695
unselect
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5696
    "forget and unhilight selection - must take care of cursor here"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5697
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5698
    |wasOn|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5699
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5700
    wasOn := self hideCursor.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5701
    super unselect.
2606
6a3ab90d339f redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents: 2599
diff changeset
  5702
    typeOfSelection := nil.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5703
    wasOn ifTrue:[self showCursor]
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  5704
! !
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  5705
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  5706
!EditTextView methodsFor:'undo & again'!
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  5707
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5708
addUndo:action
2989
5dcc2912bcb6 undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents: 2984
diff changeset
  5709
    ^ undoSupport addUndo:action.
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5710
!
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5711
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  5712
again
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  5713
    "repeat the last action (which was a cut or replace).
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  5714
     If current selection is not last string, search forward to
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  5715
     next occurence of it before repeating the last operation."
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  5716
2323
ef201d5d0689 fixed search-again if cursor is at start of text, and
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
  5717
    |s l c sel savedSelectStyle startColForSearch|
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  5718
2579
74d3798f4200 do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents: 2574
diff changeset
  5719
    lastString isNil ifTrue:[
74d3798f4200 do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents: 2574
diff changeset
  5720
        ^ false
74d3798f4200 do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents: 2574
diff changeset
  5721
    ].
74d3798f4200 do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents: 2574
diff changeset
  5722
74d3798f4200 do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents: 2574
diff changeset
  5723
    s := lastString asString.
74d3798f4200 do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents: 2574
diff changeset
  5724
74d3798f4200 do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents: 2574
diff changeset
  5725
    "remove final cr"
74d3798f4200 do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents: 2574
diff changeset
  5726
    (s endsWith:Character cr) ifTrue:[s := s copyWithoutLast:1].
840
b0071cea13fd fixed Again when spaces are replaced
Claus Gittinger <cg@exept.de>
parents: 828
diff changeset
  5727
"/        s := s withoutSpaces.        "XXX - replacing text with spaces ..."
2579
74d3798f4200 do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents: 2574
diff changeset
  5728
    savedSelectStyle := selectStyle.
74d3798f4200 do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents: 2574
diff changeset
  5729
    selectStyle := nil.
74d3798f4200 do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents: 2574
diff changeset
  5730
74d3798f4200 do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents: 2574
diff changeset
  5731
    sel := self selection.
74d3798f4200 do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents: 2574
diff changeset
  5732
74d3798f4200 do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents: 2574
diff changeset
  5733
    "if we are already there (after a find), ommit search"
74d3798f4200 do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents: 2574
diff changeset
  5734
74d3798f4200 do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents: 2574
diff changeset
  5735
    (sel notNil and:[sel asString withoutSeparators = s]) ifTrue:[
74d3798f4200 do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents: 2574
diff changeset
  5736
        l := selectionStartLine "cursorLine". 
74d3798f4200 do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents: 2574
diff changeset
  5737
        c := selectionStartCol "cursorCol".
74d3798f4200 do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents: 2574
diff changeset
  5738
        self deleteSelection.
74d3798f4200 do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents: 2574
diff changeset
  5739
        lastReplacement notNil ifTrue:[
74d3798f4200 do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents: 2574
diff changeset
  5740
            self insertLines:lastReplacement asStringCollection withCR:false.
74d3798f4200 do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents: 2574
diff changeset
  5741
            self selectFromLine:l col:c toLine:cursorLine col:(cursorCol - 1).
2323
ef201d5d0689 fixed search-again if cursor is at start of text, and
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
  5742
        ].
2579
74d3798f4200 do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents: 2574
diff changeset
  5743
        selectStyle := savedSelectStyle.
74d3798f4200 do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents: 2574
diff changeset
  5744
        ^ true
74d3798f4200 do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents: 2574
diff changeset
  5745
    ].
74d3798f4200 do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents: 2574
diff changeset
  5746
    startColForSearch := cursorCol.
74d3798f4200 do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents: 2574
diff changeset
  5747
    sel isNil ifTrue:[
74d3798f4200 do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents: 2574
diff changeset
  5748
        startColForSearch := startColForSearch - 1
74d3798f4200 do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents: 2574
diff changeset
  5749
    ].
74d3798f4200 do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents: 2574
diff changeset
  5750
    self searchForwardFor:s startingAtLine:cursorLine col:startColForSearch 
74d3798f4200 do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents: 2574
diff changeset
  5751
        ifFound:
74d3798f4200 do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents: 2574
diff changeset
  5752
            [
74d3798f4200 do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents: 2574
diff changeset
  5753
                :line :col |
74d3798f4200 do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents: 2574
diff changeset
  5754
74d3798f4200 do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents: 2574
diff changeset
  5755
                |repl|
74d3798f4200 do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents: 2574
diff changeset
  5756
74d3798f4200 do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents: 2574
diff changeset
  5757
                self selectFromLine:line col:col
74d3798f4200 do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents: 2574
diff changeset
  5758
                             toLine:line col:(col + s size - 1).
74d3798f4200 do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents: 2574
diff changeset
  5759
                self makeLineVisible:line.
74d3798f4200 do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents: 2574
diff changeset
  5760
74d3798f4200 do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents: 2574
diff changeset
  5761
                self deleteSelection.
74d3798f4200 do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents: 2574
diff changeset
  5762
                lastReplacement notNil ifTrue:[
74d3798f4200 do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents: 2574
diff changeset
  5763
                    lastReplacement isString ifFalse:[
74d3798f4200 do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents: 2574
diff changeset
  5764
                        repl := lastReplacement asString "withoutSpaces"
74d3798f4200 do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents: 2574
diff changeset
  5765
                    ] ifTrue:[
74d3798f4200 do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents: 2574
diff changeset
  5766
                        repl := lastReplacement "withoutSpaces".
2323
ef201d5d0689 fixed search-again if cursor is at start of text, and
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
  5767
                    ].
2579
74d3798f4200 do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents: 2574
diff changeset
  5768
                    self insertLines:repl asStringCollection withCR:false.
74d3798f4200 do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents: 2574
diff changeset
  5769
                    self selectFromLine:line col:col toLine:cursorLine col:(cursorCol - 1).
74d3798f4200 do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents: 2574
diff changeset
  5770
                ].
74d3798f4200 do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents: 2574
diff changeset
  5771
                selectStyle := savedSelectStyle.
74d3798f4200 do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents: 2574
diff changeset
  5772
                ^ true
74d3798f4200 do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents: 2574
diff changeset
  5773
            ] 
74d3798f4200 do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents: 2574
diff changeset
  5774
       ifAbsent:
74d3798f4200 do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents: 2574
diff changeset
  5775
            [
2730
61a2f1981ac6 Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents: 2725
diff changeset
  5776
                self sensor compressKeyPressEventsWithKey:#Again.
2579
74d3798f4200 do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents: 2574
diff changeset
  5777
                self showNotFound.
74d3798f4200 do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents: 2574
diff changeset
  5778
                selectStyle := savedSelectStyle.
74d3798f4200 do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents: 2574
diff changeset
  5779
                ^ false
2730
61a2f1981ac6 Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents: 2725
diff changeset
  5780
            ].
61a2f1981ac6 Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents: 2725
diff changeset
  5781
61a2f1981ac6 Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents: 2725
diff changeset
  5782
    ^ true.
501
13fc7b9ce5cb fixed (?) again-replace
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  5783
840
b0071cea13fd fixed Again when spaces are replaced
Claus Gittinger <cg@exept.de>
parents: 828
diff changeset
  5784
    "Modified: 9.10.1996 / 16:14:11 / cg"
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  5785
!
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  5786
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5787
hasRedoAction
2989
5dcc2912bcb6 undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents: 2984
diff changeset
  5788
    ^ undoSupport hasRedoAction.
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5789
!
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5790
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5791
hasUndoAction
2989
5dcc2912bcb6 undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents: 2984
diff changeset
  5792
    ^ undoSupport hasUndoAction.
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5793
!
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5794
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5795
multipleAgain
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5796
    "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
  5797
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5798
    [self again] whileTrue:[]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5799
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5800
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5801
nonUndoableDo:aBlock
2989
5dcc2912bcb6 undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents: 2984
diff changeset
  5802
    undoSupport nonUndoableDo:aBlock.
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5803
!
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5804
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5805
redo
2989
5dcc2912bcb6 undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents: 2984
diff changeset
  5806
    undoSupport hasRedoAction ifFalse:[
5dcc2912bcb6 undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents: 2984
diff changeset
  5807
        self beep
5dcc2912bcb6 undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents: 2984
diff changeset
  5808
    ] ifTrue:[
5dcc2912bcb6 undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents: 2984
diff changeset
  5809
        undoSupport redo.
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5810
    ]
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5811
!
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5812
121
claus
parents: 118
diff changeset
  5813
undo
2989
5dcc2912bcb6 undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents: 2984
diff changeset
  5814
    undoSupport hasUndoAction ifFalse:[
5dcc2912bcb6 undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents: 2984
diff changeset
  5815
        self beep
5dcc2912bcb6 undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents: 2984
diff changeset
  5816
    ] ifTrue:[
5dcc2912bcb6 undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents: 2984
diff changeset
  5817
        undoSupport undo.
121
claus
parents: 118
diff changeset
  5818
    ]
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5819
!
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5820
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5821
undoableDo:aBlock
2989
5dcc2912bcb6 undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents: 2984
diff changeset
  5822
    self checkModificationsAllowed not ifTrue:[
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5823
        aBlock value.
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5824
    ] ifFalse:[
2989
5dcc2912bcb6 undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents: 2984
diff changeset
  5825
        undoSupport undoableDo:aBlock.
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5826
    ].
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5827
! !
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5828
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5829
!EditTextView::EditAction class methodsFor:'instance creation'!
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5830
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5831
line1:arg1 col1:arg2 line2:arg3 col2:arg4
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5832
    ^ self new line1:arg1 col1:arg2 line2:arg3 col2:arg4
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5833
!
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5834
3115
b75128334006 info string in undo
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
  5835
line1:arg1 col1:arg2 line2:arg3 col2:arg4 info:info
b75128334006 info string in undo
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
  5836
    ^ (self new line1:arg1 col1:arg2 line2:arg3 col2:arg4) info:info 
b75128334006 info string in undo
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
  5837
!
b75128334006 info string in undo
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
  5838
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5839
line:arg1 col:arg2 character:arg3
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5840
    ^ self new line:arg1 col:arg2 character:arg3
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5841
!
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5842
3115
b75128334006 info string in undo
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
  5843
line:arg1 col:arg2 character:arg3 info:info
b75128334006 info string in undo
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
  5844
    ^ (self new line:arg1 col:arg2 character:arg3) info:info 
b75128334006 info string in undo
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
  5845
!
b75128334006 info string in undo
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
  5846
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5847
line:arg1 col:arg2 string:arg3
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5848
    ^ self new line:arg1 col:arg2 string:arg3
3115
b75128334006 info string in undo
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
  5849
!
b75128334006 info string in undo
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
  5850
b75128334006 info string in undo
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
  5851
line:arg1 col:arg2 string:arg3 info:info
b75128334006 info string in undo
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
  5852
    ^ (self new line:arg1 col:arg2 string:arg3) info:info
b75128334006 info string in undo
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
  5853
! !
b75128334006 info string in undo
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
  5854
b75128334006 info string in undo
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
  5855
!EditTextView::EditAction methodsFor:'accessing'!
b75128334006 info string in undo
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
  5856
b75128334006 info string in undo
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
  5857
info
b75128334006 info string in undo
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
  5858
    ^ userFriendlyInfo
b75128334006 info string in undo
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
  5859
!
b75128334006 info string in undo
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
  5860
b75128334006 info string in undo
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
  5861
info:aString
b75128334006 info string in undo
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
  5862
    userFriendlyInfo := aString
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5863
! !
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5864
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5865
!EditTextView::DeleteRange methodsFor:'accessing'!
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5866
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5867
line1:line1Arg col1:col1Arg line2:line2Arg col2:col2Arg 
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5868
    "set instance variables (automatically generated)"
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5869
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5870
    self assert:(line1Arg notNil).
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5871
    self assert:(col1Arg notNil).
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5872
    self assert:(line2Arg notNil).
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5873
    self assert:(col2Arg notNil).
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5874
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5875
    line1 := line1Arg.
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5876
    col1 := col1Arg.
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5877
    line2 := line2Arg.
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5878
    col2 := col2Arg.
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5879
! !
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5880
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5881
!EditTextView::DeleteRange methodsFor:'execution'!
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5882
2989
5dcc2912bcb6 undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents: 2984
diff changeset
  5883
executeIn:editor 
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5884
    editor unselect.
2989
5dcc2912bcb6 undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents: 2984
diff changeset
  5885
    editor 
5dcc2912bcb6 undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents: 2984
diff changeset
  5886
        deleteFromLine:line1
5dcc2912bcb6 undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents: 2984
diff changeset
  5887
        col:col1
5dcc2912bcb6 undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents: 2984
diff changeset
  5888
        toLine:line2
5dcc2912bcb6 undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents: 2984
diff changeset
  5889
        col:col2.
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5890
    editor cursorLine:line1 col:col1.
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5891
! !
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5892
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5893
!EditTextView::InsertCharacter methodsFor:'accessing'!
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5894
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5895
line:lineArg col:colArg character:characterArg 
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5896
    "set instance variables (automatically generated)"
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5897
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5898
    line := lineArg.
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5899
    col := colArg.
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5900
    character := characterArg.
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5901
! !
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5902
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5903
!EditTextView::InsertCharacter methodsFor:'execution'!
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5904
2989
5dcc2912bcb6 undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents: 2984
diff changeset
  5905
executeIn:editor 
5dcc2912bcb6 undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents: 2984
diff changeset
  5906
    editor 
5dcc2912bcb6 undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents: 2984
diff changeset
  5907
        replace:character
5dcc2912bcb6 undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents: 2984
diff changeset
  5908
        atLine:line
5dcc2912bcb6 undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents: 2984
diff changeset
  5909
        col:col.
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5910
    editor cursorLine:line col:col.
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5911
! !
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5912
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5913
!EditTextView::PasteString methodsFor:'accessing'!
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5914
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5915
line:lineArg col:colArg string:stringArg 
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5916
    self assert:(lineArg notNil).
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5917
    self assert:(colArg notNil).
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5918
    self assert:(stringArg notNil).
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5919
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5920
    line := lineArg.
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5921
    col := colArg.
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5922
    string := stringArg.
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5923
!
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5924
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5925
line:lineArg col:colArg string:stringArg selected:selectedArg
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5926
    self assert:(lineArg notNil).
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5927
    self assert:(colArg notNil).
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5928
    self assert:(stringArg notNil).
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5929
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5930
    line := lineArg.
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5931
    col := colArg.
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5932
    string := stringArg.
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5933
    selected := selectedArg.
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5934
! !
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5935
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5936
!EditTextView::PasteString methodsFor:'execution'!
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5937
2989
5dcc2912bcb6 undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents: 2984
diff changeset
  5938
executeIn:editor 
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5939
    editor cursorLine:line col:col.
2989
5dcc2912bcb6 undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents: 2984
diff changeset
  5940
    editor paste:string.
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5941
    selected ~~ true ifTrue:[
2989
5dcc2912bcb6 undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents: 2984
diff changeset
  5942
        editor unselect
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5943
    ].
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5944
! !
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5945
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5946
!EditTextView::ReplaceCharacter methodsFor:'accessing'!
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5947
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5948
line:lineArg col:colArg character:characterArg 
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5949
    "set instance variables (automatically generated)"
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5950
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5951
    line := lineArg.
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5952
    col := colArg.
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5953
    character := characterArg.
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5954
! !
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5955
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5956
!EditTextView::ReplaceCharacter methodsFor:'execution'!
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5957
2989
5dcc2912bcb6 undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents: 2984
diff changeset
  5958
executeIn:editor 
5dcc2912bcb6 undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents: 2984
diff changeset
  5959
    editor 
5dcc2912bcb6 undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents: 2984
diff changeset
  5960
        replace:character
5dcc2912bcb6 undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents: 2984
diff changeset
  5961
        atLine:line
5dcc2912bcb6 undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents: 2984
diff changeset
  5962
        col:col.
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5963
    editor cursorLine:line col:col.
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  5964
! !
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  5965
865
d42c7c99e67d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 840
diff changeset
  5966
!EditTextView class methodsFor:'documentation'!
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5967
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5968
version
3115
b75128334006 info string in undo
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
  5969
    ^ '$Header: /cvs/stx/stx/libwidg/EditTextView.st,v 1.366 2004-11-30 11:55:50 cg Exp $'
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  5970
! !