EditTextView.st
author Claus Gittinger <cg@exept.de>
Mon, 04 Feb 2008 13:19:29 +0100
changeset 3542 30ed44ed0178
parent 3517 0a2f117c2fb8
child 3549 569d0e4ab5a3
permissions -rw-r--r--
+joinLines (CTRL-j); undolist: operation names
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
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
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
"
2184
fb634dc3e606 learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents: 2157
diff changeset
    12
"{ Package: 'stx:libwidg' }"
fb634dc3e606 learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents: 2157
diff changeset
    13
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    14
TextView subclass:#EditTextView
2724
23f4e16dc4f4 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2720
diff changeset
    15
	instanceVariableNames:'cursorLine cursorVisibleLine cursorCol cursorShown
23f4e16dc4f4 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2720
diff changeset
    16
		prevCursorState readOnly modifiedChannel fixedSize exceptionBlock
23f4e16dc4f4 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2720
diff changeset
    17
		cursorFgColor cursorBgColor cursorNoFocusFgColor cursorType
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
    18
		cursorTypeNoFocus typeOfSelection lastString lastReplacement
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
    19
		lastAction replacing showMatchingParenthesis hasKeyboardFocus
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
    20
		acceptAction lockUpdates tabMeansNextField autoIndent insertMode
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
    21
		editMode trimBlankLines wordWrap replacementWordSelectStyle
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
    22
		acceptChannel acceptEnabled st80Mode disableIfInvisible
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
    23
		cursorMovementWhenUpdating learnMode learnedMacro
3241
9258970123b9 dropTarget
Claus Gittinger <cg@exept.de>
parents: 3240
diff changeset
    24
		cursorLineHolder cursorColHolder tabRequiresControl undoSupport'
2724
23f4e16dc4f4 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2720
diff changeset
    25
	classVariableNames:'DefaultCursorForegroundColor DefaultCursorBackgroundColor
23f4e16dc4f4 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2720
diff changeset
    26
		DefaultCursorType DefaultCursorNoFocusForegroundColor
23f4e16dc4f4 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2720
diff changeset
    27
		DefaultCursorTypeNoFocus'
23f4e16dc4f4 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2720
diff changeset
    28
	poolDictionaries:''
23f4e16dc4f4 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2720
diff changeset
    29
	category:'Views-Text'
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    30
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    31
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
    32
Object subclass:#EditAction
3115
b75128334006 info string in undo
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
    33
	instanceVariableNames:'userFriendlyInfo'
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
    34
	classVariableNames:''
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
    35
	poolDictionaries:''
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
    36
	privateIn:EditTextView
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
    37
!
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
    38
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
    39
EditTextView::EditAction subclass:#DeleteRange
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
    40
	instanceVariableNames:'line1 col1 line2 col2'
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
    41
	classVariableNames:''
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
    42
	poolDictionaries:''
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
    43
	privateIn:EditTextView
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
    44
!
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
    45
3156
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
    46
EditTextView::EditAction subclass:#DeleteCharacters
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
    47
	instanceVariableNames:'line col1 col2'
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
    48
	classVariableNames:''
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
    49
	poolDictionaries:''
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
    50
	privateIn:EditTextView
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
    51
!
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
    52
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
    53
Object subclass:#EditMode
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
    54
	instanceVariableNames:''
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
    55
	classVariableNames:''
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
    56
	poolDictionaries:''
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
    57
	privateIn:EditTextView
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
    58
!
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
    59
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
    60
EditTextView::EditMode subclass:#InsertAndSelectMode
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
    61
	instanceVariableNames:''
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
    62
	classVariableNames:''
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
    63
	poolDictionaries:''
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
    64
	privateIn:EditTextView::EditMode
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
    65
!
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
    66
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
    67
EditTextView::EditMode subclass:#InsertMode
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
    68
	instanceVariableNames:''
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
    69
	classVariableNames:''
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
    70
	poolDictionaries:''
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
    71
	privateIn:EditTextView::EditMode
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
    72
!
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
    73
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
    74
EditTextView::EditMode subclass:#OverwriteMode
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
    75
	instanceVariableNames:''
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
    76
	classVariableNames:'InsertMode OverwriteMode InsertAndSelectMode'
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
    77
	poolDictionaries:''
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
    78
	privateIn:EditTextView::EditMode
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
    79
!
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
    80
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
    81
EditTextView::EditAction subclass:#PasteString
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
    82
	instanceVariableNames:'line col string selected'
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
    83
	classVariableNames:''
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
    84
	poolDictionaries:''
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
    85
	privateIn:EditTextView
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
    86
!
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
    87
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
    88
EditTextView::EditAction subclass:#ReplaceCharacter
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
    89
	instanceVariableNames:'line col character'
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
    90
	classVariableNames:''
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
    91
	poolDictionaries:''
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
    92
	privateIn:EditTextView
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
    93
!
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
    94
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
    95
EditTextView::EditAction subclass:#ReplaceCharacters
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
    96
	instanceVariableNames:'line col1 col2 characters'
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
    97
	classVariableNames:''
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
    98
	poolDictionaries:''
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
    99
	privateIn:EditTextView
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
   100
!
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
   101
3131
8f21dba07d24 undoable format
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
   102
EditTextView::EditAction subclass:#ReplaceContents
8f21dba07d24 undoable format
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
   103
	instanceVariableNames:'text'
8f21dba07d24 undoable format
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
   104
	classVariableNames:''
8f21dba07d24 undoable format
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
   105
	poolDictionaries:''
8f21dba07d24 undoable format
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
   106
	privateIn:EditTextView
8f21dba07d24 undoable format
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
   107
!
8f21dba07d24 undoable format
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
   108
3130
c0f39f9f28d6 undoable keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3127
diff changeset
   109
EditTextView::EditAction subclass:#ReplaceLine
c0f39f9f28d6 undoable keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3127
diff changeset
   110
	instanceVariableNames:'line text'
c0f39f9f28d6 undoable keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3127
diff changeset
   111
	classVariableNames:''
c0f39f9f28d6 undoable keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3127
diff changeset
   112
	poolDictionaries:''
c0f39f9f28d6 undoable keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3127
diff changeset
   113
	privateIn:EditTextView
c0f39f9f28d6 undoable keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3127
diff changeset
   114
!
c0f39f9f28d6 undoable keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3127
diff changeset
   115
3402
d6545009a22b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3400
diff changeset
   116
EditTextView::EditAction subclass:#ReplaceLines
d6545009a22b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3400
diff changeset
   117
	instanceVariableNames:'line text'
d6545009a22b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3400
diff changeset
   118
	classVariableNames:''
d6545009a22b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3400
diff changeset
   119
	poolDictionaries:''
d6545009a22b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3400
diff changeset
   120
	privateIn:EditTextView
d6545009a22b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3400
diff changeset
   121
!
d6545009a22b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3400
diff changeset
   122
865
d42c7c99e67d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 840
diff changeset
   123
!EditTextView class methodsFor:'documentation'!
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   124
33
5eeef3ea8ebd added access methods for cursorLine & cursorCol
claus
parents: 25
diff changeset
   125
copyright
5eeef3ea8ebd added access methods for cursorLine & cursorCol
claus
parents: 25
diff changeset
   126
"
5eeef3ea8ebd added access methods for cursorLine & cursorCol
claus
parents: 25
diff changeset
   127
 COPYRIGHT (c) 1989 by Claus Gittinger
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   128
	      All Rights Reserved
33
5eeef3ea8ebd added access methods for cursorLine & cursorCol
claus
parents: 25
diff changeset
   129
5eeef3ea8ebd added access methods for cursorLine & cursorCol
claus
parents: 25
diff changeset
   130
 This software is furnished under a license and may be used
5eeef3ea8ebd added access methods for cursorLine & cursorCol
claus
parents: 25
diff changeset
   131
 only in accordance with the terms of that license and with the
5eeef3ea8ebd added access methods for cursorLine & cursorCol
claus
parents: 25
diff changeset
   132
 inclusion of the above copyright notice.   This software may not
5eeef3ea8ebd added access methods for cursorLine & cursorCol
claus
parents: 25
diff changeset
   133
 be provided or otherwise made available to, or used by, any
5eeef3ea8ebd added access methods for cursorLine & cursorCol
claus
parents: 25
diff changeset
   134
 other person.  No title to or ownership of the software is
5eeef3ea8ebd added access methods for cursorLine & cursorCol
claus
parents: 25
diff changeset
   135
 hereby transferred.
5eeef3ea8ebd added access methods for cursorLine & cursorCol
claus
parents: 25
diff changeset
   136
"
5eeef3ea8ebd added access methods for cursorLine & cursorCol
claus
parents: 25
diff changeset
   137
!
5eeef3ea8ebd added access methods for cursorLine & cursorCol
claus
parents: 25
diff changeset
   138
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   139
documentation
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   140
"
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   141
    a view for editable text - adds editing functionality to TextView
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   142
    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
   143
    acceptAction to be performed for accept
125
claus
parents: 123
diff changeset
   144
claus
parents: 123
diff changeset
   145
    If used with a model, this is informed by sending it a changeMsg with
claus
parents: 123
diff changeset
   146
    the current contents as argument.
297
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   147
    (however, it is possible to define both changeMsg and acceptAction)
125
claus
parents: 123
diff changeset
   148
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
   149
    Please read the historic notice in the ListView class.
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   150
586
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 567
diff changeset
   151
    [Instance variables:]
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   152
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   153
	cursorLine              <Number>        line where cursor sits (1..)
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   154
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   155
	cursorVisibleLine       <Number>        visible line where cursor sits (1..nLinesShown)
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   156
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   157
	cursorCol               <Number>        col where cursor sits (1..)
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   158
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   159
	cursorShown             <Boolean>       true, if cursor is currently shown
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   161
	readOnly                <Boolean>       true, if text may not be edited
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   162
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   163
	modifiedChannel         <ValueHolder>   holding true, if text has been modified.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   164
						cleared on accept.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   165
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   166
	acceptChannel           <ValueHolder>   holding true, if text has been accepted.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   167
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   168
	fixedSize               <Boolean>       true, if no lines may be added/removed
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   169
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   170
	exceptionBlock          <Block>         block to be evaluated when readonly text is about to be modified
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   171
						if it returns true, the modification will be done anyway.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   172
						if it returns anything else, the modification is not done.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   173
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   174
	cursorFgColor           <Color>         color used for cursor drawing
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   175
	cursorBgColor           <Color>         color used for cursor drawing
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   176
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   177
	cursorType              <Symbol>        how the cursor is drawn; currently implemented
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   178
						are #block (solid-block cursor), #ibeam
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   179
						(vertical bar at insertion point)
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   180
						and #caret (caret below insertion-point)
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   181
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   182
	cursorTypeNoFocus       <Symbol>        like above, if view has no focus
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   183
						nil means: hide the cursor.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   184
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   185
	undoAction              <Block>         block which undoes last cut, paste or replace
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   186
						(not yet fully implemented)
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   187
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   188
	typeOfSelection         <Symbol>        #paste, if selection created by paste, nil otherwise
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   189
						this affects the next keyPress: if #paste it does not
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   190
						replace; otherwise it replaces the selection.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   191
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   192
	lastCut                 <String>        last cut or replaced string
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   193
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   194
	lastReplacement         <String>        last replacement
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   195
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   196
	replacing               <Boolean>       true if entered characters replace last selection
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   197
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   198
	showMatchingParenthesis <Boolean>       if true, shows matching parenthesis
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   199
						when entering one; this is the default.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   200
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   201
	hasKeyboardFocus        <Boolean>       true if this view has the focus
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   202
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   203
	acceptAction            <Block>         accept action - evaluated passing the contents as
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   204
						argument
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   205
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   206
	tabMeansNextField       <Boolean>       if true, Tab is ignored as input and shifts keyboard
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   207
						focus to the next field. For editTextViews, this is false
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   208
						by default (i.e. tabs can be entered into the text).
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   209
						For some subclasses (inputFields), this may be true.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   210
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   211
	trimBlankLines          <Boolean>       if true, trailing blanks are
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   212
						removed when editing.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   213
						Default is true.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   214
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   215
	wordWrap                <Boolean>       Currently not used.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   216
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   217
	lockUpdates             <Boolean>       internal, private
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   218
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   219
	prevCursorState         <Boolean>       temporary, private
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   220
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   221
	cursorMovementWhenUpdating
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   222
				<Symbol>        defines where the cursor is to be positioned if the
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   223
						model changes its value by some outside activity
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   224
						(i.e. not by user input into the field).
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   225
						Can be one of:
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   226
						    #keep / nil     -> stay where it was
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   227
						    #endOfText      -> cursor to the end
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   228
						    #endOfLine      -> stay in the line, but move to end
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   229
						    #beginOfText    -> cursor to the beginning
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   230
						    #beginOfLine    -> stay in the line, but move to begin
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   231
						The default is #beginOfText
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   232
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   233
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   234
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   235
	dropTarget              <DropTarget|nil> drop operation descriptor or nil (drop disabled)
2589
62794ae04446 support drop
ca
parents: 2580
diff changeset
   236
62794ae04446 support drop
ca
parents: 2580
diff changeset
   237
2712
e83d71c9bdec ST80Mode classVariables is now UserPreferences.st80EditMode
Claus Gittinger <cg@exept.de>
parents: 2707
diff changeset
   238
    userPreference values:
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   239
	userPreferences.st80EditMode
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   240
				<Boolean>       if true, cursor positioning is
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   241
						done as in vi or ST80; i.e.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   242
						wysiwyg mode is somewhat relaxed,
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   243
						in that the cursor cannot be
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   244
						positioned behind a lines end.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   245
						This is not yet completely implemented.
33
5eeef3ea8ebd added access methods for cursorLine & cursorCol
claus
parents: 25
diff changeset
   246
    used globals:
5eeef3ea8ebd added access methods for cursorLine & cursorCol
claus
parents: 25
diff changeset
   247
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   248
	DeleteHistory           <Text>          last 1000 lines of deleted text
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   249
						(but only if this variable exists already)
586
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 567
diff changeset
   250
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 567
diff changeset
   251
    [styleSheet parameters:]
121
claus
parents: 118
diff changeset
   252
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   253
	textCursorForegroundColor <Color>          cursor fg color; default: text background
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   254
	textCursorBackgroundColor <Color>          cursor bg color; default: text foreground
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   255
	textCursorNoFocusForegroundColor
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   256
				  <Color>          cursor fg color if no focus; default: cursor fg color
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   257
	textCursorType            <Symbol>         cursor type; default:  #block
586
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 567
diff changeset
   258
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 567
diff changeset
   259
    [author:]
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   260
	Claus Gittinger
586
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 567
diff changeset
   261
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 567
diff changeset
   262
    [see also:]
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   263
	CodeView Workspace TextView ListView
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   264
	EditField
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   265
"
297
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   266
!
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   267
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   268
examples
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
  non MVC operation:
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   271
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   272
    basic setup:
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   273
									[exBegin]
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   274
	|top textView|
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   275
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   276
	top := StandardSystemView new.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   277
	top extent:300@200.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   278
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   279
	textView := EditTextView new.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   280
	textView origin:0.0 @ 0.0 corner:1.0 @ 1.0.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   281
	top addSubView:textView.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   282
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   283
	textView contents:('/etc/hosts' asFilename contentsOfEntireFile).
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   284
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   285
	top open.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   286
									[exEnd]
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   287
297
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   288
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   289
    with vertical scrollbar:
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   290
									[exBegin]
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   291
	|top scrollView textView|
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   292
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   293
	top := StandardSystemView new.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   294
	top extent:300@200.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   295
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   296
	scrollView := ScrollableView for:EditTextView.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   297
	textView := scrollView scrolledView.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   298
	scrollView origin:0.0 @ 0.0 corner:1.0 @ 1.0.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   299
	top addSubView:scrollView.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   300
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   301
	textView contents:('/etc/hosts' asFilename contentsOfEntireFile).
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   302
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   303
	top open.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   304
									[exEnd]
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   305
297
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   306
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   307
    with horizontal & vertical scrollbars:
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   308
									[exBegin]
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   309
	|top scrollView textView|
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   310
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   311
	top := StandardSystemView new.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   312
	top extent:300@200.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   313
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   314
	scrollView := HVScrollableView for:EditTextView.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   315
	textView := scrollView scrolledView.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   316
	scrollView origin:0.0 @ 0.0 corner:1.0 @ 1.0.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   317
	top addSubView:scrollView.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   318
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   319
	textView contents:('/etc/hosts' asFilename contentsOfEntireFile).
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   320
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   321
	top open.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   322
									[exEnd]
297
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   323
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   324
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   325
    set the action for accept:
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   326
									[exBegin]
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   327
	|top textView|
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   328
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   329
	top := StandardSystemView new.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   330
	top extent:300@200.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   331
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   332
	textView := EditTextView new.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   333
	textView origin:0.0 @ 0.0 corner:1.0 @ 1.0.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   334
	top addSubView:textView.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   335
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   336
	textView contents:('/etc/hosts' asFilename contentsOfEntireFile).
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   337
	textView acceptAction:[:contents |
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   338
				Transcript showCR:'will not overwrite the file with:'.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   339
				Transcript showCR:contents asString
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   340
			      ].
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   341
	top open.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   342
									[exEnd]
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   343
297
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   344
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   345
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
   346
    non-string (text) items:
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   347
									[exBegin]
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   348
	|top textView list|
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   349
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   350
	list := '/etc/hosts' asFilename contentsOfEntireFile asStringCollection.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   351
	1 to:list size by:2 do:[:nr |
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   352
	    list at:nr put:(Text string:(list at:nr)
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   353
				 emphasis:(Array with:#bold with:(#color->Color red)))
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   354
	].
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   355
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   356
	top := StandardSystemView new.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   357
	top extent:300@200.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   358
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   359
	textView := EditTextView new.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   360
	textView origin:0.0 @ 0.0 corner:1.0 @ 1.0.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   361
	top addSubView:textView.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   362
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   363
	textView contents:list.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   364
	top open.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   365
									[exEnd]
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
   366
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
   367
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
   368
297
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   369
  MVC operation:
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   370
    (the examples model here is a plug simulating a real model;
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   371
     real world applications would not use a plug ..)
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   372
									[exBegin]
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   373
	|top textView model|
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   374
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   375
	model := Plug new.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   376
	model respondTo:#accepted:
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   377
		   with:[:newContents |
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   378
				Transcript showCR:'will not overwrite the file with:'.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   379
				Transcript showCR:newContents asString
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   380
			].
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   381
	model respondTo:#getList
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   382
		   with:['/etc/hosts' asFilename contentsOfEntireFile].
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   383
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   384
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   385
	top := StandardSystemView new.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   386
	top extent:300@200.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   387
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   388
	textView := EditTextView new.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   389
	textView origin:0.0 @ 0.0 corner:1.0 @ 1.0.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   390
	top addSubView:textView.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   391
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   392
	textView listMessage:#getList;
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   393
		 model:model;
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   394
		 changeMessage:#accepted:;
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   395
		 aspect:#list.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   396
	top open.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   397
									[exEnd]
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   398
297
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   399
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   400
    two textViews on the same model:
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   401
									[exBegin]
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   402
	|top1 textView1 top2 textView2 model currentContents|
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   403
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   404
	model := Plug new.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   405
	model respondTo:#accepted:
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   406
		   with:[:newContents |
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   407
				Transcript showCR:'accepted:'.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   408
				Transcript showCR:newContents asString.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   409
				currentContents := newContents.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   410
				model changed:#contents
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   411
			].
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   412
	model respondTo:#getList
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   413
		   with:[Transcript showCR:'query'.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   414
			 currentContents].
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   415
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   416
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   417
	top1 := StandardSystemView new.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   418
	top1 extent:300@200.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   419
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   420
	textView1 := EditTextView new.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   421
	textView1 origin:0.0 @ 0.0 corner:1.0 @ 1.0.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   422
	top1 addSubView:textView1.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   423
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   424
	textView1 listMessage:#getList;
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   425
		  model:model;
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   426
		  aspect:#contents;
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   427
		  changeMessage:#accepted:.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   428
	top1 open.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   429
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   430
	top2 := StandardSystemView new.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   431
	top2 extent:300@200.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   432
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   433
	textView2 := EditTextView new.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   434
	textView2 origin:0.0 @ 0.0 corner:1.0 @ 1.0.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   435
	top2 addSubView:textView2.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   436
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   437
	textView2 listMessage:#getList;
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   438
		  model:model;
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   439
		  aspect:#contents;
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   440
		  changeMessage:#accepted:.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   441
	top2 open.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   442
									[exEnd]
297
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   443
"
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   444
! !
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   445
865
d42c7c99e67d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 840
diff changeset
   446
!EditTextView class methodsFor:'defaults'!
59
450ce95a72a4 *** empty log message ***
claus
parents: 46
diff changeset
   447
1419
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   448
st80Mode
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   449
    "return true, if the st80 editing mode is turned on.
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   450
     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
   451
     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
   452
2647
23dca8f032c3 changed st80Mode from classVar to userPreferences value
Claus Gittinger <cg@exept.de>
parents: 2627
diff changeset
   453
    ^ UserPreferences current st80EditMode
1419
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   454
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   455
   "
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   456
    EditTextView st80Mode:true
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   457
    EditTextView st80Mode:false
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   458
   "
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   459
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   460
    "Modified: / 16.1.1998 / 22:54:57 / cg"
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   461
!
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   462
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   463
st80Mode:aBoolean
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   464
    "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
   465
     beyond the end of a line or the last line"
1419
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   466
2647
23dca8f032c3 changed st80Mode from classVar to userPreferences value
Claus Gittinger <cg@exept.de>
parents: 2627
diff changeset
   467
    UserPreferences current st80EditMode:aBoolean.
1419
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   468
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   469
   "
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   470
    EditTextView st80Mode:true
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   471
    EditTextView st80Mode:false
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   472
   "
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   473
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   474
    "Modified: / 16.1.1998 / 22:55:19 / cg"
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   475
!
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   476
59
450ce95a72a4 *** empty log message ***
claus
parents: 46
diff changeset
   477
updateStyleCache
440
2beb33cb0146 added style resource directive
Claus Gittinger <cg@exept.de>
parents: 428
diff changeset
   478
    "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
   479
1390
99674e1d9c85 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
   480
    <resource: #style (#'textCursor.foregroundColor' #'textCursor.backgroundColor'
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   481
		       #'textCursor.noFocusForegroundColor'
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   482
		       #'textCursor.type'
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   483
		       #'textCursor.typeNoFocus'
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   484
		       #'editText.st80Mode')>
1355
6725ab9cc6f5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
   485
6725ab9cc6f5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
   486
    DefaultCursorForegroundColor := StyleSheet colorAt:'textCursor.foregroundColor'.
6725ab9cc6f5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
   487
    DefaultCursorBackgroundColor := StyleSheet colorAt:'textCursor.backgroundColor'.
6725ab9cc6f5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
   488
    DefaultCursorNoFocusForegroundColor := StyleSheet colorAt:'textCursor.noFocusForegroundColor'.
6725ab9cc6f5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
   489
    DefaultCursorType := StyleSheet at:'textCursor.type' default:#block.
1534
bcb211e1b41a read noFocus cursorStyle from styleSheet
Claus Gittinger <cg@exept.de>
parents: 1533
diff changeset
   490
    DefaultCursorTypeNoFocus := StyleSheet at:'textCursor.typeNoFocus'.
bcb211e1b41a read noFocus cursorStyle from styleSheet
Claus Gittinger <cg@exept.de>
parents: 1533
diff changeset
   491
1419
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   492
    "
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   493
     self updateStyleCache
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   494
    "
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   495
1534
bcb211e1b41a read noFocus cursorStyle from styleSheet
Claus Gittinger <cg@exept.de>
parents: 1533
diff changeset
   496
    "Modified: / 20.5.1998 / 04:27:41 / cg"
59
450ce95a72a4 *** empty log message ***
claus
parents: 46
diff changeset
   497
! !
450ce95a72a4 *** empty log message ***
claus
parents: 46
diff changeset
   498
3431
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   499
!EditTextView class methodsFor:'specs'!
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   500
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   501
searchReplaceDialogSpec
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   502
    "This resource specification was automatically generated
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   503
     by the UIPainter of ST/X."
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   504
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   505
    "Do not manually edit this!! If it is corrupted,
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   506
     the UIPainter may not be able to read the specification."
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   507
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   508
    "
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   509
     UIPainter new openOnClass:DAPASX::ProjectEditorTextView andSelector:#searchReplaceDialogSpec
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   510
    "
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   511
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   512
    <resource: #canvas>
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   513
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   514
    ^ 
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   515
     #(FullSpec
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   516
        name: searchReplaceDialogSpec
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   517
        window: 
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   518
       (WindowSpec
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   519
          label: 'String Search and Replace'
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   520
          name: 'String Search and Replace'
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   521
          min: (Point 283 196)
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   522
          max: (Point 283 196)
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   523
          bounds: (Rectangle 0 0 279 192)
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   524
        )
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   525
        component: 
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   526
       (SpecCollection
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   527
          collection: (
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   528
           (LabelSpec
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   529
              label: 'Search Pattern:'
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   530
              name: 'label'
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   531
              layout: (LayoutFrame 1 0.0 3 0 -1 1.0 20 0)
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   532
              level: 0
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   533
              translateLabel: true
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   534
              adjust: left
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   535
            )
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   536
           (ComboBoxSpec
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   537
              name: 'patternComboBox'
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   538
              layout: (LayoutFrame 3 0.0 26 0 -3 1.0 48 0)
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   539
              tabable: true
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   540
              model: searchPattern
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   541
              immediateAccept: false
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   542
              acceptOnLeave: true
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   543
              acceptOnReturn: true
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   544
              acceptOnTab: true
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   545
              acceptOnLostFocus: true
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   546
              acceptOnPointerLeave: false
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   547
              autoSelectInitialText: true
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   548
              comboList: patternList
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   549
            )
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   550
           (ComboBoxSpec
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   551
              name: 'replaceComboBox'
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   552
              layout: (LayoutFrame 3 0.0 76 0 -3 1.0 98 0)
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   553
              tabable: true
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   554
              model: replacePattern
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   555
              immediateAccept: false
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   556
              acceptOnLeave: true
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   557
              acceptOnReturn: true
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   558
              acceptOnTab: true
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   559
              acceptOnLostFocus: true
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   560
              acceptOnPointerLeave: false
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   561
              autoSelectInitialText: true
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   562
              comboList: patternList
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   563
            )
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   564
           (CheckBoxSpec
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   565
              label: 'Ignore Case'
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   566
              name: 'ignoreCaseCheckBox'
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   567
              layout: (LayoutFrame 3 0.0 107 0 -3 1.0 130 0)
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   568
              level: 0
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   569
              tabable: true
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   570
              model: ignoreCase
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   571
              translateLabel: true
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   572
            )
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   573
           (VariableVerticalPanelSpec
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   574
              name: 'VariableVerticalPanel1'
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   575
              layout: (LayoutFrame 0 0 -64 1 0 1 -4 1)
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   576
              component: 
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   577
             (SpecCollection
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   578
                collection: (
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   579
                 (HorizontalPanelViewSpec
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   580
                    name: 'HorizontalPanel1'
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   581
                    level: 0
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   582
                    horizontalLayout: fitSpace
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   583
                    verticalLayout: center
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   584
                    horizontalSpace: 3
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   585
                    verticalSpace: 3
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   586
                    ignoreInvisibleComponents: true
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   587
                    reverseOrderIfOKAtLeft: true
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   588
                    component: 
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   589
                   (SpecCollection
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   590
                      collection: (
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   591
                       (ActionButtonSpec
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   592
                          label: 'Replace'
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   593
                          name: 'replaceButton'
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   594
                          level: 2
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   595
                          translateLabel: true
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   596
                          tabable: true
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   597
                          model: replaceAction
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   598
                          extent: (Point 134 21)
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   599
                        )
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   600
                       (ActionButtonSpec
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   601
                          label: 'Replace All'
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   602
                          name: 'replaceAllButton'
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   603
                          level: 2
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   604
                          borderWidth: 1
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   605
                          translateLabel: true
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   606
                          tabable: true
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   607
                          model: replaceAllAction
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   608
                          extent: (Point 134 21)
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   609
                        )
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   610
                       )
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   611
                     
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   612
                    )
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   613
                  )
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   614
                 (HorizontalPanelViewSpec
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   615
                    name: 'horizontalPanelView'
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   616
                    level: 0
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   617
                    horizontalLayout: fitSpace
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   618
                    verticalLayout: center
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   619
                    horizontalSpace: 3
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   620
                    verticalSpace: 3
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   621
                    ignoreInvisibleComponents: true
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   622
                    reverseOrderIfOKAtLeft: true
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   623
                    component: 
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   624
                   (SpecCollection
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   625
                      collection: (
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   626
                       (ActionButtonSpec
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   627
                          label: 'Cancel'
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   628
                          name: 'cancelButton'
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   629
                          level: 2
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   630
                          translateLabel: true
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   631
                          tabable: true
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   632
                          model: cancel
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   633
                          extent: (Point 88 21)
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   634
                        )
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   635
                       (ActionButtonSpec
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   636
                          label: 'Prev'
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   637
                          name: 'prevButton'
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   638
                          level: 2
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   639
                          translateLabel: true
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   640
                          tabable: true
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   641
                          model: prevAction
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   642
                          extent: (Point 89 21)
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   643
                        )
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   644
                       (ActionButtonSpec
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   645
                          label: 'Next'
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   646
                          name: 'nextButton'
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   647
                          level: 2
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   648
                          borderWidth: 1
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   649
                          translateLabel: true
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   650
                          tabable: true
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   651
                          model: nextAction
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   652
                          isDefault: true
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   653
                          extent: (Point 88 21)
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   654
                        )
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   655
                       )
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   656
                     
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   657
                    )
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   658
                  )
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   659
                 )
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   660
               
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   661
              )
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   662
              handles: (Any 0.5 1.0)
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   663
            )
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   664
           (LabelSpec
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   665
              label: 'Replace By:'
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   666
              name: 'ReplaceLabel'
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   667
              layout: (LayoutFrame 1 0.0 53 0 -1 1.0 70 0)
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   668
              level: 0
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   669
              translateLabel: true
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   670
              adjust: left
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   671
            )
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   672
           )
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   673
         
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   674
        )
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   675
      )
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   676
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   677
    "Modified: / 11-10-2006 / 21:05:09 / cg"
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   678
! !
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   679
2744
cb920467a4b4 method category rename
Claus Gittinger <cg@exept.de>
parents: 2730
diff changeset
   680
!EditTextView methodsFor:'Compatibility-ST80'!
1552
d3d4afaf4c68 dummy ST80 compatibility: #autoAccept:
Claus Gittinger <cg@exept.de>
parents: 1548
diff changeset
   681
d3d4afaf4c68 dummy ST80 compatibility: #autoAccept:
Claus Gittinger <cg@exept.de>
parents: 1548
diff changeset
   682
autoAccept:aBoolean
d3d4afaf4c68 dummy ST80 compatibility: #autoAccept:
Claus Gittinger <cg@exept.de>
parents: 1548
diff changeset
   683
    "ignored for now"
d3d4afaf4c68 dummy ST80 compatibility: #autoAccept:
Claus Gittinger <cg@exept.de>
parents: 1548
diff changeset
   684
2019
b6b078ea3bbf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2018
diff changeset
   685
    "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
   686
!
9bf6cf249376 two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents: 1580
diff changeset
   687
9bf6cf249376 two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents: 1580
diff changeset
   688
continuousAccept:aBoolean
9bf6cf249376 two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents: 1580
diff changeset
   689
    "ignored for now"
9bf6cf249376 two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents: 1580
diff changeset
   690
9bf6cf249376 two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents: 1580
diff changeset
   691
    "Created: / 19.6.1998 / 00:03:49 / cg"
9bf6cf249376 two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents: 1580
diff changeset
   692
!
9bf6cf249376 two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents: 1580
diff changeset
   693
1390
99674e1d9c85 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
   694
cutSelection
99674e1d9c85 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
   695
    self cut
99674e1d9c85 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
   696
99674e1d9c85 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
   697
    "Created: / 31.10.1997 / 03:29:50 / cg"
99674e1d9c85 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
   698
!
99674e1d9c85 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
   699
1590
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   700
deselect
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   701
    "remove the selection"
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   702
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   703
    ^ self unselect
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   704
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   705
    "Created: / 19.6.1998 / 02:41:54 / cg"
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   706
!
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   707
2101
8f2fab818f71 category renamining
Claus Gittinger <cg@exept.de>
parents: 2088
diff changeset
   708
enabled:aBoolean
8f2fab818f71 category renamining
Claus Gittinger <cg@exept.de>
parents: 2088
diff changeset
   709
8f2fab818f71 category renamining
Claus Gittinger <cg@exept.de>
parents: 2088
diff changeset
   710
    self readOnly:aBoolean not
8f2fab818f71 category renamining
Claus Gittinger <cg@exept.de>
parents: 2088
diff changeset
   711
8f2fab818f71 category renamining
Claus Gittinger <cg@exept.de>
parents: 2088
diff changeset
   712
    "Created: / 30.3.1999 / 15:10:23 / stefan"
8f2fab818f71 category renamining
Claus Gittinger <cg@exept.de>
parents: 2088
diff changeset
   713
    "Modified: / 30.3.1999 / 15:10:53 / stefan"
8f2fab818f71 category renamining
Claus Gittinger <cg@exept.de>
parents: 2088
diff changeset
   714
!
8f2fab818f71 category renamining
Claus Gittinger <cg@exept.de>
parents: 2088
diff changeset
   715
1732
2d433e114bbc added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 1717
diff changeset
   716
find:pattern
2d433e114bbc added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 1717
diff changeset
   717
    self searchFwd:pattern ifAbsent:nil
2d433e114bbc added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 1717
diff changeset
   718
2d433e114bbc added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 1717
diff changeset
   719
    "Created: / 29.1.1999 / 19:09:42 / cg"
2d433e114bbc added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 1717
diff changeset
   720
    "Modified: / 29.1.1999 / 19:10:12 / cg"
2d433e114bbc added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 1717
diff changeset
   721
!
2d433e114bbc added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 1717
diff changeset
   722
1294
dac755d4acd3 added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   723
insert:aString at:aCharacterPosition
dac755d4acd3 added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   724
    "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
   725
dac755d4acd3 added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   726
    |line col|
dac755d4acd3 added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   727
dac755d4acd3 added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   728
    line := self lineOfCharacterPosition:aCharacterPosition.
dac755d4acd3 added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   729
    col := aCharacterPosition - (self characterPositionOfLine:line col:1) + 1.
1480
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
   730
    col < 1 ifTrue:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   731
	col := 1
1480
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
   732
    ].
1294
dac755d4acd3 added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   733
    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
   734
dac755d4acd3 added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   735
    "
dac755d4acd3 added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   736
     |top v|
dac755d4acd3 added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   737
dac755d4acd3 added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   738
     top := StandardSystemView new.
dac755d4acd3 added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   739
     top extent:300@300.
dac755d4acd3 added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   740
     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
   741
     top openAndWait.
dac755d4acd3 added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   742
     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
   743
     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
   744
    "
dac755d4acd3 added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   745
1480
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
   746
    "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
   747
!
dac755d4acd3 added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   748
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   749
insertAndSelect:aString at:aCharacterPosition
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   750
    "insert a selected string at aCharacterPosition."
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   751
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   752
    |line col|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   753
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   754
    line := self lineOfCharacterPosition:aCharacterPosition.
2310
861ab02b13b9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2225
diff changeset
   755
    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
   756
    self insertString:aString atLine:line col:col.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   757
    self selectFromLine:line col:col toLine:line col:col + aString size - 1
125
claus
parents: 123
diff changeset
   758
    "
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   759
     |v|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   760
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   761
     v := EditTextView new openAndWait.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   762
     v contents:'1234567890\1234567890\1234567890\' withCRs.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   763
     v insertAndSelect:'<- hello there' at:5.
125
claus
parents: 123
diff changeset
   764
    "
1390
99674e1d9c85 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
   765
!
99674e1d9c85 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
   766
99674e1d9c85 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
   767
pasteSelection
99674e1d9c85 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
   768
    self paste
99674e1d9c85 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
   769
99674e1d9c85 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
   770
    "Created: / 31.10.1997 / 03:28:53 / cg"
1590
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   771
!
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   772
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   773
replaceSelectionWith:aString
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   774
    ^ self replaceSelectionBy:aString
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   775
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   776
    "Created: / 19.6.1998 / 02:42:32 / cg"
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   777
!
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   778
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   779
selectAt:pos
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   780
    "move the cursor before cursorPosition."
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   781
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   782
    self cursorToCharacterPosition:pos
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   783
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   784
    "Modified: / 19.6.1998 / 02:41:28 / cg"
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   785
    "Created: / 19.6.1998 / 02:43:39 / cg"
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   786
!
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   787
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   788
selectFrom:startPos to:endPos
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   789
    "change the selection given two aCharacterPositions."
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   790
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   791
    |line1 col1 line2 col2|
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   792
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   793
    startPos > endPos ifTrue:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   794
	^ self unselect
1590
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   795
    ].
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   796
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   797
    line1 := self lineOfCharacterPosition:startPos.
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   798
    col1 := startPos - (self characterPositionOfLine:line1 col:1) + 1.
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   799
    col1 < 1 ifTrue:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   800
	col1 := 1
1590
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   801
    ].
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   802
    line2 := self lineOfCharacterPosition:endPos.
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   803
    col2 := startPos - (self characterPositionOfLine:line2 col:1) + 1.
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   804
    col2 < 1 ifTrue:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   805
	col2 := 1
1590
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   806
    ].
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   807
    self selectFromLine:line1 col:col1 toLine:line2 col:col2
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   808
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   809
    "Modified: / 19.6.1998 / 02:41:28 / cg"
2101
8f2fab818f71 category renamining
Claus Gittinger <cg@exept.de>
parents: 2088
diff changeset
   810
!
8f2fab818f71 category renamining
Claus Gittinger <cg@exept.de>
parents: 2088
diff changeset
   811
8f2fab818f71 category renamining
Claus Gittinger <cg@exept.de>
parents: 2088
diff changeset
   812
textHasChanged
8f2fab818f71 category renamining
Claus Gittinger <cg@exept.de>
parents: 2088
diff changeset
   813
    ^ self modified
8f2fab818f71 category renamining
Claus Gittinger <cg@exept.de>
parents: 2088
diff changeset
   814
8f2fab818f71 category renamining
Claus Gittinger <cg@exept.de>
parents: 2088
diff changeset
   815
    "Created: / 19.6.1998 / 00:09:43 / cg"
2117
b50c6d182e28 added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 2107
diff changeset
   816
!
b50c6d182e28 added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 2107
diff changeset
   817
b50c6d182e28 added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 2107
diff changeset
   818
textHasChanged:aBoolean
b50c6d182e28 added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 2107
diff changeset
   819
    "ST-80 compatibility: set/clear the modified flag."
b50c6d182e28 added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 2107
diff changeset
   820
b50c6d182e28 added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 2107
diff changeset
   821
    self modified:aBoolean
b50c6d182e28 added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 2107
diff changeset
   822
b50c6d182e28 added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 2107
diff changeset
   823
    "Created: / 5.2.2000 / 17:07:59 / cg"
259
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
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   826
!EditTextView methodsFor:'accessing-behavior'!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   827
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   828
acceptAction
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   829
    "return the action to be performed on accept (or nil)"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   830
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   831
    ^ acceptAction
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   832
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   833
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   834
acceptAction:aBlock
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   835
    "set the action to be performed on accept"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   836
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   837
    acceptAction := aBlock
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   838
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   839
2792
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   840
acceptChannel
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   841
    "return the valueHolder holding true if text was accepted.
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   842
     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
   843
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   844
    ^ acceptChannel
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   845
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   846
    "Modified: / 30.1.1998 / 14:17:11 / cg"
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   847
!
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   848
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   849
acceptChannel:aValueHolder
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   850
    "set the valueHolder holding true if text was accepted.
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   851
     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
   852
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   853
    |prev|
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   854
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   855
    prev := acceptChannel.
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   856
    acceptChannel := aValueHolder.
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   857
    self setupChannel:aValueHolder for:nil withOld:prev
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   858
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   859
    "Created: / 30.1.1998 / 14:51:09 / cg"
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   860
!
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   861
1108
3d14bb6bceb7 added disableAccept
Claus Gittinger <cg@exept.de>
parents: 1082
diff changeset
   862
acceptEnabled:aBoolean
3d14bb6bceb7 added disableAccept
Claus Gittinger <cg@exept.de>
parents: 1082
diff changeset
   863
    "enable/disable accept. This greys the corresponding item in the menu"
3d14bb6bceb7 added disableAccept
Claus Gittinger <cg@exept.de>
parents: 1082
diff changeset
   864
3d14bb6bceb7 added disableAccept
Claus Gittinger <cg@exept.de>
parents: 1082
diff changeset
   865
    acceptEnabled := aBoolean
3d14bb6bceb7 added disableAccept
Claus Gittinger <cg@exept.de>
parents: 1082
diff changeset
   866
3d14bb6bceb7 added disableAccept
Claus Gittinger <cg@exept.de>
parents: 1082
diff changeset
   867
    "Created: 7.3.1997 / 11:04:34 / cg"
3d14bb6bceb7 added disableAccept
Claus Gittinger <cg@exept.de>
parents: 1082
diff changeset
   868
!
3d14bb6bceb7 added disableAccept
Claus Gittinger <cg@exept.de>
parents: 1082
diff changeset
   869
2792
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   870
accepted
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   871
    "return true if text was accepted"
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   872
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   873
    ^ acceptChannel value
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   874
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   875
    "Created: 14.2.1997 / 16:43:46 / cg"
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   876
!
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   877
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   878
accepted:aBoolean
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   879
    "set/clear the accepted flag.
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   880
     This may force my current contents to be placed into my model."
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   881
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   882
    acceptChannel value:aBoolean.
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   883
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   884
    "Created: / 14.2.1997 / 16:44:01 / cg"
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   885
    "Modified: / 30.1.1998 / 14:20:15 / cg"
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   886
!
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   887
474
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   888
autoIndent:aBoolean
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   889
    autoIndent := aBoolean
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   890
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   891
    "Created: 5.3.1996 / 14:37:50 / cg"
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   892
!
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   893
2774
0415ba0f8cb5 cursorMovement getter
penk
parents: 2762
diff changeset
   894
cursorMovementWhenUpdating
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   895
    "return what is be done with the cursor,
2774
0415ba0f8cb5 cursorMovement getter
penk
parents: 2762
diff changeset
   896
     when I get a new text (via the model or the #contents/#list)
0415ba0f8cb5 cursorMovement getter
penk
parents: 2762
diff changeset
   897
     Allowed arguments are:
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   898
	#keep / nil     -> stay where it was
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   899
	#endOfText      -> position cursor to the end
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   900
	#beginOfText    -> position cursor to the beginning
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   901
	#endOfLine      -> position cursor to the current lines end
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   902
	#beginOfLine    -> position cursor to the current lines start
2774
0415ba0f8cb5 cursorMovement getter
penk
parents: 2762
diff changeset
   903
     The default is #beginOfText.
0415ba0f8cb5 cursorMovement getter
penk
parents: 2762
diff changeset
   904
     This may be useful for fields which get new values assigned from
0415ba0f8cb5 cursorMovement getter
penk
parents: 2762
diff changeset
   905
     the program (i.e. not from the user)"
0415ba0f8cb5 cursorMovement getter
penk
parents: 2762
diff changeset
   906
0415ba0f8cb5 cursorMovement getter
penk
parents: 2762
diff changeset
   907
    ^ cursorMovementWhenUpdating
0415ba0f8cb5 cursorMovement getter
penk
parents: 2762
diff changeset
   908
0415ba0f8cb5 cursorMovement getter
penk
parents: 2762
diff changeset
   909
    "Modified: 16.12.1995 / 16:27:55 / cg"
0415ba0f8cb5 cursorMovement getter
penk
parents: 2762
diff changeset
   910
!
0415ba0f8cb5 cursorMovement getter
penk
parents: 2762
diff changeset
   911
2133
47a23fdfc83f comment
Claus Gittinger <cg@exept.de>
parents: 2131
diff changeset
   912
cursorMovementWhenUpdating:aSymbolOrNil
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   913
    "define what should be done with the cursor,
2133
47a23fdfc83f comment
Claus Gittinger <cg@exept.de>
parents: 2131
diff changeset
   914
     when I get a new text (via the model or the #contents/#list)
47a23fdfc83f comment
Claus Gittinger <cg@exept.de>
parents: 2131
diff changeset
   915
     Allowed arguments are:
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   916
	#keep / nil     -> stay where it was
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   917
	#endOfText      -> position cursor to the end
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   918
	#beginOfText    -> position cursor to the beginning
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   919
	#endOfLine      -> position cursor to the current lines end
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   920
	#beginOfLine    -> position cursor to the current lines start
2133
47a23fdfc83f comment
Claus Gittinger <cg@exept.de>
parents: 2131
diff changeset
   921
     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
   922
     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
   923
     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
   924
2133
47a23fdfc83f comment
Claus Gittinger <cg@exept.de>
parents: 2131
diff changeset
   925
    cursorMovementWhenUpdating := aSymbolOrNil
2129
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   926
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   927
    "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
   928
!
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
   929
2035
6924861adf08 added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents: 2029
diff changeset
   930
disableIfInvisible:aBoolean
6924861adf08 added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents: 2029
diff changeset
   931
    disableIfInvisible := aBoolean
6924861adf08 added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents: 2029
diff changeset
   932
!
6924861adf08 added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents: 2029
diff changeset
   933
2438
6406f4444ee4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2432
diff changeset
   934
dontReplaceSelectionOnInput
6406f4444ee4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2432
diff changeset
   935
    typeOfSelection := #paste
6406f4444ee4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2432
diff changeset
   936
!
6406f4444ee4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2432
diff changeset
   937
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
   938
editModeHolder
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
   939
    ^ editMode.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
   940
!
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
   941
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
   942
editModeInsert
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
   943
    editMode value:EditMode insertMode
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
   944
!
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
   945
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
   946
editModeInsertAndSelect
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
   947
    editMode value:EditMode insertAndSelectMode
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
   948
!
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
   949
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
   950
editModeOverwrite
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
   951
    editMode value:EditMode overwriteMode
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
   952
!
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
   953
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   954
exceptionBlock:aBlock
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   955
    "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
   956
     readonly text"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   957
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   958
    exceptionBlock := aBlock
323
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   959
!
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   960
3296
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
   961
fixedSize
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
   962
    "make the texts size fixed (no lines may be added).
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
   963
     OBSOLETE: use readOnly"
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
   964
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
   965
    <resource:#obsolete>
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
   966
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
   967
    self obsoleteMethodWarning:'use #readOnly:'.
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
   968
    readOnly == true ifFalse:[
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
   969
	readOnly := true.
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
   970
	middleButtonMenu notNil ifTrue:[
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
   971
	    middleButtonMenu disableAll:#(cut paste replace indent)
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
   972
	]
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
   973
    ]
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
   974
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
   975
    "Modified: 14.2.1997 / 17:35:24 / cg"
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
   976
!
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
   977
477
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
   978
insertMode:aBoolean
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
   979
    editMode value:(aBoolean ifTrue:[EditMode insertMode] ifFalse:[EditMode overwriteMode])
477
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
   980
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
   981
    "Created: 6.3.1996 / 12:24:05 / cg"
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
   982
!
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
   983
2795
1f7b5f242eee learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents: 2792
diff changeset
   984
insertModeHolder
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
   985
    ^ BlockValue
3465
a6eb20608b1f BlockValue usage cleanup
Claus Gittinger <cg@exept.de>
parents: 3439
diff changeset
   986
        with:[:m | m isInsertMode] 
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
   987
        argument:(editMode).
3465
a6eb20608b1f BlockValue usage cleanup
Claus Gittinger <cg@exept.de>
parents: 3439
diff changeset
   988
a6eb20608b1f BlockValue usage cleanup
Claus Gittinger <cg@exept.de>
parents: 3439
diff changeset
   989
    "Modified: / 08-03-2007 / 22:58:37 / cg"
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
   990
!
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
   991
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
   992
isInInsertMode 
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
   993
    ^ editMode value isInsertMode
2795
1f7b5f242eee learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents: 2792
diff changeset
   994
!
1f7b5f242eee learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents: 2792
diff changeset
   995
2792
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   996
isReadOnly
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   997
    "return true, if the text is readonly."
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   998
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   999
    ^ readOnly value
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1000
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1001
    "Modified: 14.2.1997 / 17:35:56 / cg"
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1002
!
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1003
2796
481d9e54434c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2795
diff changeset
  1004
modeLabelHolder
481d9e54434c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2795
diff changeset
  1005
    "a valueHolder, which contains 'L' (learnMode), I (insertMode) or empty"
481d9e54434c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2795
diff changeset
  1006
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1007
    ^ BlockValue
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  1008
        with:[:e :l |
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  1009
            self isReadOnly ifTrue:[
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  1010
                ''
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  1011
            ] ifFalse:[
3465
a6eb20608b1f BlockValue usage cleanup
Claus Gittinger <cg@exept.de>
parents: 3439
diff changeset
  1012
                l ifTrue:[ 'L' asText allBold colorizeAllWith:Color red]
a6eb20608b1f BlockValue usage cleanup
Claus Gittinger <cg@exept.de>
parents: 3439
diff changeset
  1013
                  ifFalse:[ e infoPrintString]]]
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  1014
        argument:(self editModeHolder)
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  1015
        argument:(self learnModeHolder).
3465
a6eb20608b1f BlockValue usage cleanup
Claus Gittinger <cg@exept.de>
parents: 3439
diff changeset
  1016
a6eb20608b1f BlockValue usage cleanup
Claus Gittinger <cg@exept.de>
parents: 3439
diff changeset
  1017
    "Modified: / 08-03-2007 / 22:58:59 / cg"
2796
481d9e54434c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2795
diff changeset
  1018
!
481d9e54434c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2795
diff changeset
  1019
2792
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1020
modified
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1021
    "return true if text was modified"
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1022
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1023
    ^ modifiedChannel value
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1024
!
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1025
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1026
modified:aBoolean
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1027
    "set/clear the modified flag"
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1028
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1029
    modifiedChannel value:aBoolean
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1030
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1031
    "Modified: 14.2.1997 / 16:44:05 / cg"
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1032
!
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1033
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1034
modifiedChannel
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1035
    "return the valueHolder holding true if text was modified"
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1036
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1037
    ^ modifiedChannel
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1038
!
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1039
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1040
modifiedChannel:aValueHolder
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1041
    "set the valueHolder holding true if text was modified"
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1042
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1043
    |prev|
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1044
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1045
    prev := modifiedChannel.
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1046
    modifiedChannel := aValueHolder.
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1047
    self setupChannel:aValueHolder for:nil withOld:prev
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1048
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1049
    "Created: / 30.1.1998 / 14:51:32 / cg"
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1050
!
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1051
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1052
readOnly
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1053
    "make the text readonly.
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1054
     Somewhat obsolete - use #readOnly:"
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1055
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1056
    <resource:#obsolete>
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1057
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1058
    self obsoleteMethodWarning:'use #readOnly:'.
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1059
    readOnly := true
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1060
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1061
    "Modified: 14.2.1997 / 17:35:56 / cg"
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1062
!
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1063
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1064
readOnly:aBoolean
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1065
    "make the text readonly (aBoolean == true) or writable (aBoolean == false).
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1066
     The argument may also be a valueHolder."
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1067
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1068
    readOnly := aBoolean
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1069
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1070
    "Created: 14.2.1997 / 17:35:39 / cg"
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1071
!
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1072
323
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
  1073
tabMeansNextField:aBoolean
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
  1074
    "set/clear tabbing to the next field.
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
  1075
     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
  1076
     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
  1077
     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
  1078
     input fields."
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
  1079
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
  1080
    tabMeansNextField := aBoolean
2779
5ca530482fdd unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 2774
diff changeset
  1081
!
5ca530482fdd unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 2774
diff changeset
  1082
5ca530482fdd unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 2774
diff changeset
  1083
tabRequiresControl
5ca530482fdd unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 2774
diff changeset
  1084
    "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
  1085
     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
  1086
     to allow for easier text entry"
5ca530482fdd unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 2774
diff changeset
  1087
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1088
    ^ tabRequiresControl
2779
5ca530482fdd unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 2774
diff changeset
  1089
!
5ca530482fdd unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 2774
diff changeset
  1090
5ca530482fdd unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 2774
diff changeset
  1091
tabRequiresControl:aBoolean
5ca530482fdd unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 2774
diff changeset
  1092
    "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
  1093
     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
  1094
     to allow for easier text entry"
5ca530482fdd unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 2774
diff changeset
  1095
5ca530482fdd unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 2774
diff changeset
  1096
    tabRequiresControl := aBoolean
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1097
! !
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1098
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1099
!EditTextView methodsFor:'accessing-contents'!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1100
1902
302a68c2255e added #at:basicPut: to access a line without change notification.
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
  1101
at:lineNr basicPut:aLine
302a68c2255e added #at:basicPut: to access a line without change notification.
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
  1102
    "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
  1103
302a68c2255e added #at:basicPut: to access a line without change notification.
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
  1104
    (self at:lineNr) = aLine ifFalse:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1105
	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
  1106
    ].
302a68c2255e added #at:basicPut: to access a line without change notification.
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
  1107
!
302a68c2255e added #at:basicPut: to access a line without change notification.
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
  1108
522
aa9458e4643e indent/undent did not trigger a modify
ca
parents: 503
diff changeset
  1109
at:lineNr put:aLine
aa9458e4643e indent/undent did not trigger a modify
ca
parents: 503
diff changeset
  1110
    (self at:lineNr) = aLine ifFalse:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1111
	super at:lineNr put:aLine.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1112
	self textChanged
522
aa9458e4643e indent/undent did not trigger a modify
ca
parents: 503
diff changeset
  1113
    ].
aa9458e4643e indent/undent did not trigger a modify
ca
parents: 503
diff changeset
  1114
!
aa9458e4643e indent/undent did not trigger a modify
ca
parents: 503
diff changeset
  1115
1577
4e487247ad33 dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents: 1568
diff changeset
  1116
characterBeforeCursor
2707
810c994db0b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2696
diff changeset
  1117
    "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
  1118
     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
  1119
     of the insertion-bar or caret."
4e487247ad33 dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents: 1568
diff changeset
  1120
4e487247ad33 dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents: 1568
diff changeset
  1121
    cursorCol == 1 ifTrue:[^ nil].
4e487247ad33 dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents: 1568
diff changeset
  1122
4e487247ad33 dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents: 1568
diff changeset
  1123
    ^ self characterAtLine:cursorLine col:cursorCol-1
4e487247ad33 dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents: 1568
diff changeset
  1124
4e487247ad33 dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents: 1568
diff changeset
  1125
    "Created: / 17.6.1998 / 15:16:41 / cg"
4e487247ad33 dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents: 1568
diff changeset
  1126
!
4e487247ad33 dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents: 1568
diff changeset
  1127
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1128
characterUnderCursor
2707
810c994db0b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2696
diff changeset
  1129
    "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
  1130
     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
  1131
     of the insertion-bar or caret."
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1132
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1133
    ^ self characterAtLine:cursorLine col:cursorCol
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1134
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1135
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1136
contents
2213
6068f2786bd6 added #contentsAsString
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1137
    "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
  1138
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1139
    list isNil ifTrue:[^ ''].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1140
    self removeTrailingBlankLines.
3313
6c2fd7c5a02f CRLF management
fm
parents: 3310
diff changeset
  1141
^ super contents.
6c2fd7c5a02f CRLF management
fm
parents: 3310
diff changeset
  1142
"/    ^ list asStringWithCRs
6c2fd7c5a02f CRLF management
fm
parents: 3310
diff changeset
  1143
6c2fd7c5a02f CRLF management
fm
parents: 3310
diff changeset
  1144
    "Modified: / 04-07-2006 / 19:22:32 / fm"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1145
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1146
3249
a4beb76b3f59 code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents: 3241
diff changeset
  1147
contents:something
a4beb76b3f59 code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents: 3241
diff changeset
  1148
    self contents:something keepUndoHistory:false.
a4beb76b3f59 code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents: 3241
diff changeset
  1149
!
a4beb76b3f59 code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents: 3241
diff changeset
  1150
a4beb76b3f59 code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents: 3241
diff changeset
  1151
contents:something keepUndoHistory:keepUndoHistory
a4beb76b3f59 code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents: 3241
diff changeset
  1152
    super contents:something.
a4beb76b3f59 code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents: 3241
diff changeset
  1153
    keepUndoHistory ifFalse:[
a4beb76b3f59 code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents: 3241
diff changeset
  1154
        undoSupport resetHistories.
a4beb76b3f59 code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents: 3241
diff changeset
  1155
    ].
a4beb76b3f59 code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents: 3241
diff changeset
  1156
!
a4beb76b3f59 code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents: 3241
diff changeset
  1157
2213
6068f2786bd6 added #contentsAsString
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1158
contentsAsString
6068f2786bd6 added #contentsAsString
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1159
    "return the contents as a String (i.e. without emphasis)"
6068f2786bd6 added #contentsAsString
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1160
6068f2786bd6 added #contentsAsString
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1161
    list isNil ifTrue:[^ ''].
6068f2786bd6 added #contentsAsString
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1162
    self removeTrailingBlankLines.
6068f2786bd6 added #contentsAsString
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1163
    ^ (list collect:[:each | each isNil ifTrue:['']
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1164
					ifFalse:[each string]
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1165
		    ]) asStringWithCRs
2213
6068f2786bd6 added #contentsAsString
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1166
!
6068f2786bd6 added #contentsAsString
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1167
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1168
cursorCol
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1169
    "return the cursors col (1..).
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1170
     This is the absolute col; NOT the visible col"
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
    ^ cursorCol
125
claus
parents: 123
diff changeset
  1173
!
claus
parents: 123
diff changeset
  1174
2422
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1175
cursorColHolder
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1176
    "return a valueHolder for the cursors column (1..)."
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1177
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1178
    ^ cursorColHolder
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1179
!
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1180
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1181
cursorLine
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1182
    "return the cursors line (1..).
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1183
     This is the absolute line; NOT the visible line"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1184
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1185
    ^ cursorLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1186
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1187
2422
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1188
cursorLineHolder
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1189
    "return a valueHolder for the cursors line (1..).
2422
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1190
     This is the absolute line; NOT the visible line"
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1191
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1192
    ^ cursorLineHolder
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1193
!
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1194
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1195
list:something
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1196
    "position cursor home when setting contents"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1197
2129
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  1198
    |prevCursorLine prevCursorCol|
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  1199
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  1200
    prevCursorLine := cursorLine.
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  1201
    prevCursorCol := cursorCol.
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  1202
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1203
    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
  1204
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  1205
    (cursorMovementWhenUpdating == #endOfText
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  1206
    or:[cursorMovementWhenUpdating == #end]) ifTrue:[
3249
a4beb76b3f59 code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents: 3241
diff changeset
  1207
        ^ self cursorToEndOfText
2129
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  1208
    ].
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  1209
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  1210
    (cursorMovementWhenUpdating == #endOfLine) ifTrue:[
3249
a4beb76b3f59 code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents: 3241
diff changeset
  1211
        ^ self cursorLine:prevCursorLine col:(self listAt:cursorLine) size + 1.
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1212
    ].
2129
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  1213
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  1214
    (cursorMovementWhenUpdating == #beginOfText
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  1215
    or:[cursorMovementWhenUpdating == #begin]) ifTrue:[
3249
a4beb76b3f59 code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents: 3241
diff changeset
  1216
        ^ self cursorHome
2129
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  1217
    ].
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  1218
    (cursorMovementWhenUpdating == #beginOfLine) ifTrue:[
3249
a4beb76b3f59 code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents: 3241
diff changeset
  1219
        ^ self cursorLine:prevCursorLine col:1.
2129
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  1220
    ].
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  1221
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  1222
    "/ 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
  1223
    "/ self cursorLine:prevCursorLine col:prevCursorCol.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1224
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1225
1476
ac38c8af8585 setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents: 1449
diff changeset
  1226
setContents:something
ac38c8af8585 setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents: 1449
diff changeset
  1227
    |selType|
ac38c8af8585 setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents: 1449
diff changeset
  1228
2989
5dcc2912bcb6 undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents: 2984
diff changeset
  1229
    undoSupport resetHistories.
2955
Claus Gittinger <cg@exept.de>
parents: 2954
diff changeset
  1230
1476
ac38c8af8585 setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents: 1449
diff changeset
  1231
    selType := typeOfSelection.
ac38c8af8585 setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents: 1449
diff changeset
  1232
    super setContents:something.
ac38c8af8585 setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents: 1449
diff changeset
  1233
    typeOfSelection := selType.
ac38c8af8585 setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents: 1449
diff changeset
  1234
ac38c8af8585 setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents: 1449
diff changeset
  1235
    "Created: / 31.3.1998 / 23:35:06 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1236
! !
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1237
474
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  1238
!EditTextView methodsFor:'accessing-look'!
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  1239
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  1240
cursorForegroundColor:color1 backgroundColor:color2
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  1241
    "set both cursor foreground and cursor background colors"
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  1242
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  1243
    |wasOn|
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  1244
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  1245
    wasOn := self hideCursor.
1993
5ffe0b3943cd #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1967
diff changeset
  1246
    cursorFgColor := color1 onDevice:device.
5ffe0b3943cd #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1967
diff changeset
  1247
    cursorBgColor := color2 onDevice:device.
474
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  1248
    wasOn ifTrue:[self showCursor]
1333
56af09878b96 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1325
diff changeset
  1249
!
56af09878b96 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1325
diff changeset
  1250
1899
c98fc612bab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
  1251
cursorType
c98fc612bab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
  1252
    "return the style of the text cursor.
c98fc612bab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
  1253
     Currently, supported are: #block, #frame, #ibeam, #caret, #solidCaret
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1254
			       #bigCaret and #bigSolidCaret"
1899
c98fc612bab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
  1255
c98fc612bab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
  1256
    ^ cursorType
c98fc612bab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
  1257
c98fc612bab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
  1258
    "Modified: / 5.5.1999 / 14:52:33 / cg"
c98fc612bab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
  1259
!
c98fc612bab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
  1260
1333
56af09878b96 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1325
diff changeset
  1261
cursorType:aCursorTypeSymbol
56af09878b96 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1325
diff changeset
  1262
    "set the style of the text cursor.
56af09878b96 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1325
diff changeset
  1263
     Currently, supported are: #block, #frame, #ibeam, #caret, #solidCaret
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1264
			       #bigCaret and #bigSolidCaret"
1333
56af09878b96 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1325
diff changeset
  1265
1334
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  1266
    cursorType := aCursorTypeSymbol.
1333
56af09878b96 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1325
diff changeset
  1267
56af09878b96 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1325
diff changeset
  1268
    "Created: 21.9.1997 / 13:42:23 / cg"
56af09878b96 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1325
diff changeset
  1269
    "Modified: 21.9.1997 / 13:43:35 / cg"
1334
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  1270
!
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  1271
1899
c98fc612bab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
  1272
cursorTypeNoFocus
c98fc612bab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
  1273
    "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
  1274
     If left unspecified, this is the same as the regular cursorType."
c98fc612bab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
  1275
c98fc612bab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
  1276
    ^ cursorTypeNoFocus
c98fc612bab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
  1277
c98fc612bab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
  1278
    "Created: / 5.5.1999 / 14:52:46 / cg"
c98fc612bab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
  1279
!
c98fc612bab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
  1280
1334
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  1281
cursorTypeNoFocus:aCursorTypeSymbol
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  1282
    "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
  1283
     If left unspecified, this is the same as the regular cursorType."
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  1284
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  1285
    cursorTypeNoFocus := aCursorTypeSymbol
474
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  1286
! !
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  1287
2119
2aa585fc62a3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2117
diff changeset
  1288
!EditTextView methodsFor:'change & update'!
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1289
125
claus
parents: 123
diff changeset
  1290
accept
claus
parents: 123
diff changeset
  1291
    "accept the current contents by executing the accept-action and/or
claus
parents: 123
diff changeset
  1292
     changeMessage."
claus
parents: 123
diff changeset
  1293
1108
3d14bb6bceb7 added disableAccept
Claus Gittinger <cg@exept.de>
parents: 1082
diff changeset
  1294
    acceptEnabled == false ifTrue:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1295
	self beep.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1296
	^ self
2035
6924861adf08 added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents: 2029
diff changeset
  1297
    ].
6924861adf08 added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents: 2029
diff changeset
  1298
    (disableIfInvisible == true and:[self reallyRealized not]) ifTrue:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1299
	^ self
1108
3d14bb6bceb7 added disableAccept
Claus Gittinger <cg@exept.de>
parents: 1082
diff changeset
  1300
    ].
3d14bb6bceb7 added disableAccept
Claus Gittinger <cg@exept.de>
parents: 1082
diff changeset
  1301
125
claus
parents: 123
diff changeset
  1302
    lockUpdates := true.
1013
391290c747b3 added an acceptChannel
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
  1303
391290c747b3 added an acceptChannel
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
  1304
    "/
391290c747b3 added an acceptChannel
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
  1305
    "/ ST-80 way of doing it
391290c747b3 added an acceptChannel
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
  1306
    "/
391290c747b3 added an acceptChannel
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
  1307
    model notNil ifTrue:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1308
	self sendChangeMessageWith:self argForChangeMessage.
1013
391290c747b3 added an acceptChannel
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
  1309
    ].
391290c747b3 added an acceptChannel
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
  1310
2999
40d3a383e8db *** empty log message ***
ca
parents: 2989
diff changeset
  1311
    model notNil ifTrue:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1312
	acceptChannel value:true withoutNotifying:self.
2999
40d3a383e8db *** empty log message ***
ca
parents: 2989
diff changeset
  1313
    ].
40d3a383e8db *** empty log message ***
ca
parents: 2989
diff changeset
  1314
757
2cc7e423f0ef only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents: 730
diff changeset
  1315
    "/
2cc7e423f0ef only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents: 730
diff changeset
  1316
    "/ ST/X way of doing things
2cc7e423f0ef only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents: 730
diff changeset
  1317
    "/ as a historic (and temporary) leftover,
2cc7e423f0ef only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents: 730
diff changeset
  1318
    "/ 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
  1319
    "/ - not with the actual string
2cc7e423f0ef only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents: 730
diff changeset
  1320
    "/
2cc7e423f0ef only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents: 730
diff changeset
  1321
    acceptAction notNil ifTrue:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1322
	acceptAction value:self list
757
2cc7e423f0ef only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents: 730
diff changeset
  1323
    ].
2cc7e423f0ef only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents: 730
diff changeset
  1324
125
claus
parents: 123
diff changeset
  1325
    lockUpdates := false.
757
2cc7e423f0ef only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents: 730
diff changeset
  1326
1437
ab84b08a9f9c allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
  1327
    "Modified: / 30.1.1998 / 14:19:00 / cg"
131
claus
parents: 130
diff changeset
  1328
!
claus
parents: 130
diff changeset
  1329
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1330
argForChangeMessage
597
fb42c94a042e commentary
Claus Gittinger <cg@exept.de>
parents: 594
diff changeset
  1331
    "return the argument to be passed with the change notification.
fb42c94a042e commentary
Claus Gittinger <cg@exept.de>
parents: 594
diff changeset
  1332
     Defined as separate method for easier subclassability."
fb42c94a042e commentary
Claus Gittinger <cg@exept.de>
parents: 594
diff changeset
  1333
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1334
    ^ self contents
597
fb42c94a042e commentary
Claus Gittinger <cg@exept.de>
parents: 594
diff changeset
  1335
fb42c94a042e commentary
Claus Gittinger <cg@exept.de>
parents: 594
diff changeset
  1336
    "Modified: 29.4.1996 / 12:42:14 / cg"
121
claus
parents: 118
diff changeset
  1337
!
claus
parents: 118
diff changeset
  1338
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1339
getListFromModel
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1340
    "get my contents from the model.
597
fb42c94a042e commentary
Claus Gittinger <cg@exept.de>
parents: 594
diff changeset
  1341
     Redefined to ignore updates resulting from my own changes
fb42c94a042e commentary
Claus Gittinger <cg@exept.de>
parents: 594
diff changeset
  1342
     (i.e. if lockUpdates is true)."
121
claus
parents: 118
diff changeset
  1343
claus
parents: 118
diff changeset
  1344
    "
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1345
     ignore updates from my own change
121
claus
parents: 118
diff changeset
  1346
    "
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1347
    lockUpdates ifTrue:[
3249
a4beb76b3f59 code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents: 3241
diff changeset
  1348
        lockUpdates := false.
a4beb76b3f59 code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents: 3241
diff changeset
  1349
        ^ self
121
claus
parents: 118
diff changeset
  1350
    ].
2196
f8c955dd6eb9 validate the cursorLine, when updating from a changed model
Claus Gittinger <cg@exept.de>
parents: 2186
diff changeset
  1351
    super getListFromModel.
3249
a4beb76b3f59 code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents: 3241
diff changeset
  1352
    undoSupport resetHistories.
2196
f8c955dd6eb9 validate the cursorLine, when updating from a changed model
Claus Gittinger <cg@exept.de>
parents: 2186
diff changeset
  1353
f8c955dd6eb9 validate the cursorLine, when updating from a changed model
Claus Gittinger <cg@exept.de>
parents: 2186
diff changeset
  1354
    "/ validate the cursorLine
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1355
    (cursorLine notNil
2310
861ab02b13b9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2225
diff changeset
  1356
     and:[ cursorLine > list size ]) ifTrue:[
3249
a4beb76b3f59 code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents: 3241
diff changeset
  1357
        self cursorLine:list size + 1 col:1
2196
f8c955dd6eb9 validate the cursorLine, when updating from a changed model
Claus Gittinger <cg@exept.de>
parents: 2186
diff changeset
  1358
    ].
1437
ab84b08a9f9c allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
  1359
!
ab84b08a9f9c allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
  1360
ab84b08a9f9c allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
  1361
update:something with:aParameter from:changedObject
1438
bed1564b0640 fixed update for acceptChannel
Claus Gittinger <cg@exept.de>
parents: 1437
diff changeset
  1362
    changedObject == acceptChannel ifTrue:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1363
	acceptChannel value == true ifTrue:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1364
	    self accept.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1365
	].
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1366
	^ self.
1437
ab84b08a9f9c allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
  1367
    ].
ab84b08a9f9c allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
  1368
    super update:something with:aParameter from:changedObject
ab84b08a9f9c allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
  1369
ab84b08a9f9c allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
  1370
    "Created: / 30.1.1998 / 14:15:56 / cg"
1439
d1b3ca91ed8a fixed update for acceptChannel
Claus Gittinger <cg@exept.de>
parents: 1438
diff changeset
  1371
    "Modified: / 1.2.1998 / 13:15:55 / cg"
121
claus
parents: 118
diff changeset
  1372
! !
claus
parents: 118
diff changeset
  1373
claus
parents: 118
diff changeset
  1374
!EditTextView methodsFor:'cursor handling'!
claus
parents: 118
diff changeset
  1375
2406
aeabb4ccf07c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2404
diff changeset
  1376
characterPositionOfCursor
aeabb4ccf07c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2404
diff changeset
  1377
    ^ self characterPositionOfLine:cursorLine col:cursorCol
aeabb4ccf07c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2404
diff changeset
  1378
!
aeabb4ccf07c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2404
diff changeset
  1379
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1380
cursorBacktab
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1381
    "move cursor to prev tabstop"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1382
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1383
    self cursorCol:(self prevTabBefore:cursorCol).
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1384
!
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
cursorCol:newCol
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1387
    "move cursor to some column in the current line"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1388
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1389
    |wasOn|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1390
2822
08ceab3fc237 search refactored;
Claus Gittinger <cg@exept.de>
parents: 2819
diff changeset
  1391
    (cursorCol == newCol) ifTrue:[^ self].
08ceab3fc237 search refactored;
Claus Gittinger <cg@exept.de>
parents: 2819
diff changeset
  1392
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1393
    wasOn := self hideCursor.
2422
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1394
    self setValidatedCursorCol:newCol.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1395
    self makeCursorVisibleAndShowCursor:wasOn.
672
065750d02339 added cursorCol-validation
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  1396
065750d02339 added cursorCol-validation
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  1397
    "Modified: 22.5.1996 / 14:25:53 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1398
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1399
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1400
cursorDown
632
5af2c22002e4 dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
  1401
    "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
  1402
     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
  1403
5af2c22002e4 dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
  1404
    |wasOn|
5af2c22002e4 dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
  1405
5af2c22002e4 dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
  1406
    self cursorDown:1.
5af2c22002e4 dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
  1407
2707
810c994db0b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2696
diff changeset
  1408
    "/ cursor beyond text ?
632
5af2c22002e4 dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
  1409
    cursorLine > list size ifTrue:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1410
	wasOn := self hideCursor.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1411
	self setValidatedCursorLine:(list size + 1) col:cursorCol.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1412
	self makeCursorVisibleAndShowCursor:wasOn.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1413
	self beep.
632
5af2c22002e4 dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
  1414
    ].
5af2c22002e4 dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
  1415
1561
db5f27354172 make cursor correctly visible if in partial last line.
Claus Gittinger <cg@exept.de>
parents: 1560
diff changeset
  1416
    "Modified: / 10.6.1998 / 17:00:23 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1417
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1418
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1419
cursorDown:n
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1420
    "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
  1421
2422
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1422
    |wasOn nv nL|
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1423
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1424
    cursorVisibleLine notNil ifTrue:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1425
	wasOn := self hideCursor.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1426
	nv := cursorVisibleLine + n - 1.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1427
	(nv >= nFullLinesShown) ifTrue:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1428
	    self scrollDown:(nv - nFullLinesShown + 1)
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1429
	].
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1430
	self setValidatedCursorLine:(cursorLine + n) col:cursorCol.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1431
	self makeCursorVisibleAndShowCursor:wasOn.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1432
    ] ifFalse:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1433
	(nL := cursorLine) isNil ifTrue:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1434
	    nL := firstLineShown
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1435
	].
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1436
	self setValidatedCursorLine:(nL + n) col:cursorCol.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1437
	self makeCursorVisible.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1438
    ].
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  1439
1561
db5f27354172 make cursor correctly visible if in partial last line.
Claus Gittinger <cg@exept.de>
parents: 1560
diff changeset
  1440
    "Modified: / 10.6.1998 / 16:59:17 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1441
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1442
121
claus
parents: 118
diff changeset
  1443
cursorHome
597
fb42c94a042e commentary
Claus Gittinger <cg@exept.de>
parents: 594
diff changeset
  1444
    "scroll to top AND move cursor to first line of text."
121
claus
parents: 118
diff changeset
  1445
674
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  1446
    self cursorLine:1 col:1
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  1447
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  1448
"/    |wasOn|
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  1449
"/
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  1450
"/    wasOn := self hideCursor.
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  1451
"/    self scrollToTop.
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  1452
"/    cursorLine := cursorVisibleLine := 1.
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  1453
"/    cursorCol := self validateCursorCol:1 inLine:cursorLine.
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  1454
"/    self makeCursorVisibleAndShowCursor:wasOn.
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  1455
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  1456
    "Modified: 22.5.1996 / 18:26:42 / cg"
121
claus
parents: 118
diff changeset
  1457
!
claus
parents: 118
diff changeset
  1458
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1459
cursorLeft
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1460
    "move cursor to left"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1461
1300
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  1462
    (cursorCol ~~ 1) ifTrue:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1463
	self cursorCol:(cursorCol - 1)
1300
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  1464
    ] ifFalse:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1465
	cursorLine ~~ 1 ifTrue:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1466
	    self st80EditMode ifTrue:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1467
		self cursorUp.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1468
		self cursorToEndOfLine.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1469
	   ]
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1470
	]
1300
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  1471
    ]
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  1472
1426
de76570ba19e crsrLeft/crsrRight does not wrap to prev/next line in st80 mode
Claus Gittinger <cg@exept.de>
parents: 1419
diff changeset
  1473
    "Modified: / 23.1.1998 / 12:37:13 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1474
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1475
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1476
cursorLine:line col:col
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1477
    "this positions onto physical - not visible - line"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1478
676
b65b82a1ffcb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
  1479
    |wasOn newCol|
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1480
2822
08ceab3fc237 search refactored;
Claus Gittinger <cg@exept.de>
parents: 2819
diff changeset
  1481
    ((line == cursorLine) and:[col == cursorCol]) ifTrue:[^ self].
08ceab3fc237 search refactored;
Claus Gittinger <cg@exept.de>
parents: 2819
diff changeset
  1482
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1483
    wasOn := self hideCursor.
2422
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1484
    self setValidatedCursorLine:line.
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1485
672
065750d02339 added cursorCol-validation
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  1486
    (col < 1) ifTrue:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1487
	newCol := 1
672
065750d02339 added cursorCol-validation
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  1488
    ] ifFalse:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1489
	newCol := col.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1490
    ].
2647
23dca8f032c3 changed st80Mode from classVar to userPreferences value
Claus Gittinger <cg@exept.de>
parents: 2627
diff changeset
  1491
    self st80EditMode ifTrue:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1492
	(cursorLine == list size
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1493
	and:[cursorLine ~~ line]) ifTrue:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1494
	    newCol := (self listAt:(list size)) size + 1.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1495
	]
1419
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
  1496
    ].
2422
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1497
    self setValidatedCursorCol:newCol.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1498
    self makeCursorVisibleAndShowCursor:wasOn.
672
065750d02339 added cursorCol-validation
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  1499
1596
0bbdb4e9fc43 made st80Mode also an inst-flag;
Claus Gittinger <cg@exept.de>
parents: 1591
diff changeset
  1500
    "Modified: / 20.6.1998 / 18:19:06 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1501
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1502
1580
d30e562bea15 allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
  1503
cursorMovementAllowed
d30e562bea15 allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
  1504
    "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
  1505
     (via button-click, or cursor-key with selection).
d30e562bea15 allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
  1506
     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
  1507
     in special subclasses (such as a terminal view), where
d30e562bea15 allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
  1508
     this is not wanted"
d30e562bea15 allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
  1509
d30e562bea15 allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
  1510
    ^ true
d30e562bea15 allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
  1511
d30e562bea15 allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
  1512
    "Created: / 18.6.1998 / 14:11:16 / cg"
d30e562bea15 allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
  1513
!
d30e562bea15 allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
  1514
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1515
cursorReturn
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1516
    "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
  1517
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1518
    |wasOn|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1519
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1520
    self checkForExistingLine:(cursorLine + 1).
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1521
    cursorVisibleLine notNil ifTrue:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1522
	nFullLinesShown notNil ifTrue:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1523
	    (cursorVisibleLine >= nFullLinesShown) ifTrue:[self scrollDown]
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1524
	]
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1525
    ].
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
    wasOn := self hideCursor.
2422
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1528
    self setValidatedCursorLine:(cursorLine + 1) col:1.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1529
    self makeCursorVisibleAndShowCursor:wasOn.
672
065750d02339 added cursorCol-validation
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  1530
674
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  1531
    "Modified: 22.5.1996 / 18:27:34 / cg"
259
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
cursorRight
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1535
    "move cursor to right"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1536
1300
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  1537
    |l|
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  1538
3023
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  1539
    self st80EditMode ifTrue:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1540
	l := (self listAt:cursorLine).
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1541
	cursorCol >= (l size + 1) ifTrue:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1542
	    cursorLine < list size ifTrue:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1543
		self cursorReturn.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1544
	    ].
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1545
	    ^ self
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1546
	]
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1547
    ].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1548
    self cursorCol:(cursorCol + 1)
1300
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  1549
1596
0bbdb4e9fc43 made st80Mode also an inst-flag;
Claus Gittinger <cg@exept.de>
parents: 1591
diff changeset
  1550
    "Modified: / 20.6.1998 / 18:19:07 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1551
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1552
1833
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  1553
cursorShown:aBoolean
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  1554
    "change cursor visibility
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  1555
     return true if cursor was visible before."
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  1556
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  1557
    |oldState|
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  1558
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  1559
    oldState := cursorShown.
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  1560
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  1561
    aBoolean ifTrue:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1562
	self drawCursor.
1833
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  1563
    ] ifFalse:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1564
	(cursorShown and:[shown]) ifTrue: [
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1565
	    self undrawCursor.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1566
	].
1833
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  1567
    ].
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  1568
    cursorShown := aBoolean.
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  1569
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  1570
    ^ oldState
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  1571
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  1572
    "Modified: / 30.3.1999 / 15:32:43 / stefan"
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  1573
    "Created: / 30.3.1999 / 15:59:30 / stefan"
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  1574
!
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  1575
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1576
cursorTab
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1577
    "move cursor to next tabstop"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1578
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1579
    self cursorCol:(self nextTabAfter:cursorCol).
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
cursorToBeginOfLine
3020
68a2dfad4e5e CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents: 2999
diff changeset
  1583
    "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
  1584
68a2dfad4e5e CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents: 2999
diff changeset
  1585
    |textStart l|
68a2dfad4e5e CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents: 2999
diff changeset
  1586
68a2dfad4e5e CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents: 2999
diff changeset
  1587
    l := self listAt:cursorLine.
68a2dfad4e5e CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents: 2999
diff changeset
  1588
    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
  1589
    cursorCol > textStart ifTrue:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1590
	self cursorCol:textStart
3020
68a2dfad4e5e CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents: 2999
diff changeset
  1591
    ] ifFalse:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1592
	self cursorCol:1
3020
68a2dfad4e5e CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents: 2999
diff changeset
  1593
    ]
68a2dfad4e5e CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents: 2999
diff changeset
  1594
68a2dfad4e5e CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents: 2999
diff changeset
  1595
    "Created: / 8.8.2004 / 18:51:21 / janfrog"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1596
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1597
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1598
cursorToBottom
2129
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  1599
    "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
  1600
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1601
    |wasOn newTop|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1602
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1603
    wasOn := self hideCursor.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1604
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1605
    newTop := list size - nFullLinesShown.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1606
    (newTop < 1) ifTrue:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1607
	newTop := 1
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1608
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1609
    self scrollToLine:newTop.
2422
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1610
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1611
    self setValidatedCursorLine:(list size) col:1.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1612
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1613
    self makeCursorVisibleAndShowCursor:wasOn.
672
065750d02339 added cursorCol-validation
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  1614
674
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  1615
    "Modified: 22.5.1996 / 18:27:45 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1616
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1617
1415
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1618
cursorToCharacterPosition:pos
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1619
    "compute line/col from character position (1..)
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1620
     and move the cursor onto that char"
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1621
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1622
    |line col|
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1623
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1624
    line := self lineOfCharacterPosition:pos.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1625
    col := pos - (self characterPositionOfLine:line col:1) + 1.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1626
    self cursorLine:line col:col
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1627
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1628
    "Created: / 15.1.1998 / 21:55:33 / cg"
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1629
!
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1630
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1631
cursorToEnd
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1632
    "move cursor down below last line of text"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1633
2422
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1634
    |wasOn newTop lineNr line|
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1635
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1636
    lineNr := list size.
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1637
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1638
    cursorLine >= lineNr ifTrue:[
3238
7b868226a0c0 isEmptyOrNil / notEmptyOrNil refactoring
Claus Gittinger <cg@exept.de>
parents: 3236
diff changeset
  1639
        line := self listAt:cursorLine.
7b868226a0c0 isEmptyOrNil / notEmptyOrNil refactoring
Claus Gittinger <cg@exept.de>
parents: 3236
diff changeset
  1640
        (line isEmptyOrNil) ifTrue:[
7b868226a0c0 isEmptyOrNil / notEmptyOrNil refactoring
Claus Gittinger <cg@exept.de>
parents: 3236
diff changeset
  1641
            ^ self
7b868226a0c0 isEmptyOrNil / notEmptyOrNil refactoring
Claus Gittinger <cg@exept.de>
parents: 3236
diff changeset
  1642
        ]
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1643
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1644
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1645
    wasOn := self hideCursor.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1646
2422
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1647
    lineNr := lineNr + 1.
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1648
    newTop :=  lineNr - nFullLinesShown.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1649
    (newTop < 1) ifTrue:[
3238
7b868226a0c0 isEmptyOrNil / notEmptyOrNil refactoring
Claus Gittinger <cg@exept.de>
parents: 3236
diff changeset
  1650
        newTop := 1
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1651
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1652
    self scrollToLine:newTop.
2422
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1653
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1654
    self setValidatedCursorLine:lineNr col:1.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1655
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1656
    self makeCursorVisibleAndShowCursor:wasOn.
672
065750d02339 added cursorCol-validation
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  1657
674
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  1658
    "Modified: 22.5.1996 / 18:27:53 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1659
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1660
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1661
cursorToEndOfLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1662
    "move cursor to end of current line"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1663
1300
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  1664
    |line|
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  1665
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  1666
    line := (self listAt:cursorLine).
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  1667
    self cursorCol:(line size + 1)
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  1668
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  1669
    "Modified: 13.8.1997 / 15:34:02 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1670
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1671
2129
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  1672
cursorToEndOfText
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  1673
    "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
  1674
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  1675
    |wasOn newTop|
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  1676
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  1677
    wasOn := self hideCursor.
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  1678
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  1679
    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
  1680
    (newTop < 1) ifTrue:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1681
	newTop := 1
2129
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  1682
    ].
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  1683
    self scrollToLine:newTop.
2422
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1684
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1685
    self setValidatedCursorLine:list size.
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1686
    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
  1687
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  1688
    self makeCursorVisibleAndShowCursor:wasOn.
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  1689
!
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  1690
3310
83368f9014a1 word check
Claus Gittinger <cg@exept.de>
parents: 3303
diff changeset
  1691
cursorToEndOfWord
83368f9014a1 word check
Claus Gittinger <cg@exept.de>
parents: 3303
diff changeset
  1692
    "move the cursor to the end of the word"
83368f9014a1 word check
Claus Gittinger <cg@exept.de>
parents: 3303
diff changeset
  1693
83368f9014a1 word check
Claus Gittinger <cg@exept.de>
parents: 3303
diff changeset
  1694
    (cursorLine > list size) ifTrue:[^ self].
83368f9014a1 word check
Claus Gittinger <cg@exept.de>
parents: 3303
diff changeset
  1695
83368f9014a1 word check
Claus Gittinger <cg@exept.de>
parents: 3303
diff changeset
  1696
    self wordAtLine:cursorLine col:cursorCol do:[
83368f9014a1 word check
Claus Gittinger <cg@exept.de>
parents: 3303
diff changeset
  1697
        :beginLine :beginCol :endLine :endCol :style |
83368f9014a1 word check
Claus Gittinger <cg@exept.de>
parents: 3303
diff changeset
  1698
83368f9014a1 word check
Claus Gittinger <cg@exept.de>
parents: 3303
diff changeset
  1699
        self cursorLine:endLine col:endCol+1
83368f9014a1 word check
Claus Gittinger <cg@exept.de>
parents: 3303
diff changeset
  1700
    ]
83368f9014a1 word check
Claus Gittinger <cg@exept.de>
parents: 3303
diff changeset
  1701
83368f9014a1 word check
Claus Gittinger <cg@exept.de>
parents: 3303
diff changeset
  1702
    "Created: / 28-06-2006 / 19:16:30 / cg"
83368f9014a1 word check
Claus Gittinger <cg@exept.de>
parents: 3303
diff changeset
  1703
!
83368f9014a1 word check
Claus Gittinger <cg@exept.de>
parents: 3303
diff changeset
  1704
131
claus
parents: 130
diff changeset
  1705
cursorToFirstVisibleLine
claus
parents: 130
diff changeset
  1706
    "place cursor into the first visible line; do not scroll."
claus
parents: 130
diff changeset
  1707
claus
parents: 130
diff changeset
  1708
    self cursorLine:(self visibleLineToAbsoluteLine:1) col:1
claus
parents: 130
diff changeset
  1709
!
claus
parents: 130
diff changeset
  1710
claus
parents: 130
diff changeset
  1711
cursorToLastVisibleLine
claus
parents: 130
diff changeset
  1712
    "place cursor into the first visible line; do not scroll."
claus
parents: 130
diff changeset
  1713
claus
parents: 130
diff changeset
  1714
    self cursorLine:(self visibleLineToAbsoluteLine:nFullLinesShown) col:1
claus
parents: 130
diff changeset
  1715
!
claus
parents: 130
diff changeset
  1716
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1717
cursorToNextWord
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1718
    "move the cursor to the beginning of the next word"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1719
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1720
    |col line searching|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1721
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1722
    (cursorLine > list size) ifTrue:[^ self].
2422
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1723
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1724
    self wordAtLine:cursorLine col:cursorCol do:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1725
	:beginLine :beginCol :endLine :endCol :style |
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1726
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1727
	line := endLine.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1728
	col := endCol + 1.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1729
	searching := true.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1730
	[searching
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1731
	 and:[(self characterAtLine:line col:col) isSeparator]] whileTrue:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1732
	    self wordAtLine:line col:col do:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1733
		:beginLine :beginCol :endLine :endCol :style |
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1734
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1735
		(line > list size) ifTrue:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1736
		    "break out"
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1737
		    searching := false
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1738
		] ifFalse:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1739
		    line := endLine.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1740
		    col := endCol + 1.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1741
		]
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1742
	    ]
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1743
	].
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1744
	self cursorLine:line col:col
121
claus
parents: 118
diff changeset
  1745
    ]
claus
parents: 118
diff changeset
  1746
!
claus
parents: 118
diff changeset
  1747
499
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
  1748
cursorToPreviousWord
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
  1749
    "move the cursor to the beginning of this or the previous word"
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
  1750
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
  1751
    |col line searching l|
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
  1752
2422
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1753
    (cursorLine > list size) ifTrue:[^ self].      "/ this is rubbish
499
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
  1754
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
  1755
    self wordAtLine:cursorLine col:cursorCol do:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1756
	:beginLine :beginCol :endLine :endCol :style |
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1757
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1758
	line := beginLine.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1759
	col := beginCol.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1760
	style == #wordLeft ifTrue:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1761
	    col := col + 1
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1762
	].
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1763
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1764
	(cursorLine == line
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1765
	and:[cursorCol == col]) ifTrue:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1766
	    searching := true.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1767
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1768
	    col > 1 ifTrue:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1769
		col := col - 1.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1770
	    ].
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1771
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1772
	    [searching] whileTrue:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1773
		(col == 1) ifTrue:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1774
		    line == 1 ifTrue:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1775
			searching := false
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1776
		    ] ifFalse:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1777
			line := line - 1.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1778
			l := list at:line.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1779
			col := l size + 1.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1780
		    ]
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1781
		] ifFalse:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1782
		    (self characterAtLine:line col:col) isSeparator ifFalse:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1783
			self wordAtLine:line col:col do:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1784
			    :beginLine :beginCol :endLine :endCol :style |
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1785
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1786
			    line := beginLine.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1787
			    col := beginCol.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1788
			    style == #wordLeft ifTrue:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1789
				col := col + 1
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1790
			    ].
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1791
			    searching := false.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1792
			]
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1793
		    ] ifTrue:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1794
			col := col - 1
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1795
		    ]
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1796
		]
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1797
	    ]
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1798
	].
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1799
	self cursorLine:line col:col
499
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
  1800
    ]
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
  1801
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
  1802
    "Created: 8.3.1996 / 21:52:48 / cg"
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
  1803
    "Modified: 8.3.1996 / 22:12:45 / cg"
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
  1804
!
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
  1805
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1806
cursorToTop
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1807
    "move cursor to absolute home"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1808
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1809
    self cursorLine:1 col:1
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1810
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1811
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1812
cursorUp
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1813
    "move cursor up; scroll if at start of visible text"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1814
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1815
    self cursorUp:1
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1816
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1817
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1818
cursorUp:n
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1819
    "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
  1820
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1821
    |wasOn nv nl|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1822
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1823
    cursorLine isNil ifTrue:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1824
	self setCursorLine:(firstLineShown + nFullLinesShown - 1).
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1825
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1826
    nl := cursorLine - n.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1827
    nl < 1 ifTrue:[nl := 1].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1828
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1829
    (nl ~~ cursorLine) ifTrue: [
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1830
	wasOn := self hideCursor.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1831
	cursorVisibleLine notNil ifTrue:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1832
	    nv := cursorVisibleLine - n.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1833
	    nv < 1 ifTrue:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1834
		self scrollUp:(nv negated + 1)
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1835
	    ].
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1836
	].
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1837
	self setValidatedCursorLine:nl col:cursorCol.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1838
	wasOn ifTrue:[self showCursor].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1839
    ]
672
065750d02339 added cursorCol-validation
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  1840
674
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  1841
    "Modified: 22.5.1996 / 18:28:11 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1842
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1843
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1844
cursorVisibleLine:visibleLineNr col:colNr
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1845
    "put cursor to visibleline/col"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1846
2422
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1847
    |wasOn newCol listLine|
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1848
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1849
    wasOn := self hideCursor.
2422
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1850
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1851
    listLine := self visibleLineToAbsoluteLine:visibleLineNr.
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1852
    self setValidatedCursorLine:listLine.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1853
    cursorVisibleLine := visibleLineNr.
2422
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1854
676
b65b82a1ffcb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
  1855
    newCol := colNr.
b65b82a1ffcb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
  1856
    (newCol < 1) ifTrue:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1857
	newCol := 1
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1858
    ].
2422
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1859
    self setValidatedCursorCol:newCol.
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1860
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1861
    self makeCursorVisibleAndShowCursor:wasOn.
672
065750d02339 added cursorCol-validation
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  1862
1597
5fdcfcedb91c fixed cursor positioning after replaceStringAtCursor.
Claus Gittinger <cg@exept.de>
parents: 1596
diff changeset
  1863
    "Modified: / 20.6.1998 / 18:40:28 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1864
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1865
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1866
cursorX:x y:y
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1867
    "put cursor to position next to x/y coordinate in view"
121
claus
parents: 118
diff changeset
  1868
claus
parents: 118
diff changeset
  1869
    |line col|
claus
parents: 118
diff changeset
  1870
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1871
    line := self visibleLineOfY:y.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1872
    col := self colOfX:x inVisibleLine:line.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1873
    self cursorVisibleLine:line col:col.
121
claus
parents: 118
diff changeset
  1874
!
claus
parents: 118
diff changeset
  1875
claus
parents: 118
diff changeset
  1876
drawCursor
claus
parents: 118
diff changeset
  1877
    "draw the cursor if shown and cursor is visible.
claus
parents: 118
diff changeset
  1878
     (but not, if there is a selection - to avoid confusion)"
claus
parents: 118
diff changeset
  1879
claus
parents: 118
diff changeset
  1880
    shown ifTrue:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1881
	cursorVisibleLine notNil ifTrue:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1882
	    self hasSelection ifFalse:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1883
		self drawCursorCharacter
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1884
	    ]
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1885
	]
121
claus
parents: 118
diff changeset
  1886
    ]
claus
parents: 118
diff changeset
  1887
!
claus
parents: 118
diff changeset
  1888
claus
parents: 118
diff changeset
  1889
drawCursor:cursorType with:fgColor and:bgColor
claus
parents: 118
diff changeset
  1890
    "draw a cursor; the argument cursorType specifies what type
125
claus
parents: 123
diff changeset
  1891
     of cursor should be drawn.
728
3ef81000ee8c new cursorTypes: #bigCaret and #bigSolidCaret
Claus Gittinger <cg@exept.de>
parents: 698
diff changeset
  1892
     Currently, supported are: #block, #frame, #ibeam, #caret, #solidCaret
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1893
			       #bigCaret and #bigSolidCaret"
2085
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  1894
2570
590956e81610 Remove unused method vars.
Stefan Vogel <sv@exept.de>
parents: 2569
diff changeset
  1895
    |x y w char y2 x1 x2 oldPaint oldClip|
121
claus
parents: 118
diff changeset
  1896
claus
parents: 118
diff changeset
  1897
    self hasSelection ifTrue:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1898
	"
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1899
	 hide cursor, if there is a selection
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1900
	"
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1901
	^ super redrawVisibleLine:cursorVisibleLine col:cursorCol.
121
claus
parents: 118
diff changeset
  1902
    ].
claus
parents: 118
diff changeset
  1903
1334
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  1904
    cursorType == #none ifTrue:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1905
	^ self
1334
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  1906
    ].
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  1907
121
claus
parents: 118
diff changeset
  1908
    cursorType == #block ifTrue:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1909
	super drawVisibleLine:cursorVisibleLine
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1910
			  col:cursorCol
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1911
			 with:fgColor
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1912
			  and:bgColor.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1913
	^ self
121
claus
parents: 118
diff changeset
  1914
    ].
2429
eed79a96e43b eliminated accesses to leftOffset
Claus Gittinger <cg@exept.de>
parents: 2427
diff changeset
  1915
    x := (self xOfCol:cursorCol inVisibleLine:cursorVisibleLine) - viewOrigin x.
121
claus
parents: 118
diff changeset
  1916
    y := self yOfVisibleLine:cursorVisibleLine.
claus
parents: 118
diff changeset
  1917
1449
2a54bdfff203 eliminated direct refs to paint instvar
Claus Gittinger <cg@exept.de>
parents: 1446
diff changeset
  1918
    oldPaint := self paint. "/ do not clobber GC
121
claus
parents: 118
diff changeset
  1919
    cursorType == #frame ifTrue:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1920
	super redrawVisibleLine:cursorVisibleLine col:cursorCol.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1921
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1922
	char := self characterUnderCursor asString.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1923
	self paint:bgColor.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1924
	self displayRectangleX:x y:y
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1925
			 width:(font widthOf:char) height:fontHeight.
133
claus
parents: 132
diff changeset
  1926
    ] ifFalse:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1927
	self paint:bgColor.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1928
	cursorType == #ibeam ifTrue:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1929
	    x1 := x - 1.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1930
	    y2 := y + fontHeight - 1.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1931
	    self displayLineFromX:x1 y:y toX:x1 y:y2.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1932
	    self displayLineFromX:x y:y toX:x y:y2.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1933
	    ^ self
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1934
	].
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1935
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1936
	cursorType == #Ibeam ifTrue:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1937
	    x1 := x - 1.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1938
	    y := y + 1.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1939
	    y2 := y + fontHeight - 1.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1940
	    self displayLineFromX:x1 y:y toX:x1 y:y2.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1941
	    self displayLineFromX:x y:y toX:x y:y2.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1942
	    self displayLineFromX:x1-2 y:y toX:x+2 y:y.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1943
	    self displayLineFromX:x1-2 y:y2 toX:x+2 y:y2.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1944
	    ^ self
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1945
	].
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1946
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1947
	y := y + fontHeight - 3.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1948
	((cursorType == #bigCaret) or:[cursorType == #bigSolidCaret]) ifTrue:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1949
	    w := (fontWidth * 2 // 3) max:4.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1950
	    y2 := y + w + (w//2).
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1951
	] ifFalse:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1952
	    w := (fontWidth // 2) max:4.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1953
	    y2 := y + w.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1954
	].
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1955
	x1 := x - w.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1956
	x2 := x + w.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1957
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1958
	oldClip := self clippingRectangleOrNil.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1959
	self clippingRectangle:(margin@margin extent:(width-margin) @ (height-margin)).
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1960
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1961
	cursorType == #caret ifTrue:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1962
	    self lineWidth:2.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1963
	    self displayLineFromX:x1 y:y2 toX:x y:y.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1964
	    self displayLineFromX:x y:y toX:x2 y:y2.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1965
	] ifFalse:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1966
	    "anything else: solidCaret"
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1967
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1968
	    self fillPolygon:(Array with:(x1 @ y2)
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1969
				    with:(x @ y)
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1970
				    with:(x2 @ y2))
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1971
	].
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1972
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1973
	self clippingRectangle:oldClip
121
claus
parents: 118
diff changeset
  1974
    ].
133
claus
parents: 132
diff changeset
  1975
    self paint:oldPaint.
662
4bcdf0cce3a7 dont let caret cursor become too small (with small fonts)
Claus Gittinger <cg@exept.de>
parents: 655
diff changeset
  1976
2088
b2beb67b1a98 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2085
diff changeset
  1977
    "Modified: / 15.12.1999 / 22:24:17 / cg"
121
claus
parents: 118
diff changeset
  1978
!
claus
parents: 118
diff changeset
  1979
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1980
drawCursorCharacter
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1981
    "draw the cursor.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1982
     (i.e. the cursor if no selection)
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1983
     - helper for many cursor methods"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1984
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1985
    (hasKeyboardFocus
3296
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
  1986
     and:[self enabled
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
  1987
     and:[self isReadOnly not]]) ifTrue:[
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
  1988
        self drawFocusCursor
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1989
    ] ifFalse:[
3296
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
  1990
        self drawNoFocusCursor
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1991
    ]
1817
1a9e22f755c8 show non-focus cursor when disabled or readOnly
Claus Gittinger <cg@exept.de>
parents: 1816
diff changeset
  1992
1a9e22f755c8 show non-focus cursor when disabled or readOnly
Claus Gittinger <cg@exept.de>
parents: 1816
diff changeset
  1993
    "Modified: / 23.3.1999 / 13:52:48 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1994
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1995
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1996
drawFocusCursor
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1997
    "draw the cursor when the focus is in the view."
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
    self hasSelection ifTrue:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2000
	^ super redrawVisibleLine:cursorVisibleLine col:cursorCol.
1334
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  2001
    ].
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  2002
    cursorType == #none ifTrue:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2003
	^ self undrawCursor
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2004
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2005
    self drawCursor:cursorType with:cursorFgColor and:cursorBgColor.
1334
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  2006
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  2007
    "Modified: 22.9.1997 / 00:16:38 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2008
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2009
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2010
drawNoFocusCursor
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2011
    "draw the cursor for the case when the view has no keyboard focus"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2012
1334
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  2013
    |cType|
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  2014
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2015
    self hasSelection ifTrue:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2016
	^ super redrawVisibleLine:cursorVisibleLine col:cursorCol.
121
claus
parents: 118
diff changeset
  2017
    ].
1022
4362861fe15e allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents: 1018
diff changeset
  2018
1334
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  2019
    cType := cursorTypeNoFocus ? cursorType.
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  2020
    cType == #none ifTrue:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2021
	^ self undrawCursor
1334
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  2022
    ].
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  2023
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  2024
    cType == #block ifTrue:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2025
	^ self drawCursor:#frame with:cursorNoFocusFgColor and:cursorBgColor
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2026
    ].
1022
4362861fe15e allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents: 1018
diff changeset
  2027
1334
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  2028
    ^ self drawCursor:cType with:cursorNoFocusFgColor and:cursorNoFocusFgColor.
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  2029
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  2030
    "Modified: 22.9.1997 / 00:16:13 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2031
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2032
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2033
gotoLine:aLineNumber
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2034
    "position cursor onto line, aLineNumber.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2035
     Make certain that this line is visible"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2036
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2037
    self makeLineVisible:aLineNumber.
2951
eb820ef25acf unselect before gotoLine
Claus Gittinger <cg@exept.de>
parents: 2950
diff changeset
  2038
    self unselect.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2039
    self cursorLine:aLineNumber col:1
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2040
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2041
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2042
hideCursor
1833
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  2043
    "make cursor invisible if currently invisible"
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  2044
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  2045
    ^ self cursorShown:false
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  2046
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  2047
    "Modified: / 30.3.1999 / 16:02:28 / stefan"
121
claus
parents: 118
diff changeset
  2048
!
claus
parents: 118
diff changeset
  2049
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2050
makeCursorVisible
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2051
    "scroll text to make cursorline visible
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2052
     (i.e. to have cursorLine in visible area)"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2053
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2054
    |line col|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2055
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2056
    cursorLine notNil ifTrue:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2057
	line := cursorLine.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2058
	col := cursorCol.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2059
	"
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2060
	 if there is a selection, its better to
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2061
	 have its start being visible, instead of the end
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2062
	"
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2063
	(selectionStartLine notNil
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2064
	and:[selectionEndLine notNil]) ifTrue:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2065
	    expandingTop ~~ false ifTrue:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2066
		line := selectionStartLine.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2067
		col := selectionStartCol.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2068
	    ] ifFalse:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2069
		line := selectionEndLine.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2070
		col := selectionEndCol
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2071
	    ]
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2072
	].
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2073
	self makeLineVisible:line.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2074
	self makeColVisible:col inLine:line
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2075
    ]
479
fae6d1251888 fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 477
diff changeset
  2076
fae6d1251888 fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 477
diff changeset
  2077
    "Modified: 6.3.1996 / 13:46:46 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2078
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2079
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2080
makeCursorVisibleAndShowCursor:flag
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2081
    "scroll to make cursorLine visible;
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2082
     if flag is true, draw the cursor"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2083
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2084
    self makeCursorVisible.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2085
    flag ifTrue:[self showCursor]
121
claus
parents: 118
diff changeset
  2086
!
claus
parents: 118
diff changeset
  2087
2422
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2088
setCursorCol:colNr
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2089
    "strictly private: set the cursorCol"
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2090
2815
d71f43d7de3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2796
diff changeset
  2091
    cursorCol := (colNr max:1).
2422
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2092
    cursorColHolder value:cursorCol.
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2093
!
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2094
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2095
setCursorLine:lineNr
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2096
    "strictly private: set the cursorLine"
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2097
3303
add21df4dcb1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3296
diff changeset
  2098
    "/ self assert:(lineNr notNil).
add21df4dcb1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3296
diff changeset
  2099
add21df4dcb1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3296
diff changeset
  2100
    cursorLine := (lineNr ? 1).
2422
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2101
    cursorLineHolder value:cursorLine.
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2102
    self updateCursorVisibleLine.
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2103
!
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2104
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2105
setCursorLine:lineNr col:colNr
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2106
    "strictly private: set the cursorLine, col and update the visibleLine"
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2107
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2108
    self setCursorLine:lineNr.
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2109
    self setCursorCol:colNr.
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2110
!
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2111
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2112
setValidatedCursorCol:colNr
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2113
    "strictly private: set the cursorCol"
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2114
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2115
    self setCursorCol:(self validateCursorCol:colNr inLine:cursorLine).
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2116
!
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2117
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2118
setValidatedCursorLine:lineNr
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2119
    "strictly private: set the cursorLine and update the visibleLine"
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2120
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2121
    self setCursorLine:(self validateCursorLine:lineNr).
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2122
!
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2123
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2124
setValidatedCursorLine:lineNr col:colNr
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2125
    "strictly private: set the cursorLine, col and update the visibleLine"
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2126
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2127
    self setValidatedCursorLine:lineNr.
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2128
    self setValidatedCursorCol:colNr.
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2129
!
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2130
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2131
showCursor
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2132
    "make cursor visible if currently invisible"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2133
1833
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  2134
    ^ self cursorShown:true
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  2135
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  2136
    "Modified: / 30.3.1999 / 16:02:34 / stefan"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2137
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2138
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2139
undrawCursor
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2140
    "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
  2141
2085
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  2142
    |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
  2143
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2144
    cursorVisibleLine notNil ifTrue:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2145
	prevCol := cursorCol - 1.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2146
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2147
	"/ if there is any italic stuff in the cursor line,
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2148
	"/ redraw it completely (because characters overlap).
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2149
	cursorCol > 1 ifTrue:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2150
	    (line := self listAt:cursorLine) notNil ifTrue:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2151
		line hasChangeOfEmphasis ifTrue:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2152
		    line size >= (cursorCol-1) ifTrue:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2153
			e1 := Text extractEmphasis:#italic from:(line emphasisAt:cursorCol-1).
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2154
			line size >= (cursorCol) ifTrue:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2155
			    e2 := Text extractEmphasis:#italic from:(line emphasisAt:cursorCol).
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2156
			    line size >= (cursorCol+1) ifTrue:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2157
				e3 := Text extractEmphasis:#italic from:(line emphasisAt:cursorCol+1)
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2158
			    ].
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2159
			].
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2160
		    ].
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2161
		    (e1 notNil or:[e2 notNil or:[e3 notNil]]) ifTrue:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2162
			^ super redrawVisibleLine:cursorVisibleLine
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2163
		    ]
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2164
		]
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2165
	    ]
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2166
	].
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2167
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2168
	((cursorType == #caret)
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2169
	 or:[cursorType == #solidCaret
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2170
	 or:[cursorType == #bigSolidCaret
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2171
	 or:[cursorType == #bigCaret
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2172
	 or:[cursorType == #Ibeam]]]]) ifTrue:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2173
	    "caret-cursor touches 4 characters"
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2174
	    ((cursorCol > 1) and:[fontIsFixedWidth]) ifTrue:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2175
		super redrawVisibleLine:cursorVisibleLine-1 from:prevCol to:cursorCol.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2176
		super redrawVisibleLine:cursorVisibleLine from:prevCol to:cursorCol.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2177
		super redrawVisibleLine:cursorVisibleLine+1 from:prevCol to:cursorCol.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2178
	    ] ifFalse:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2179
		"care for left margin"
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2180
		super redrawVisibleLine:cursorVisibleLine; redrawVisibleLine:cursorVisibleLine+1.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2181
	    ].
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2182
	    ^ self
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2183
	].
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2184
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2185
	cursorType == #ibeam ifTrue:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2186
	    "ibeam-cursor touches 2 characters"
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2187
	    cursorCol > 1 ifTrue:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2188
		super redrawVisibleLine:cursorVisibleLine from:prevCol to:cursorCol.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2189
	    ] ifFalse:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2190
		"care for left margin"
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2191
		super redrawVisibleLine:cursorVisibleLine.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2192
	    ].
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2193
	    ^ self
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2194
	].
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2195
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2196
	"block cursor is simple - just one character under cursor"
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2197
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2198
	"/ however, if italic characters are involved, we must care
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2199
	"/ for the chars before/after the cursor.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2200
	"/ We redraw the part of the previous character which got
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2201
	"/ detroyed by the block cursor.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2202
	"/ (must change the clip, to avoid destroying the prev-prev character)
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2203
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2204
	line := self visibleAt:cursorVisibleLine.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2205
	(line notNil and:[line isText]) ifTrue:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2206
	    cursorCol > 1 ifTrue:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2207
		oldClip := self clippingRectangleOrNil.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2208
		x := (self xOfCol:cursorCol inVisibleLine:cursorVisibleLine) - viewOrigin x.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2209
		y := self yOfVisibleLine:cursorVisibleLine.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2210
		self clippingRectangle:(x@y extent:((font width * 2) @ fontHeight)).
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2211
		super redrawVisibleLine:cursorVisibleLine from:cursorCol-1 to:cursorCol.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2212
		self clippingRectangle:oldClip.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2213
		^ self.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2214
	    ].
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2215
	].
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2216
	super redrawVisibleLine:cursorVisibleLine col:cursorCol
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2217
    ]
728
3ef81000ee8c new cursorTypes: #bigCaret and #bigSolidCaret
Claus Gittinger <cg@exept.de>
parents: 698
diff changeset
  2218
2088
b2beb67b1a98 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2085
diff changeset
  2219
    "Modified: / 15.12.1999 / 22:25:59 / cg"
121
claus
parents: 118
diff changeset
  2220
!
claus
parents: 118
diff changeset
  2221
2422
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2222
updateCursorVisibleLine
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2223
    "strictly private: set the visibleLine from the cursorLine.
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2224
     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
  2225
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2226
    cursorVisibleLine := self listLineToVisibleLine:cursorLine.
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2227
!
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2228
672
065750d02339 added cursorCol-validation
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  2229
validateCursorCol:col inLine:line
674
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  2230
    "check of col is a valid cursor position; return a new col-nr if not.
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2231
     Here, no limits are enforced (and col is returned),
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2232
     but it may be redefined in EditFields or views which dont like the
674
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  2233
     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
  2234
1300
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  2235
    |l max|
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  2236
1419
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
  2237
    "/ in ST80 mode,
2707
810c994db0b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2696
diff changeset
  2238
    "/ the cursor may not be positioned beyond the
810c994db0b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2696
diff changeset
  2239
    "/ end of a line or beyond the last line of the text
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2240
3023
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  2241
    self st80EditMode ifTrue:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2242
	l := (self listAt:line).
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2243
	max := l size + 1.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2244
	col > max ifTrue:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2245
	    ^ max
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2246
	]
1300
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  2247
    ].
672
065750d02339 added cursorCol-validation
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  2248
    ^ col
065750d02339 added cursorCol-validation
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  2249
1419
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
  2250
    "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
  2251
    "Modified: / 20.6.1998 / 18:19:24 / cg"
674
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  2252
!
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  2253
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  2254
validateCursorLine:line
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  2255
    "check of line is a valid cursor line; return a fixed line-nr if not.
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2256
     Here, no limits are enforced (and line is returned), but it may be
674
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  2257
     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
  2258
     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
  2259
     skip reserved regions"
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  2260
1419
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
  2261
    "/
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
  2262
    "/ in st80Mode, the cursor may not be positioned
2707
810c994db0b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2696
diff changeset
  2263
    "/ beyond the last line
1419
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
  2264
    "/
3023
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  2265
    self st80EditMode ifTrue:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2266
	^ (line min:(list size)) max:1
1419
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
  2267
    ].
674
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  2268
    ^ line
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  2269
1419
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
  2270
    "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
  2271
    "Modified: / 20.6.1998 / 18:19:26 / cg"
672
065750d02339 added cursorCol-validation
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  2272
!
065750d02339 added cursorCol-validation
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  2273
121
claus
parents: 118
diff changeset
  2274
withCursorOffDo:aBlock
claus
parents: 118
diff changeset
  2275
    "evaluate aBlock with cursor off; turn it on afterwards."
claus
parents: 118
diff changeset
  2276
claus
parents: 118
diff changeset
  2277
    (shown not or:[cursorShown not]) ifTrue:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2278
	^ aBlock value
121
claus
parents: 118
diff changeset
  2279
    ].
claus
parents: 118
diff changeset
  2280
    self hideCursor.
2522
d80496af7eaf #valueNowOrOnUnwindDo: -> #ensure:
Claus Gittinger <cg@exept.de>
parents: 2506
diff changeset
  2281
    aBlock ensure:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2282
	self showCursor
121
claus
parents: 118
diff changeset
  2283
    ]
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2284
! !
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2285
2589
62794ae04446 support drop
ca
parents: 2580
diff changeset
  2286
!EditTextView methodsFor:'drag & drop'!
62794ae04446 support drop
ca
parents: 2580
diff changeset
  2287
62794ae04446 support drop
ca
parents: 2580
diff changeset
  2288
allowDrop:aBoolean
3236
aeb1fe5a6ead drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3235
diff changeset
  2289
    "enable/disable drop support"
aeb1fe5a6ead drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3235
diff changeset
  2290
2589
62794ae04446 support drop
ca
parents: 2580
diff changeset
  2291
    aBoolean ifFalse:[
3236
aeb1fe5a6ead drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3235
diff changeset
  2292
        dropTarget := nil.
2589
62794ae04446 support drop
ca
parents: 2580
diff changeset
  2293
    ] ifTrue:[
3439
3bdadf887895 changed #allowDrop:
Claus Gittinger <cg@exept.de>
parents: 3431
diff changeset
  2294
        dropTarget isNil ifTrue:[
3236
aeb1fe5a6ead drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3235
diff changeset
  2295
            dropTarget := DropTarget receiver:self
aeb1fe5a6ead drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3235
diff changeset
  2296
                              argument:nil
aeb1fe5a6ead drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3235
diff changeset
  2297
                          dropSelector:#'drop:'
aeb1fe5a6ead drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3235
diff changeset
  2298
                       canDropSelector:#'canDrop:'
aeb1fe5a6ead drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3235
diff changeset
  2299
        ]
aeb1fe5a6ead drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3235
diff changeset
  2300
    ].
aeb1fe5a6ead drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3235
diff changeset
  2301
!
aeb1fe5a6ead drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3235
diff changeset
  2302
3412
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  2303
canDrop:aDropContext
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  2304
    "public from d&d.
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  2305
     I accept textObjects and fileObjects only."
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  2306
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  2307
    aDropContext sourceWidget == self ifTrue:[^ false].
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  2308
    ^ self canDropObjects:aDropContext dropObjects
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  2309
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  2310
    "Modified: / 13-10-2006 / 17:41:09 / cg"
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  2311
!
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  2312
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  2313
canDropObjects:aCollectionOfDropObjects
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  2314
    "public from d&d.
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  2315
     I accept textObjects and fileObjects only."
2589
62794ae04446 support drop
ca
parents: 2580
diff changeset
  2316
62794ae04446 support drop
ca
parents: 2580
diff changeset
  2317
    self checkModificationsAllowed ifFalse:[^ false].
62794ae04446 support drop
ca
parents: 2580
diff changeset
  2318
3412
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  2319
    aCollectionOfDropObjects isEmpty ifTrue:[ ^ false ].
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  2320
    ^ aCollectionOfDropObjects conform:[:obj| (obj isTextObject or:[obj isFileObject])]
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  2321
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  2322
    "Created: / 13-10-2006 / 15:56:57 / cg"
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  2323
    "Modified: / 13-10-2006 / 17:41:14 / cg"
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  2324
!
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  2325
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  2326
drop:aDropContext
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  2327
    "public from d&d.
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  2328
     drop objects (new API)"
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  2329
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  2330
    self dropObjects:(aDropContext dropObjects)
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  2331
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  2332
    "Modified: / 13-10-2006 / 17:41:19 / cg"
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  2333
!
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  2334
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  2335
dropFileObject:aDropObject
2589
62794ae04446 support drop
ca
parents: 2580
diff changeset
  2336
    "drop objects
3236
aeb1fe5a6ead drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3235
diff changeset
  2337
     For bw. compatibility, also collections of drop objects are handled (may vanish)"
aeb1fe5a6ead drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3235
diff changeset
  2338
3412
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  2339
    |obj answer text fn|
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  2340
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  2341
    fn := aDropObject asFilename.
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  2342
    (fn exists and:[fn isRegularFile]) ifTrue:[
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  2343
        answer := Dialog 
3416
02d209269ec3 drag & drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3415
diff changeset
  2344
                    confirmWithCancel:(resources 
02d209269ec3 drag & drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3415
diff changeset
  2345
                                        string:'Drop the Filename (%1) or its Contents ?' 
02d209269ec3 drag & drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3415
diff changeset
  2346
                                        with:fn name allBold)
3412
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  2347
                    labels:#( 'Cancel' 'Name' 'Contents').
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  2348
        answer isNil ifTrue:[ ^ self ].
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  2349
        answer ifTrue:[
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  2350
            text := fn contentsOfEntireFile
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  2351
        ] ifFalse:[
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  2352
            text := fn pathName 
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  2353
        ].
3236
aeb1fe5a6ead drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3235
diff changeset
  2354
    ] ifFalse:[
3412
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  2355
        text := obj asString 
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  2356
    ].
3495
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  2357
    self undoablePaste:text info:'drop file'.
3412
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  2358
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  2359
    "Created: / 13-10-2006 / 17:38:31 / cg"
3495
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  2360
    "Modified: / 28-07-2007 / 13:27:09 / cg"
3412
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  2361
!
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  2362
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  2363
dropObject:aDropObject
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  2364
    "drop objects
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  2365
     For bw. compatibility, also collections of drop objects are handled (may vanish)"
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  2366
3415
35ffbeec46d9 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3412
diff changeset
  2367
    |text|
35ffbeec46d9 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3412
diff changeset
  2368
3412
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  2369
    (aDropObject isFileObject) ifTrue:[
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  2370
        self dropFileObject:aDropObject
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  2371
    ] ifFalse:[
3415
35ffbeec46d9 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3412
diff changeset
  2372
        aDropObject isTextObject ifTrue:[
35ffbeec46d9 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3412
diff changeset
  2373
            text := aDropObject theObject asStringWithoutFinalCR
35ffbeec46d9 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3412
diff changeset
  2374
        ] ifFalse:[
35ffbeec46d9 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3412
diff changeset
  2375
            text := aDropObject theObject asString
35ffbeec46d9 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3412
diff changeset
  2376
        ].
3495
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  2377
        self undoablePaste:text info:'drop'.
3412
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  2378
    ].
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  2379
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  2380
    "Created: / 13-10-2006 / 17:37:05 / cg"
3495
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  2381
    "Modified: / 28-07-2007 / 13:26:53 / cg"
3412
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  2382
!
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  2383
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  2384
dropObjects:aCollectionOfDropObjects
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  2385
    "public from d&d.
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  2386
     drop objects (old API)"
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  2387
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  2388
    aCollectionOfDropObjects do:[:el| 
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  2389
        self dropObject:el
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  2390
    ].
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  2391
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  2392
    "Created: / 13-10-2006 / 15:59:40 / cg"
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  2393
    "Modified: / 13-10-2006 / 17:41:23 / cg"
2589
62794ae04446 support drop
ca
parents: 2580
diff changeset
  2394
! !
62794ae04446 support drop
ca
parents: 2580
diff changeset
  2395
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2396
!EditTextView methodsFor:'editing'!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2397
313
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2398
copyAndDeleteSelection
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2399
    "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
  2400
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2401
    selectionStartLine notNil ifTrue:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2402
	self setClipboardText:(self selection).
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2403
	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
  2404
    ].
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2405
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2406
    "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
  2407
!
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  2408
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2409
deleteCharAtCursor
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2410
    "delete single character under cursor; does not merge lines"
121
claus
parents: 118
diff changeset
  2411
claus
parents: 118
diff changeset
  2412
    |wasOn|
claus
parents: 118
diff changeset
  2413
claus
parents: 118
diff changeset
  2414
    wasOn := self hideCursor.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2415
    self deleteCharAtLine:cursorLine col:cursorCol.
121
claus
parents: 118
diff changeset
  2416
    wasOn ifTrue:[self showCursor]
claus
parents: 118
diff changeset
  2417
!
claus
parents: 118
diff changeset
  2418
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2419
deleteCharAtLine:lineNr col:colNr
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2420
    "delete a single character at colNr in line lineNr"
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2421
3023
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  2422
    self st80EditMode ifTrue:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2423
	(self listAt:cursorLine) size + 1 = colNr ifTrue:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2424
	    | wasOn |
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2425
	    wasOn := self hideCursor.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2426
	    self
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2427
		cursorReturn;
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2428
		cursorCol:1;
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2429
		deleteCharBeforeCursor.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2430
	    wasOn ifTrue:[ self showCursor].
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2431
	    ^ self.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2432
	].
3023
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  2433
    ].
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  2434
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2435
    self deleteCharsAtLine:lineNr fromCol:colNr toCol:colNr
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2436
!
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2437
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2438
deleteCharBeforeCursor
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2439
    "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
  2440
2491
f3e207ae5156 auto indent fix
Claus Gittinger <cg@exept.de>
parents: 2461
diff changeset
  2441
    |soCol wasOn lineNrAboveCursor ln prevTab|
121
claus
parents: 118
diff changeset
  2442
claus
parents: 118
diff changeset
  2443
    wasOn := self hideCursor.
2491
f3e207ae5156 auto indent fix
Claus Gittinger <cg@exept.de>
parents: 2461
diff changeset
  2444
    autoIndent ifTrue:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2445
	prevTab := (self prevTabBefore:cursorCol) max:1.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2446
	ln := (list at:cursorLine) ? ''.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2447
	ln size < prevTab ifTrue:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2448
	    ln := ln , (String new:prevTab withAll:Character space).
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2449
	].
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2450
	(ln copyTo:prevTab) isBlank ifTrue:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2451
	    (ln copyFrom:prevTab+1) isBlank ifTrue:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2452
		cursorCol > prevTab ifTrue:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2453
		    self cursorLine:cursorLine col:prevTab.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2454
		    wasOn ifTrue:[ self showCursor ].
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2455
		    ^  self
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2456
		].
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2457
	    ] ifFalse:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2458
		self deleteFromLine:cursorLine col:prevTab toLine:cursorLine col:cursorCol-1.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2459
		self cursorLine:cursorLine col:prevTab.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2460
		wasOn ifTrue:[ self showCursor ].
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2461
		^  self.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2462
	    ]
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2463
	].
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2464
    ].
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2465
2491
f3e207ae5156 auto indent fix
Claus Gittinger <cg@exept.de>
parents: 2461
diff changeset
  2466
"/        (autoIndent
f3e207ae5156 auto indent fix
Claus Gittinger <cg@exept.de>
parents: 2461
diff changeset
  2467
"/    and:[cursorCol  ~~ 1
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2468
"/    and:[cursorLine <= (list size)]])
2491
f3e207ae5156 auto indent fix
Claus Gittinger <cg@exept.de>
parents: 2461
diff changeset
  2469
"/     ifTrue:[
f3e207ae5156 auto indent fix
Claus Gittinger <cg@exept.de>
parents: 2461
diff changeset
  2470
"/        soCol := (self leftIndentForLine:cursorLine) + 1.
f3e207ae5156 auto indent fix
Claus Gittinger <cg@exept.de>
parents: 2461
diff changeset
  2471
"/
f3e207ae5156 auto indent fix
Claus Gittinger <cg@exept.de>
parents: 2461
diff changeset
  2472
"/        (cursorCol == soCol and:[soCol > 1]) ifTrue:[
f3e207ae5156 auto indent fix
Claus Gittinger <cg@exept.de>
parents: 2461
diff changeset
  2473
"/            ln := list at:cursorLine.
f3e207ae5156 auto indent fix
Claus Gittinger <cg@exept.de>
parents: 2461
diff changeset
  2474
"/            (ln notNil and:[(ln indexOfNonSeparatorStartingAt:1) < soCol]) ifTrue:[
f3e207ae5156 auto indent fix
Claus Gittinger <cg@exept.de>
parents: 2461
diff changeset
  2475
"/                soCol := 1
f3e207ae5156 auto indent fix
Claus Gittinger <cg@exept.de>
parents: 2461
diff changeset
  2476
"/            ]
f3e207ae5156 auto indent fix
Claus Gittinger <cg@exept.de>
parents: 2461
diff changeset
  2477
"/        ]
f3e207ae5156 auto indent fix
Claus Gittinger <cg@exept.de>
parents: 2461
diff changeset
  2478
"/    ] ifFalse:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2479
	soCol := 1.
2491
f3e207ae5156 auto indent fix
Claus Gittinger <cg@exept.de>
parents: 2461
diff changeset
  2480
"/    ].
f3e207ae5156 auto indent fix
Claus Gittinger <cg@exept.de>
parents: 2461
diff changeset
  2481
1419
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
  2482
    (cursorCol ~~ soCol and:[cursorCol ~~ 1]) ifTrue:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2483
	"
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2484
	 somewhere in the middle of a line
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2485
	"
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2486
	self cursorLeft.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2487
	self deleteCharAtLine:cursorLine col:cursorCol.
1419
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
  2488
    ] ifFalse:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2489
	"
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2490
	 at begin of line - merge with previous line;
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2491
	 except for the very first line.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2492
	"
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2493
	(cursorLine == 1) ifFalse:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2494
	    lineNrAboveCursor := self validateCursorLine:(cursorLine - 1).
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2495
	    lineNrAboveCursor < cursorLine ifTrue:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2496
		(lineNrAboveCursor > 0 and:[lineNrAboveCursor > list size]) ifTrue:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2497
		    "/ we are beyond the end of the text.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2498
		    "/ move the cursor to the previous line.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2499
		    self cursorLine:lineNrAboveCursor col:1.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2500
		] ifFalse:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2501
		    self mergeLine:lineNrAboveCursor removeBlanks:false.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2502
		]
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2503
	    ]
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2504
	]
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2505
    ].
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2506
    wasOn ifTrue:[ self showCursor ]
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2507
1419
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
  2508
    "Modified: / 16.1.1998 / 22:33:04 / cg"
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2509
!
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2510
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2511
deleteCharsAtLine:lineNr fromCol:colNr
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2512
    "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
  2513
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2514
    |line|
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2515
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2516
    (line := self listAt:lineNr) notNil ifTrue:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2517
	self deleteCharsAtLine:lineNr fromCol:colNr toCol:(line size)
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2518
    ]
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2519
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2520
!
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2521
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2522
deleteCharsAtLine:lineNr toCol:colNr
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2523
    "delete characters from start up to colNr in line lineNr"
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2524
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2525
    self deleteCharsAtLine:lineNr fromCol:1 toCol:colNr
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2526
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2527
121
claus
parents: 118
diff changeset
  2528
!
claus
parents: 118
diff changeset
  2529
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2530
deleteCursorLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2531
    "delete the line where the cursor sits"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2532
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2533
    self deleteLine:cursorLine
121
claus
parents: 118
diff changeset
  2534
!
claus
parents: 118
diff changeset
  2535
2385
357e8a1cb2b2 added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents: 2373
diff changeset
  2536
deleteFromCharacterPosition:charPos1 to:charPos2
357e8a1cb2b2 added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents: 2373
diff changeset
  2537
    "delete a substring at a character position"
357e8a1cb2b2 added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents: 2373
diff changeset
  2538
357e8a1cb2b2 added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents: 2373
diff changeset
  2539
    |line1 col1 line2 col2|
357e8a1cb2b2 added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents: 2373
diff changeset
  2540
357e8a1cb2b2 added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents: 2373
diff changeset
  2541
    line1 := self lineOfCharacterPosition:charPos1.
357e8a1cb2b2 added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents: 2373
diff changeset
  2542
    col1 := charPos1 - (self characterPositionOfLine:line1 col:1) + 1.
2725
eccf283b2efb deleteFromCharacterPos - fixed
Claus Gittinger <cg@exept.de>
parents: 2724
diff changeset
  2543
    col1 == 0 ifTrue:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2544
	line1 := line1 - 1.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2545
	col1 := (self listAt:line1) size + 1.
2725
eccf283b2efb deleteFromCharacterPos - fixed
Claus Gittinger <cg@exept.de>
parents: 2724
diff changeset
  2546
    ].
2385
357e8a1cb2b2 added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents: 2373
diff changeset
  2547
357e8a1cb2b2 added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents: 2373
diff changeset
  2548
    line2 := self lineOfCharacterPosition:charPos2.
357e8a1cb2b2 added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents: 2373
diff changeset
  2549
    col2 := charPos2 - (self characterPositionOfLine:line2 col:1) + 1.
357e8a1cb2b2 added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents: 2373
diff changeset
  2550
357e8a1cb2b2 added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents: 2373
diff changeset
  2551
    self deleteFromLine:line1 col:col1 toLine:line2 col:col2.
357e8a1cb2b2 added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents: 2373
diff changeset
  2552
!
357e8a1cb2b2 added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents: 2373
diff changeset
  2553
2954
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  2554
deleteFromLine:startLine col:startCol toLine:endLine col:endCol
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  2555
    "delete all text from startLine/startCol to endLine/endCol -
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  2556
     joining lines if nescessary"
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  2557
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  2558
    |line newLine lineSize nMore|
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  2559
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  2560
    self checkModificationsAllowed ifFalse:[ ^ self].
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  2561
    list isNil ifTrue:[^ self].
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  2562
    startLine > list size ifTrue:[ ^ self]. "/ deleted space below text
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  2563
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  2564
    (startLine == endLine) ifTrue:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2565
	"/ delete chars within a line
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2566
	self deleteCharsAtLine:startLine fromCol:startCol toCol:endCol.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2567
	^ self
2954
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  2568
    ].
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  2569
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  2570
    ((startCol == 1) and:[endCol == 0]) ifTrue:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2571
	"/ delete full lines only
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2572
	endLine > startLine ifTrue:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2573
	    self deleteFromLine:startLine toLine:(endLine - 1)
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2574
	].
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2575
	^ self
2954
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  2576
    ].
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  2577
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  2578
    "/ delete right rest of 1st line
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  2579
    self deleteCharsAtLine:startLine fromCol:startCol.
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  2580
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  2581
    "/ delete the inner lines ...
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  2582
    endLine > (startLine + 1) ifTrue:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2583
	self deleteFromLine:(startLine + 1) toLine:(endLine - 1)
2954
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  2584
    ].
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  2585
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  2586
    (endCol ~~ 0) ifTrue:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2587
	"/ delete the left rest of the last line
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2588
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2589
	self deleteCharsAtLine:(startLine + 1) toCol:endCol.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2590
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2591
	"/ must add blanks, if startCol lies beyond end of startLine
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2592
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2593
	line := list at:startLine.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2594
	lineSize := line size.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2595
	(startCol > lineSize) ifTrue:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2596
	    newLine := line.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2597
	    line isNil ifTrue:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2598
		newLine := String new:(startCol - 1)
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2599
	    ] ifFalse:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2600
		nMore := startCol - 1 - lineSize.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2601
		nMore > 0 ifTrue:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2602
		    newLine := line , (line species new:nMore)
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2603
		]
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2604
	    ].
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2605
	    newLine ~~ line ifTrue:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2606
		list at:startLine put:newLine.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2607
	    ].
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2608
	    "/ TODO: remember old maxwidth of linerange,
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2609
	    "/ only clear widthOfWidestLine, if this max
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2610
	    "/ length was (one of) the longest.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2611
	    "/ avoids slow delete with huge texts.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2612
	    widthOfWidestLine := nil. "/ i.e. unknown
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2613
	    self textChanged.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2614
	]
2954
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  2615
    ].
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  2616
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  2617
    "/ 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
  2618
    self mergeLine:startLine removeBlanks:false
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  2619
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  2620
    "Modified: / 10.11.1998 / 23:52:59 / cg"
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  2621
!
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  2622
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2623
deleteLine:lineNr
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2624
    "delete line"
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2625
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2626
    self deleteFromLine:lineNr toLine:lineNr
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2627
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2628
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2629
!
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2630
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2631
deleteLinesWithoutRedrawFrom:startLine to:endLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2632
    "delete lines - no redraw;
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2633
     return true, if something was really deleted"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2634
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2635
    |lastLine|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2636
331
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
  2637
    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
  2638
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2639
    (list isNil or:[startLine > list size]) ifTrue:[^ false].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2640
    (endLine > list size) ifTrue:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2641
	lastLine := list size
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2642
    ] ifFalse:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2643
	lastLine := endLine
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2644
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2645
    list removeFromIndex:startLine toIndex:lastLine.
1717
83203096a851 dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  2646
    "/ TODO: remember old maxwidth of linerange,
83203096a851 dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  2647
    "/ only clear widthOfWidestLine, if this max
83203096a851 dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  2648
    "/ length was (one of) the longest.
83203096a851 dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  2649
    "/ avoids slow delete with huge texts.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2650
    widthOfWidestLine := nil. "/ i.e. unknown
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
    ^ true
1717
83203096a851 dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  2653
83203096a851 dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  2654
    "Modified: / 10.11.1998 / 23:55:29 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2655
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2656
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2657
deleteSelection
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2658
    "delete the selection"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2659
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2660
    |wasOn startLine startCol endLine endCol|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2661
331
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
  2662
    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
  2663
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2664
    selectionStartLine notNil ifTrue:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2665
	wasOn := self hideCursor.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2666
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2667
	startLine := selectionStartLine.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2668
	startCol := selectionStartCol.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2669
	endLine := selectionEndLine.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2670
	endCol := selectionEndCol.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2671
	self unselectWithoutRedraw.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2672
	self deleteFromLine:startLine col:startCol toLine:endLine col:endCol.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2673
	self setCursorLine:startLine col:startCol.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2674
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2675
	self makeCursorVisibleAndShowCursor:wasOn
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2676
    ]
121
claus
parents: 118
diff changeset
  2677
!
claus
parents: 118
diff changeset
  2678
2157
ba22c3cc278b added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
  2679
deleteWordBeforeCursor
ba22c3cc278b added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
  2680
    "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
  2681
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  2682
    |wasOn beginCol beginLine endCol endLine|
2157
ba22c3cc278b added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
  2683
ba22c3cc278b added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
  2684
    wasOn := self hideCursor.
ba22c3cc278b added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
  2685
    endCol := cursorCol-1.
ba22c3cc278b added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
  2686
    endLine := cursorLine.
ba22c3cc278b added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
  2687
    self cursorToPreviousWord.
ba22c3cc278b added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
  2688
    beginCol := cursorCol.
ba22c3cc278b added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
  2689
    beginLine := cursorLine.
ba22c3cc278b added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
  2690
    self deleteFromLine:beginLine col:beginCol toLine:endLine col:endCol.
ba22c3cc278b added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
  2691
    wasOn ifTrue:[ self showCursor ].
ba22c3cc278b added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
  2692
ba22c3cc278b added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
  2693
    "Modified: / 22.2.2000 / 23:59:04 / cg"
ba22c3cc278b added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
  2694
!
ba22c3cc278b added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
  2695
121
claus
parents: 118
diff changeset
  2696
insertCharAtCursor:aCharacter
1566
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  2697
    "insert a single character at cursor-position - advance cursor."
121
claus
parents: 118
diff changeset
  2698
claus
parents: 118
diff changeset
  2699
    |wasOn|
claus
parents: 118
diff changeset
  2700
claus
parents: 118
diff changeset
  2701
    wasOn := self hideCursor.
1566
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  2702
    aCharacter == Character tab ifTrue:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2703
	"/ needs special care to advance cursor correctly
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2704
	self insertTabAtCursor
121
claus
parents: 118
diff changeset
  2705
    ] ifFalse:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2706
	self insert:aCharacter atLine:cursorLine col:cursorCol.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2707
	aCharacter == (Character cr) ifTrue:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2708
	    self cursorReturn
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2709
	] ifFalse:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2710
	    self cursorRight.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2711
	].
121
claus
parents: 118
diff changeset
  2712
    ].
claus
parents: 118
diff changeset
  2713
    self makeCursorVisibleAndShowCursor:wasOn.
1566
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  2714
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  2715
    "Modified: / 12.6.1998 / 21:50:20 / cg"
121
claus
parents: 118
diff changeset
  2716
!
claus
parents: 118
diff changeset
  2717
641
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  2718
insertLine:aString before:lineNr
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  2719
    "insert the line aString before line lineNr"
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  2720
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  2721
    ^ self insertLines:(Array with:aString) from:1 to:1  before:lineNr.
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  2722
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  2723
    "Modified: 14.5.1996 / 13:42:54 / cg"
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  2724
!
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  2725
155
claus
parents: 133
diff changeset
  2726
insertLines:aStringCollection before:lineNr
claus
parents: 133
diff changeset
  2727
    "insert a bunch before line lineNr"
claus
parents: 133
diff changeset
  2728
claus
parents: 133
diff changeset
  2729
    self insertLines:aStringCollection from:1 to:aStringCollection size before:lineNr
claus
parents: 133
diff changeset
  2730
claus
parents: 133
diff changeset
  2731
    "Modified: 6.9.1995 / 20:51:03 / claus"
claus
parents: 133
diff changeset
  2732
!
claus
parents: 133
diff changeset
  2733
654
d621e63baaa5 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 641
diff changeset
  2734
insertLines:lines withCR:withCr
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2735
    "insert a bunch of lines at cursor position.
1566
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  2736
     Cursor is moved behind insertion.
641
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  2737
     If withCr is true, append cr after last line"
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  2738
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  2739
    |start end nLines wasOn|
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  2740
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  2741
    lines notNil ifTrue:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2742
	nLines := lines size.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2743
	(nLines == 1) ifTrue:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2744
	    self insertStringAtCursor:(lines at:1).
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2745
	    withCr ifTrue:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2746
		self insertCharAtCursor:(Character cr)
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2747
	    ]
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2748
	] ifFalse:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2749
	    (cursorCol ~~ 1) ifTrue:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2750
		self insertStringAtCursor:(lines at:1).
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2751
		self insertCharAtCursor:(Character cr).
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2752
		start := 2
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2753
	    ] ifFalse:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2754
		start := 1
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2755
	    ].
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2756
	    withCr ifTrue:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2757
		end := nLines
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2758
	    ] ifFalse:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2759
		end := nLines - 1
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2760
	    ].
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2761
	    (start < nLines) ifTrue:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2762
		(end >= start) ifTrue:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2763
		    wasOn := self hideCursor.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2764
		    self insertLines:lines from:start to:end before:cursorLine.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2765
		    self setCursorLine:(cursorLine + (end - start + 1)).
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2766
		    wasOn ifTrue:[self showCursor].
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2767
		]
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2768
	    ].
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2769
	    withCr ifFalse:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2770
		"last line without cr"
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2771
		self insertStringAtCursor:(lines at:nLines)
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2772
	    ]
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2773
	]
641
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  2774
    ]
654
d621e63baaa5 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 641
diff changeset
  2775
1566
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  2776
    "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
  2777
    "Modified: / 12.6.1998 / 21:51:16 / cg"
654
d621e63baaa5 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 641
diff changeset
  2778
!
d621e63baaa5 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 641
diff changeset
  2779
d621e63baaa5 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 641
diff changeset
  2780
insertLines:lines withCr:withCr
d621e63baaa5 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 641
diff changeset
  2781
    "insert a bunch of lines at cursor position. Cursor
d621e63baaa5 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 641
diff changeset
  2782
     is moved behind insertion.
d621e63baaa5 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 641
diff changeset
  2783
     If withCr is true, append cr after last line"
d621e63baaa5 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 641
diff changeset
  2784
2363
1982139b2c0b Use <resource:#obsolete>
Stefan Vogel <sv@exept.de>
parents: 2357
diff changeset
  2785
    <resource:#obsolete>
1982139b2c0b Use <resource:#obsolete>
Stefan Vogel <sv@exept.de>
parents: 2357
diff changeset
  2786
1292
ca4c9a957a32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1290
diff changeset
  2787
    self obsoleteMethodWarning:'use #insertLines:withCR:'.
ca4c9a957a32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1290
diff changeset
  2788
    self insertLines:lines withCR:withCr.
ca4c9a957a32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1290
diff changeset
  2789
ca4c9a957a32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1290
diff changeset
  2790
    "Modified: 31.7.1997 / 23:07:22 / cg"
641
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  2791
!
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  2792
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2793
insertSelectedStringAtCursor:aString
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2794
    "insert the argument, aString at cursor position and select it"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2795
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2796
    |startLine startCol|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2797
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2798
    startLine := cursorLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2799
    startCol := cursorCol.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2800
    self insertStringAtCursor:aString.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2801
    self selectFromLine:startLine col:startCol
3514
98e103cad51d insertSelectedStringAtCursor: - make selection visible afterwards;
Michael Beyl <mb@exept.de>
parents: 3510
diff changeset
  2802
                 toLine:cursorLine col:(cursorCol - 1).
98e103cad51d insertSelectedStringAtCursor: - make selection visible afterwards;
Michael Beyl <mb@exept.de>
parents: 3510
diff changeset
  2803
    self makeSelectionVisible.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2804
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2805
1935
b59ff4681762 added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
  2806
insertString:aString atCharacterPosition:charPos
b59ff4681762 added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
  2807
    "insert the argument, aString at a character position"
b59ff4681762 added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
  2808
b59ff4681762 added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
  2809
    |line col|
b59ff4681762 added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
  2810
b59ff4681762 added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
  2811
    line := self lineOfCharacterPosition:charPos.
b59ff4681762 added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
  2812
    col := charPos - (self characterPositionOfLine:line col:1) + 1.
b59ff4681762 added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
  2813
    self insertString:aString atLine:line col:col
b59ff4681762 added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
  2814
!
b59ff4681762 added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
  2815
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2816
insertString:aString atLine:lineNr col:colNr
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2817
    "insert the string, aString at line/col;
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2818
     handle cr's correctly"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2819
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2820
    |start           "{ Class: SmallInteger }"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2821
     stop            "{ Class: SmallInteger }"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2822
     end             "{ Class: SmallInteger }"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2823
     subString c
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2824
     l               "{ Class: SmallInteger }" |
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2825
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2826
    aString isNil ifTrue:[^ self].
1560
43d0f7c2143f use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents: 1559
diff changeset
  2827
    (aString includes:(Character cr)) ifFalse:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2828
	^ self insertStringWithoutCRs:aString atLine:lineNr col:colNr
121
claus
parents: 118
diff changeset
  2829
    ].
1560
43d0f7c2143f use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents: 1559
diff changeset
  2830
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2831
    l := lineNr.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2832
    c := colNr.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2833
    start := 1.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2834
    end := aString size.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2835
    [start <= end] whileTrue:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2836
	stop := aString indexOf:(Character cr) startingAt:start.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2837
	stop == 0 ifTrue:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2838
	    stop := end + 1
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2839
	].
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2840
	subString := aString copyFrom:start to:(stop - 1).
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2841
	self insertStringWithoutCRs:subString atLine:l col:c.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2842
	(stop <= end) ifTrue:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2843
	    c := c + subString size.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2844
	    self insert:(Character cr) atLine:l col:c.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2845
	    l := l + 1.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2846
	    c := 1
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2847
	].
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2848
	start := stop + 1
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2849
    ]
1480
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  2850
1560
43d0f7c2143f use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents: 1559
diff changeset
  2851
    "Modified: / 10.6.1998 / 19:03:59 / cg"
121
claus
parents: 118
diff changeset
  2852
!
claus
parents: 118
diff changeset
  2853
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2854
insertStringAtCursor:aString
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2855
    "insert the argument, aString at cursor position
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2856
     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
  2857
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2858
    aString isNil ifTrue:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2859
	"new:"
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2860
	self insertCharAtCursor:(Character cr).
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2861
	^ self
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  2862
    ].
1560
43d0f7c2143f use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents: 1559
diff changeset
  2863
    (aString includes:(Character cr)) ifFalse:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2864
	^ self insertStringWithoutCRsAtCursor:aString
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  2865
    ].
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  2866
654
d621e63baaa5 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 641
diff changeset
  2867
    self insertLines:aString asStringCollection withCR:false.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2868
1560
43d0f7c2143f use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents: 1559
diff changeset
  2869
    "Modified: / 10.6.1998 / 19:03:21 / cg"
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  2870
!
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  2871
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2872
insertStringWithoutCRs:aString atLine:lineNr col:colNr
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2873
    "insert aString (which has no crs) at lineNr/colNr"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2874
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2875
    self withoutRedrawInsertStringWithoutCRs:aString atLine:lineNr col:colNr.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2876
    shown ifTrue:[self redrawLine:lineNr from:colNr]
1480
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  2877
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  2878
    "Modified: / 5.4.1998 / 16:51:14 / cg"
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  2879
!
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  2880
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2881
insertStringWithoutCRsAtCursor:aString
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2882
    "insert a string (which has no crs) at cursor position
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2883
     - advance cursor"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2884
2422
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2885
    |wasOn oldLen newLen deltaLen|
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2886
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2887
    aString size > 0 ifTrue:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2888
	wasOn := self hideCursor.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2889
	(aString includes:Character tab) ifTrue:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2890
	    self checkForExistingLine:cursorLine.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2891
	    oldLen := (list at:cursorLine) size.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2892
	    self insertString:aString atLine:cursorLine col:cursorCol.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2893
	    newLen := (list at:cursorLine) size.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2894
	    deltaLen := newLen - oldLen.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2895
	] ifFalse:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2896
	    self insertString:aString atLine:(cursorLine ? 1) col:cursorCol.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2897
	    deltaLen := aString size.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2898
	].
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2899
	self setCursorCol:(cursorCol + deltaLen).
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2900
	wasOn ifTrue:[self showCursor]
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2901
    ]
1563
b4eb49efdfcd fixed cursor positioning if inserting a string with tabs.
Claus Gittinger <cg@exept.de>
parents: 1561
diff changeset
  2902
b4eb49efdfcd fixed cursor positioning if inserting a string with tabs.
Claus Gittinger <cg@exept.de>
parents: 1561
diff changeset
  2903
    "Modified: / 10.6.1998 / 20:43:52 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2904
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2905
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2906
insertTabAtCursor
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2907
    "insert spaces to next tab"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2908
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2909
    |wasOn nextTab|
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  2910
121
claus
parents: 118
diff changeset
  2911
    wasOn := self hideCursor.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2912
    nextTab := self nextTabAfter:cursorCol.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2913
    self insertStringAtCursor:(String new:(nextTab - cursorCol)).
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2914
    self makeCursorVisibleAndShowCursor:wasOn.
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  2915
!
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  2916
3542
30ed44ed0178 +joinLines (CTRL-j);
Claus Gittinger <cg@exept.de>
parents: 3517
diff changeset
  2917
joinLines
30ed44ed0178 +joinLines (CTRL-j);
Claus Gittinger <cg@exept.de>
parents: 3517
diff changeset
  2918
    self 
30ed44ed0178 +joinLines (CTRL-j);
Claus Gittinger <cg@exept.de>
parents: 3517
diff changeset
  2919
        undoableDo:[
30ed44ed0178 +joinLines (CTRL-j);
Claus Gittinger <cg@exept.de>
parents: 3517
diff changeset
  2920
            self mergeLine:cursorLine removeBlanks:true
30ed44ed0178 +joinLines (CTRL-j);
Claus Gittinger <cg@exept.de>
parents: 3517
diff changeset
  2921
        ]
30ed44ed0178 +joinLines (CTRL-j);
Claus Gittinger <cg@exept.de>
parents: 3517
diff changeset
  2922
        info:'Join'
30ed44ed0178 +joinLines (CTRL-j);
Claus Gittinger <cg@exept.de>
parents: 3517
diff changeset
  2923
!
30ed44ed0178 +joinLines (CTRL-j);
Claus Gittinger <cg@exept.de>
parents: 3517
diff changeset
  2924
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  2925
mergeLine:lineNr
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  2926
    "merge line lineNr with line lineNr+1"
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  2927
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  2928
    self mergeLine:lineNr removeBlanks:true
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  2929
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  2930
    "Modified: 9.9.1997 / 09:28:03 / cg"
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  2931
!
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  2932
2506
5568d67dbddd Ctrl-8 / Ctrl-9,
Claus Gittinger <cg@exept.de>
parents: 2505
diff changeset
  2933
parenthizeSelectionWith:openingCharacter and:closingCharacter
2505
9204d5313979 Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents: 2491
diff changeset
  2934
    |newSelectionEnd|
9204d5313979 Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents: 2491
diff changeset
  2935
9204d5313979 Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents: 2491
diff changeset
  2936
    self hasSelection ifFalse:[^ self].
9204d5313979 Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents: 2491
diff changeset
  2937
9204d5313979 Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents: 2491
diff changeset
  2938
    newSelectionEnd := selectionEndCol.
9204d5313979 Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents: 2491
diff changeset
  2939
2506
5568d67dbddd Ctrl-8 / Ctrl-9,
Claus Gittinger <cg@exept.de>
parents: 2505
diff changeset
  2940
    (self characterAtLine:selectionStartLine col:selectionStartCol) == openingCharacter ifTrue:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2941
	(self characterAtLine:selectionEndLine col:selectionEndCol) == closingCharacter ifTrue:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2942
	    self deleteCharAtLine:selectionEndLine col:selectionEndCol.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2943
	    newSelectionEnd := newSelectionEnd-1.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2944
	].
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2945
	self deleteCharAtLine:selectionStartLine col:selectionStartCol.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2946
	selectionStartLine == selectionEndLine ifTrue:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2947
	    newSelectionEnd := newSelectionEnd-1.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2948
	]
2505
9204d5313979 Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents: 2491
diff changeset
  2949
    ] ifFalse:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2950
	self insert:closingCharacter atLine:selectionEndLine col:selectionEndCol+1.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2951
	newSelectionEnd := newSelectionEnd+1.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2952
	self insert:openingCharacter atLine:selectionStartLine col:selectionStartCol.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2953
	selectionStartLine == selectionEndLine ifTrue:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2954
	    newSelectionEnd := newSelectionEnd+1.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2955
	]
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2956
    ].
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2957
    self
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2958
	selectFromLine:selectionStartLine col:selectionStartCol
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2959
	toLine:selectionEndLine col:newSelectionEnd.
2505
9204d5313979 Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents: 2491
diff changeset
  2960
!
9204d5313979 Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents: 2491
diff changeset
  2961
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2962
removeTrailingBlankLines
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2963
    "remove all blank lines at end of text"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2964
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2965
    |lastLine "{ Class: SmallInteger }"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2966
     line finished|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2967
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2968
    lastLine := list size.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2969
    finished := false.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2970
    [finished] whileFalse:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2971
	(lastLine <= 1) ifTrue:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2972
	    finished := true
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2973
	] ifFalse:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2974
	    line := list at:lastLine.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2975
	    line notNil ifTrue:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2976
		line isBlank ifTrue:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2977
		    list at:lastLine put:nil.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2978
		    line := nil
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2979
		]
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2980
	    ].
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2981
	    line notNil ifTrue:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2982
		finished := true
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2983
	    ] ifFalse:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2984
		lastLine := lastLine - 1
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2985
	    ]
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2986
	]
118
claus
parents: 105
diff changeset
  2987
    ].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2988
    (lastLine ~~ list size) ifTrue:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2989
	list grow:lastLine.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2990
"/        self textChanged
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2991
    ]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2992
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2993
3430
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  2994
replace:patternArg by:replacePatternArg all:all ignoreCase:ign 
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  2995
    |pattern replacePattern|
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  2996
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  2997
    pattern := patternArg string.
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  2998
    replacePattern := replacePatternArg string.
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  2999
    ^ (pattern notEmpty and:[ replacePattern notEmpty ]) ifTrue:[
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  3000
        self rememberSearchPattern:pattern.
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  3001
        self rememberSearchPattern:replacePattern.
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  3002
        LastSearchIgnoredCase := ign.
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  3003
        self 
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  3004
            undoableDo:[
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  3005
                all ifTrue:[
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  3006
                    self 
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  3007
                        replaceString:pattern
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  3008
                        to:replacePattern
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  3009
                        ignoreCase:ign
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  3010
                ] ifFalse:[
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  3011
                    (self selectionAsString notNil 
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  3012
                        and:[ self selectionAsString sameAs:pattern ignoreCase:ign ]) 
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  3013
                            ifTrue:[
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  3014
                                self replaceSelectionWith:replacePattern.
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  3015
                                self 
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  3016
                                    search:pattern
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  3017
                                    ignoreCase:ign
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  3018
                                    forward:(lastSearchDirection = #forward).
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  3019
                            ].
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  3020
                ]
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  3021
            ]
3542
30ed44ed0178 +joinLines (CTRL-j);
Claus Gittinger <cg@exept.de>
parents: 3517
diff changeset
  3022
            info:'Replace'
3430
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  3023
    ]
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  3024
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  3025
    "Created: / 11-07-2006 / 11:19:57 / fm"
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  3026
!
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  3027
477
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  3028
replaceCharAtCursor:aCharacter
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  3029
    "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
  3030
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  3031
    |wasOn|
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  3032
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  3033
    wasOn := self hideCursor.
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  3034
    aCharacter == (Character cr) ifTrue:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3035
	self cursorReturn
477
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  3036
    ] ifFalse:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3037
	self replace:aCharacter atLine:cursorLine col:cursorCol.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3038
	self cursorRight.
477
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  3039
    ].
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  3040
    self makeCursorVisibleAndShowCursor:wasOn.
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  3041
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  3042
    "Created: 6.3.1996 / 12:27:42 / cg"
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  3043
!
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  3044
2427
43cc7ea39bac more editing stuff (xxx-characterPosition)
Claus Gittinger <cg@exept.de>
parents: 2422
diff changeset
  3045
replaceFromCharacterPosition:charPos1 to:charPos2 with:newString
43cc7ea39bac more editing stuff (xxx-characterPosition)
Claus Gittinger <cg@exept.de>
parents: 2422
diff changeset
  3046
    "replace a substring at a character position"
43cc7ea39bac more editing stuff (xxx-characterPosition)
Claus Gittinger <cg@exept.de>
parents: 2422
diff changeset
  3047
43cc7ea39bac more editing stuff (xxx-characterPosition)
Claus Gittinger <cg@exept.de>
parents: 2422
diff changeset
  3048
    self insertString:newString atCharacterPosition:charPos1.
43cc7ea39bac more editing stuff (xxx-characterPosition)
Claus Gittinger <cg@exept.de>
parents: 2422
diff changeset
  3049
    self deleteFromCharacterPosition:charPos1+newString size to:charPos2+newString size.
43cc7ea39bac more editing stuff (xxx-characterPosition)
Claus Gittinger <cg@exept.de>
parents: 2422
diff changeset
  3050
!
43cc7ea39bac more editing stuff (xxx-characterPosition)
Claus Gittinger <cg@exept.de>
parents: 2422
diff changeset
  3051
1564
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  3052
replaceLines:lines withCR:withCr
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  3053
    "replace a bunch of lines at cursor position. Cursor
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  3054
     is moved behind replacement.
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  3055
     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
  3056
     after the last line"
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  3057
1809
111f603c0a1c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1807
diff changeset
  3058
    |line col nLines wasOn|
1564
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  3059
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  3060
    lines notNil ifTrue:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3061
	wasOn := self hideCursor.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3062
	nLines := lines size.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3063
	line := cursorLine.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3064
	col := cursorCol.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3065
	lines keysAndValuesDo:[:i :l |
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3066
	    self replaceString:l atLine:line col:col.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3067
	    (i ~~ nLines or:[withCr]) ifTrue:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3068
		line := line + 1.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3069
		col := 1.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3070
	    ] ifFalse:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3071
		col := col + (l size).
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3072
	    ]
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3073
	].
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3074
	self cursorLine:line col:col.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3075
	self makeCursorVisibleAndShowCursor:wasOn.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3076
	"/ wasOn ifTrue:[self showCursor].
1564
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  3077
    ]
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  3078
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  3079
    "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
  3080
    "Modified: / 12.6.1998 / 22:05:51 / cg"
1564
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  3081
!
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  3082
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3083
replaceSelectionBy:something
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3084
    "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
  3085
     leave cursor after insertion"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3086
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3087
    self replaceSelectionBy:something keepCursor:false
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  3088
!
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  3089
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  3090
replaceSelectionBy:something keepCursor:keep
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  3091
    "delete the selection (if any) and insert something, a character or string;
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  3092
     leave cursor after insertion or leave it, depending on keep"
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  3093
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  3094
    |sel l c|
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  3095
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  3096
    l := cursorLine.
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  3097
    c := cursorCol.
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  3098
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  3099
    sel := self selection.
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  3100
    sel notNil ifTrue:[
3161
982c2e416728 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3160
diff changeset
  3101
        lastString := sel.
982c2e416728 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3160
diff changeset
  3102
        self deleteSelection.
982c2e416728 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3160
diff changeset
  3103
        replacing := true.
982c2e416728 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3160
diff changeset
  3104
        lastReplacement := ''.
982c2e416728 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3160
diff changeset
  3105
        undoSupport actionInfo:'replace'.
982c2e416728 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3160
diff changeset
  3106
    ].
982c2e416728 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3160
diff changeset
  3107
982c2e416728 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3160
diff changeset
  3108
    something isCharacter ifTrue:[
982c2e416728 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3160
diff changeset
  3109
        lastReplacement notNil ifTrue:[
840
b0071cea13fd fixed Again when spaces are replaced
Claus Gittinger <cg@exept.de>
parents: 828
diff changeset
  3110
"/ "XXX - replacing text with spaces ..."
b0071cea13fd fixed Again when spaces are replaced
Claus Gittinger <cg@exept.de>
parents: 828
diff changeset
  3111
"/            (lastReplacement endsWith:Character space) ifTrue:[
b0071cea13fd fixed Again when spaces are replaced
Claus Gittinger <cg@exept.de>
parents: 828
diff changeset
  3112
"/                lastReplacement := lastReplacement copyWithoutLast:1 "copyTo:(lastReplacement size - 1)".
b0071cea13fd fixed Again when spaces are replaced
Claus Gittinger <cg@exept.de>
parents: 828
diff changeset
  3113
"/                lastReplacement := lastReplacement copyWith:something.
b0071cea13fd fixed Again when spaces are replaced
Claus Gittinger <cg@exept.de>
parents: 828
diff changeset
  3114
"/                lastReplacement := lastReplacement copyWith:Character space
b0071cea13fd fixed Again when spaces are replaced
Claus Gittinger <cg@exept.de>
parents: 828
diff changeset
  3115
"/            ] ifFalse:[
3161
982c2e416728 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3160
diff changeset
  3116
                lastReplacement := lastReplacement copyWith:something.
840
b0071cea13fd fixed Again when spaces are replaced
Claus Gittinger <cg@exept.de>
parents: 828
diff changeset
  3117
"/            ]
3161
982c2e416728 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3160
diff changeset
  3118
        ].
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  3119
        self isInInsertMode ifTrue:[
3161
982c2e416728 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3160
diff changeset
  3120
            self insertCharAtCursor:something
982c2e416728 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3160
diff changeset
  3121
        ] ifFalse:[
982c2e416728 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3160
diff changeset
  3122
            self replaceCharAtCursor:something
982c2e416728 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3160
diff changeset
  3123
        ]
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  3124
    ] ifFalse:[
3161
982c2e416728 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3160
diff changeset
  3125
        something isString ifTrue:[
982c2e416728 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3160
diff changeset
  3126
            lastReplacement := something.
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  3127
            self isInInsertMode ifTrue:[
3161
982c2e416728 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3160
diff changeset
  3128
                self insertStringAtCursor:something
982c2e416728 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3160
diff changeset
  3129
            ] ifFalse:[
982c2e416728 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3160
diff changeset
  3130
                self replaceStringAtCursor:something
982c2e416728 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3160
diff changeset
  3131
            ]
982c2e416728 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3160
diff changeset
  3132
        ] ifFalse:[
982c2e416728 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3160
diff changeset
  3133
            Transcript showCR:'EditTextView: non String-or-Character in replace'.
982c2e416728 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3160
diff changeset
  3134
        ].
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  3135
    ].
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  3136
    keep ifTrue:[
3161
982c2e416728 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3160
diff changeset
  3137
        self cursorLine:l col:c
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  3138
    ]
477
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  3139
840
b0071cea13fd fixed Again when spaces are replaced
Claus Gittinger <cg@exept.de>
parents: 828
diff changeset
  3140
    "Modified: 9.10.1996 / 16:14:35 / cg"
1564
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  3141
!
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  3142
3430
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  3143
replaceString:aString to:aNewString ignoreCase:ign
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  3144
|continue count|
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  3145
self cursorToTop.
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  3146
self selectFromBeginning.
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  3147
count := 0.
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  3148
continue := true.
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  3149
[continue] whileTrue:[
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  3150
     (self selectionAsString notNil and:[self selectionAsString sameAs:aString ignoreCase: ign])
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  3151
        ifTrue:[self replaceSelectionWith: aNewString.          
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  3152
                count := count + 1.].
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  3153
     self searchFwd: aString 
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  3154
        ignoreCase:ign 
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  3155
        ifAbsent:[Dialog information: aString, ' has been replaced to ', aNewString, ' ',count printString, ' times'.
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  3156
                  continue := false.].
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  3157
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  3158
].
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  3159
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  3160
    "Created: / 10-07-2006 / 16:42:48 / fm"
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  3161
!
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  3162
1564
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  3163
replaceStringAtCursor:aString
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  3164
    "replace multiple characters at cursor-position - advance cursor"
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  3165
1566
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  3166
    |wasOn i1 i2|
1564
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  3167
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  3168
    wasOn := self hideCursor.
1566
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  3169
    (aString includes:Character tab) ifTrue:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3170
	"/ need special care for TAB (to move cursor correctly)
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3171
	i1 := 1.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3172
	[i1 ~~ 0] whileTrue:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3173
	    i2 := aString indexOf:Character tab startingAt:i1.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3174
	    i2 ~~ 0 ifTrue:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3175
		i1 ~~ i2 ifTrue:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3176
		    self replaceString:(aString copyFrom:i1 to:i2-1) atLine:cursorLine col:cursorCol.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3177
		    self cursorCol:(cursorCol + (i2 - i1)).
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3178
		].
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3179
		self replaceTABAtCursor.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3180
		i2 := i2 + 1.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3181
	    ] ifFalse:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3182
		self replaceString:(aString copyFrom:i1) atLine:cursorLine col:cursorCol.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3183
		self cursorCol:(cursorCol + (aString size - i1 + 1)).
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3184
	    ].
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3185
	    i1 := i2.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3186
	]
1566
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  3187
    ] ifFalse:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3188
	self replaceString:aString atLine:cursorLine col:cursorCol.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3189
	self cursorCol:(cursorCol + aString size).
1566
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  3190
    ].
1564
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  3191
    self makeCursorVisibleAndShowCursor:wasOn.
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  3192
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  3193
    "Created: / 9.6.1998 / 20:33:20 / cg"
1597
5fdcfcedb91c fixed cursor positioning after replaceStringAtCursor.
Claus Gittinger <cg@exept.de>
parents: 1596
diff changeset
  3194
    "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
  3195
!
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  3196
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  3197
replaceTABAtCursor
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  3198
    "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
  3199
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  3200
    |wasOn nextTab|
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  3201
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  3202
    wasOn := self hideCursor.
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  3203
    nextTab := self nextTabAfter:cursorCol.
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  3204
    self replaceStringAtCursor:(String new:(nextTab - cursorCol)).
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  3205
    self makeCursorVisibleAndShowCursor:wasOn.
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  3206
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  3207
    "Created: / 12.6.1998 / 21:53:23 / cg"
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  3208
! !
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  3209
2752
5650a9ab5935 method category rename
Claus Gittinger <cg@exept.de>
parents: 2744
diff changeset
  3210
!EditTextView methodsFor:'editing-basic'!
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  3211
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3212
basicDeleteCharsAtLine:lineNr fromCol:startCol toCol:endCol
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3213
    "delete characters from startCol to endCol in line lineNr
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3214
    "
1803
ac7cc1b99407 scroll left as required, if deleting characters of the longest line,
Claus Gittinger <cg@exept.de>
parents: 1796
diff changeset
  3215
    |line lineSize newLine start stop prevWidth newWidth|
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  3216
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  3217
    line := self listAt:lineNr.
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3218
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3219
    (self checkModificationsAllowed and:[line notNil]) ifTrue:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3220
	lineSize := line size.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3221
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3222
	startCol == 0     ifFalse:[ start := startCol ]
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3223
			   ifTrue:[ start := 1 ].
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3224
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3225
	endCol > lineSize ifFalse:[ stop  := endCol ]
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3226
			   ifTrue:[ stop  := lineSize ].
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3227
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3228
	stop >= start ifTrue:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3229
	    start ~~ 1 ifTrue:[ newLine := line copyFrom:1 to:(start-1) ]
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3230
		      ifFalse:[ newLine := '' ].
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3231
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3232
	    stop == lineSize ifFalse:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3233
		line bitsPerCharacter > newLine bitsPerCharacter ifTrue:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3234
		    newLine := line string species fromString:newLine.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3235
		].
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3236
		newLine := newLine, (line copyFrom:(stop + 1) to:lineSize)
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3237
	    ].
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3238
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3239
	    (trimBlankLines and:[newLine isBlank]) ifTrue:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3240
		newLine := nil
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3241
	    ].
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3242
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3243
	    prevWidth := self widthOfLine:lineNr.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3244
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3245
	    list at:lineNr put:newLine.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3246
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3247
	    (prevWidth = widthOfWidestLine) ifTrue:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3248
		"/ remember old width of this line,
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3249
		"/ only clear widthOfWidestLine, if this lines
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3250
		"/ length was (one of) the longest.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3251
		"/ avoids slow delete with huge texts.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3252
		widthOfWidestLine := nil.   "i.e. unknown"
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3253
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3254
		"/ scroll left if reqiured
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3255
		viewOrigin x > 0 ifTrue:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3256
		    newWidth := self widthOfLine:lineNr.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3257
		    newWidth < (viewOrigin x + width) ifTrue:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3258
			self scrollHorizontalTo:(newWidth
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3259
						 - width
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3260
						 + margin + margin
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3261
						 + (font widthOf:'  '))
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3262
		    ]
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3263
		].
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3264
		self textChanged.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3265
	    ] ifFalse:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3266
		self textChanged "/ textChangedButNoSizeChange
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3267
	    ].
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3268
	    self redrawLine:lineNr from:start.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3269
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3270
	]
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3271
    ]
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3272
1717
83203096a851 dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  3273
    "Modified: / 11.11.1998 / 00:01:09 / cg"
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  3274
!
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  3275
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3276
basicDeleteFromLine:startLineNr toLine:endLineNr
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  3277
    "delete some lines"
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  3278
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  3279
    |wasOn nLines|
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  3280
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  3281
    self checkModificationsAllowed ifFalse:[ ^ self].
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  3282
    list isNil ifTrue:[^ self].
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  3283
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  3284
    wasOn := self hideCursor.
1717
83203096a851 dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  3285
83203096a851 dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  3286
    "/ isnt this the same as:
83203096a851 dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  3287
    "/ self deleteLinesWithoutRedrawFrom:startLineNr to:endLineNr.
83203096a851 dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  3288
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  3289
    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
  3290
    "/ TODO: remember old maxwidth of linerange,
83203096a851 dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  3291
    "/ only clear widthOfWidestLine, if this max
83203096a851 dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  3292
    "/ length was (one of) the longest.
83203096a851 dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  3293
    "/ avoids slow delete with huge texts.
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  3294
    widthOfWidestLine := nil. "/ i.e. unknown
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  3295
    self textChanged.
1717
83203096a851 dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  3296
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  3297
    self redrawFromLine:startLineNr.
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  3298
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  3299
    nLines := list size.
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  3300
    (firstLineShown >= nLines) ifTrue:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3301
	self makeLineVisible:nLines
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  3302
    ].
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  3303
    wasOn ifTrue:[self showCursor].
1717
83203096a851 dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  3304
83203096a851 dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  3305
    "Modified: / 10.11.1998 / 23:55:05 / cg"
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  3306
!
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  3307
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3308
basicDeleteLineWithoutRedraw:lineNr
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  3309
    "delete line - no redraw;
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  3310
     return true, if something was really deleted"
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  3311
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3312
    self checkModificationsAllowed ifFalse:[ ^ false].
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  3313
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  3314
    (list isNil or:[lineNr > list size]) ifTrue:[^ false].
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  3315
    list removeIndex:lineNr.
1717
83203096a851 dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  3316
    "/ TODO: remember old maxwidth of linerange,
83203096a851 dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  3317
    "/ only clear widthOfWidestLine, if this max
83203096a851 dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  3318
    "/ length was (one of) the longest.
83203096a851 dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  3319
    "/ avoids slow delete with huge texts.
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  3320
    widthOfWidestLine := nil. "/ i.e. unknown
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  3321
    self textChanged.
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  3322
    ^ true
1717
83203096a851 dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  3323
83203096a851 dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  3324
    "Modified: / 10.11.1998 / 23:53:24 / cg"
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  3325
!
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  3326
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3327
basicInsert:aCharacter atLine:lineNr col:colNr
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3328
    "insert a single character at lineNr/colNr;
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3329
     set emphasis to character at current position"
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3330
1929
8e70fb7c9701 fixed handling of italic text when inserting
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  3331
    |line lineSize newLine drawCharacterOnly attribute oldClip x y|
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  3332
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  3333
    self checkModificationsAllowed ifFalse:[ ^ self].
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  3334
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  3335
    aCharacter == (Character cr) ifTrue:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3336
	self splitLine:lineNr before:colNr.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3337
	^ self
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  3338
    ].
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3339
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  3340
    drawCharacterOnly := false.
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  3341
    self checkForExistingLine:lineNr.
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  3342
    line := list at:lineNr.
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  3343
    lineSize := line size.
671
f3fe0d8c604d added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents: 666
diff changeset
  3344
3023
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  3345
    self st80EditMode ifFalse:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3346
	(trimBlankLines
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3347
	and:[colNr > lineSize
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3348
	and:[aCharacter == Character space]]) ifTrue:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3349
	    ^ self
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3350
	]
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  3351
    ].
671
f3fe0d8c604d added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents: 666
diff changeset
  3352
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  3353
    (lineSize == 0) ifTrue:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3354
	newLine := aCharacter asString species new:colNr.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3355
	drawCharacterOnly := true
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  3356
    ] ifFalse: [
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3357
	(colNr > lineSize) ifTrue: [
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3358
	    colNr == (lineSize +1) ifTrue:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3359
		attribute := line emphasisAt:lineSize
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3360
	    ].
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3361
	    newLine := line species new:colNr.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3362
	    newLine replaceFrom:1 to:lineSize with:line startingAt:1.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3363
	    drawCharacterOnly := true
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3364
	] ifFalse: [
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3365
	    attribute := line emphasisAt:colNr.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3366
	    newLine   := line species new:(lineSize + 1).
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3367
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3368
	    newLine replaceFrom:1 to:(colNr - 1) with:line startingAt:1.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3369
	    newLine replaceFrom:(colNr + 1) to:(lineSize + 1) with:line startingAt:colNr
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3370
	]
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  3371
    ].
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3372
2869
48d830f0aea5 insertCharacter: care for wide chars
Claus Gittinger <cg@exept.de>
parents: 2866
diff changeset
  3373
    aCharacter asString bitsPerCharacter > newLine bitsPerCharacter ifTrue:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3374
	newLine := aCharacter asString species fromString:newLine.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3375
	line isText ifTrue:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3376
	    newLine := newLine asText
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3377
	]
2869
48d830f0aea5 insertCharacter: care for wide chars
Claus Gittinger <cg@exept.de>
parents: 2866
diff changeset
  3378
    ].
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  3379
    newLine at:colNr put:aCharacter.
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3380
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3381
    attribute notNil ifTrue:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3382
	newLine emphasisAt:colNr put:attribute
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3383
    ].
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3384
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  3385
    aCharacter == (Character tab) ifTrue:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3386
	newLine := self withTabsExpanded:newLine.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3387
	drawCharacterOnly := false
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  3388
    ].
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3389
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  3390
    list at:lineNr put:newLine.
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  3391
    widthOfWidestLine notNil ifTrue:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3392
	widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:line).
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  3393
    ].
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  3394
    self textChanged.
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  3395
    shown ifTrue:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3396
	"/ care for italic text - in this case, we must also
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3397
	"/ redraw the character before the insertion in order
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3398
	"/ to fix the slanted piece of the character.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3399
	"/ (but we must clip, to avoid destoying the character before)
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3400
	(newLine notNil and:[newLine isText]) ifTrue:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3401
	    colNr > 1 ifTrue:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3402
		cursorVisibleLine notNil ifTrue:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3403
		    oldClip := self clippingRectangleOrNil.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3404
		    x := (self xOfCol:colNr inVisibleLine:cursorVisibleLine) - viewOrigin x.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3405
		    y := self yOfVisibleLine:cursorVisibleLine.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3406
		    drawCharacterOnly ifTrue:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3407
			self clippingRectangle:(x@y extent:((font width * 2) @ fontHeight)).
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3408
			self redrawLine:lineNr from:colNr-1 to:colNr
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3409
		    ] ifFalse:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3410
			self clippingRectangle:(x@y extent:((width - x) @ fontHeight)).
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3411
			self redrawLine:lineNr from:colNr-1
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3412
		    ].
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3413
		    self clippingRectangle:oldClip.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3414
		].
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3415
		^ self.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3416
	    ].
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3417
	].
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3418
	drawCharacterOnly ifTrue:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3419
	    self redrawLine:lineNr col:colNr
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3420
	] ifFalse:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3421
	    self redrawLine:lineNr from:colNr
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3422
	]
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  3423
    ]
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  3424
1596
0bbdb4e9fc43 made st80Mode also an inst-flag;
Claus Gittinger <cg@exept.de>
parents: 1591
diff changeset
  3425
    "Modified: / 20.6.1998 / 18:19:22 / cg"
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  3426
!
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  3427
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3428
basicMergeLine:lineNr removeBlanks:removeBlanks
1319
2739903e7a80 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  3429
    "merge line lineNr with line lineNr+1"
2739903e7a80 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  3430
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3431
    |leftPart rightPart bothParts nextLineNr i|
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3432
2356
6416beb0f23a backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents: 2350
diff changeset
  3433
    (list notNil and:[(list size) >= lineNr]) ifFalse:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3434
	"/ empty list or beyond end of text
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3435
	^ self
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3436
    ].
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3437
    leftPart := self listAt:lineNr.
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3438
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3439
    leftPart isNil ifTrue:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3440
	leftPart := ''.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3441
	autoIndent ifTrue:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3442
	    (i := self leftIndentForLine:cursorLine) == 0 ifFalse:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3443
		leftPart := String new:i
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3444
	    ]
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3445
	]
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3446
    ].
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3447
    self cursorLine:lineNr col:((leftPart size) + 1).
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3448
    nextLineNr := self validateCursorLine:(lineNr + 1).
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3449
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3450
    nextLineNr > (list size) ifFalse:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3451
	(rightPart := self listAt:nextLineNr) isNil ifTrue:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3452
	    rightPart := ''
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3453
	] ifFalse:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3454
	    removeBlanks ifTrue:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3455
		rightPart := rightPart withoutLeadingSeparators.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3456
	    ]
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3457
	].
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3458
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3459
	bothParts := leftPart , rightPart.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3460
	(trimBlankLines and:[bothParts isBlank]) ifTrue:[bothParts := nil].
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3461
	list at:lineNr put:bothParts.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3462
	self redrawLine:lineNr.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3463
	self deleteLine:nextLineNr
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  3464
    ]
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  3465
1319
2739903e7a80 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  3466
    "Created: 9.9.1997 / 09:27:38 / cg"
2739903e7a80 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  3467
    "Modified: 9.9.1997 / 09:28:27 / cg"
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  3468
!
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  3469
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3470
basicReplace:aCharacter atLine:lineNr col:colNr
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  3471
    "replace a single character at lineNr/colNr"
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  3472
1558
abf35cc39757 minimize redraw in overwrite-replace;
Claus Gittinger <cg@exept.de>
parents: 1557
diff changeset
  3473
    |line lineSize newLine drawCharacterOnly|
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  3474
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  3475
    self checkModificationsAllowed ifFalse:[ ^ self].
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  3476
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  3477
    aCharacter == (Character cr) ifTrue:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3478
	^ self
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  3479
    ].
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  3480
1558
abf35cc39757 minimize redraw in overwrite-replace;
Claus Gittinger <cg@exept.de>
parents: 1557
diff changeset
  3481
    drawCharacterOnly := true.
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  3482
    self checkForExistingLine:lineNr.
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  3483
    line := list at:lineNr.
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  3484
    lineSize := line size.
671
f3fe0d8c604d added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents: 666
diff changeset
  3485
f3fe0d8c604d added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents: 666
diff changeset
  3486
    (trimBlankLines
f3fe0d8c604d added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents: 666
diff changeset
  3487
    and:[colNr > lineSize
f3fe0d8c604d added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents: 666
diff changeset
  3488
    and:[aCharacter == Character space]]) ifTrue:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3489
	^ self
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  3490
    ].
671
f3fe0d8c604d added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents: 666
diff changeset
  3491
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  3492
    (lineSize == 0) ifTrue:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3493
	newLine := aCharacter asString species new:colNr.
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  3494
    ] ifFalse: [
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3495
	(colNr > lineSize) ifTrue: [
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3496
	    newLine := line species new:colNr.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3497
	    newLine replaceFrom:1 to:lineSize with:line startingAt:1.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3498
	] ifFalse: [
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3499
	    newLine := line copy.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3500
	]
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  3501
    ].
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  3502
    newLine at:colNr put:aCharacter.
1558
abf35cc39757 minimize redraw in overwrite-replace;
Claus Gittinger <cg@exept.de>
parents: 1557
diff changeset
  3503
    aCharacter == (Character tab) ifTrue:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3504
	newLine := self withTabsExpanded:newLine.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3505
	drawCharacterOnly := false
1558
abf35cc39757 minimize redraw in overwrite-replace;
Claus Gittinger <cg@exept.de>
parents: 1557
diff changeset
  3506
    ].
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  3507
    list at:lineNr put:newLine.
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  3508
    widthOfWidestLine notNil ifTrue:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3509
	widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:line).
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  3510
    ].
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  3511
    self textChanged.
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  3512
    shown ifTrue:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3513
	drawCharacterOnly ifTrue:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3514
	    self redrawLine:lineNr col:colNr
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3515
	] ifFalse:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3516
	    self redrawLine:lineNr from:colNr
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3517
	]
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  3518
    ]
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  3519
1558
abf35cc39757 minimize redraw in overwrite-replace;
Claus Gittinger <cg@exept.de>
parents: 1557
diff changeset
  3520
    "Created: / 6.3.1996 / 12:29:20 / cg"
1559
cecf77805bff expand tabs in #replaceAll:...
Claus Gittinger <cg@exept.de>
parents: 1558
diff changeset
  3521
    "Modified: / 10.6.1998 / 18:50:18 / cg"
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  3522
!
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  3523
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  3524
basicReplaceString:aString atLine:lineNr col:colNr
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  3525
    "replace multiple characters starting at lineNr/colNr.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  3526
     This is not prepared to encounter special chars (except TAB)
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  3527
     in the string."
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  3528
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  3529
    |line lineSize newLine endCol|
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  3530
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  3531
    self checkModificationsAllowed ifFalse:[ ^ self].
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  3532
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  3533
    self checkForExistingLine:lineNr.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  3534
    line := list at:lineNr.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  3535
    lineSize := line size.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  3536
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  3537
    endCol := colNr + aString size - 1.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  3538
    (lineSize == 0) ifTrue:[
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  3539
        newLine := aString species new:endCol.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  3540
    ] ifFalse: [
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  3541
        (endCol > lineSize) ifTrue: [
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  3542
            aString isText ifTrue:[
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  3543
                newLine := aString species new:endCol.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  3544
            ] ifFalse:[
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  3545
                newLine := line species new:endCol.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  3546
            ].
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  3547
            newLine replaceFrom:1 to:lineSize with:line startingAt:1.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  3548
        ] ifFalse: [
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  3549
            aString isText ifTrue:[
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  3550
                newLine := aString species new:line size.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  3551
                newLine replaceFrom:1 to:lineSize with:line startingAt:1.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  3552
            ] ifFalse:[
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  3553
                newLine := line copy.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  3554
            ]
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  3555
        ]
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  3556
    ].
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  3557
    newLine replaceFrom:colNr with:aString.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  3558
    (aString includes:(Character tab)) ifTrue:[
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  3559
        newLine := self withTabsExpanded:newLine.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  3560
    ].
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  3561
    list at:lineNr put:newLine.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  3562
    widthOfWidestLine notNil ifTrue:[
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  3563
        widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:line).
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  3564
    ].
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  3565
    self textChanged.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  3566
    shown ifTrue:[
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  3567
        self redrawLine:lineNr from:colNr
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  3568
    ]
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  3569
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  3570
    "Created: / 11.6.1998 / 10:38:32 / cg"
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  3571
    "Modified: / 20.6.1998 / 20:23:50 / cg"
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  3572
!
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  3573
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3574
basicSplitLine:lineNr before:colNr
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3575
    "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
  3576
     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
  3577
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3578
    |line lineSize leftRest rightRest visLine w h mustWait
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3579
     srcY    "{ Class: SmallInteger }" |
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3580
3027
0dd9657b8033 *** empty log message ***
ca
parents: 3024
diff changeset
  3581
    list isNil ifTrue:[ ^ self ].
0dd9657b8033 *** empty log message ***
ca
parents: 3024
diff changeset
  3582
    lineNr > (list size) ifTrue:[ ^ self ].
0dd9657b8033 *** empty log message ***
ca
parents: 3024
diff changeset
  3583
0dd9657b8033 *** empty log message ***
ca
parents: 3024
diff changeset
  3584
    (colNr == 1) ifTrue:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3585
	self nonUndoableDo:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3586
	    self insertLine:nil before:lineNr.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3587
	].
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3588
	^ self
3027
0dd9657b8033 *** empty log message ***
ca
parents: 3024
diff changeset
  3589
    ].
0dd9657b8033 *** empty log message ***
ca
parents: 3024
diff changeset
  3590
0dd9657b8033 *** empty log message ***
ca
parents: 3024
diff changeset
  3591
    line := list at:lineNr.
0dd9657b8033 *** empty log message ***
ca
parents: 3024
diff changeset
  3592
    line isNil ifFalse:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3593
	lineSize := line size.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3594
	(colNr <= lineSize) ifTrue:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3595
	    rightRest := line copyFrom:colNr to:lineSize.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3596
	    (colNr > 1) ifTrue:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3597
		leftRest := line copyTo:(colNr - 1)
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3598
	    ]
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3599
	] ifFalse:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3600
	    leftRest := line
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3601
	]
3027
0dd9657b8033 *** empty log message ***
ca
parents: 3024
diff changeset
  3602
    ].
0dd9657b8033 *** empty log message ***
ca
parents: 3024
diff changeset
  3603
    leftRest notNil ifTrue:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3604
	(trimBlankLines and:[leftRest isBlank]) ifTrue:[leftRest := nil]
3027
0dd9657b8033 *** empty log message ***
ca
parents: 3024
diff changeset
  3605
    ].
0dd9657b8033 *** empty log message ***
ca
parents: 3024
diff changeset
  3606
    list at:lineNr put:leftRest.
0dd9657b8033 *** empty log message ***
ca
parents: 3024
diff changeset
  3607
    self nonUndoableDo:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3608
	self withoutRedrawInsertLine:rightRest before:(lineNr + 1).
3027
0dd9657b8033 *** empty log message ***
ca
parents: 3024
diff changeset
  3609
    ].
0dd9657b8033 *** empty log message ***
ca
parents: 3024
diff changeset
  3610
    visLine := self listLineToVisibleLine:(lineNr).
0dd9657b8033 *** empty log message ***
ca
parents: 3024
diff changeset
  3611
    visLine notNil ifTrue:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3612
	w := self widthForScrollBetween:lineNr
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3613
				    and:(firstLineShown + nLinesShown).
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3614
	srcY := topMargin + (visLine * fontHeight).
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3615
	h := ((nLinesShown - visLine - 1) * fontHeight).
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3616
	(mustWait := (w > 0 and:[h > 0])) ifTrue:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3617
	    self catchExpose.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3618
	    self
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3619
		copyFrom:self
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3620
		x:textStartLeft y:srcY
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3621
		toX:textStartLeft y:(srcY + fontHeight)
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3622
		width:w
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3623
		height:((nLinesShown - visLine - 1) * fontHeight)
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3624
		async:true.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3625
	].
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3626
	self redrawLine:lineNr.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3627
	self redrawLine:(lineNr + 1).
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3628
	mustWait ifTrue:[self waitForExpose]
3027
0dd9657b8033 *** empty log message ***
ca
parents: 3024
diff changeset
  3629
    ].
0dd9657b8033 *** empty log message ***
ca
parents: 3024
diff changeset
  3630
    widthOfWidestLine := nil. "/ unknown
0dd9657b8033 *** empty log message ***
ca
parents: 3024
diff changeset
  3631
    self textChanged.
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3632
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3633
    "Modified: 29.1.1997 / 13:03:22 / cg"
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3634
!
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3635
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3636
basicWithoutRedrawInsertLine:aString before:lineNr
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3637
    "insert the argument, aString before line lineNr; the string
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3638
     becomes line nileNr; everything else is moved down; the view
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3639
     is not redrawn"
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3640
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3641
    |line|
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3642
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3643
    self checkModificationsAllowed ifFalse:[ ^ self].
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3644
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3645
    line := aString.
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3646
    line notNil ifTrue:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3647
	line isString ifTrue:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3648
	    line isBlank ifTrue:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3649
		line := nil
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3650
	    ] ifFalse:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3651
		(line includes:(Character tab)) ifTrue:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3652
		    line := self withTabsExpanded:line
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3653
		]
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3654
	    ]
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3655
	]
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3656
    ].
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3657
    list isNil ifTrue: [
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3658
	list := StringCollection new:lineNr
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3659
    ] ifFalse: [
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3660
	list grow:((list size + 1) max:lineNr)
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3661
    ].
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3662
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3663
    "I have changed 'replaceFrom:to:with:startingAt:' to correctly handle
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3664
     overlapping copy - if it didn't, we had to use:"
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3665
"
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3666
    index := list size.
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3667
    [index > lineNr] whileTrue: [
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3668
	pIndex := index - 1.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3669
	list at:index put:(list at:pIndex).
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3670
	index := pIndex
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3671
    ].
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3672
"
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3673
    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
  3674
    list at:lineNr put:line.
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3675
    self contentsChanged
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3676
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3677
    "Modified: / 10.6.1998 / 19:00:56 / cg"
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3678
!
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3679
2954
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3680
basicWithoutRedrawInsertLines:lines from:start to:end before:lineNr
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3681
    "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
  3682
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3683
    |newLine newLines nLines|
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3684
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3685
    nLines := end - start + 1.
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3686
    newLines := Array new:(lines size).
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3687
    start to:end do:[:index |
3296
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
  3688
        newLine := lines at:index.
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
  3689
        newLine notNil ifTrue:[
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
  3690
            newLine isString ifTrue:[
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
  3691
                newLine isBlank ifTrue:[
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
  3692
                    newLine := nil
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
  3693
                ] ifFalse:[
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
  3694
                    (newLine includes:(Character tab)) ifTrue:[
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
  3695
                        newLine := self withTabsExpanded:newLine
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
  3696
                    ]
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
  3697
                ]
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
  3698
            ]
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
  3699
        ].
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
  3700
        newLines at:index put:newLine
2954
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3701
    ].
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3702
    list isNil ifTrue: [
3296
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
  3703
        list := StringCollection new:(lineNr + nLines + 1)
2954
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3704
    ] ifFalse: [
3296
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
  3705
        list grow:((list size + nLines) max:(lineNr + nLines - 1))
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3706
    ].
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3707
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3708
    "I have changed 'replaceFrom:to:with:startingAt:' to correctly handle
2954
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3709
     overlapping copy - if it didn't, we had to use:"
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3710
"
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3711
    index := list size.
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3712
    [index > lineNr] whileTrue: [
3296
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
  3713
        pIndex := index - 1.
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
  3714
        list at:index put:(list at:pIndex).
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
  3715
        index := pIndex
2954
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3716
    ].
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3717
"
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3718
    list replaceFrom:(lineNr + nLines) to:(list size) with:list startingAt:lineNr.
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3719
    list replaceFrom:lineNr to:(lineNr + nLines - 1) with:newLines startingAt:start.
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3720
    self contentsChanged
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3721
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3722
    "Modified: / 10.6.1998 / 19:01:16 / cg"
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3723
!
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3724
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3725
basicWithoutRedrawInsertStringWithoutCRs:aString atLine:lineNr col:colNr
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3726
    "insert aString (which has no crs) at lineNr/colNr"
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3727
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3728
    |isText strLen line lineSize newLine stringType sz|
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3729
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3730
    (aString notNil) ifFalse:[ ^ self].
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3731
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3732
    strLen := aString size.
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3733
    self checkForExistingLine:lineNr.
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3734
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3735
    stringType := aString string species.
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3736
    isText     := aString isText.
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3737
    line       := list at:lineNr.
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3738
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3739
    line notNil ifTrue:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3740
	lineSize := line size.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3741
	line isString ifFalse:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3742
	    stringType := line species
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3743
	] ifTrue:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3744
	    line bitsPerCharacter > aString bitsPerCharacter ifTrue:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3745
		stringType := line string species
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3746
	    ].
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3747
	    line isText ifTrue:[ isText := true ]
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3748
	].
2954
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3749
    ] ifFalse:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3750
	lineSize := 0
2954
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3751
    ].
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3752
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3753
    ((colNr == 1) and:[lineSize == 0]) ifTrue: [
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3754
	newLine := aString
2954
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3755
    ] ifFalse:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3756
	(lineSize == 0 or:[colNr > lineSize]) ifTrue: [
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3757
	    sz := colNr + strLen - 1
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3758
	] ifFalse:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3759
	    sz := lineSize + strLen
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3760
	].
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3761
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3762
	isText ifFalse:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3763
	    newLine := stringType new:sz
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3764
	] ifTrue:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3765
	    newLine := Text string:(stringType new:sz)
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3766
	].
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3767
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3768
	(lineSize ~~ 0) ifTrue: [
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3769
	    (colNr > lineSize) ifTrue: [
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3770
		newLine replaceFrom:1 to:lineSize
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3771
			       with:line startingAt:1
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3772
	    ] ifFalse: [
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3773
		newLine replaceFrom:1 to:(colNr - 1)
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3774
			       with:line startingAt:1.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3775
		newLine replaceFrom:(colNr + strLen) to:(lineSize + strLen)
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3776
			       with:line startingAt:colNr
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3777
	    ]
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3778
	].
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3779
	newLine replaceFrom:colNr to:(colNr + strLen - 1) with:aString startingAt:1
2954
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3780
    ].
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3781
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3782
    (aString includes:(Character tab)) ifTrue:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3783
	newLine := self withTabsExpanded:newLine
2954
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3784
    ].
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3785
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3786
    list at:lineNr put:newLine.
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3787
    widthOfWidestLine notNil ifTrue:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3788
	widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:newLine).
2954
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3789
    ].
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3790
    self textChanged.
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3791
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3792
    "Modified: / 10.6.1998 / 19:01:52 / cg"
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3793
!
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3794
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3795
deleteCharsAtLine:lineNr fromCol:startCol toCol:endCol
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3796
    "delete characters from startCol to endCol in line lineNr
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3797
    "
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3798
    |deleted|
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3799
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3800
    deleted := self textFromLine:lineNr col:startCol toLine:lineNr col:endCol.
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3801
    self basicDeleteCharsAtLine:lineNr fromCol:startCol toCol:endCol.
3115
b75128334006 info string in undo
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
  3802
    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
  3803
!
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3804
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3805
deleteFromLine:startLineNr toLine:endLineNr
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3806
    "delete some lines"
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3807
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3808
    |deleted|
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3809
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3810
    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
  3811
    self basicDeleteFromLine:startLineNr toLine:endLineNr.
3115
b75128334006 info string in undo
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
  3812
    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
  3813
!
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3814
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3815
deleteLineWithoutRedraw:lineNr
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3816
    "delete line - no redraw;
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3817
     return true, if something was really deleted"
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3818
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3819
    |deleted ret|
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3820
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3821
    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
  3822
    ret := self basicDeleteLineWithoutRedraw:lineNr.
3115
b75128334006 info string in undo
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
  3823
    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
  3824
    ^ ret.
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3825
!
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3826
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3827
insert:aCharacter atLine:lineNr col:colNr
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3828
    "insert a single character at lineNr/colNr;
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3829
     set emphasis to character at current position"
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3830
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3831
    self basicInsert:aCharacter atLine:lineNr col:colNr.
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3832
    aCharacter ~~ Character cr ifTrue:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3833
	self addUndo:(DeleteCharacters line:lineNr col:colNr info:'insert').
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3834
    ]
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3835
!
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3836
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3837
insertLines:someText from:start to:end before:lineNr
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3838
    "insert a bunch of lines before line lineNr"
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3839
2954
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3840
    |text indent visLine w nLines "{ Class: SmallInteger }"
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3841
     srcY "{ Class: SmallInteger }"
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3842
     dstY "{ Class: SmallInteger }" |
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3843
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3844
    autoIndent ifTrue:[
3296
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
  3845
        indent := self leftIndentForLine:lineNr.
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
  3846
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
  3847
        text := someText collect:[:ln||line|
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
  3848
            ln notNil ifTrue:[
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
  3849
                line := ln withoutLeadingSeparators.
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
  3850
                (line isEmpty or:[indent == 0]) ifFalse:[
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
  3851
                    line := (String new:indent), line
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
  3852
                ].
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
  3853
                line
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
  3854
            ] ifFalse:[
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
  3855
                nil
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
  3856
            ]
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
  3857
        ].
2954
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3858
    ] ifFalse:[
3296
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
  3859
        text := someText
2954
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3860
    ].
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3861
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3862
    visLine := self listLineToVisibleLine:lineNr.
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3863
    (shown not or:[visLine isNil]) ifTrue:[
3296
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
  3864
        self withoutRedrawInsertLines:text
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
  3865
             from:start to:end
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
  3866
             before:lineNr.
2954
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3867
    ] ifFalse:[
3296
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
  3868
        nLines := end - start + 1.
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
  3869
        ((visLine + nLines) >= nLinesShown) ifTrue:[
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
  3870
            self withoutRedrawInsertLines:text
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
  3871
                 from:start to:end
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
  3872
                 before:lineNr.
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
  3873
            self redrawFromVisibleLine:visLine to:nLinesShown
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
  3874
        ] ifFalse:[
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
  3875
            w := self widthForScrollBetween:(lineNr + nLines)
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
  3876
                                        and:(firstLineShown + nLines + nLinesShown).
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
  3877
            srcY := topMargin + ((visLine - 1) * fontHeight).
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
  3878
            dstY := srcY + (nLines * fontHeight).
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
  3879
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
  3880
            "/
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
  3881
            "/ scroll ...
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
  3882
            "/
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
  3883
            "
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
  3884
             stupid: must catchExpose before inserting new
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
  3885
             stuff - since catchExpose may perform redraws
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
  3886
            "
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
  3887
            self catchExpose.
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
  3888
            self withoutRedrawInsertLines:text
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
  3889
                 from:start to:end
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
  3890
                 before:lineNr.
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
  3891
            self
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
  3892
                copyFrom:self
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
  3893
                x:textStartLeft y:srcY
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
  3894
                toX:textStartLeft y:dstY
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
  3895
                width:w
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
  3896
                height:(height - dstY)
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
  3897
                async:true.
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
  3898
            self redrawFromVisibleLine:visLine to:(visLine + nLines - 1).
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
  3899
            self waitForExpose
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
  3900
        ].
2954
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3901
    ].
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3902
    widthOfWidestLine notNil ifTrue:[
3296
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
  3903
        text do:[:line |
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
  3904
            widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:line).
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
  3905
        ]
2954
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3906
    ].
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3907
    self textChanged.
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3908
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3909
    "Modified: 29.1.1997 / 13:02:39 / cg"
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3910
!
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3911
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3912
mergeLine:lineNr removeBlanks:removeBlanks
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3913
    "merge line lineNr with line lineNr+1"
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3914
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3915
    |len|
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3916
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3917
    len := (self listAt:lineNr) size.
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3918
    self nonUndoableDo:[
3542
30ed44ed0178 +joinLines (CTRL-j);
Claus Gittinger <cg@exept.de>
parents: 3517
diff changeset
  3919
        self basicMergeLine:lineNr removeBlanks:removeBlanks.
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3920
    ].
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3921
    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
  3922
!
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3923
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3924
replace:aCharacter atLine:lineNr col:colNr
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3925
    "replace a single character at lineNr/colNr"
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3926
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3927
    |originalChar|
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3928
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3929
    originalChar := self characterAtLine:lineNr col:colNr.
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3930
    self basicReplace:aCharacter atLine:lineNr col:colNr.
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  3931
    self addUndo:(ReplaceCharacters line:lineNr col:colNr character:originalChar info:'replace').
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3932
!
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3933
3131
8f21dba07d24 undoable format
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
  3934
replaceContentsWith:newContents
8f21dba07d24 undoable format
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
  3935
    "replace everything"
8f21dba07d24 undoable format
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
  3936
8f21dba07d24 undoable format
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
  3937
    |originalContents|
8f21dba07d24 undoable format
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
  3938
8f21dba07d24 undoable format
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
  3939
    originalContents := self contents.
3249
a4beb76b3f59 code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents: 3241
diff changeset
  3940
    self contents:newContents keepUndoHistory:true.
3131
8f21dba07d24 undoable format
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
  3941
    self addUndo:(ReplaceContents text:originalContents info:'replace').
8f21dba07d24 undoable format
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
  3942
!
8f21dba07d24 undoable format
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
  3943
3130
c0f39f9f28d6 undoable keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3127
diff changeset
  3944
replaceLine:lineNr with:newText
c0f39f9f28d6 undoable keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3127
diff changeset
  3945
    "replace a line at lineNr"
c0f39f9f28d6 undoable keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3127
diff changeset
  3946
c0f39f9f28d6 undoable keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3127
diff changeset
  3947
    |originalLine|
c0f39f9f28d6 undoable keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3127
diff changeset
  3948
c0f39f9f28d6 undoable keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3127
diff changeset
  3949
    originalLine := self listAt:lineNr.
3479
5f9c6ff4fe6d care for non-existing line when replacing (i.e. comment)
Claus Gittinger <cg@exept.de>
parents: 3476
diff changeset
  3950
    originalLine isNil ifTrue:[
5f9c6ff4fe6d care for non-existing line when replacing (i.e. comment)
Claus Gittinger <cg@exept.de>
parents: 3476
diff changeset
  3951
        self checkForExistingLine:lineNr
5f9c6ff4fe6d care for non-existing line when replacing (i.e. comment)
Claus Gittinger <cg@exept.de>
parents: 3476
diff changeset
  3952
    ].
3130
c0f39f9f28d6 undoable keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3127
diff changeset
  3953
    self list at:lineNr put:newText.
c0f39f9f28d6 undoable keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3127
diff changeset
  3954
    self addUndo:(ReplaceLine line:lineNr string:originalLine info:'replace').
c0f39f9f28d6 undoable keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3127
diff changeset
  3955
    self invalidateLine:lineNr.
3479
5f9c6ff4fe6d care for non-existing line when replacing (i.e. comment)
Claus Gittinger <cg@exept.de>
parents: 3476
diff changeset
  3956
5f9c6ff4fe6d care for non-existing line when replacing (i.e. comment)
Claus Gittinger <cg@exept.de>
parents: 3476
diff changeset
  3957
    "Modified: / 12-04-2007 / 09:31:33 / cg"
3130
c0f39f9f28d6 undoable keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3127
diff changeset
  3958
!
c0f39f9f28d6 undoable keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3127
diff changeset
  3959
1564
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  3960
replaceString:aString atLine:lineNr col:colNr
1557
b88c7410311f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1552
diff changeset
  3961
    "replace multiple characters starting at lineNr/colNr.
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  3962
     This is not prepared to encounter special chars (except TAB) in the string."
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  3963
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  3964
    |originalString|
1557
b88c7410311f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1552
diff changeset
  3965
b88c7410311f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1552
diff changeset
  3966
    self checkModificationsAllowed ifFalse:[ ^ self].
b88c7410311f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1552
diff changeset
  3967
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  3968
    originalString := self textFromLine:lineNr col:colNr toLine:lineNr col:colNr+aString size-1.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  3969
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  3970
    self basicReplaceString:aString atLine:lineNr col:colNr.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  3971
    self addUndo:(ReplaceCharacters line:lineNr col:colNr characters:originalString info:'replace').
1557
b88c7410311f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1552
diff changeset
  3972
!
b88c7410311f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1552
diff changeset
  3973
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3974
splitLine:lineNr before:colNr
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3975
    "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
  3976
     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
  3977
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3978
    self basicSplitLine:lineNr before:colNr.
3115
b75128334006 info string in undo
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
  3979
    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
  3980
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3981
3130
c0f39f9f28d6 undoable keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3127
diff changeset
  3982
withoutRedrawAt:lineNr put:aString
c0f39f9f28d6 undoable keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3127
diff changeset
  3983
    "replace a line at lineNr"
c0f39f9f28d6 undoable keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3127
diff changeset
  3984
c0f39f9f28d6 undoable keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3127
diff changeset
  3985
    |originalLine|
c0f39f9f28d6 undoable keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3127
diff changeset
  3986
c0f39f9f28d6 undoable keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3127
diff changeset
  3987
    originalLine := self listAt:lineNr.
c0f39f9f28d6 undoable keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3127
diff changeset
  3988
    self addUndo:(ReplaceLine line:lineNr string:originalLine info:'replace').
c0f39f9f28d6 undoable keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3127
diff changeset
  3989
    super withoutRedrawAt:lineNr put:aString.
c0f39f9f28d6 undoable keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3127
diff changeset
  3990
!
c0f39f9f28d6 undoable keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3127
diff changeset
  3991
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3992
withoutRedrawInsertLine:aString before:lineNr
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3993
    "insert the argument, aString before line lineNr; the string
2954
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3994
     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
  3995
     is not redrawn"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3996
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3997
    self basicWithoutRedrawInsertLine:aString before:lineNr.
3115
b75128334006 info string in undo
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
  3998
    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
  3999
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4000
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4001
withoutRedrawInsertLines:lines from:start to:end before:lineNr
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4002
    "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
  4003
2954
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  4004
    self basicWithoutRedrawInsertLines:lines from:start to:end before:lineNr.
3296
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
  4005
    self isReadOnly ifFalse:[
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
  4006
        self addUndo:(DeleteRange line1:lineNr col1:1 line2:lineNr+end-start+1 col2:0 info:'insert').
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
  4007
    ].
121
claus
parents: 118
diff changeset
  4008
!
claus
parents: 118
diff changeset
  4009
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4010
withoutRedrawInsertStringWithoutCRs:aString atLine:lineNr col:colNr
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4011
    "insert aString (which has no crs) at lineNr/colNr"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4012
2954
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  4013
    self basicWithoutRedrawInsertStringWithoutCRs:aString atLine:lineNr col:colNr.
3115
b75128334006 info string in undo
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
  4014
    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
  4015
! !
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4016
2752
5650a9ab5935 method category rename
Claus Gittinger <cg@exept.de>
parents: 2744
diff changeset
  4017
!EditTextView methodsFor:'event handling'!
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4018
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4019
buttonPress:button x:x y:y
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4020
    "hide the cursor when button is activated"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4021
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4022
    hasKeyboardFocus := true.
2589
62794ae04446 support drop
ca
parents: 2580
diff changeset
  4023
    dragIsActive := false.
62794ae04446 support drop
ca
parents: 2580
diff changeset
  4024
1817
1a9e22f755c8 show non-focus cursor when disabled or readOnly
Claus Gittinger <cg@exept.de>
parents: 1816
diff changeset
  4025
    cursorShown ifTrue: [
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  4026
	self drawCursor
1817
1a9e22f755c8 show non-focus cursor when disabled or readOnly
Claus Gittinger <cg@exept.de>
parents: 1816
diff changeset
  4027
    ].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4028
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4029
    ((button == 1) or:[button == #select]) ifTrue:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  4030
	self hideCursor
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4031
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4032
    (button == #paste) ifTrue:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  4033
	self pasteOrReplace.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  4034
	^ self
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4035
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4036
    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
  4037
1a9e22f755c8 show non-focus cursor when disabled or readOnly
Claus Gittinger <cg@exept.de>
parents: 1816
diff changeset
  4038
    "Modified: / 23.3.1999 / 13:51:40 / cg"
121
claus
parents: 118
diff changeset
  4039
!
claus
parents: 118
diff changeset
  4040
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4041
buttonRelease:button x:x y:y
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4042
    "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
  4043
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4044
    ((button == 1) or:[button == #select]) ifTrue:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  4045
	typeOfSelection := nil.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  4046
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  4047
	dragIsActive ifTrue:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  4048
	    self unselect
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  4049
	].
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  4050
	selectionStartLine isNil ifTrue:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  4051
	    clickCol notNil ifTrue:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  4052
		self cursorMovementAllowed ifTrue:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  4053
		    self cursorLine:clickLine col:clickCol
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  4054
		]
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  4055
	    ]
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  4056
	] ifFalse:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  4057
	    lastString := nil. "new selection invalidates remembered string"
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  4058
	].
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  4059
	self showCursor
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4060
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4061
    super buttonRelease:button x:x y:y
1580
d30e562bea15 allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
  4062
d30e562bea15 allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
  4063
    "Modified: / 18.6.1998 / 14:14:05 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4064
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4065
2580
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  4066
cursorKeyPress:key shifted:shifted
2730
61a2f1981ac6 Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents: 2725
diff changeset
  4067
    |n|
61a2f1981ac6 Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents: 2725
diff changeset
  4068
2606
6a3ab90d339f redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents: 2599
diff changeset
  4069
    self changeTypeOfSelectionTo:nil.
2580
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  4070
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  4071
    (key == #CursorRight) ifTrue:[
3232
3db2628edf98 shift-cursor line select
Claus Gittinger <cg@exept.de>
parents: 3227
diff changeset
  4072
        (shifted and:[selectionStartLine isNil]) ifTrue:[
3db2628edf98 shift-cursor line select
Claus Gittinger <cg@exept.de>
parents: 3227
diff changeset
  4073
            selectionStartLine := selectionEndLine := clickStartLine := cursorLine.
3db2628edf98 shift-cursor line select
Claus Gittinger <cg@exept.de>
parents: 3227
diff changeset
  4074
            selectionStartCol := selectionEndCol := clickStartCol := cursorCol.
3db2628edf98 shift-cursor line select
Claus Gittinger <cg@exept.de>
parents: 3227
diff changeset
  4075
            expandingTop := false.
3db2628edf98 shift-cursor line select
Claus Gittinger <cg@exept.de>
parents: 3227
diff changeset
  4076
            self validateNewSelection.
3db2628edf98 shift-cursor line select
Claus Gittinger <cg@exept.de>
parents: 3227
diff changeset
  4077
            self redrawLine:selectionStartLine.
3db2628edf98 shift-cursor line select
Claus Gittinger <cg@exept.de>
parents: 3227
diff changeset
  4078
            ^ self.
3db2628edf98 shift-cursor line select
Claus Gittinger <cg@exept.de>
parents: 3227
diff changeset
  4079
        ].
3db2628edf98 shift-cursor line select
Claus Gittinger <cg@exept.de>
parents: 3227
diff changeset
  4080
3db2628edf98 shift-cursor line select
Claus Gittinger <cg@exept.de>
parents: 3227
diff changeset
  4081
        selectionStartLine notNil ifTrue:[
3db2628edf98 shift-cursor line select
Claus Gittinger <cg@exept.de>
parents: 3227
diff changeset
  4082
            self cursorMovementAllowed ifTrue:[
3db2628edf98 shift-cursor line select
Claus Gittinger <cg@exept.de>
parents: 3227
diff changeset
  4083
                "/
3db2628edf98 shift-cursor line select
Claus Gittinger <cg@exept.de>
parents: 3227
diff changeset
  4084
                "/ treat the whole selection as cursor
3db2628edf98 shift-cursor line select
Claus Gittinger <cg@exept.de>
parents: 3227
diff changeset
  4085
                "/
3303
add21df4dcb1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3296
diff changeset
  4086
                self setCursorLine:(selectionEndLine ? selectionStartLine).
3232
3db2628edf98 shift-cursor line select
Claus Gittinger <cg@exept.de>
parents: 3227
diff changeset
  4087
                selectionEndCol == 0 ifTrue:[
3db2628edf98 shift-cursor line select
Claus Gittinger <cg@exept.de>
parents: 3227
diff changeset
  4088
                    selectionEndCol := 1.
3db2628edf98 shift-cursor line select
Claus Gittinger <cg@exept.de>
parents: 3227
diff changeset
  4089
                ].
3db2628edf98 shift-cursor line select
Claus Gittinger <cg@exept.de>
parents: 3227
diff changeset
  4090
                self setCursorCol:selectionEndCol.
3db2628edf98 shift-cursor line select
Claus Gittinger <cg@exept.de>
parents: 3227
diff changeset
  4091
                shifted ifTrue:[
3db2628edf98 shift-cursor line select
Claus Gittinger <cg@exept.de>
parents: 3227
diff changeset
  4092
                    self expandSelectionRight.
3db2628edf98 shift-cursor line select
Claus Gittinger <cg@exept.de>
parents: 3227
diff changeset
  4093
                    ^ self
3db2628edf98 shift-cursor line select
Claus Gittinger <cg@exept.de>
parents: 3227
diff changeset
  4094
                ].
3db2628edf98 shift-cursor line select
Claus Gittinger <cg@exept.de>
parents: 3227
diff changeset
  4095
                self unselect; makeCursorVisible.
3db2628edf98 shift-cursor line select
Claus Gittinger <cg@exept.de>
parents: 3227
diff changeset
  4096
                cursorCol == 1 ifTrue:[^ self].
3db2628edf98 shift-cursor line select
Claus Gittinger <cg@exept.de>
parents: 3227
diff changeset
  4097
            ].
3db2628edf98 shift-cursor line select
Claus Gittinger <cg@exept.de>
parents: 3227
diff changeset
  4098
        ].
3db2628edf98 shift-cursor line select
Claus Gittinger <cg@exept.de>
parents: 3227
diff changeset
  4099
        self cursorRight.
3db2628edf98 shift-cursor line select
Claus Gittinger <cg@exept.de>
parents: 3227
diff changeset
  4100
        ^ self
2580
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  4101
    ].
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  4102
    (key == #CursorDown) ifTrue:[
3232
3db2628edf98 shift-cursor line select
Claus Gittinger <cg@exept.de>
parents: 3227
diff changeset
  4103
        (shifted and:[selectionStartLine isNil]) ifTrue:[
3db2628edf98 shift-cursor line select
Claus Gittinger <cg@exept.de>
parents: 3227
diff changeset
  4104
            selectionStartLine := clickStartLine := cursorLine. selectionEndLine := cursorLine + 1.
3db2628edf98 shift-cursor line select
Claus Gittinger <cg@exept.de>
parents: 3227
diff changeset
  4105
            selectionStartCol := clickStartCol := selectionEndCol := cursorCol.
3db2628edf98 shift-cursor line select
Claus Gittinger <cg@exept.de>
parents: 3227
diff changeset
  4106
            selectionEndCol == 1 ifTrue:[
3db2628edf98 shift-cursor line select
Claus Gittinger <cg@exept.de>
parents: 3227
diff changeset
  4107
                selectionEndCol := 0.
3db2628edf98 shift-cursor line select
Claus Gittinger <cg@exept.de>
parents: 3227
diff changeset
  4108
            ].
3db2628edf98 shift-cursor line select
Claus Gittinger <cg@exept.de>
parents: 3227
diff changeset
  4109
            self validateNewSelection.
3db2628edf98 shift-cursor line select
Claus Gittinger <cg@exept.de>
parents: 3227
diff changeset
  4110
            self redrawLine:selectionStartLine.
3db2628edf98 shift-cursor line select
Claus Gittinger <cg@exept.de>
parents: 3227
diff changeset
  4111
            expandingTop := false.
3db2628edf98 shift-cursor line select
Claus Gittinger <cg@exept.de>
parents: 3227
diff changeset
  4112
            self redrawLine:selectionEndLine.
3db2628edf98 shift-cursor line select
Claus Gittinger <cg@exept.de>
parents: 3227
diff changeset
  4113
            ^ self
3db2628edf98 shift-cursor line select
Claus Gittinger <cg@exept.de>
parents: 3227
diff changeset
  4114
        ].
3db2628edf98 shift-cursor line select
Claus Gittinger <cg@exept.de>
parents: 3227
diff changeset
  4115
3db2628edf98 shift-cursor line select
Claus Gittinger <cg@exept.de>
parents: 3227
diff changeset
  4116
        selectionStartLine notNil ifTrue:[
3db2628edf98 shift-cursor line select
Claus Gittinger <cg@exept.de>
parents: 3227
diff changeset
  4117
            self cursorMovementAllowed ifTrue:[
3db2628edf98 shift-cursor line select
Claus Gittinger <cg@exept.de>
parents: 3227
diff changeset
  4118
                "/
3db2628edf98 shift-cursor line select
Claus Gittinger <cg@exept.de>
parents: 3227
diff changeset
  4119
                "/ treat the whole selection as cursor
3db2628edf98 shift-cursor line select
Claus Gittinger <cg@exept.de>
parents: 3227
diff changeset
  4120
                "/
3303
add21df4dcb1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3296
diff changeset
  4121
                self setCursorLine:(selectionEndLine ? selectionStartLine).
3232
3db2628edf98 shift-cursor line select
Claus Gittinger <cg@exept.de>
parents: 3227
diff changeset
  4122
                self setCursorCol:selectionStartCol.
3db2628edf98 shift-cursor line select
Claus Gittinger <cg@exept.de>
parents: 3227
diff changeset
  4123
                cursorCol == 0 ifTrue:[
3db2628edf98 shift-cursor line select
Claus Gittinger <cg@exept.de>
parents: 3227
diff changeset
  4124
                    self setCursorCol:1.
3db2628edf98 shift-cursor line select
Claus Gittinger <cg@exept.de>
parents: 3227
diff changeset
  4125
                    self setCursorLine:(cursorLine - 1).
3db2628edf98 shift-cursor line select
Claus Gittinger <cg@exept.de>
parents: 3227
diff changeset
  4126
                ].
3db2628edf98 shift-cursor line select
Claus Gittinger <cg@exept.de>
parents: 3227
diff changeset
  4127
                self makeCursorVisible.
3db2628edf98 shift-cursor line select
Claus Gittinger <cg@exept.de>
parents: 3227
diff changeset
  4128
3db2628edf98 shift-cursor line select
Claus Gittinger <cg@exept.de>
parents: 3227
diff changeset
  4129
                shifted ifTrue:[
3db2628edf98 shift-cursor line select
Claus Gittinger <cg@exept.de>
parents: 3227
diff changeset
  4130
                    clickLine := cursorLine.
3db2628edf98 shift-cursor line select
Claus Gittinger <cg@exept.de>
parents: 3227
diff changeset
  4131
                    clickCol := cursorCol.
3db2628edf98 shift-cursor line select
Claus Gittinger <cg@exept.de>
parents: 3227
diff changeset
  4132
                    self expandSelectionDown.
3db2628edf98 shift-cursor line select
Claus Gittinger <cg@exept.de>
parents: 3227
diff changeset
  4133
                    ^ self
3db2628edf98 shift-cursor line select
Claus Gittinger <cg@exept.de>
parents: 3227
diff changeset
  4134
                ].
3db2628edf98 shift-cursor line select
Claus Gittinger <cg@exept.de>
parents: 3227
diff changeset
  4135
                self unselect.
3db2628edf98 shift-cursor line select
Claus Gittinger <cg@exept.de>
parents: 3227
diff changeset
  4136
            ].
3db2628edf98 shift-cursor line select
Claus Gittinger <cg@exept.de>
parents: 3227
diff changeset
  4137
        ].
3db2628edf98 shift-cursor line select
Claus Gittinger <cg@exept.de>
parents: 3227
diff changeset
  4138
3db2628edf98 shift-cursor line select
Claus Gittinger <cg@exept.de>
parents: 3227
diff changeset
  4139
        n := 1 + (self sensor compressKeyPressEventsWithKey:#CursorDown).
3db2628edf98 shift-cursor line select
Claus Gittinger <cg@exept.de>
parents: 3227
diff changeset
  4140
        self cursorDown:n.
3db2628edf98 shift-cursor line select
Claus Gittinger <cg@exept.de>
parents: 3227
diff changeset
  4141
        "/
3db2628edf98 shift-cursor line select
Claus Gittinger <cg@exept.de>
parents: 3227
diff changeset
  4142
        "/ flush keyboard to avoid runaway cursor
3db2628edf98 shift-cursor line select
Claus Gittinger <cg@exept.de>
parents: 3227
diff changeset
  4143
        "/
3db2628edf98 shift-cursor line select
Claus Gittinger <cg@exept.de>
parents: 3227
diff changeset
  4144
        self sensor flushKeyboardFor:self.
3db2628edf98 shift-cursor line select
Claus Gittinger <cg@exept.de>
parents: 3227
diff changeset
  4145
        ^ self
2580
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  4146
    ].
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  4147
    (key == #CursorLeft or:[key == #CursorUp]) ifTrue:[
3232
3db2628edf98 shift-cursor line select
Claus Gittinger <cg@exept.de>
parents: 3227
diff changeset
  4148
        (shifted and:[selectionStartLine isNil]) ifTrue:[
3db2628edf98 shift-cursor line select
Claus Gittinger <cg@exept.de>
parents: 3227
diff changeset
  4149
            expandingTop := true.
3db2628edf98 shift-cursor line select
Claus Gittinger <cg@exept.de>
parents: 3227
diff changeset
  4150
            key == #CursorLeft ifTrue:[
3db2628edf98 shift-cursor line select
Claus Gittinger <cg@exept.de>
parents: 3227
diff changeset
  4151
                cursorCol > 1 ifTrue:[
3db2628edf98 shift-cursor line select
Claus Gittinger <cg@exept.de>
parents: 3227
diff changeset
  4152
                    selectionStartLine := selectionEndLine := clickStartLine := cursorLine.
3db2628edf98 shift-cursor line select
Claus Gittinger <cg@exept.de>
parents: 3227
diff changeset
  4153
                    selectionEndCol := clickStartCol := cursorCol-1.
3db2628edf98 shift-cursor line select
Claus Gittinger <cg@exept.de>
parents: 3227
diff changeset
  4154
                    selectionStartCol := cursorCol-1.
3db2628edf98 shift-cursor line select
Claus Gittinger <cg@exept.de>
parents: 3227
diff changeset
  4155
                    self validateNewSelection.
3db2628edf98 shift-cursor line select
Claus Gittinger <cg@exept.de>
parents: 3227
diff changeset
  4156
                    self redrawLine:selectionStartLine.
3db2628edf98 shift-cursor line select
Claus Gittinger <cg@exept.de>
parents: 3227
diff changeset
  4157
                    ^ self
3db2628edf98 shift-cursor line select
Claus Gittinger <cg@exept.de>
parents: 3227
diff changeset
  4158
                ]
3db2628edf98 shift-cursor line select
Claus Gittinger <cg@exept.de>
parents: 3227
diff changeset
  4159
            ] ifFalse:[
3db2628edf98 shift-cursor line select
Claus Gittinger <cg@exept.de>
parents: 3227
diff changeset
  4160
                cursorLine > 1 ifTrue:[
3db2628edf98 shift-cursor line select
Claus Gittinger <cg@exept.de>
parents: 3227
diff changeset
  4161
                    selectionEndLine := clickStartLine := cursorLine.
3db2628edf98 shift-cursor line select
Claus Gittinger <cg@exept.de>
parents: 3227
diff changeset
  4162
                    selectionEndCol := selectionStartCol := clickStartCol := cursorCol.
3db2628edf98 shift-cursor line select
Claus Gittinger <cg@exept.de>
parents: 3227
diff changeset
  4163
                    selectionStartLine := cursorLine - 1.
3db2628edf98 shift-cursor line select
Claus Gittinger <cg@exept.de>
parents: 3227
diff changeset
  4164
                    selectionEndCol == 1 ifTrue:[
3db2628edf98 shift-cursor line select
Claus Gittinger <cg@exept.de>
parents: 3227
diff changeset
  4165
                        selectionEndCol := 0.
3db2628edf98 shift-cursor line select
Claus Gittinger <cg@exept.de>
parents: 3227
diff changeset
  4166
                    ].
3db2628edf98 shift-cursor line select
Claus Gittinger <cg@exept.de>
parents: 3227
diff changeset
  4167
                    self validateNewSelection.
3db2628edf98 shift-cursor line select
Claus Gittinger <cg@exept.de>
parents: 3227
diff changeset
  4168
                    self redrawFromLine:selectionStartLine to:cursorLine.
3db2628edf98 shift-cursor line select
Claus Gittinger <cg@exept.de>
parents: 3227
diff changeset
  4169
                    ^ self
3db2628edf98 shift-cursor line select
Claus Gittinger <cg@exept.de>
parents: 3227
diff changeset
  4170
                ]
3db2628edf98 shift-cursor line select
Claus Gittinger <cg@exept.de>
parents: 3227
diff changeset
  4171
            ]
3db2628edf98 shift-cursor line select
Claus Gittinger <cg@exept.de>
parents: 3227
diff changeset
  4172
        ].
3db2628edf98 shift-cursor line select
Claus Gittinger <cg@exept.de>
parents: 3227
diff changeset
  4173
3db2628edf98 shift-cursor line select
Claus Gittinger <cg@exept.de>
parents: 3227
diff changeset
  4174
        selectionStartLine notNil ifTrue:[
3db2628edf98 shift-cursor line select
Claus Gittinger <cg@exept.de>
parents: 3227
diff changeset
  4175
            self cursorMovementAllowed ifTrue:[
3db2628edf98 shift-cursor line select
Claus Gittinger <cg@exept.de>
parents: 3227
diff changeset
  4176
                "/
3db2628edf98 shift-cursor line select
Claus Gittinger <cg@exept.de>
parents: 3227
diff changeset
  4177
                "/ treat the whole selection as cursor
3db2628edf98 shift-cursor line select
Claus Gittinger <cg@exept.de>
parents: 3227
diff changeset
  4178
                "/
3db2628edf98 shift-cursor line select
Claus Gittinger <cg@exept.de>
parents: 3227
diff changeset
  4179
                self setCursorLine:selectionStartLine.
3db2628edf98 shift-cursor line select
Claus Gittinger <cg@exept.de>
parents: 3227
diff changeset
  4180
                self setCursorCol:selectionStartCol.
3db2628edf98 shift-cursor line select
Claus Gittinger <cg@exept.de>
parents: 3227
diff changeset
  4181
                (key == #CursorLeft) ifTrue:[
3db2628edf98 shift-cursor line select
Claus Gittinger <cg@exept.de>
parents: 3227
diff changeset
  4182
                    self setCursorCol:(cursorCol+1).  "/ compensate for followup crsr-left
3db2628edf98 shift-cursor line select
Claus Gittinger <cg@exept.de>
parents: 3227
diff changeset
  4183
                ].
3db2628edf98 shift-cursor line select
Claus Gittinger <cg@exept.de>
parents: 3227
diff changeset
  4184
                self makeCursorVisible.
3db2628edf98 shift-cursor line select
Claus Gittinger <cg@exept.de>
parents: 3227
diff changeset
  4185
3db2628edf98 shift-cursor line select
Claus Gittinger <cg@exept.de>
parents: 3227
diff changeset
  4186
                shifted ifTrue:[
3db2628edf98 shift-cursor line select
Claus Gittinger <cg@exept.de>
parents: 3227
diff changeset
  4187
                    (key == #CursorUp) ifTrue:[
3db2628edf98 shift-cursor line select
Claus Gittinger <cg@exept.de>
parents: 3227
diff changeset
  4188
                        clickLine := cursorLine.
3db2628edf98 shift-cursor line select
Claus Gittinger <cg@exept.de>
parents: 3227
diff changeset
  4189
                        self expandSelectionUp.
3db2628edf98 shift-cursor line select
Claus Gittinger <cg@exept.de>
parents: 3227
diff changeset
  4190
                    ] ifFalse:[
3db2628edf98 shift-cursor line select
Claus Gittinger <cg@exept.de>
parents: 3227
diff changeset
  4191
                        self expandSelectionLeft.
3db2628edf98 shift-cursor line select
Claus Gittinger <cg@exept.de>
parents: 3227
diff changeset
  4192
                    ].
3db2628edf98 shift-cursor line select
Claus Gittinger <cg@exept.de>
parents: 3227
diff changeset
  4193
                    ^ self
3db2628edf98 shift-cursor line select
Claus Gittinger <cg@exept.de>
parents: 3227
diff changeset
  4194
                ].
3db2628edf98 shift-cursor line select
Claus Gittinger <cg@exept.de>
parents: 3227
diff changeset
  4195
                self unselect.
3db2628edf98 shift-cursor line select
Claus Gittinger <cg@exept.de>
parents: 3227
diff changeset
  4196
            ].
3db2628edf98 shift-cursor line select
Claus Gittinger <cg@exept.de>
parents: 3227
diff changeset
  4197
        ].
3db2628edf98 shift-cursor line select
Claus Gittinger <cg@exept.de>
parents: 3227
diff changeset
  4198
        (key == #CursorLeft) ifTrue:[
3db2628edf98 shift-cursor line select
Claus Gittinger <cg@exept.de>
parents: 3227
diff changeset
  4199
            self cursorLeft. ^self
3db2628edf98 shift-cursor line select
Claus Gittinger <cg@exept.de>
parents: 3227
diff changeset
  4200
        ].
3db2628edf98 shift-cursor line select
Claus Gittinger <cg@exept.de>
parents: 3227
diff changeset
  4201
        (key == #CursorUp)        ifTrue:[
3db2628edf98 shift-cursor line select
Claus Gittinger <cg@exept.de>
parents: 3227
diff changeset
  4202
            n := 1 + (self sensor compressKeyPressEventsWithKey:#CursorUp).
3db2628edf98 shift-cursor line select
Claus Gittinger <cg@exept.de>
parents: 3227
diff changeset
  4203
            self cursorUp:n.
3db2628edf98 shift-cursor line select
Claus Gittinger <cg@exept.de>
parents: 3227
diff changeset
  4204
            "/
3db2628edf98 shift-cursor line select
Claus Gittinger <cg@exept.de>
parents: 3227
diff changeset
  4205
            "/ flush keyboard to avoid runaway cursor
3db2628edf98 shift-cursor line select
Claus Gittinger <cg@exept.de>
parents: 3227
diff changeset
  4206
            "/
3db2628edf98 shift-cursor line select
Claus Gittinger <cg@exept.de>
parents: 3227
diff changeset
  4207
            self sensor flushKeyboardFor:self.
3db2628edf98 shift-cursor line select
Claus Gittinger <cg@exept.de>
parents: 3227
diff changeset
  4208
            ^ self
3db2628edf98 shift-cursor line select
Claus Gittinger <cg@exept.de>
parents: 3227
diff changeset
  4209
        ].
2580
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  4210
    ].
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  4211
!
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  4212
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4213
doKeyPress:key x:x y:y
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4214
    "handle keyboard input"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4215
2978
b5b3527cbb6b undo key
Claus Gittinger <cg@exept.de>
parents: 2965
diff changeset
  4216
    <resource: #keyboard (#Paste #Insert #Cut #Again #Replace #Undo #Accept
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4217
                          #Delete #BasicDelete #BackSpace #BasicBackspace
3542
30ed44ed0178 +joinLines (CTRL-j);
Claus Gittinger <cg@exept.de>
parents: 3517
diff changeset
  4218
                          #SelectWord #DeleteSpaces #Join
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4219
                          #SearchMatchingParent #SelectMatchingParents
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4220
                          #SelectToEnd #SelectFromBeginning
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4221
                          #BeginOfLine #EndOfLine #NextWord #PreviousWord
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4222
                          #CursorRight #CursorDown #CursorLeft #CursorUp
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4223
                          #Return #Tab #BackTab #NonInsertingTab #Escape
3324
1297aecf6699 delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents: 3313
diff changeset
  4224
                          #GotoLine #BeginOfText #EndOfText
1297aecf6699 delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents: 3313
diff changeset
  4225
                          #SelectLine #ExpandSelectionByLine
1297aecf6699 delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents: 3313
diff changeset
  4226
                          #InsertLine #DeleteLine
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4227
                          #SelectLineFromBeginning
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4228
                          #LearnKeyboardMacro #ExecuteKeyboardMacro #ToggleInsertMode
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4229
                          #'F*' #'f*')>
2017
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  4230
3023
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  4231
    |fKeyMacros shiftPressed ctrlPressed i event cmdMacro|
2184
fb634dc3e606 learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents: 2157
diff changeset
  4232
fb634dc3e606 learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents: 2157
diff changeset
  4233
    event := WindowGroup lastEventQuerySignal query.
3023
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  4234
    shiftPressed := event hasShift.
3024
e2d7e40e6481 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3023
diff changeset
  4235
    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
  4236
2416
56acdd9e31b5 lifted mkeyboardMacro handling from Workspace to EditTextView
Claus Gittinger <cg@exept.de>
parents: 2406
diff changeset
  4237
    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
  4238
    cmdMacro notNil ifTrue:[
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4239
        self
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4240
            undoableDo:
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4241
                [ self executeKeyboardMacro:cmdMacro ]
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4242
            info: key.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4243
        ^ self
2416
56acdd9e31b5 lifted mkeyboardMacro handling from Workspace to EditTextView
Claus Gittinger <cg@exept.de>
parents: 2406
diff changeset
  4244
    ].
56acdd9e31b5 lifted mkeyboardMacro handling from Workspace to EditTextView
Claus Gittinger <cg@exept.de>
parents: 2406
diff changeset
  4245
3257
628e1e05814d shift-Tab fix.
Claus Gittinger <cg@exept.de>
parents: 3252
diff changeset
  4246
    (key == #BackSpace or:[key == #BasicBackspace]) ifTrue:[
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4247
        selectionStartLine notNil ifTrue:[
3326
4740a22e21c5 *** empty log message ***
fm
parents: 3324
diff changeset
  4248
            ((key == #BasicBackspace) 
4740a22e21c5 *** empty log message ***
fm
parents: 3324
diff changeset
  4249
            or:[ UserPreferences current deleteSetsClipboardText not ])
4740a22e21c5 *** empty log message ***
fm
parents: 3324
diff changeset
  4250
            ifTrue:[
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4251
                self deleteSelection.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4252
            ] ifFalse: [
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4253
                self copyAndDeleteSelection.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4254
            ].
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4255
            ^ self
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4256
        ].
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4257
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4258
        self makeCursorVisible.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4259
        shiftPressed ifTrue:[
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4260
            self deleteWordBeforeCursor.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4261
        ] ifFalse:[
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4262
            self deleteCharBeforeCursor.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4263
        ].
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4264
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4265
        ^ self
2205
230cf9cef6c3 searchPatter, if from selection (escape meta characters)
Claus Gittinger <cg@exept.de>
parents: 2196
diff changeset
  4266
    ].
2184
fb634dc3e606 learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents: 2157
diff changeset
  4267
fb634dc3e606 learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents: 2157
diff changeset
  4268
    (key == #LearnKeyboardMacro) ifTrue:[
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4269
        self toggleLearnMode.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4270
        ^ self
2184
fb634dc3e606 learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents: 2157
diff changeset
  4271
    ].
fb634dc3e606 learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents: 2157
diff changeset
  4272
    (key == #ExecuteKeyboardMacro) ifTrue:[
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4273
        self executeLearnedKeyboardMacro.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4274
        ^ self.
2184
fb634dc3e606 learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents: 2157
diff changeset
  4275
    ].
2795
1f7b5f242eee learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents: 2792
diff changeset
  4276
    self learnMode ifTrue:[
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4277
        learnedMacro add:event.
2184
fb634dc3e606 learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents: 2157
diff changeset
  4278
    ].
fb634dc3e606 learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents: 2157
diff changeset
  4279
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4280
    (key isMemberOf:Character) ifTrue:[
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4281
        self handleNonCommandKey:key.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4282
        ^ self
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4283
    ].
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4284
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4285
    key == #ToggleInsertMode ifTrue:[
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4286
        editMode value == EditMode insertMode ifTrue:[
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4287
            editMode value:(EditMode overwriteMode).
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4288
            ^ self.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4289
        ].
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4290
        editMode value == EditMode overwriteMode ifTrue:[
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4291
            editMode value:(EditMode insertAndSelectMode).
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4292
            ^ self.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4293
        ].
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4294
        editMode value == EditMode insertAndSelectMode ifTrue:[
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4295
            editMode value:(EditMode insertMode).
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4296
            ^ self.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4297
        ].
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4298
        ^ self.
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  4299
    ].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4300
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4301
    replacing := false.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4302
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4303
    "
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4304
     Fn      pastes a key-sequence (but only if not overlayed with
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4305
             another function in the keyboard map)
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4306
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4307
     see TextView>>:x:y
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4308
    "
1177
9d23e1241404 avoid match: if possible (to not clobber the previous matchString)
Claus Gittinger <cg@exept.de>
parents: 1108
diff changeset
  4309
    (key at:1) asLowercase == $f ifTrue:[
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4310
        (('[fF][0-9]' match:key)
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4311
        or:['[fF][0-9][0-9]' match:key]) ifTrue:[
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4312
            shiftPressed ifFalse:[
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4313
                fKeyMacros := UserPreferences current functionKeySequences.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4314
                fKeyMacros notNil ifTrue:[
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4315
                    (fKeyMacros includesKey:key) ifTrue:[
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4316
                        self pasteOrReplace:(fKeyMacros at:key) asStringCollection.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4317
                        ^ self
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4318
                    ]
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4319
                ]
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4320
            ]
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4321
        ].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4322
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4323
2506
5568d67dbddd Ctrl-8 / Ctrl-9,
Claus Gittinger <cg@exept.de>
parents: 2505
diff changeset
  4324
    (key == #'Ctrl8' or:[key == #'Ctrl9']) ifTrue:[
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4325
        self parenthizeSelectionWith:$( and:$).
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4326
        ^ self.
2506
5568d67dbddd Ctrl-8 / Ctrl-9,
Claus Gittinger <cg@exept.de>
parents: 2505
diff changeset
  4327
    ].
5568d67dbddd Ctrl-8 / Ctrl-9,
Claus Gittinger <cg@exept.de>
parents: 2505
diff changeset
  4328
    (key == #'Ctrl2') ifTrue:[
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4329
        self parenthizeSelectionWith:$" and:$".
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4330
        ^ self.
2506
5568d67dbddd Ctrl-8 / Ctrl-9,
Claus Gittinger <cg@exept.de>
parents: 2505
diff changeset
  4331
    ].
5568d67dbddd Ctrl-8 / Ctrl-9,
Claus Gittinger <cg@exept.de>
parents: 2505
diff changeset
  4332
    (key == #'Ctrl#') ifTrue:[
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4333
        self parenthizeSelectionWith:$' and:$'.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4334
        ^ self.
2505
9204d5313979 Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents: 2491
diff changeset
  4335
    ].
9204d5313979 Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents: 2491
diff changeset
  4336
274
6df4bb990f04 handle accept where acceptAction is define (this was a historic leftover)
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
  4337
    (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
  4338
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4339
    ((key == #Paste) or:[key == #Insert]) ifTrue:[self pasteOrReplace. ^self].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4340
    (key == #Cut) ifTrue:[self cut. ^self].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4341
    (key == #Again) ifTrue:[self again. ^self].
2978
b5b3527cbb6b undo key
Claus Gittinger <cg@exept.de>
parents: 2965
diff changeset
  4342
    (key == #Undo) ifTrue:[self undo. ^self].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4343
3542
30ed44ed0178 +joinLines (CTRL-j);
Claus Gittinger <cg@exept.de>
parents: 3517
diff changeset
  4344
    (key == #Join) ifTrue:[self joinLines. ^self].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4345
    (key == #Replace) ifTrue:[self replace. ^self].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4346
    (key == #SelectWord) ifTrue:[
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4347
        self makeCursorVisible.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4348
        self selectWordUnderCursor.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4349
        ^ self
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4350
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4351
2505
9204d5313979 Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents: 2491
diff changeset
  4352
    (key == #SearchMatchingParent) ifTrue:[self searchForMatchingParenthesis. ^ self].
9204d5313979 Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents: 2491
diff changeset
  4353
    (key == #SelectMatchingParents) ifTrue:[self searchForAndSelectMatchingParenthesis. ^ self].
9204d5313979 Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents: 2491
diff changeset
  4354
    (key == #SelectToEnd) ifTrue:[self selectUpToEnd. ^ self].
9204d5313979 Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents: 2491
diff changeset
  4355
    (key == #SelectFromBeginning) ifTrue:[self selectFromBeginning. ^ self].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4356
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4357
" disabled - nobody liked it ...
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4358
  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
  4359
1304
173d00c195f9 flush pending keyboard events in cursor-up/down
Claus Gittinger <cg@exept.de>
parents: 1300
diff changeset
  4360
    (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
  4361
    (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
  4362
    (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
  4363
    (key == #Ctrlp) ifTrue:[self unselect. self cursorUp. ^ self].
259
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
1675
b1cba2341f95 EndOfLine / BeginOfLine unselect first.
Claus Gittinger <cg@exept.de>
parents: 1601
diff changeset
  4366
    (key == #BeginOfLine) ifTrue:[
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4367
        shiftPressed ifTrue: [
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4368
            "/ "Original St/X code - now use Ctrl modifier"
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4369
            "/ self unselect.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4370
            "/ self cursorHome.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4371
            "Jan's modification"
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4372
            self addToSelectionAfter:[ self cursorToBeginOfLine ].
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4373
        ] ifFalse: [
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4374
            self unselect.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4375
            ctrlPressed ifTrue:[
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4376
                self cursorHome.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4377
            ] ifFalse:[
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4378
                self cursorToBeginOfLine.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4379
            ]
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4380
        ].
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4381
        ^ self
1675
b1cba2341f95 EndOfLine / BeginOfLine unselect first.
Claus Gittinger <cg@exept.de>
parents: 1601
diff changeset
  4382
    ].
b1cba2341f95 EndOfLine / BeginOfLine unselect first.
Claus Gittinger <cg@exept.de>
parents: 1601
diff changeset
  4383
    (key == #EndOfLine) ifTrue:[
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4384
        shiftPressed ifTrue:[
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4385
            "/ "Original St/X code - now use Ctrl modifier"
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4386
            "/ self unselect.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4387
            "/ self cursorToBottom
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4388
            "Jan's modification"
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4389
            self addToSelectionAfter:[ self cursorToEndOfLine ] .
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4390
        ] ifFalse:[
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4391
            self unselect.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4392
            ctrlPressed ifTrue:[
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4393
                self cursorToBottom
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4394
            ] ifFalse:[
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4395
                self cursorToEndOfLine.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4396
            ]
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4397
        ].
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4398
        ^ self
1675
b1cba2341f95 EndOfLine / BeginOfLine unselect first.
Claus Gittinger <cg@exept.de>
parents: 1601
diff changeset
  4399
    ].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4400
    (key == #NextWord) ifTrue:[self cursorToNextWord. ^self].
3310
83368f9014a1 word check
Claus Gittinger <cg@exept.de>
parents: 3303
diff changeset
  4401
    (key == #EndOfWord) ifTrue:[self cursorToEndOfWord. ^self].
499
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
  4402
    (key == #PreviousWord) ifTrue:[self cursorToPreviousWord. ^self].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4403
    (key == #GotoLine) ifTrue:[self gotoLine. ^self].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4404
2580
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  4405
    (key == #CursorRight
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  4406
    or:[key == #CursorDown
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  4407
    or:[key == #CursorLeft
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  4408
    or:[key == #CursorUp]]]) ifTrue:[
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4409
        self cursorKeyPress:key shifted:shiftPressed.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4410
        ^ self.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4411
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4412
3257
628e1e05814d shift-Tab fix.
Claus Gittinger <cg@exept.de>
parents: 3252
diff changeset
  4413
    (key == #NonInsertingReturn) ifTrue:[
628e1e05814d shift-Tab fix.
Claus Gittinger <cg@exept.de>
parents: 3252
diff changeset
  4414
        self unselect. self cursorReturn.
628e1e05814d shift-Tab fix.
Claus Gittinger <cg@exept.de>
parents: 3252
diff changeset
  4415
        ^ self
628e1e05814d shift-Tab fix.
Claus Gittinger <cg@exept.de>
parents: 3252
diff changeset
  4416
    ].
628e1e05814d shift-Tab fix.
Claus Gittinger <cg@exept.de>
parents: 3252
diff changeset
  4417
628e1e05814d shift-Tab fix.
Claus Gittinger <cg@exept.de>
parents: 3252
diff changeset
  4418
    (key == #Return) ifTrue:[
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4419
        shiftPressed ifTrue:[
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4420
            self unselect. self cursorReturn.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4421
            ^ self
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4422
        ].
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4423
        self isReadOnly ifTrue:[
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4424
            self unselect; makeCursorVisible.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4425
            self cursorReturn
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4426
        ] ifFalse:[
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4427
            self isInInsertMode ifFalse:[
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4428
                self cursorReturn.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4429
                autoIndent == true ifTrue:[
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4430
                    i := self leftIndentForLine:(cursorLine + 1).
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4431
                    self cursorCol:(i+1 max:1)
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4432
                ]
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4433
            ] ifTrue:[
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4434
                "/ old version just unselected ...
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4435
                "/ self unselect; makeCursorVisible.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4436
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4437
                "/ new version deletes ...
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4438
                typeOfSelection == #paste ifTrue:[
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4439
                    self unselect; makeCursorVisible.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4440
                ] ifFalse:[
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4441
                    self copyAndDeleteSelection.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4442
                ].
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4443
                self insertCharAtCursor:(Character cr).
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4444
                autoIndent == true ifTrue:[
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4445
                    i := self leftIndentForLine:cursorLine.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4446
                    self indentFromLine:cursorLine toLine:cursorLine.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4447
                    self cursorCol:(i+1 max:1)
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4448
                ].
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4449
            ].
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4450
        ].
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4451
        ^ self
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4452
    ].
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
  4453
2819
a7a41dfb9df7 BackTab / NonInsertingTab modifiers now defined in keyboard.rc
ca
parents: 2817
diff changeset
  4454
    (key == #NonInsertingTab) ifTrue:[
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4455
        self unselect. self cursorTab.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4456
        ^ self
2819
a7a41dfb9df7 BackTab / NonInsertingTab modifiers now defined in keyboard.rc
ca
parents: 2817
diff changeset
  4457
    ].
3422
a0c68e8bd56e tab with line selection means: indent/undent
Claus Gittinger <cg@exept.de>
parents: 3416
diff changeset
  4458
    ((key == #BackTab) or:[(key == #Tab)]) ifTrue:[
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4459
        self tabMeansNextField ifTrue:[^ super keyPress:key x:x y:y].
3422
a0c68e8bd56e tab with line selection means: indent/undent
Claus Gittinger <cg@exept.de>
parents: 3416
diff changeset
  4460
a0c68e8bd56e tab with line selection means: indent/undent
Claus Gittinger <cg@exept.de>
parents: 3416
diff changeset
  4461
        self hasSelection ifTrue:[
a0c68e8bd56e tab with line selection means: indent/undent
Claus Gittinger <cg@exept.de>
parents: 3416
diff changeset
  4462
            selectStyle == #line ifTrue:[
a0c68e8bd56e tab with line selection means: indent/undent
Claus Gittinger <cg@exept.de>
parents: 3416
diff changeset
  4463
                fKeyMacros := UserPreferences current functionKeySequences.
a0c68e8bd56e tab with line selection means: indent/undent
Claus Gittinger <cg@exept.de>
parents: 3416
diff changeset
  4464
                fKeyMacros notNil ifTrue:[
a0c68e8bd56e tab with line selection means: indent/undent
Claus Gittinger <cg@exept.de>
parents: 3416
diff changeset
  4465
                    ((key == #Tab) and:[shiftPressed not]) ifTrue:[
a0c68e8bd56e tab with line selection means: indent/undent
Claus Gittinger <cg@exept.de>
parents: 3416
diff changeset
  4466
                        cmdMacro := fKeyMacros at:#IndentBy4 ifAbsent:nil.
a0c68e8bd56e tab with line selection means: indent/undent
Claus Gittinger <cg@exept.de>
parents: 3416
diff changeset
  4467
                    ] ifFalse:[ 
a0c68e8bd56e tab with line selection means: indent/undent
Claus Gittinger <cg@exept.de>
parents: 3416
diff changeset
  4468
                        cmdMacro := fKeyMacros at:#UndentBy4 ifAbsent:nil.
a0c68e8bd56e tab with line selection means: indent/undent
Claus Gittinger <cg@exept.de>
parents: 3416
diff changeset
  4469
                    ].
a0c68e8bd56e tab with line selection means: indent/undent
Claus Gittinger <cg@exept.de>
parents: 3416
diff changeset
  4470
                    cmdMacro notNil ifTrue:[
a0c68e8bd56e tab with line selection means: indent/undent
Claus Gittinger <cg@exept.de>
parents: 3416
diff changeset
  4471
                        self
a0c68e8bd56e tab with line selection means: indent/undent
Claus Gittinger <cg@exept.de>
parents: 3416
diff changeset
  4472
                            undoableDo:
a0c68e8bd56e tab with line selection means: indent/undent
Claus Gittinger <cg@exept.de>
parents: 3416
diff changeset
  4473
                                [ self executeKeyboardMacro:cmdMacro ]
a0c68e8bd56e tab with line selection means: indent/undent
Claus Gittinger <cg@exept.de>
parents: 3416
diff changeset
  4474
                            info:'IndentBy4'.
a0c68e8bd56e tab with line selection means: indent/undent
Claus Gittinger <cg@exept.de>
parents: 3416
diff changeset
  4475
                        ^ self
a0c68e8bd56e tab with line selection means: indent/undent
Claus Gittinger <cg@exept.de>
parents: 3416
diff changeset
  4476
                    ].
a0c68e8bd56e tab with line selection means: indent/undent
Claus Gittinger <cg@exept.de>
parents: 3416
diff changeset
  4477
                ].
a0c68e8bd56e tab with line selection means: indent/undent
Claus Gittinger <cg@exept.de>
parents: 3416
diff changeset
  4478
            ]
a0c68e8bd56e tab with line selection means: indent/undent
Claus Gittinger <cg@exept.de>
parents: 3416
diff changeset
  4479
        ].
a0c68e8bd56e tab with line selection means: indent/undent
Claus Gittinger <cg@exept.de>
parents: 3416
diff changeset
  4480
a0c68e8bd56e tab with line selection means: indent/undent
Claus Gittinger <cg@exept.de>
parents: 3416
diff changeset
  4481
        self unselect. 
a0c68e8bd56e tab with line selection means: indent/undent
Claus Gittinger <cg@exept.de>
parents: 3416
diff changeset
  4482
        (key == #Tab) ifTrue:[
a0c68e8bd56e tab with line selection means: indent/undent
Claus Gittinger <cg@exept.de>
parents: 3416
diff changeset
  4483
            (shiftPressed or:[self isInInsertMode not]) ifTrue:[
a0c68e8bd56e tab with line selection means: indent/undent
Claus Gittinger <cg@exept.de>
parents: 3416
diff changeset
  4484
                self cursorTab.
a0c68e8bd56e tab with line selection means: indent/undent
Claus Gittinger <cg@exept.de>
parents: 3416
diff changeset
  4485
                ^ self
a0c68e8bd56e tab with line selection means: indent/undent
Claus Gittinger <cg@exept.de>
parents: 3416
diff changeset
  4486
            ].
a0c68e8bd56e tab with line selection means: indent/undent
Claus Gittinger <cg@exept.de>
parents: 3416
diff changeset
  4487
            self insertTabAtCursor.
3257
628e1e05814d shift-Tab fix.
Claus Gittinger <cg@exept.de>
parents: 3252
diff changeset
  4488
            ^ self
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4489
        ].
3422
a0c68e8bd56e tab with line selection means: indent/undent
Claus Gittinger <cg@exept.de>
parents: 3416
diff changeset
  4490
        self cursorBacktab.
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4491
        ^ self
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4492
    ].
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
  4493
2883
6cdb4a5a7b5e shift-delete - delete whiteSpace
Claus Gittinger <cg@exept.de>
parents: 2880
diff changeset
  4494
    "/ key == #DeleteSpaces ifTrue:[
6cdb4a5a7b5e shift-delete - delete whiteSpace
Claus Gittinger <cg@exept.de>
parents: 2880
diff changeset
  4495
    (key == #Delete) ifTrue:[
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4496
        shiftPressed ifTrue:[
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4497
            [(cursorCol <= (self listAt:cursorLine) size)
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4498
             and:[self characterUnderCursor isSeparator]] whileTrue:[
3324
1297aecf6699 delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents: 3313
diff changeset
  4499
             self makeCursorVisible.
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4500
                self deleteCharAtCursor.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4501
            ].
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4502
            ^ self
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4503
        ]
2883
6cdb4a5a7b5e shift-delete - delete whiteSpace
Claus Gittinger <cg@exept.de>
parents: 2880
diff changeset
  4504
    ].
6cdb4a5a7b5e shift-delete - delete whiteSpace
Claus Gittinger <cg@exept.de>
parents: 2880
diff changeset
  4505
870
c606f29db5d7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 865
diff changeset
  4506
    (key == #Delete
c606f29db5d7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 865
diff changeset
  4507
     or:[key == #BasicDelete]) ifTrue:[
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4508
        selectionStartLine notNil ifTrue:[
3324
1297aecf6699 delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents: 3313
diff changeset
  4509
            ((key == #BasicDelete) 
1297aecf6699 delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents: 3313
diff changeset
  4510
            or:[UserPreferences current deleteSetsClipboardText not]) ifTrue:[
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4511
                self deleteSelection.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4512
            ] ifFalse:[
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4513
                self copyAndDeleteSelection.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4514
            ].
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4515
            ^ self
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4516
        ].
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4517
        self makeCursorVisible.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4518
        self deleteCharAtCursor.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4519
        ^ self
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4520
    ].
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
  4521
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4522
    (key == #BeginOfText) ifTrue:[     "i.e. HOME"
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4523
        self unselect.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4524
        cursorVisibleLine == 1 ifTrue:[
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4525
            self cursorHome.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4526
        ] ifFalse:[
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4527
            self cursorToFirstVisibleLine
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4528
        ].
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4529
        ^ self
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4530
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4531
    (key == #EndOfText) ifTrue:[       "i.e. END"
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4532
        self unselect.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4533
        cursorVisibleLine == nFullLinesShown ifTrue:[
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4534
            self cursorToBottom.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4535
        ] ifFalse:[
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4536
            self cursorToLastVisibleLine
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4537
        ].
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4538
        ^ self
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4539
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4540
    ((key == #Escape)
3257
628e1e05814d shift-Tab fix.
Claus Gittinger <cg@exept.de>
parents: 3252
diff changeset
  4541
    or:[key == #SelectLineFromBeginning]) ifTrue:[
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4542
        self makeCursorVisible.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4543
        self unselect. self selectCursorLineFromBeginning.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4544
        ^ self
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4545
    ].
3257
628e1e05814d shift-Tab fix.
Claus Gittinger <cg@exept.de>
parents: 3252
diff changeset
  4546
    (key == #SelectLine) ifTrue:[
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4547
        self makeCursorVisible.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4548
        self unselect. self selectCursorLine.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4549
        ^ self
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4550
    ].
3257
628e1e05814d shift-Tab fix.
Claus Gittinger <cg@exept.de>
parents: 3252
diff changeset
  4551
    (key == #ExpandSelectionByLine) ifTrue:[
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4552
"/        self makeCursorVisible.
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4553
        self selectExpandCursorLine.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4554
        ^ self
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4555
    ].
3257
628e1e05814d shift-Tab fix.
Claus Gittinger <cg@exept.de>
parents: 3252
diff changeset
  4556
    (key == #DeleteLine) ifTrue:[
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4557
        self makeCursorVisible.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4558
        self unselect. self deleteCursorLine.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4559
        ^ self
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4560
    ].
3257
628e1e05814d shift-Tab fix.
Claus Gittinger <cg@exept.de>
parents: 3252
diff changeset
  4561
    (key == #InsertLine) ifTrue:[
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4562
        self makeCursorVisible.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4563
        self unselect. self insertLine:nil before:cursorLine.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4564
        ^ self
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4565
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4566
    super keyPress:key x:x y:y
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4567
3310
83368f9014a1 word check
Claus Gittinger <cg@exept.de>
parents: 3303
diff changeset
  4568
    "Modified: / 06-02-1998 / 11:59:59 / stefan"
3422
a0c68e8bd56e tab with line selection means: indent/undent
Claus Gittinger <cg@exept.de>
parents: 3416
diff changeset
  4569
    "Modified: / 28-10-2006 / 15:37:47 / cg"
121
claus
parents: 118
diff changeset
  4570
!
claus
parents: 118
diff changeset
  4571
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4572
executeKeyboardMacro:cmdMacro
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4573
    Error handle:[:ex |
3296
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
  4574
        self warn:'Error in keyboard macro: ' , ex description.
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
  4575
        ex return.
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4576
    ] do:[
3296
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
  4577
        AbortOperationRequest handle:[:ex |
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
  4578
            self warn:'Keyboard macro aborted'.
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
  4579
            ex return.
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
  4580
        ] do:[
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
  4581
            Parser
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
  4582
                evaluate:cmdMacro asString
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
  4583
                receiver:self
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
  4584
                notifying:nil
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
  4585
                compile:false.
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
  4586
        ].
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4587
    ].
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4588
!
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4589
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4590
handleNonCommandKey:keyArg
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4591
    |selStartLine selStartCol selEndLine selEndCol sel key|
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4592
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4593
    self isReadOnly ifTrue:[
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4594
        self flash.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4595
        ^ self.
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4596
    ].
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4597
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4598
    key := keyArg.
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4599
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4600
    typeOfSelection == #paste ifTrue:[
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4601
        "pasted selection will NOT be replaced by keystroke"
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4602
        self unselect
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4603
    ].
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4604
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4605
    selStartLine := selectionStartLine.
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4606
    selStartCol := self selectionStartCol.
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4607
    selEndLine := selectionEndLine.
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4608
    selEndCol := self selectionEndCol.
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4609
    sel := self selection.
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4610
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4611
    (characterEncoding ? #'iso10646-1') ~~ #'iso10646-1' ifTrue:[
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4612
        key := CharacterEncoder encode:key from:#'iso10646-1' into:characterEncoding.
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4613
    ].
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4614
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4615
    "replace selection by what is typed in -
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4616
     if word was selected with a space, keep it.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4617
     if there was no selection, the keys character is inserted"
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4618
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4619
    editMode value isInsertAndSelectMode ifTrue:[
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4620
        selectionStartLine := selectionStartCol := selectionEndLine := selectionEndCol := nil.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4621
    ].
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4622
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4623
    (selectStyle == #wordLeft) ifTrue:[
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4624
        self replaceSelectionBy:(' ' , key asString)
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4625
    ] ifFalse:[
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4626
        (selectStyle == #wordRight) ifTrue:[
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4627
            self replaceSelectionBy:(key asString , ' ').
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4628
            self cursorLeft
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4629
        ] ifFalse:[
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4630
            self replaceSelectionBy:key
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4631
        ]
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  4632
    ].
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4633
    selectStyle := nil.
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4634
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4635
    editMode value isInsertAndSelectMode ifTrue:[
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4636
        selectionStartLine := selStartLine.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4637
        selectionStartCol := selStartCol.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4638
        selectionEndLine := selEndLine.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4639
        selectionEndCol := selEndCol.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4640
    ].
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4641
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4642
    showMatchingParenthesis ifTrue:[
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4643
        "emacs style parenthesis shower"
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4644
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4645
        "claus: only do it for closing parenthesis -
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4646
                otherwise its too anoying.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4647
        "
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4648
"
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4649
        (#( $( $) $[ $] ${ $} ) includes:key) ifTrue:[
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4650
"
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4651
        (#( $) $] $} ) includes:key) ifTrue:[
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4652
        self
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4653
            searchForMatchingParenthesisFromLine:cursorLine col:(cursorCol - 1)
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4654
            ifFound:[:line :col |
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4655
                         |savLine savCol sensor|
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4656
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4657
                         self withCursor:Cursor eye do:[
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4658
                             savLine := cursorLine.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4659
                             savCol := cursorCol.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4660
                             self cursorLine:line col:col.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4661
                             device flush.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4662
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4663
                             "/ want to wait 200ms, but not if another keyPress
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4664
                             "/ arrives in the meantime ...
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4665
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4666
                             sensor := self sensor.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4667
                             5 timesRepeat:[
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4668
                                 (sensor hasKeyPressEventFor:self) ifFalse:[
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4669
                                     Processor activeProcess millisecondDelay:40.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4670
                                 ]
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4671
                             ].
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4672
                             self cursorLine:savLine col:savCol
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4673
                         ]
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4674
                    ]
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4675
            ifNotFound:[self showNotFound]
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4676
            onError:[self beep]
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4677
        ].
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4678
    ].
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4679
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4680
"/    true "autoExpandWhileTyping" ifTrue:[
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4681
"/        self wordAtLine:cursorLine col:cursorCol-1 do:[
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4682
"/            :beginLine :beginCol :endLine :endCol :style |
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4683
"/
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4684
"/            self selectFromLine:beginLine col:beginCol toLine:endLine col:endCol.
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4685
"/            self selection.
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4686
"/            typeOfSelection := #paste.
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  4687
"/        ].
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4688
"/    ].   
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4689
    editMode value isInsertAndSelectMode ifTrue:[
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4690
        selectionStartLine isNil ifTrue:[
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4691
            self selectFromLine:cursorLine col:cursorCol-1 toLine:cursorLine col:cursorCol-1.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4692
        ] ifFalse:[
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4693
            self selectFromLine:selectionStartLine col:selectionStartCol toLine:cursorLine col:cursorCol-1.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4694
        ].
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4695
    ].
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4696
!
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4697
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4698
keyPress:key x:x y:y
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4699
    "handle keyboard input"
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4700
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4701
    self undoableDo:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  4702
	self doKeyPress:key x:x y:y
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4703
    ].
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4704
!
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4705
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4706
mapped
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4707
    "view was made visible"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4708
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4709
    super mapped.
2422
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  4710
    self updateCursorVisibleLine.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4711
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4712
3268
d30df22739ca move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents: 3257
diff changeset
  4713
requestAutoAccept
d30df22739ca move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents: 3257
diff changeset
  4714
    "this is invoked when a dialog closes via accept or cancel.
d30df22739ca move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents: 3257
diff changeset
  4715
     This forces my value to be accepted into my model"
d30df22739ca move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents: 3257
diff changeset
  4716
d30df22739ca move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents: 3257
diff changeset
  4717
    acceptEnabled == false ifTrue:[
d30df22739ca move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents: 3257
diff changeset
  4718
        "/ nope -
d30df22739ca move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents: 3257
diff changeset
  4719
        ^ false
d30df22739ca move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents: 3257
diff changeset
  4720
    ].
d30df22739ca move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents: 3257
diff changeset
  4721
    self accept.
d30df22739ca move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents: 3257
diff changeset
  4722
    ^ true.
d30df22739ca move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents: 3257
diff changeset
  4723
!
d30df22739ca move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents: 3257
diff changeset
  4724
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4725
sizeChanged:how
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4726
    "make certain, cursor is visible after the sizechange"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4727
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4728
    |cv|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4729
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4730
    cv := cursorVisibleLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4731
    super sizeChanged:how.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4732
    cv notNil ifTrue:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  4733
	self makeLineVisible:cursorLine
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4734
    ]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4735
! !
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4736
1807
30526cb1acfc category and comment
Claus Gittinger <cg@exept.de>
parents: 1804
diff changeset
  4737
!EditTextView methodsFor:'focus handling'!
30526cb1acfc category and comment
Claus Gittinger <cg@exept.de>
parents: 1804
diff changeset
  4738
30526cb1acfc category and comment
Claus Gittinger <cg@exept.de>
parents: 1804
diff changeset
  4739
hasKeyboardFocus:aBoolean
30526cb1acfc category and comment
Claus Gittinger <cg@exept.de>
parents: 1804
diff changeset
  4740
    "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
  4741
     (otherwise, I would not know about this)"
30526cb1acfc category and comment
Claus Gittinger <cg@exept.de>
parents: 1804
diff changeset
  4742
30526cb1acfc category and comment
Claus Gittinger <cg@exept.de>
parents: 1804
diff changeset
  4743
    hasKeyboardFocus := aBoolean.
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  4744
    (cursorShown
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  4745
    and:[self enabled
3296
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
  4746
    and:[self isReadOnly not]]) ifTrue:[
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
  4747
        self drawCursor
1816
0b9380a0cc7e only take keyboardFocus (and show cursor)
Claus Gittinger <cg@exept.de>
parents: 1811
diff changeset
  4748
    ].
0b9380a0cc7e only take keyboardFocus (and show cursor)
Claus Gittinger <cg@exept.de>
parents: 1811
diff changeset
  4749
0b9380a0cc7e only take keyboardFocus (and show cursor)
Claus Gittinger <cg@exept.de>
parents: 1811
diff changeset
  4750
    "Modified: / 23.3.1999 / 13:49:35 / cg"
1807
30526cb1acfc category and comment
Claus Gittinger <cg@exept.de>
parents: 1804
diff changeset
  4751
!
30526cb1acfc category and comment
Claus Gittinger <cg@exept.de>
parents: 1804
diff changeset
  4752
30526cb1acfc category and comment
Claus Gittinger <cg@exept.de>
parents: 1804
diff changeset
  4753
showFocus:explicit
30526cb1acfc category and comment
Claus Gittinger <cg@exept.de>
parents: 1804
diff changeset
  4754
    "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
  4755
     displayed, show the cursor when I got the focus"
30526cb1acfc category and comment
Claus Gittinger <cg@exept.de>
parents: 1804
diff changeset
  4756
30526cb1acfc category and comment
Claus Gittinger <cg@exept.de>
parents: 1804
diff changeset
  4757
    self showCursor.
30526cb1acfc category and comment
Claus Gittinger <cg@exept.de>
parents: 1804
diff changeset
  4758
    self hasKeyboardFocus:true.
30526cb1acfc category and comment
Claus Gittinger <cg@exept.de>
parents: 1804
diff changeset
  4759
    super showFocus:explicit
30526cb1acfc category and comment
Claus Gittinger <cg@exept.de>
parents: 1804
diff changeset
  4760
30526cb1acfc category and comment
Claus Gittinger <cg@exept.de>
parents: 1804
diff changeset
  4761
    "Modified: 11.12.1996 / 16:56:54 / cg"
1918
3ac07b97b4f7 use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents: 1902
diff changeset
  4762
!
3ac07b97b4f7 use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents: 1902
diff changeset
  4763
3ac07b97b4f7 use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents: 1902
diff changeset
  4764
wantsFocusWithPointerEnter
3ac07b97b4f7 use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents: 1902
diff changeset
  4765
    "return true, if I want the focus when
3ac07b97b4f7 use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents: 1902
diff changeset
  4766
     the mouse pointer enters"
3ac07b97b4f7 use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents: 1902
diff changeset
  4767
3296
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
  4768
    (UserPreferences current focusFollowsMouse ~~ false
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
  4769
     and:[(styleSheet at:#'editText.requestFocusOnPointerEnter' default:true)
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
  4770
     and:[self enabled
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
  4771
     and:[self isReadOnly not]]]) ifTrue:[
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
  4772
        ^ true
1918
3ac07b97b4f7 use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents: 1902
diff changeset
  4773
    ].
3ac07b97b4f7 use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents: 1902
diff changeset
  4774
3ac07b97b4f7 use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents: 1902
diff changeset
  4775
    ^ false
1807
30526cb1acfc category and comment
Claus Gittinger <cg@exept.de>
parents: 1804
diff changeset
  4776
! !
30526cb1acfc category and comment
Claus Gittinger <cg@exept.de>
parents: 1804
diff changeset
  4777
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4778
!EditTextView methodsFor:'formatting'!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4779
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4780
indent
3221
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  4781
    "indent a line-range - this is done by searching for the
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  4782
     last non-empty line before the selection, and changing the indent
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  4783
     of the selected line-range based on that lines indent."
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4784
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4785
    |start end|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4786
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4787
    selectionStartLine isNil ifTrue:[^ self].
3221
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  4788
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4789
    start := selectionStartLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4790
    end := selectionEndLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4791
    (selectionEndCol == 0) ifTrue:[
3221
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  4792
        end := end - 1
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4793
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4794
    self unselect.
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  4795
    self
3221
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  4796
        undoableDo:[
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  4797
            self indentFromLine:start toLine:end
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  4798
        ]
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  4799
        info:'indent'
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4800
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4801
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4802
indentFromLine:start toLine:end
3221
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  4803
    "indent a line-range - this is done by searching for the
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4804
     last non-empty line before start, and change the indent
3221
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  4805
     of the selected line-range based on that lines indent."
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4806
474
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  4807
    |leftStart delta d line spaces|
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  4808
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  4809
    leftStart := self leftIndentForLine:start.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4810
    (leftStart == 0) ifTrue:[^ self].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4811
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4812
    delta := leftStart - (self leftIndentOfLine:start).
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4813
    (delta == 0) ifTrue:[^ self].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4814
    (delta > 0) ifTrue:[
3221
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  4815
        spaces := String new:delta
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4816
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4817
    start to:end do:[:lineNr |
3221
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  4818
        line := self listAt:lineNr.
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  4819
        line notNil ifTrue:[
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  4820
            line isBlank ifTrue:[
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  4821
                list at:lineNr put:nil
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  4822
            ] ifFalse:[
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  4823
                (delta > 0) ifTrue:[
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  4824
                    line := spaces , line.
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  4825
                    widthOfWidestLine notNil ifTrue:[
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  4826
                        widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:line).
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  4827
                    ]
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  4828
                ] ifFalse:[
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  4829
                    "check if deletion is ok"
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  4830
                    d := delta negated + 1.
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  4831
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  4832
                    line size > d ifTrue:[
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  4833
                        (line copyTo:(d - 1)) withoutSeparators isEmpty ifTrue:[
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  4834
                            line := line copyFrom:d
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  4835
                        ]
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  4836
                    ].
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  4837
                    widthOfWidestLine := nil
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  4838
                ].
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  4839
                self replaceLine:lineNr with:line.
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  4840
                self textChanged.
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  4841
            ]
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  4842
        ]
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  4843
    ].
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  4844
    "/ self redrawFromLine:start to:end
474
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  4845
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  4846
    "Modified: 5.3.1996 / 14:59:18 / cg"
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  4847
!
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  4848
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  4849
leftIndentForLine:lineNr
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  4850
    "find an appropriate indent for a line.
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  4851
     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
  4852
     and returning its indent."
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  4853
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  4854
    "SHOULD GO TO ListView"
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  4855
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  4856
    |line lnr indent|
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  4857
474
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  4858
    lnr := lineNr.
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  4859
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  4860
    [lnr ~~ 1] whileTrue:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  4861
	lnr  := lnr - 1.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  4862
	line := self listAt:lnr.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  4863
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  4864
	line notNil ifTrue:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  4865
	    indent := line indexOfNonSeparatorStartingAt:1.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  4866
	    indent ~~ 0 ifTrue:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  4867
		^ indent - 1
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  4868
	    ]
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  4869
	]
474
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  4870
    ].
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  4871
    ^ 0
474
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  4872
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  4873
    "Created: 5.3.1996 / 14:58:53 / cg"
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  4874
! !
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  4875
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  4876
!EditTextView methodsFor:'initialization'!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  4877
941
f06fa4d47f26 fetch device resources early
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  4878
fetchDeviceResources
f06fa4d47f26 fetch device resources early
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  4879
    "fetch device colors, to avoid reallocation at redraw time"
f06fa4d47f26 fetch device resources early
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  4880
f06fa4d47f26 fetch device resources early
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  4881
    super fetchDeviceResources.
f06fa4d47f26 fetch device resources early
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  4882
1993
5ffe0b3943cd #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1967
diff changeset
  4883
    cursorFgColor notNil ifTrue:[cursorFgColor := cursorFgColor onDevice:device].
5ffe0b3943cd #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1967
diff changeset
  4884
    cursorBgColor notNil ifTrue:[cursorBgColor := cursorBgColor onDevice:device].
5ffe0b3943cd #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1967
diff changeset
  4885
    cursorNoFocusFgColor notNil ifTrue:[cursorNoFocusFgColor := cursorNoFocusFgColor onDevice:device].
941
f06fa4d47f26 fetch device resources early
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  4886
f06fa4d47f26 fetch device resources early
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  4887
    "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
  4888
    "Modified: 18.2.1997 / 15:02:46 / cg"
941
f06fa4d47f26 fetch device resources early
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  4889
!
f06fa4d47f26 fetch device resources early
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  4890
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4891
initEvents
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4892
    "enable enter/leave events in addition"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4893
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4894
    super initEvents.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4895
    self enableEnterLeaveEvents
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4896
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4897
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4898
initStyle
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4899
    "initialize style specific stuff"
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
    super initStyle.
2088
b2beb67b1a98 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2085
diff changeset
  4902
    lineSpacing := 1.       "/ for underwave - also looks better
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4903
    lockUpdates := false.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4904
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4905
    cursorFgColor := DefaultCursorForegroundColor.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4906
    cursorFgColor isNil ifTrue:[cursorFgColor := bgColor].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4907
    cursorBgColor := DefaultCursorBackgroundColor.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4908
    cursorBgColor isNil ifTrue:[cursorBgColor := fgColor].
1334
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  4909
    cursorType := cursorTypeNoFocus := DefaultCursorType.
1534
bcb211e1b41a read noFocus cursorStyle from styleSheet
Claus Gittinger <cg@exept.de>
parents: 1533
diff changeset
  4910
    DefaultCursorTypeNoFocus notNil ifTrue:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  4911
	cursorTypeNoFocus := DefaultCursorTypeNoFocus.
1534
bcb211e1b41a read noFocus cursorStyle from styleSheet
Claus Gittinger <cg@exept.de>
parents: 1533
diff changeset
  4912
    ].
1022
4362861fe15e allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents: 1018
diff changeset
  4913
    cursorNoFocusFgColor := DefaultCursorNoFocusForegroundColor.
4362861fe15e allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents: 1018
diff changeset
  4914
    cursorNoFocusFgColor isNil ifTrue:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  4915
	cursorType ~~ #block ifTrue:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  4916
	    cursorNoFocusFgColor := cursorBgColor
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  4917
	] ifFalse:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  4918
	    cursorNoFocusFgColor := cursorFgColor
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  4919
	]
1022
4362861fe15e allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents: 1018
diff changeset
  4920
    ].
4362861fe15e allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents: 1018
diff changeset
  4921
2088
b2beb67b1a98 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2085
diff changeset
  4922
    "Modified: / 15.12.1999 / 22:27:45 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4923
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4924
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4925
initialize
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4926
    "initialize a new EditTextView;
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4927
     setup some instance variables"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4928
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4929
    super initialize.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4930
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4931
    self level:-1.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4932
    readOnly := false.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4933
    fixedSize := false.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4934
    exceptionBlock := [:errorText | ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4935
    cursorShown := prevCursorState := true.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4936
    cursorLine := 1.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4937
    cursorVisibleLine := 1.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4938
    cursorCol := 1.
2815
d71f43d7de3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2796
diff changeset
  4939
    cursorLineHolder := 1 asValue.
d71f43d7de3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2796
diff changeset
  4940
    cursorColHolder := 1 asValue.
2119
2aa585fc62a3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2117
diff changeset
  4941
    modifiedChannel := ValueHolder with:false.
2aa585fc62a3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2117
diff changeset
  4942
    acceptChannel := ValueHolder with:false.
1437
ab84b08a9f9c allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
  4943
    acceptChannel addDependent:self.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4944
    showMatchingParenthesis := false.
3296
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
  4945
    hasKeyboardFocus := false.
323
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
  4946
    tabMeansNextField := false.
474
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  4947
    autoIndent := false.
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4948
    editMode := EditMode insertMode asValue.
2795
1f7b5f242eee learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents: 2792
diff changeset
  4949
    learnMode := false asValue.
3296
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
  4950
    trimBlankLines := self st80EditMode not. 
2131
858209ba8509 cursor movement default
Claus Gittinger <cg@exept.de>
parents: 2129
diff changeset
  4951
    cursorMovementWhenUpdating := #beginOfText.
1596
0bbdb4e9fc43 made st80Mode also an inst-flag;
Claus Gittinger <cg@exept.de>
parents: 1591
diff changeset
  4952
3236
aeb1fe5a6ead drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3235
diff changeset
  4953
    "/ enable drop by default 
2589
62794ae04446 support drop
ca
parents: 2580
diff changeset
  4954
    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
  4955
5dcc2912bcb6 undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents: 2984
diff changeset
  4956
    undoSupport := UndoSupport for:self.
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  4957
! !
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  4958
2580
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  4959
!EditTextView methodsFor:'macros'!
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  4960
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  4961
executeLearnedKeyboardMacro
2795
1f7b5f242eee learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents: 2792
diff changeset
  4962
    (self learnMode not and:[learnedMacro size > 0]) ifTrue:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  4963
	learnedMacro do:[:event |
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  4964
			    WindowGroup lastEventQuerySignal answer:event
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  4965
			    do:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  4966
				self
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  4967
				    dispatchEvent:event
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  4968
				    withFocusOn:nil
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  4969
				    delegate:false
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  4970
			    ]
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  4971
			].
2580
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  4972
    ] ifFalse:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  4973
	self flash.
2580
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  4974
    ].
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  4975
!
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  4976
2795
1f7b5f242eee learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents: 2792
diff changeset
  4977
learnMode
1f7b5f242eee learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents: 2792
diff changeset
  4978
    ^ (learnMode value ? false).
1f7b5f242eee learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents: 2792
diff changeset
  4979
!
1f7b5f242eee learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents: 2792
diff changeset
  4980
2580
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  4981
learnMode:aBoolean
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  4982
    |fg bg|
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  4983
2795
1f7b5f242eee learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents: 2792
diff changeset
  4984
    self learnModeHolder value:aBoolean.
1f7b5f242eee learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents: 2792
diff changeset
  4985
1f7b5f242eee learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents: 2792
diff changeset
  4986
    aBoolean ifTrue:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  4987
	learnedMacro := OrderedCollection new.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  4988
	fg := Color white.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  4989
	bg := Color black.
2580
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  4990
    ] ifFalse:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  4991
	cursorFgColor := fg := DefaultCursorForegroundColor ? bgColor.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  4992
	cursorBgColor := bg := DefaultCursorBackgroundColor ? fgColor.
2580
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  4993
    ].
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  4994
    self cursorForegroundColor:fg backgroundColor:bg.
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  4995
!
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  4996
2795
1f7b5f242eee learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents: 2792
diff changeset
  4997
learnModeHolder
1f7b5f242eee learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents: 2792
diff changeset
  4998
    learnMode isNil ifTrue:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  4999
	learnMode := false asValue
2795
1f7b5f242eee learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents: 2792
diff changeset
  5000
    ].
1f7b5f242eee learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents: 2792
diff changeset
  5001
    ^ learnMode
1f7b5f242eee learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents: 2792
diff changeset
  5002
!
1f7b5f242eee learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents: 2792
diff changeset
  5003
2580
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  5004
toggleLearnMode
2795
1f7b5f242eee learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents: 2792
diff changeset
  5005
    self learnMode: self learnMode not.
2580
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  5006
! !
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  5007
121
claus
parents: 118
diff changeset
  5008
!EditTextView methodsFor:'menu actions'!
claus
parents: 118
diff changeset
  5009
2680
208d99c47d7c babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents: 2677
diff changeset
  5010
babelFishTranslate:fromToModeString
208d99c47d7c babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents: 2677
diff changeset
  5011
    "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
  5012
208d99c47d7c babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents: 2677
diff changeset
  5013
    |original translated|
208d99c47d7c babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents: 2677
diff changeset
  5014
208d99c47d7c babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents: 2677
diff changeset
  5015
    original := self selectionAsString.
208d99c47d7c babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents: 2677
diff changeset
  5016
    original size == 0 ifTrue:[^ self].
208d99c47d7c babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents: 2677
diff changeset
  5017
208d99c47d7c babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents: 2677
diff changeset
  5018
    self withWaitCursorDo:[
3495
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  5019
        SOAP::SoapImplError handle:[:ex |
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  5020
            Dialog warn:('Translation failed - WEB Service error:\\%1.' bindWith:ex description allBold) withCRs
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  5021
        ] do:[
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  5022
            translated := SOAP::BabelFishClient new translate:original mode:fromToModeString.
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  5023
        ]
2680
208d99c47d7c babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents: 2677
diff changeset
  5024
    ].
208d99c47d7c babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents: 2677
diff changeset
  5025
208d99c47d7c babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents: 2677
diff changeset
  5026
    "/ v pasteOrReplace:translated
208d99c47d7c babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents: 2677
diff changeset
  5027
    self cursorLine:(self selectionEndLine) col:(self selectionEndCol + 1).
208d99c47d7c babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents: 2677
diff changeset
  5028
    self unselect.
3495
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  5029
    self undoablePaste:translated info:'translate'
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  5030
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  5031
    "Modified: / 28-07-2007 / 13:27:21 / cg"
2680
208d99c47d7c babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents: 2677
diff changeset
  5032
!
208d99c47d7c babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents: 2677
diff changeset
  5033
3517
0a2f117c2fb8 +compare menu item
Claus Gittinger <cg@exept.de>
parents: 3514
diff changeset
  5034
compareWithClipboard
0a2f117c2fb8 +compare menu item
Claus Gittinger <cg@exept.de>
parents: 3514
diff changeset
  5035
    "compare the selection against the clipboard contents"
0a2f117c2fb8 +compare menu item
Claus Gittinger <cg@exept.de>
parents: 3514
diff changeset
  5036
0a2f117c2fb8 +compare menu item
Claus Gittinger <cg@exept.de>
parents: 3514
diff changeset
  5037
    |t1 t2|
0a2f117c2fb8 +compare menu item
Claus Gittinger <cg@exept.de>
parents: 3514
diff changeset
  5038
0a2f117c2fb8 +compare menu item
Claus Gittinger <cg@exept.de>
parents: 3514
diff changeset
  5039
    t2 := self getClipboardText.
0a2f117c2fb8 +compare menu item
Claus Gittinger <cg@exept.de>
parents: 3514
diff changeset
  5040
    t2 isEmptyOrNil ifTrue:[    
0a2f117c2fb8 +compare menu item
Claus Gittinger <cg@exept.de>
parents: 3514
diff changeset
  5041
        Dialog information:'Clipboard is empty.'.
0a2f117c2fb8 +compare menu item
Claus Gittinger <cg@exept.de>
parents: 3514
diff changeset
  5042
        ^ self.
0a2f117c2fb8 +compare menu item
Claus Gittinger <cg@exept.de>
parents: 3514
diff changeset
  5043
    ].
0a2f117c2fb8 +compare menu item
Claus Gittinger <cg@exept.de>
parents: 3514
diff changeset
  5044
0a2f117c2fb8 +compare menu item
Claus Gittinger <cg@exept.de>
parents: 3514
diff changeset
  5045
    self hasSelection ifTrue:[
0a2f117c2fb8 +compare menu item
Claus Gittinger <cg@exept.de>
parents: 3514
diff changeset
  5046
        t1 := self selectionAsString.
0a2f117c2fb8 +compare menu item
Claus Gittinger <cg@exept.de>
parents: 3514
diff changeset
  5047
    ] ifFalse:[
0a2f117c2fb8 +compare menu item
Claus Gittinger <cg@exept.de>
parents: 3514
diff changeset
  5048
        t1 := self contents asString
0a2f117c2fb8 +compare menu item
Claus Gittinger <cg@exept.de>
parents: 3514
diff changeset
  5049
    ].
0a2f117c2fb8 +compare menu item
Claus Gittinger <cg@exept.de>
parents: 3514
diff changeset
  5050
    t1 := t1 string.
0a2f117c2fb8 +compare menu item
Claus Gittinger <cg@exept.de>
parents: 3514
diff changeset
  5051
0a2f117c2fb8 +compare menu item
Claus Gittinger <cg@exept.de>
parents: 3514
diff changeset
  5052
    t1 = t2 ifTrue:[
0a2f117c2fb8 +compare menu item
Claus Gittinger <cg@exept.de>
parents: 3514
diff changeset
  5053
        Dialog information:'Strings are equal.'.
0a2f117c2fb8 +compare menu item
Claus Gittinger <cg@exept.de>
parents: 3514
diff changeset
  5054
        ^ self.
0a2f117c2fb8 +compare menu item
Claus Gittinger <cg@exept.de>
parents: 3514
diff changeset
  5055
    ].
0a2f117c2fb8 +compare menu item
Claus Gittinger <cg@exept.de>
parents: 3514
diff changeset
  5056
    DiffTextView
0a2f117c2fb8 +compare menu item
Claus Gittinger <cg@exept.de>
parents: 3514
diff changeset
  5057
        openOn:t1 label:'Editor' 
0a2f117c2fb8 +compare menu item
Claus Gittinger <cg@exept.de>
parents: 3514
diff changeset
  5058
        and:t2 label:'Clipboard' 
0a2f117c2fb8 +compare menu item
Claus Gittinger <cg@exept.de>
parents: 3514
diff changeset
  5059
!
0a2f117c2fb8 +compare menu item
Claus Gittinger <cg@exept.de>
parents: 3514
diff changeset
  5060
121
claus
parents: 118
diff changeset
  5061
cut
claus
parents: 118
diff changeset
  5062
    "cut selection into copybuffer"
claus
parents: 118
diff changeset
  5063
3324
1297aecf6699 delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents: 3313
diff changeset
  5064
    self deleteCopyToClipboard:true
121
claus
parents: 118
diff changeset
  5065
!
claus
parents: 118
diff changeset
  5066
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5067
defaultForGotoLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5068
    "return a default value to show in the gotoLine box"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5069
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5070
    cursorLine notNil ifTrue:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  5071
	^ cursorLine
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5072
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5073
    ^ super defaultForGotoLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5074
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5075
3324
1297aecf6699 delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents: 3313
diff changeset
  5076
deleteCopyToClipboard:toClipboard
1297aecf6699 delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents: 3313
diff changeset
  5077
    "cut selection into copybuffer"
1297aecf6699 delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents: 3313
diff changeset
  5078
1297aecf6699 delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents: 3313
diff changeset
  5079
    |line col history sel s|
1297aecf6699 delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents: 3313
diff changeset
  5080
1297aecf6699 delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents: 3313
diff changeset
  5081
    (self checkModificationsAllowed) ifFalse:[
1297aecf6699 delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents: 3313
diff changeset
  5082
        self flash.
1297aecf6699 delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents: 3313
diff changeset
  5083
        ^ self
1297aecf6699 delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents: 3313
diff changeset
  5084
    ].
1297aecf6699 delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents: 3313
diff changeset
  5085
1297aecf6699 delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents: 3313
diff changeset
  5086
    sel := self selection.
1297aecf6699 delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents: 3313
diff changeset
  5087
    sel notNil ifTrue:[
1297aecf6699 delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents: 3313
diff changeset
  5088
        lastString := s := sel asStringWithCRs.
1297aecf6699 delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents: 3313
diff changeset
  5089
        line := selectionStartLine.
1297aecf6699 delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents: 3313
diff changeset
  5090
        col := selectionStartCol.
1297aecf6699 delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents: 3313
diff changeset
  5091
1297aecf6699 delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents: 3313
diff changeset
  5092
        toClipboard ifTrue:[
1297aecf6699 delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents: 3313
diff changeset
  5093
            "
1297aecf6699 delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents: 3313
diff changeset
  5094
             remember in CopyBuffer
1297aecf6699 delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents: 3313
diff changeset
  5095
            "
1297aecf6699 delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents: 3313
diff changeset
  5096
            self setClipboardText:sel. "/ lastString.
1297aecf6699 delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents: 3313
diff changeset
  5097
        ].
1297aecf6699 delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents: 3313
diff changeset
  5098
1297aecf6699 delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents: 3313
diff changeset
  5099
        "
1297aecf6699 delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents: 3313
diff changeset
  5100
         append to DeleteHistory (if there is one)
1297aecf6699 delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents: 3313
diff changeset
  5101
        "
1297aecf6699 delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents: 3313
diff changeset
  5102
        history := Smalltalk at:#DeleteHistory.
1297aecf6699 delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents: 3313
diff changeset
  5103
        history notNil ifTrue:[
1297aecf6699 delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents: 3313
diff changeset
  5104
            history addAll:(sel asStringCollection).
1297aecf6699 delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents: 3313
diff changeset
  5105
            history size > 1000 ifTrue:[
1297aecf6699 delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents: 3313
diff changeset
  5106
                history := history copyFrom:(history size - 1000)
1297aecf6699 delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents: 3313
diff changeset
  5107
            ].
1297aecf6699 delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents: 3313
diff changeset
  5108
        ].
1297aecf6699 delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents: 3313
diff changeset
  5109
1297aecf6699 delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents: 3313
diff changeset
  5110
        "
1297aecf6699 delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents: 3313
diff changeset
  5111
         now, delete it
1297aecf6699 delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents: 3313
diff changeset
  5112
        "
1297aecf6699 delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents: 3313
diff changeset
  5113
        self undoableDo:[
1297aecf6699 delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents: 3313
diff changeset
  5114
            self deleteSelection.
3542
30ed44ed0178 +joinLines (CTRL-j);
Claus Gittinger <cg@exept.de>
parents: 3517
diff changeset
  5115
        ] info:'Delete'.
3324
1297aecf6699 delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents: 3313
diff changeset
  5116
        lastReplacement := nil
1297aecf6699 delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents: 3313
diff changeset
  5117
    ] ifFalse:[
1297aecf6699 delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents: 3313
diff changeset
  5118
        "
1297aecf6699 delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents: 3313
diff changeset
  5119
         a cut without selection will search&cut again
1297aecf6699 delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents: 3313
diff changeset
  5120
        "
1297aecf6699 delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents: 3313
diff changeset
  5121
        self undoableDo:[
1297aecf6699 delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents: 3313
diff changeset
  5122
            self again
1297aecf6699 delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents: 3313
diff changeset
  5123
        ]
1297aecf6699 delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents: 3313
diff changeset
  5124
    ]
1297aecf6699 delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents: 3313
diff changeset
  5125
1297aecf6699 delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents: 3313
diff changeset
  5126
    "Modified: / 5.4.1998 / 16:51:53 / cg"
1297aecf6699 delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents: 3313
diff changeset
  5127
!
1297aecf6699 delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents: 3313
diff changeset
  5128
428
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  5129
editMenu
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  5130
    "return the views middleButtonMenu"
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  5131
488
d10fe3a5f0cf resources
Claus Gittinger <cg@exept.de>
parents: 479
diff changeset
  5132
    <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
  5133
    <resource: #programMenu>
1054
d699ecd13e60 menu resource
Claus Gittinger <cg@exept.de>
parents: 1049
diff changeset
  5134
3495
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  5135
    |items m sub translateItems sortItems miscItems toolItems subSub toolSub 
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  5136
     transSub sortSub what undoIdx sensor main mainItems|
1515
9e9b65bd6efb care for nil sensor
Claus Gittinger <cg@exept.de>
parents: 1495
diff changeset
  5137
2460
Claus Gittinger <cg@exept.de>
parents: 2438
diff changeset
  5138
    items := #(
3221
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  5139
                    ('Redo'             redo                    )
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  5140
                    ('Again (for All)'  multipleAgain           )
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  5141
                    ('-'                                        )
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  5142
                    ('Search...'        search         Find     )
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  5143
                    ('Goto Line...'     gotoLine       GotoLine )
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  5144
                    ('-'                                        )
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  5145
                    ('Tools'            tools                   )
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  5146
                    ('-'                                        )
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  5147
                    ('Save As...'       save           SaveAs   )
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  5148
                    ('Print'            doPrint        Print    )
3474
357e16440725 slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents: 3473
diff changeset
  5149
                    ('='                                        )
3495
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  5150
                    ('Misc'             misc           ShiftCtrl)
3221
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  5151
              ).
2460
Claus Gittinger <cg@exept.de>
parents: 2438
diff changeset
  5152
2866
9dd71df46f73 specialCharacters menu item
Claus Gittinger <cg@exept.de>
parents: 2857
diff changeset
  5153
    miscItems := #(
3221
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  5154
                    ('AutoIndent \c'    autoIndent:             )
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  5155
                    ('InsertMode \c'    insertMode:             )
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  5156
                    ('-'                                        )
3474
357e16440725 slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents: 3473
diff changeset
  5157
                    ('Paste Previous \c' pasteOrReplaceFromHistory CmdV )
357e16440725 slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents: 3473
diff changeset
  5158
                    ('-'                                        )
3221
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  5159
                    ('Learn Macro \c'     learnMode:                  LearnKeyboardMacro)
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  5160
                    ('Execute Macro'    executeLearnedKeyboardMacro ExecuteKeyboardMacro )
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  5161
                    ('-'                                        )
3474
357e16440725 slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents: 3473
diff changeset
  5162
                    ('Insert File...'              insertFile                 )
3495
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  5163
                    ('Insert new UUID'             insertUUID                 )
3474
357e16440725 slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents: 3473
diff changeset
  5164
                    ('-'                                        )
3406
c5efa51e7929 dont offer CharacterSetView display in menu, if its not available.
Claus Gittinger <cg@exept.de>
parents: 3402
diff changeset
  5165
                ).
c5efa51e7929 dont offer CharacterSetView display in menu, if its not available.
Claus Gittinger <cg@exept.de>
parents: 3402
diff changeset
  5166
    CharacterSetView notNil ifTrue:[
c5efa51e7929 dont offer CharacterSetView display in menu, if its not available.
Claus Gittinger <cg@exept.de>
parents: 3402
diff changeset
  5167
        miscItems := miscItems ,
c5efa51e7929 dont offer CharacterSetView display in menu, if its not available.
Claus Gittinger <cg@exept.de>
parents: 3402
diff changeset
  5168
                    #(
c5efa51e7929 dont offer CharacterSetView display in menu, if its not available.
Claus Gittinger <cg@exept.de>
parents: 3402
diff changeset
  5169
                        ('Special Characters...'    specialCharacters       )
c5efa51e7929 dont offer CharacterSetView display in menu, if its not available.
Claus Gittinger <cg@exept.de>
parents: 3402
diff changeset
  5170
                    ).
c5efa51e7929 dont offer CharacterSetView display in menu, if its not available.
Claus Gittinger <cg@exept.de>
parents: 3402
diff changeset
  5171
    ].
c5efa51e7929 dont offer CharacterSetView display in menu, if its not available.
Claus Gittinger <cg@exept.de>
parents: 3402
diff changeset
  5172
    miscItems := miscItems ,
c5efa51e7929 dont offer CharacterSetView display in menu, if its not available.
Claus Gittinger <cg@exept.de>
parents: 3402
diff changeset
  5173
                #(
3223
8cb04c4decd2 sort functions
Claus Gittinger <cg@exept.de>
parents: 3222
diff changeset
  5174
                    ('Font...'                  changeFont              )
2870
994a3a44c526 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2869
diff changeset
  5175
"/                    ('Encoding...'      changeEncoding          )
3406
c5efa51e7929 dont offer CharacterSetView display in menu, if its not available.
Claus Gittinger <cg@exept.de>
parents: 3402
diff changeset
  5176
                ).
2866
9dd71df46f73 specialCharacters menu item
Claus Gittinger <cg@exept.de>
parents: 2857
diff changeset
  5177
2680
208d99c47d7c babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents: 2677
diff changeset
  5178
    translateItems := #(
3221
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  5179
                    ('English -> German'      (babelFishTranslate: 'en_de')   )
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  5180
                    ('English -> French'      (babelFishTranslate: 'en_fr')   )
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  5181
                    ('English -> Italian'     (babelFishTranslate: 'en_it')   )
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  5182
                    ('English -> Spanish'     (babelFishTranslate: 'en_es')   )
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  5183
                    ('English -> Portuguese'  (babelFishTranslate: 'en_pt')   )
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  5184
                    ('-'                                        )
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  5185
                    ('German -> English'      (babelFishTranslate: 'de_en')   )
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  5186
                    ('French -> English'      (babelFishTranslate: 'fr_en')   )
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  5187
                    ('Italian -> English'     (babelFishTranslate: 'it_en')   )
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  5188
                    ('Spanish -> English'     (babelFishTranslate: 'es_en')   )
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  5189
                    ('Portuguese -> English'  (babelFishTranslate: 'pt_en')   )
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  5190
              ).
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  5191
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  5192
    sortItems := #(
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  5193
                    ('Lines'                            (sortSelection:ignoreCase: #lines false)        )
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  5194
                    ('Lines by First Word'              (sortSelection:ignoreCase: #linesByFirstWord false)     )
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  5195
                    ('Lines by nth Word'                (sortSelection:ignoreCase: #linesByNthWord false)       )
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  5196
                    ('Words'                            (sortSelection:ignoreCase: #words false)        )
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  5197
                    ('-'                                                      )
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  5198
                    ('Lines (ignore case)'              (sortSelection:ignoreCase: #lines true)         )
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  5199
                    ('Lines by First Word (ignore case)'(sortSelection:ignoreCase: #linesByFirstWord true)      )
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  5200
                    ('Lines by nth Word (ignore case)'  (sortSelection:ignoreCase: #linesByNthWord true)        )
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  5201
                    ('Words (ignore case)'              (sortSelection:ignoreCase: #words true)         )
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  5202
              ).
2680
208d99c47d7c babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents: 2677
diff changeset
  5203
2762
e29673db4ddb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2757
diff changeset
  5204
    toolItems := #(
3221
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  5205
                    ('Indent'                      indent                     )
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  5206
                    ('Sort'                        sort                       )
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  5207
                    ('-'                                                      )
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  5208
                    ('Google Spell'                googleSpellingSuggestion   )
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  5209
                    ('Translate'                   babelFishTranslate         )
3517
0a2f117c2fb8 +compare menu item
Claus Gittinger <cg@exept.de>
parents: 3514
diff changeset
  5210
                    ('Compare with Clipboard...'   compareWithClipboard       )
3221
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  5211
                    ('-'                                                      )
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  5212
                    ('Open FileBrowser on It'      openFileBrowserOnIt        )
3483
8ef0f9a0737f +openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents: 3482
diff changeset
  5213
                    ('Open Workspace with It'      openWorkspaceWithIt        )
3221
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  5214
              ).
2762
e29673db4ddb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2757
diff changeset
  5215
2460
Claus Gittinger <cg@exept.de>
parents: 2438
diff changeset
  5216
    sub := PopUpMenu itemList:items resources:resources performer:model.
2461
54d220735048 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2460
diff changeset
  5217
    sub receiver:self.
2460
Claus Gittinger <cg@exept.de>
parents: 2438
diff changeset
  5218
2919
Claus Gittinger <cg@exept.de>
parents: 2916
diff changeset
  5219
    toolSub := PopUpMenu itemList:toolItems resources:resources performer:model.
Claus Gittinger <cg@exept.de>
parents: 2916
diff changeset
  5220
    toolSub receiver:self.
Claus Gittinger <cg@exept.de>
parents: 2916
diff changeset
  5221
    sub subMenuAt:#tools put:toolSub.
Claus Gittinger <cg@exept.de>
parents: 2916
diff changeset
  5222
3495
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  5223
    transSub := PopUpMenu itemList:translateItems resources:resources performer:model.
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  5224
    transSub receiver:self.
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  5225
    toolSub subMenuAt:#babelFishTranslate put:transSub.
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  5226
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  5227
    sortSub := PopUpMenu itemList:sortItems resources:resources performer:model.
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  5228
    sortSub receiver:self.
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  5229
    toolSub subMenuAt:#sort put:sortSub.
3221
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  5230
2866
9dd71df46f73 specialCharacters menu item
Claus Gittinger <cg@exept.de>
parents: 2857
diff changeset
  5231
    subSub := PopUpMenu itemList:miscItems resources:resources performer:model.
9dd71df46f73 specialCharacters menu item
Claus Gittinger <cg@exept.de>
parents: 2857
diff changeset
  5232
    subSub receiver:self.
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5233
    subSub checkToggleAt:#autoIndent: put:autoIndent.
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  5234
    subSub checkToggleAt:#insertMode: put:(self isInInsertMode).
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5235
    subSub checkToggleAt:#learnMode: put:(self learnModeHolder value).
2866
9dd71df46f73 specialCharacters menu item
Claus Gittinger <cg@exept.de>
parents: 2857
diff changeset
  5236
    sub subMenuAt:#misc put:subSub.
9dd71df46f73 specialCharacters menu item
Claus Gittinger <cg@exept.de>
parents: 2857
diff changeset
  5237
3495
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  5238
    mainItems := #(
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  5239
                    ('Undo'    undo             Undo   )
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  5240
                    ('Again'   again            Again  )
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  5241
                    ('-'                               )
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  5242
                    ('Cut'     cut              Cut    )
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  5243
                    ('Copy'    copySelection    Copy   )
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  5244
                    ('Paste'   pasteOrReplace   Paste  )
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  5245
                    ('-'                               )
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  5246
                    ('Accept'  accept           Accept )
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  5247
                    ('='                               )
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  5248
                    ('More'    others           Ctrl   )
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  5249
              ).
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  5250
    main := PopUpMenu itemList:mainItems resources:resources.
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  5251
    main subMenuAt:#others put:sub.
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  5252
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  5253
    sensor := self sensor.
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  5254
    (sensor notNil and:[sensor ctrlDown]) ifTrue:[
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  5255
       sensor shiftDown ifTrue:[
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  5256
            m := subSub
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  5257
        ] ifFalse:[
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  5258
            m := sub
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  5259
        ]
428
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  5260
    ] ifFalse:[
3495
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  5261
        m := main
428
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  5262
    ].
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  5263
2676
cc61fa88a3fb google spelling;
Claus Gittinger <cg@exept.de>
parents: 2660
diff changeset
  5264
    SOAP::GoogleClient isNil ifTrue:[
3221
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  5265
        "/ GoogleClient new spellingSuggestionOf: 'Smmalltlaak and Soaap'.
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  5266
        m disable:#googleSpellingSuggestion
2676
cc61fa88a3fb google spelling;
Claus Gittinger <cg@exept.de>
parents: 2660
diff changeset
  5267
    ].
cc61fa88a3fb google spelling;
Claus Gittinger <cg@exept.de>
parents: 2660
diff changeset
  5268
1733
c5139b7402f0 use self isReadonly; readOnly may now be a valueHolder.
Claus Gittinger <cg@exept.de>
parents: 1732
diff changeset
  5269
    self isReadOnly ifTrue:[
3296
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
  5270
        m disableAll:#(undo again multipleAgain redo paste pasteOrReplace cut indent autoIndent: insertMode:
3223
8cb04c4decd2 sort functions
Claus Gittinger <cg@exept.de>
parents: 3222
diff changeset
  5271
                       insertFile babelFishTranslate googleSpellingSuggestion sort)
428
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  5272
    ].
2817
7c82a9535b96 not ifTrue -> ifFalse
Claus Gittinger <cg@exept.de>
parents: 2815
diff changeset
  5273
    self hasSelectionForCopy ifFalse:[
3221
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  5274
        m disable:#copySelection.
428
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  5275
    ].
2416
56acdd9e31b5 lifted mkeyboardMacro handling from Workspace to EditTextView
Claus Gittinger <cg@exept.de>
parents: 2406
diff changeset
  5276
    self hasSelection ifFalse:[
3223
8cb04c4decd2 sort functions
Claus Gittinger <cg@exept.de>
parents: 3222
diff changeset
  5277
        m disableAll:#(cut googleSpellingSuggestion babelFishTranslate openFileBrowserOnIt sort indent).
2762
e29673db4ddb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2757
diff changeset
  5278
    ] ifTrue:[
3221
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  5279
        (Error handle:[:ex |
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  5280
            ex return:false
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  5281
        ] do:[
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  5282
            self selectionAsString asSingleByteString asFilename exists
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  5283
        ]) ifFalse:[
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  5284
            m disableAll:#(openFileBrowserOnIt).
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  5285
        ]
428
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  5286
    ].
2569
b499c81c58ae added hasUndoAction query.
Claus Gittinger <cg@exept.de>
parents: 2560
diff changeset
  5287
    self hasUndoAction ifFalse:[
3221
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  5288
        m disable:#undo.
3115
b75128334006 info string in undo
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
  5289
    ] ifTrue:[
3221
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  5290
        what := undoSupport undoActionInfo.
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  5291
        what notNil ifTrue:[
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  5292
            undoIdx := m indexOf:#undo.
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  5293
            m labelAt:undoIdx put:(resources string:'Undo (%1)' with:what).
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  5294
        ]
1818
aa16d9b96e40 fixed cut to not compress multiple blanks.
Claus Gittinger <cg@exept.de>
parents: 1817
diff changeset
  5295
    ].
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5296
    self hasRedoAction ifFalse:[
3221
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  5297
        m disable:#redo.
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5298
    ].
1108
3d14bb6bceb7 added disableAccept
Claus Gittinger <cg@exept.de>
parents: 1082
diff changeset
  5299
    acceptEnabled == false ifTrue:[
3221
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  5300
        m disable:#accept
1108
3d14bb6bceb7 added disableAccept
Claus Gittinger <cg@exept.de>
parents: 1082
diff changeset
  5301
    ].
428
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  5302
    ^ m.
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  5303
3495
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  5304
    "Modified: / 28-07-2007 / 13:15:38 / cg"
428
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  5305
!
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  5306
2544
48ab4ed67816 shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  5307
getTextSelectionFromHistory
48ab4ed67816 shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  5308
    |sel list box history|
48ab4ed67816 shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  5309
48ab4ed67816 shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  5310
    history := device getCopyBufferHistory copy.
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  5311
    list := history collect:[:entry |
3473
acfc110e0b0b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3465
diff changeset
  5312
                |text shown|
acfc110e0b0b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3465
diff changeset
  5313
acfc110e0b0b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3465
diff changeset
  5314
                text := entry asString string asCollectionOfLines.
acfc110e0b0b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3465
diff changeset
  5315
                shown := text detect:[:line| line notEmptyOrNil] ifNone:['      '].
acfc110e0b0b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3465
diff changeset
  5316
                text size > 1 ifTrue:[
acfc110e0b0b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3465
diff changeset
  5317
                    shown := shown,(resources string:' ... [%1 lines]' with:text size).
acfc110e0b0b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3465
diff changeset
  5318
                ].
acfc110e0b0b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3465
diff changeset
  5319
                shown
acfc110e0b0b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3465
diff changeset
  5320
            ].
2544
48ab4ed67816 shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  5321
    box := ListSelectionBox
3473
acfc110e0b0b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3465
diff changeset
  5322
                title:'CopyBuffer History'
acfc110e0b0b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3465
diff changeset
  5323
                okText:'Paste'
acfc110e0b0b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3465
diff changeset
  5324
                abortText:'Cancel'
acfc110e0b0b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3465
diff changeset
  5325
                list:list
acfc110e0b0b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3465
diff changeset
  5326
                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
  5327
    box useIndex:true.
48ab4ed67816 shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  5328
    box show.
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  5329
    ^ sel.
2544
48ab4ed67816 shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  5330
!
48ab4ed67816 shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  5331
48ab4ed67816 shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  5332
getTextSelectionOrTextSelectionFromHistory
2730
61a2f1981ac6 Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents: 2725
diff changeset
  5333
61a2f1981ac6 Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents: 2725
diff changeset
  5334
    self sensor shiftDown ifTrue:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  5335
	^ self getTextSelectionFromHistory
2544
48ab4ed67816 shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  5336
    ].
2724
23f4e16dc4f4 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2720
diff changeset
  5337
23f4e16dc4f4 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2720
diff changeset
  5338
    "/ return either the (xterm-) selection or the clipBoard
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  5339
    ^ self
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  5340
	getClipboardText:(self sensor ctrlDown
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  5341
			    ifTrue:#selection
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  5342
			    ifFalse:#clipboard)
2544
48ab4ed67816 shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  5343
!
48ab4ed67816 shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  5344
2676
cc61fa88a3fb google spelling;
Claus Gittinger <cg@exept.de>
parents: 2660
diff changeset
  5345
googleSpellingSuggestion
cc61fa88a3fb google spelling;
Claus Gittinger <cg@exept.de>
parents: 2660
diff changeset
  5346
    "insert the google-spelling suggestion for the selected text.
cc61fa88a3fb google spelling;
Claus Gittinger <cg@exept.de>
parents: 2660
diff changeset
  5347
     Requires that the SOAP stuff is loaded and working."
cc61fa88a3fb google spelling;
Claus Gittinger <cg@exept.de>
parents: 2660
diff changeset
  5348
2677
afb234f8b822 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2676
diff changeset
  5349
    |text suggestion|
2676
cc61fa88a3fb google spelling;
Claus Gittinger <cg@exept.de>
parents: 2660
diff changeset
  5350
cc61fa88a3fb google spelling;
Claus Gittinger <cg@exept.de>
parents: 2660
diff changeset
  5351
    self withWaitCursorDo:[
3495
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  5352
        text := self selection asString string withoutSeparators.
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  5353
        text size == 0 ifTrue:[^ self].
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  5354
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  5355
        SOAP::SoapImplError handle:[:ex |
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  5356
            Dialog warn:('Spelling correction failed - WEB Service error:\\%1.' bindWith:ex description allBold) withCRs.
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  5357
            ^ self.
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  5358
        ] do:[
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  5359
            suggestion := SOAP::GoogleClient new spellingSuggestionOf:text.
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  5360
        ].
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  5361
        suggestion size == 0 ifTrue:[
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  5362
            Transcript showCR:'No SpellingSuggestion from Google for: ' , text.
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  5363
            ^ self.
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  5364
        ].
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  5365
    ].
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  5366
    self undoablePaste:suggestion info:'spelling suggestion'.
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  5367
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  5368
    "Modified: / 28-07-2007 / 13:25:10 / cg"
2676
cc61fa88a3fb google spelling;
Claus Gittinger <cg@exept.de>
parents: 2660
diff changeset
  5369
!
cc61fa88a3fb google spelling;
Claus Gittinger <cg@exept.de>
parents: 2660
diff changeset
  5370
cc61fa88a3fb google spelling;
Claus Gittinger <cg@exept.de>
parents: 2660
diff changeset
  5371
insertFile
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  5372
    "insert contents of a file
2676
cc61fa88a3fb google spelling;
Claus Gittinger <cg@exept.de>
parents: 2660
diff changeset
  5373
     - ask user for filename using a fileSelectionBox."
cc61fa88a3fb google spelling;
Claus Gittinger <cg@exept.de>
parents: 2660
diff changeset
  5374
3409
d650e3ae9085 insert-file menu item cares for current selection being a filename
Claus Gittinger <cg@exept.de>
parents: 3406
diff changeset
  5375
    |sel selFn file text ok initial|
d650e3ae9085 insert-file menu item cares for current selection being a filename
Claus Gittinger <cg@exept.de>
parents: 3406
diff changeset
  5376
d650e3ae9085 insert-file menu item cares for current selection being a filename
Claus Gittinger <cg@exept.de>
parents: 3406
diff changeset
  5377
    ((sel := self selectionAsString) notEmptyOrNil
d650e3ae9085 insert-file menu item cares for current selection being a filename
Claus Gittinger <cg@exept.de>
parents: 3406
diff changeset
  5378
    and:[ (selFn := sel asFilename) exists
d650e3ae9085 insert-file menu item cares for current selection being a filename
Claus Gittinger <cg@exept.de>
parents: 3406
diff changeset
  5379
    and:[ selFn isRegularFile ]])
d650e3ae9085 insert-file menu item cares for current selection being a filename
Claus Gittinger <cg@exept.de>
parents: 3406
diff changeset
  5380
    ifTrue:[
d650e3ae9085 insert-file menu item cares for current selection being a filename
Claus Gittinger <cg@exept.de>
parents: 3406
diff changeset
  5381
        initial := selFn pathName.
d650e3ae9085 insert-file menu item cares for current selection being a filename
Claus Gittinger <cg@exept.de>
parents: 3406
diff changeset
  5382
    ].
2757
b98097eaf8dc Stc cannot handle thisContext restart in true-Block.
Stefan Vogel <sv@exept.de>
parents: 2756
diff changeset
  5383
b98097eaf8dc Stc cannot handle thisContext restart in true-Block.
Stefan Vogel <sv@exept.de>
parents: 2756
diff changeset
  5384
    [
3190
0f5de962dab7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3180
diff changeset
  5385
        |why|
0f5de962dab7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3180
diff changeset
  5386
0f5de962dab7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3180
diff changeset
  5387
        file := Dialog
3409
d650e3ae9085 insert-file menu item cares for current selection being a filename
Claus Gittinger <cg@exept.de>
parents: 3406
diff changeset
  5388
            requestFileName:(resources string:'Insert Contents Of:')
d650e3ae9085 insert-file menu item cares for current selection being a filename
Claus Gittinger <cg@exept.de>
parents: 3406
diff changeset
  5389
            default:initial
3190
0f5de962dab7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3180
diff changeset
  5390
            ok:(resources string:'Insert')
0f5de962dab7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3180
diff changeset
  5391
            abort:(resources string:'Cancel')
0f5de962dab7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3180
diff changeset
  5392
            pattern:nil
0f5de962dab7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3180
diff changeset
  5393
            fromDirectory:directoryForFileDialog.
0f5de962dab7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3180
diff changeset
  5394
        file isNil ifTrue:[
0f5de962dab7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3180
diff changeset
  5395
            "cancel"
0f5de962dab7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3180
diff changeset
  5396
            ^ self.
0f5de962dab7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3180
diff changeset
  5397
        ].
0f5de962dab7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3180
diff changeset
  5398
        file := file asFilename.
0f5de962dab7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3180
diff changeset
  5399
        directoryForFileDialog := file.
0f5de962dab7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3180
diff changeset
  5400
0f5de962dab7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3180
diff changeset
  5401
        ok := file isReadable and:[file isDirectory not].
0f5de962dab7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3180
diff changeset
  5402
        ok ifFalse:[
0f5de962dab7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3180
diff changeset
  5403
            file isReadable ifFalse:[
0f5de962dab7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3180
diff changeset
  5404
                why := '%1 is unreadable.\\Please try again.'
0f5de962dab7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3180
diff changeset
  5405
            ] ifTrue:[
0f5de962dab7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3180
diff changeset
  5406
                why := '%1 is a directory.\\Please try again.'
0f5de962dab7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3180
diff changeset
  5407
            ].
0f5de962dab7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3180
diff changeset
  5408
            Dialog warn:(resources stringWithCRs:why with:file pathName).
0f5de962dab7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3180
diff changeset
  5409
        ].
2909
a43e1343718f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2901
diff changeset
  5410
    ] doUntil:[ok].
2757
b98097eaf8dc Stc cannot handle thisContext restart in true-Block.
Stefan Vogel <sv@exept.de>
parents: 2756
diff changeset
  5411
b98097eaf8dc Stc cannot handle thisContext restart in true-Block.
Stefan Vogel <sv@exept.de>
parents: 2756
diff changeset
  5412
    text := file contentsOfEntireFile.
3495
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  5413
    self 
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  5414
        undoableDo:[
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  5415
            self paste:text
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  5416
        ]
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  5417
        info:'paste file'
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  5418
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  5419
    "Modified: / 28-07-2007 / 13:23:32 / cg"
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  5420
!
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  5421
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  5422
insertUUID
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  5423
    "insert a new UUID's string"
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  5424
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  5425
    typeOfSelection := nil.
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  5426
    self 
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  5427
        undoableDo:[
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  5428
            self pasteOrReplace:(UUID genUUID printString).
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  5429
        ]
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  5430
        info:'paste new uuid'
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  5431
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  5432
    "Created: / 28-07-2007 / 13:01:16 / cg"
2676
cc61fa88a3fb google spelling;
Claus Gittinger <cg@exept.de>
parents: 2660
diff changeset
  5433
!
cc61fa88a3fb google spelling;
Claus Gittinger <cg@exept.de>
parents: 2660
diff changeset
  5434
2762
e29673db4ddb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2757
diff changeset
  5435
openFileBrowserOnIt
e29673db4ddb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2757
diff changeset
  5436
    "open a fileBrowser on the selected fileName"
e29673db4ddb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2757
diff changeset
  5437
e29673db4ddb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2757
diff changeset
  5438
    |fn dir|
e29673db4ddb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2757
diff changeset
  5439
e29673db4ddb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2757
diff changeset
  5440
    fn := self selectionAsString asFilename.
e29673db4ddb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2757
diff changeset
  5441
    fn exists ifFalse:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  5442
	^ self warn:'Oops - file is gone'.
2762
e29673db4ddb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2757
diff changeset
  5443
    ].
e29673db4ddb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2757
diff changeset
  5444
    (dir := fn) isDirectory ifFalse:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  5445
	dir := fn directory
2762
e29673db4ddb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2757
diff changeset
  5446
    ].
e29673db4ddb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2757
diff changeset
  5447
    UserPreferences fileBrowserClass openOn:dir
e29673db4ddb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2757
diff changeset
  5448
!
e29673db4ddb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2757
diff changeset
  5449
3483
8ef0f9a0737f +openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents: 3482
diff changeset
  5450
openWorkspaceWithIt
8ef0f9a0737f +openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents: 3482
diff changeset
  5451
    "open a workspace containing the selected text"
8ef0f9a0737f +openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents: 3482
diff changeset
  5452
8ef0f9a0737f +openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents: 3482
diff changeset
  5453
    |text|
8ef0f9a0737f +openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents: 3482
diff changeset
  5454
8ef0f9a0737f +openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents: 3482
diff changeset
  5455
    text := self selectionAsString.
8ef0f9a0737f +openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents: 3482
diff changeset
  5456
    WorkspaceApplication openWith:text selected:true
8ef0f9a0737f +openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents: 3482
diff changeset
  5457
8ef0f9a0737f +openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents: 3482
diff changeset
  5458
    "Created: / 26-05-2007 / 06:05:22 / cg"
8ef0f9a0737f +openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents: 3482
diff changeset
  5459
!
8ef0f9a0737f +openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents: 3482
diff changeset
  5460
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5461
paste
1289
e2dcc5fe612c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1287
diff changeset
  5462
    "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
  5463
     Then paste at cursor position."
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5464
2989
5dcc2912bcb6 undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents: 2984
diff changeset
  5465
    self checkModificationsAllowed ifTrue:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  5466
	self withSelfAndTextForPasteDo:[:me :text |
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  5467
	    me unselect.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  5468
	    me undoablePaste:text
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  5469
	]
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5470
    ]
259
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
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5473
paste:someText
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5474
    "paste someText at cursor"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5475
2856
bc6bb86d4d2e character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents: 2854
diff changeset
  5476
    |s nLines startLine startCol l1 l2 c1 c2 codingErrorReported|
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5477
1480
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  5478
    self checkModificationsAllowed ifFalse:[^ self].
2853
f8c1d3963b49 preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents: 2846
diff changeset
  5479
    someText isNil ifTrue:[^ self].
f8c1d3963b49 preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents: 2846
diff changeset
  5480
f8c1d3963b49 preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents: 2846
diff changeset
  5481
    s := someText.
2856
bc6bb86d4d2e character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents: 2854
diff changeset
  5482
    codingErrorReported := false.
bc6bb86d4d2e character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents: 2854
diff changeset
  5483
    CharacterEncoderError handle:[:ex |
3180
609f340fd96c paste - do not expand tabs!
Michael Beyl <mb@exept.de>
parents: 3161
diff changeset
  5484
        |code msg|
609f340fd96c paste - do not expand tabs!
Michael Beyl <mb@exept.de>
parents: 3161
diff changeset
  5485
609f340fd96c paste - do not expand tabs!
Michael Beyl <mb@exept.de>
parents: 3161
diff changeset
  5486
        code := ex parameter.
609f340fd96c paste - do not expand tabs!
Michael Beyl <mb@exept.de>
parents: 3161
diff changeset
  5487
        codingErrorReported ifFalse:[
609f340fd96c paste - do not expand tabs!
Michael Beyl <mb@exept.de>
parents: 3161
diff changeset
  5488
            msg := 'Cannot represent pasted string in this Views encoding (',characterEncoding,').'.
609f340fd96c paste - do not expand tabs!
Michael Beyl <mb@exept.de>
parents: 3161
diff changeset
  5489
            code notNil ifTrue:[
609f340fd96c paste - do not expand tabs!
Michael Beyl <mb@exept.de>
parents: 3161
diff changeset
  5490
                msg := msg , '\\Reason: No representation for ' , (code radixPrintStringRadix:16).
609f340fd96c paste - do not expand tabs!
Michael Beyl <mb@exept.de>
parents: 3161
diff changeset
  5491
            ].
3190
0f5de962dab7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3180
diff changeset
  5492
            Dialog warn:(resources stringWithCRs:msg).
3180
609f340fd96c paste - do not expand tabs!
Michael Beyl <mb@exept.de>
parents: 3161
diff changeset
  5493
            codingErrorReported := true.
609f340fd96c paste - do not expand tabs!
Michael Beyl <mb@exept.de>
parents: 3161
diff changeset
  5494
        ].
3482
485fb4d1f464 CharacterEncoderError handling (take defaultValue from target encoding)
Stefan Vogel <sv@exept.de>
parents: 3479
diff changeset
  5495
        ex proceedWith:ex defaultValue
2856
bc6bb86d4d2e character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents: 2854
diff changeset
  5496
    ] do:[
3180
609f340fd96c paste - do not expand tabs!
Michael Beyl <mb@exept.de>
parents: 3161
diff changeset
  5497
        s isString ifTrue:[
609f340fd96c paste - do not expand tabs!
Michael Beyl <mb@exept.de>
parents: 3161
diff changeset
  5498
            s encoding ~~ characterEncoding ifTrue:[
609f340fd96c paste - do not expand tabs!
Michael Beyl <mb@exept.de>
parents: 3161
diff changeset
  5499
                s := s encodeFrom:(s encoding) into:characterEncoding.
609f340fd96c paste - do not expand tabs!
Michael Beyl <mb@exept.de>
parents: 3161
diff changeset
  5500
            ].
609f340fd96c paste - do not expand tabs!
Michael Beyl <mb@exept.de>
parents: 3161
diff changeset
  5501
609f340fd96c paste - do not expand tabs!
Michael Beyl <mb@exept.de>
parents: 3161
diff changeset
  5502
            s := s asStringCollection.
609f340fd96c paste - do not expand tabs!
Michael Beyl <mb@exept.de>
parents: 3161
diff changeset
  5503
            (someText endsWith:Character cr) ifTrue:[
609f340fd96c paste - do not expand tabs!
Michael Beyl <mb@exept.de>
parents: 3161
diff changeset
  5504
                "/ s := s copyWith:nil.
609f340fd96c paste - do not expand tabs!
Michael Beyl <mb@exept.de>
parents: 3161
diff changeset
  5505
                s := s copyWith:'' "/ an empty line at the end
609f340fd96c paste - do not expand tabs!
Michael Beyl <mb@exept.de>
parents: 3161
diff changeset
  5506
609f340fd96c paste - do not expand tabs!
Michael Beyl <mb@exept.de>
parents: 3161
diff changeset
  5507
            ]
609f340fd96c paste - do not expand tabs!
Michael Beyl <mb@exept.de>
parents: 3161
diff changeset
  5508
        ] ifFalse:[
609f340fd96c paste - do not expand tabs!
Michael Beyl <mb@exept.de>
parents: 3161
diff changeset
  5509
            s isStringCollection ifTrue:[
609f340fd96c paste - do not expand tabs!
Michael Beyl <mb@exept.de>
parents: 3161
diff changeset
  5510
                s := s encodeFrom:(s encoding) into:characterEncoding.
609f340fd96c paste - do not expand tabs!
Michael Beyl <mb@exept.de>
parents: 3161
diff changeset
  5511
            ] ifFalse:[
609f340fd96c paste - do not expand tabs!
Michael Beyl <mb@exept.de>
parents: 3161
diff changeset
  5512
                (self
609f340fd96c paste - do not expand tabs!
Michael Beyl <mb@exept.de>
parents: 3161
diff changeset
  5513
                    confirm:(resources
609f340fd96c paste - do not expand tabs!
Michael Beyl <mb@exept.de>
parents: 3161
diff changeset
  5514
                        stringWithCRs:'Selection (%1) is not convertable to Text.\\Paste storeString ?'
609f340fd96c paste - do not expand tabs!
Michael Beyl <mb@exept.de>
parents: 3161
diff changeset
  5515
                        with:s class name)) ifFalse:[^ self].
609f340fd96c paste - do not expand tabs!
Michael Beyl <mb@exept.de>
parents: 3161
diff changeset
  5516
                s := StringCollection with:s storeString .
609f340fd96c paste - do not expand tabs!
Michael Beyl <mb@exept.de>
parents: 3161
diff changeset
  5517
                "/ ^ self
609f340fd96c paste - do not expand tabs!
Michael Beyl <mb@exept.de>
parents: 3161
diff changeset
  5518
            ].
609f340fd96c paste - do not expand tabs!
Michael Beyl <mb@exept.de>
parents: 3161
diff changeset
  5519
        ].
2856
bc6bb86d4d2e character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents: 2854
diff changeset
  5520
    ].
bc6bb86d4d2e character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents: 2854
diff changeset
  5521
2853
f8c1d3963b49 preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents: 2846
diff changeset
  5522
    (nLines := s size) == 0 ifTrue:[^ self].
f8c1d3963b49 preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents: 2846
diff changeset
  5523
    (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
  5524
f8c1d3963b49 preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents: 2846
diff changeset
  5525
    typeOfSelection := #paste.
f8c1d3963b49 preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents: 2846
diff changeset
  5526
f8c1d3963b49 preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents: 2846
diff changeset
  5527
    startLine := l1 := cursorLine.
f8c1d3963b49 preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents: 2846
diff changeset
  5528
    startCol := c1 := cursorCol.
3180
609f340fd96c paste - do not expand tabs!
Michael Beyl <mb@exept.de>
parents: 3161
diff changeset
  5529
609f340fd96c paste - do not expand tabs!
Michael Beyl <mb@exept.de>
parents: 3161
diff changeset
  5530
    "do not expand tabs in s  here - 
609f340fd96c paste - do not expand tabs!
Michael Beyl <mb@exept.de>
parents: 3161
diff changeset
  5531
     they get expanded in basicWithoutRedrawInsertStringWithoutCRs:aString atLine:lineNr col:colNr.
609f340fd96c paste - do not expand tabs!
Michael Beyl <mb@exept.de>
parents: 3161
diff changeset
  5532
     Some Subviews want to paste with unexpanded tabs!!"
609f340fd96c paste - do not expand tabs!
Michael Beyl <mb@exept.de>
parents: 3161
diff changeset
  5533
609f340fd96c paste - do not expand tabs!
Michael Beyl <mb@exept.de>
parents: 3161
diff changeset
  5534
    self insertLines:s withCR:false.
2853
f8c1d3963b49 preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents: 2846
diff changeset
  5535
    l2 := cursorLine.
f8c1d3963b49 preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents: 2846
diff changeset
  5536
    c2 := (cursorCol - 1).
f8c1d3963b49 preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents: 2846
diff changeset
  5537
    self selectFromLine:l1 col:c1 toLine:l2 col:c2.
f8c1d3963b49 preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents: 2846
diff changeset
  5538
    typeOfSelection := #paste. "/ sigh - cleared by #selectFromLine:
f8c1d3963b49 preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents: 2846
diff changeset
  5539
1480
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  5540
    "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
  5541
    "Modified: / 30.1.2000 / 02:32:42 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5542
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5543
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5544
pasteOrReplace
1289
e2dcc5fe612c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1287
diff changeset
  5545
    "paste the copybuffer; if there is a selection, replace it.
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  5546
     otherwise paste at cursor position.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  5547
     Replace is not done for selections which were created by a paste,
2010
ca8dcc8723dc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1993
diff changeset
  5548
     to allow multiple paste operations in a row."
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5549
2724
23f4e16dc4f4 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2720
diff changeset
  5550
    self withSelfAndTextForPasteDo:[:me :text | me pasteOrReplace:text]
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5551
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5552
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5553
pasteOrReplace:someText
1289
e2dcc5fe612c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1287
diff changeset
  5554
    "paste someText; if there is a selection, replace it.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5555
     otherwise paste at cursor position. Replace is not done
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5556
     for originating by a paste, to allow multiple
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5557
     paste."
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5558
1480
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  5559
    self checkModificationsAllowed ifFalse:[^ self].
2989
5dcc2912bcb6 undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents: 2984
diff changeset
  5560
5dcc2912bcb6 undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents: 2984
diff changeset
  5561
    self undoableDo:[
3542
30ed44ed0178 +joinLines (CTRL-j);
Claus Gittinger <cg@exept.de>
parents: 3517
diff changeset
  5562
        ((self hasSelection == true) and:[typeOfSelection ~~ #paste]) ifTrue:[
30ed44ed0178 +joinLines (CTRL-j);
Claus Gittinger <cg@exept.de>
parents: 3517
diff changeset
  5563
            self replace:someText
30ed44ed0178 +joinLines (CTRL-j);
Claus Gittinger <cg@exept.de>
parents: 3517
diff changeset
  5564
        ] ifFalse:[
30ed44ed0178 +joinLines (CTRL-j);
Claus Gittinger <cg@exept.de>
parents: 3517
diff changeset
  5565
            self paste:someText.
30ed44ed0178 +joinLines (CTRL-j);
Claus Gittinger <cg@exept.de>
parents: 3517
diff changeset
  5566
        ]
30ed44ed0178 +joinLines (CTRL-j);
Claus Gittinger <cg@exept.de>
parents: 3517
diff changeset
  5567
    ] info:'Paste/Replace'.
1289
e2dcc5fe612c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1287
diff changeset
  5568
2107
9d44232af0a0 textSelection fixes (added newLine) for MSDOS;
Claus Gittinger <cg@exept.de>
parents: 2101
diff changeset
  5569
    "Modified: / 30.1.2000 / 02:33:00 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5570
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5571
3474
357e16440725 slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents: 3473
diff changeset
  5572
pasteOrReplaceFromHistory
357e16440725 slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents: 3473
diff changeset
  5573
    "paste a previous item from the copybuffer history.
357e16440725 slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents: 3473
diff changeset
  5574
     (i.e. repaste some previously deleted or copied text)"
357e16440725 slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents: 3473
diff changeset
  5575
357e16440725 slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents: 3473
diff changeset
  5576
    |text|
357e16440725 slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents: 3473
diff changeset
  5577
357e16440725 slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents: 3473
diff changeset
  5578
    self checkModificationsAllowed ifFalse:[
357e16440725 slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents: 3473
diff changeset
  5579
        self flash.
357e16440725 slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents: 3473
diff changeset
  5580
        ^ self
357e16440725 slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents: 3473
diff changeset
  5581
    ].
357e16440725 slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents: 3473
diff changeset
  5582
    text := self getTextSelectionFromHistory.
357e16440725 slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents: 3473
diff changeset
  5583
    text notNil ifTrue:[
357e16440725 slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents: 3473
diff changeset
  5584
        self pasteOrReplace:text
357e16440725 slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents: 3473
diff changeset
  5585
    ]
357e16440725 slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents: 3473
diff changeset
  5586
!
357e16440725 slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents: 3473
diff changeset
  5587
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5588
replace
1289
e2dcc5fe612c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1287
diff changeset
  5589
    "replace the selection by the contents of the copybuffer"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5590
3269
03d04670a5d2 replace is a no op, if there is no selection
Claus Gittinger <cg@exept.de>
parents: 3268
diff changeset
  5591
    self hasSelection ifFalse:[^ self].
03d04670a5d2 replace is a no op, if there is no selection
Claus Gittinger <cg@exept.de>
parents: 3268
diff changeset
  5592
    self checkModificationsAllowed ifFalse:[^ self].
03d04670a5d2 replace is a no op, if there is no selection
Claus Gittinger <cg@exept.de>
parents: 3268
diff changeset
  5593
03d04670a5d2 replace is a no op, if there is no selection
Claus Gittinger <cg@exept.de>
parents: 3268
diff changeset
  5594
    self withSelfAndTextForPasteDo:[:me :text |
03d04670a5d2 replace is a no op, if there is no selection
Claus Gittinger <cg@exept.de>
parents: 3268
diff changeset
  5595
        me undoableDo:[
03d04670a5d2 replace is a no op, if there is no selection
Claus Gittinger <cg@exept.de>
parents: 3268
diff changeset
  5596
            me replace:text
03d04670a5d2 replace is a no op, if there is no selection
Claus Gittinger <cg@exept.de>
parents: 3268
diff changeset
  5597
        ]
3542
30ed44ed0178 +joinLines (CTRL-j);
Claus Gittinger <cg@exept.de>
parents: 3517
diff changeset
  5598
        info:'Replace'
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5599
    ]
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5600
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5601
121
claus
parents: 118
diff changeset
  5602
replace:someText
1289
e2dcc5fe612c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1287
diff changeset
  5603
    "replace the selection by someText"
121
claus
parents: 118
diff changeset
  5604
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  5605
    |selected selectedString
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  5606
     selStartLine selStartCol selEndLine selEndCol|
121
claus
parents: 118
diff changeset
  5607
1480
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  5608
    self checkModificationsAllowed ifFalse:[^ self].
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  5609
3130
c0f39f9f28d6 undoable keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3127
diff changeset
  5610
    self undoableDo:[
3542
30ed44ed0178 +joinLines (CTRL-j);
Claus Gittinger <cg@exept.de>
parents: 3517
diff changeset
  5611
        selected := self selection.
30ed44ed0178 +joinLines (CTRL-j);
Claus Gittinger <cg@exept.de>
parents: 3517
diff changeset
  5612
        selected isNil ifTrue:[
30ed44ed0178 +joinLines (CTRL-j);
Claus Gittinger <cg@exept.de>
parents: 3517
diff changeset
  5613
            ^ self paste:someText
30ed44ed0178 +joinLines (CTRL-j);
Claus Gittinger <cg@exept.de>
parents: 3517
diff changeset
  5614
        ].
30ed44ed0178 +joinLines (CTRL-j);
Claus Gittinger <cg@exept.de>
parents: 3517
diff changeset
  5615
30ed44ed0178 +joinLines (CTRL-j);
Claus Gittinger <cg@exept.de>
parents: 3517
diff changeset
  5616
        self deleteSelection.
30ed44ed0178 +joinLines (CTRL-j);
Claus Gittinger <cg@exept.de>
parents: 3517
diff changeset
  5617
30ed44ed0178 +joinLines (CTRL-j);
Claus Gittinger <cg@exept.de>
parents: 3517
diff changeset
  5618
        "take care, if we replace a selection without space by a word selected
30ed44ed0178 +joinLines (CTRL-j);
Claus Gittinger <cg@exept.de>
parents: 3517
diff changeset
  5619
         with one - in this case we usually do not want the space.
30ed44ed0178 +joinLines (CTRL-j);
Claus Gittinger <cg@exept.de>
parents: 3517
diff changeset
  5620
         But, if we replace a word-selected selection by something without a
30ed44ed0178 +joinLines (CTRL-j);
Claus Gittinger <cg@exept.de>
parents: 3517
diff changeset
  5621
         space, we DO want the space added."
30ed44ed0178 +joinLines (CTRL-j);
Claus Gittinger <cg@exept.de>
parents: 3517
diff changeset
  5622
30ed44ed0178 +joinLines (CTRL-j);
Claus Gittinger <cg@exept.de>
parents: 3517
diff changeset
  5623
        selected size == 1 ifTrue:[
30ed44ed0178 +joinLines (CTRL-j);
Claus Gittinger <cg@exept.de>
parents: 3517
diff changeset
  5624
            selectedString := selected at:1.
30ed44ed0178 +joinLines (CTRL-j);
Claus Gittinger <cg@exept.de>
parents: 3517
diff changeset
  5625
        ].
30ed44ed0178 +joinLines (CTRL-j);
Claus Gittinger <cg@exept.de>
parents: 3517
diff changeset
  5626
30ed44ed0178 +joinLines (CTRL-j);
Claus Gittinger <cg@exept.de>
parents: 3517
diff changeset
  5627
        someText size == 1 ifTrue:[
30ed44ed0178 +joinLines (CTRL-j);
Claus Gittinger <cg@exept.de>
parents: 3517
diff changeset
  5628
            |cutOffSpace addSpace replacement replacementString|
30ed44ed0178 +joinLines (CTRL-j);
Claus Gittinger <cg@exept.de>
parents: 3517
diff changeset
  5629
30ed44ed0178 +joinLines (CTRL-j);
Claus Gittinger <cg@exept.de>
parents: 3517
diff changeset
  5630
            cutOffSpace := false.
30ed44ed0178 +joinLines (CTRL-j);
Claus Gittinger <cg@exept.de>
parents: 3517
diff changeset
  5631
            addSpace := false.
30ed44ed0178 +joinLines (CTRL-j);
Claus Gittinger <cg@exept.de>
parents: 3517
diff changeset
  5632
            replacement := someText copyFrom:1.
30ed44ed0178 +joinLines (CTRL-j);
Claus Gittinger <cg@exept.de>
parents: 3517
diff changeset
  5633
30ed44ed0178 +joinLines (CTRL-j);
Claus Gittinger <cg@exept.de>
parents: 3517
diff changeset
  5634
            selectedString notNil ifTrue:[
30ed44ed0178 +joinLines (CTRL-j);
Claus Gittinger <cg@exept.de>
parents: 3517
diff changeset
  5635
                ((selectedString startsWith:' ') or:[selectedString endsWith:' ']) ifFalse:[
30ed44ed0178 +joinLines (CTRL-j);
Claus Gittinger <cg@exept.de>
parents: 3517
diff changeset
  5636
                   "selection has no space"
30ed44ed0178 +joinLines (CTRL-j);
Claus Gittinger <cg@exept.de>
parents: 3517
diff changeset
  5637
30ed44ed0178 +joinLines (CTRL-j);
Claus Gittinger <cg@exept.de>
parents: 3517
diff changeset
  5638
                    ((selectStyle == #wordleft) or:[selectStyle == #wordRight]) ifTrue:[
30ed44ed0178 +joinLines (CTRL-j);
Claus Gittinger <cg@exept.de>
parents: 3517
diff changeset
  5639
                        cutOffSpace := true
30ed44ed0178 +joinLines (CTRL-j);
Claus Gittinger <cg@exept.de>
parents: 3517
diff changeset
  5640
                    ]
30ed44ed0178 +joinLines (CTRL-j);
Claus Gittinger <cg@exept.de>
parents: 3517
diff changeset
  5641
                ] ifTrue:[
30ed44ed0178 +joinLines (CTRL-j);
Claus Gittinger <cg@exept.de>
parents: 3517
diff changeset
  5642
                    addSpace := true
30ed44ed0178 +joinLines (CTRL-j);
Claus Gittinger <cg@exept.de>
parents: 3517
diff changeset
  5643
                ]
30ed44ed0178 +joinLines (CTRL-j);
Claus Gittinger <cg@exept.de>
parents: 3517
diff changeset
  5644
            ].
30ed44ed0178 +joinLines (CTRL-j);
Claus Gittinger <cg@exept.de>
parents: 3517
diff changeset
  5645
            replacementString := replacement at:1.
30ed44ed0178 +joinLines (CTRL-j);
Claus Gittinger <cg@exept.de>
parents: 3517
diff changeset
  5646
            cutOffSpace ifTrue:[
30ed44ed0178 +joinLines (CTRL-j);
Claus Gittinger <cg@exept.de>
parents: 3517
diff changeset
  5647
                (replacementString startsWith:' ') ifTrue:[
30ed44ed0178 +joinLines (CTRL-j);
Claus Gittinger <cg@exept.de>
parents: 3517
diff changeset
  5648
                    replacementString := replacementString withoutSpaces
30ed44ed0178 +joinLines (CTRL-j);
Claus Gittinger <cg@exept.de>
parents: 3517
diff changeset
  5649
                ].
30ed44ed0178 +joinLines (CTRL-j);
Claus Gittinger <cg@exept.de>
parents: 3517
diff changeset
  5650
            ] ifFalse:[
30ed44ed0178 +joinLines (CTRL-j);
Claus Gittinger <cg@exept.de>
parents: 3517
diff changeset
  5651
                selectStyle == #wordLeft ifTrue:[
30ed44ed0178 +joinLines (CTRL-j);
Claus Gittinger <cg@exept.de>
parents: 3517
diff changeset
  5652
                    "want a space at left"
30ed44ed0178 +joinLines (CTRL-j);
Claus Gittinger <cg@exept.de>
parents: 3517
diff changeset
  5653
                    (replacementString startsWith:' ') ifFalse:[
30ed44ed0178 +joinLines (CTRL-j);
Claus Gittinger <cg@exept.de>
parents: 3517
diff changeset
  5654
                        replacementString := replacementString withoutSpaces.
30ed44ed0178 +joinLines (CTRL-j);
Claus Gittinger <cg@exept.de>
parents: 3517
diff changeset
  5655
                        replacementString := ' ' , replacementString
30ed44ed0178 +joinLines (CTRL-j);
Claus Gittinger <cg@exept.de>
parents: 3517
diff changeset
  5656
                    ]
30ed44ed0178 +joinLines (CTRL-j);
Claus Gittinger <cg@exept.de>
parents: 3517
diff changeset
  5657
                ].
30ed44ed0178 +joinLines (CTRL-j);
Claus Gittinger <cg@exept.de>
parents: 3517
diff changeset
  5658
                selectStyle == #wordRight ifTrue:[
30ed44ed0178 +joinLines (CTRL-j);
Claus Gittinger <cg@exept.de>
parents: 3517
diff changeset
  5659
                    "want a space at right"
30ed44ed0178 +joinLines (CTRL-j);
Claus Gittinger <cg@exept.de>
parents: 3517
diff changeset
  5660
30ed44ed0178 +joinLines (CTRL-j);
Claus Gittinger <cg@exept.de>
parents: 3517
diff changeset
  5661
                    (replacementString endsWith:' ') ifFalse:[
30ed44ed0178 +joinLines (CTRL-j);
Claus Gittinger <cg@exept.de>
parents: 3517
diff changeset
  5662
                        replacementString := replacementString withoutSpaces.
30ed44ed0178 +joinLines (CTRL-j);
Claus Gittinger <cg@exept.de>
parents: 3517
diff changeset
  5663
                        replacementString := replacementString , ' '
30ed44ed0178 +joinLines (CTRL-j);
Claus Gittinger <cg@exept.de>
parents: 3517
diff changeset
  5664
                    ]
30ed44ed0178 +joinLines (CTRL-j);
Claus Gittinger <cg@exept.de>
parents: 3517
diff changeset
  5665
                ].
30ed44ed0178 +joinLines (CTRL-j);
Claus Gittinger <cg@exept.de>
parents: 3517
diff changeset
  5666
            ].
30ed44ed0178 +joinLines (CTRL-j);
Claus Gittinger <cg@exept.de>
parents: 3517
diff changeset
  5667
            replacement at:1 put: replacementString.
30ed44ed0178 +joinLines (CTRL-j);
Claus Gittinger <cg@exept.de>
parents: 3517
diff changeset
  5668
            self paste:replacement.
30ed44ed0178 +joinLines (CTRL-j);
Claus Gittinger <cg@exept.de>
parents: 3517
diff changeset
  5669
        ] ifFalse:[
30ed44ed0178 +joinLines (CTRL-j);
Claus Gittinger <cg@exept.de>
parents: 3517
diff changeset
  5670
            self paste:someText
30ed44ed0178 +joinLines (CTRL-j);
Claus Gittinger <cg@exept.de>
parents: 3517
diff changeset
  5671
        ].
30ed44ed0178 +joinLines (CTRL-j);
Claus Gittinger <cg@exept.de>
parents: 3517
diff changeset
  5672
        lastString := selectedString.
30ed44ed0178 +joinLines (CTRL-j);
Claus Gittinger <cg@exept.de>
parents: 3517
diff changeset
  5673
        lastReplacement := someText.
30ed44ed0178 +joinLines (CTRL-j);
Claus Gittinger <cg@exept.de>
parents: 3517
diff changeset
  5674
30ed44ed0178 +joinLines (CTRL-j);
Claus Gittinger <cg@exept.de>
parents: 3517
diff changeset
  5675
        selStartLine := selectionStartLine.
30ed44ed0178 +joinLines (CTRL-j);
Claus Gittinger <cg@exept.de>
parents: 3517
diff changeset
  5676
        selStartCol := self selectionStartCol.
30ed44ed0178 +joinLines (CTRL-j);
Claus Gittinger <cg@exept.de>
parents: 3517
diff changeset
  5677
        selEndLine := selectionEndLine.
30ed44ed0178 +joinLines (CTRL-j);
Claus Gittinger <cg@exept.de>
parents: 3517
diff changeset
  5678
        selEndCol := self selectionEndCol.
3130
c0f39f9f28d6 undoable keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3127
diff changeset
  5679
    ]
3542
30ed44ed0178 +joinLines (CTRL-j);
Claus Gittinger <cg@exept.de>
parents: 3517
diff changeset
  5680
    info:'Replace'
362
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  5681
1480
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  5682
    "Modified: / 14.2.1996 / 10:37:02 / stefan"
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  5683
    "Modified: / 5.4.1998 / 16:55:28 / cg"
121
claus
parents: 118
diff changeset
  5684
!
claus
parents: 118
diff changeset
  5685
3430
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  5686
searchReplace
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  5687
    "search for a string - show a box to enter searchpattern 
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  5688
     replace for the found searchpattern or replace all searchpattern found to a new pattern - show  a box to enter replacepattern
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  5689
     - currently no regular expressions are handled."
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  5690
    
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  5691
    |searchBox patternHolder replacePatternHolder caseHolder flag ign initialString bindings bldr search modal replace action|
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  5692
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  5693
    modal := false "(UserPreferences current searchDialogIsModal)".
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  5694
    lastSearchDirection := #forward.
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  5695
    ign := lastSearchIgnoredCase ? LastSearchIgnoredCase ? true.
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  5696
    caseHolder := ign asValue.
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  5697
    patternHolder := '' asValue.
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  5698
    replacePatternHolder := '' asValue.
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  5699
    lastSearchPattern notNil ifTrue:[
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  5700
        initialString := lastSearchPattern
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  5701
    ].
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  5702
    self hasSelectionWithinSingleLine ifTrue:[
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  5703
        initialString := self selectionAsString
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  5704
    ].
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  5705
    initialString isNil ifTrue:[
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  5706
        LastSearchPatterns size > 0 ifTrue:[
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  5707
            initialString := LastSearchPatterns first
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  5708
        ]
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  5709
    ].
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  5710
    initialString notNil ifTrue:[
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  5711
        patternHolder value:initialString.
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  5712
        replacePatternHolder value:initialString.
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  5713
    ].
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  5714
    flag := true.
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  5715
    search := [:fwd | 
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  5716
            self 
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  5717
                search:patternHolder value
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  5718
                ignoreCase:caseHolder value
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  5719
                forward:fwd.
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  5720
        ].
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  5721
    replace := [:all | 
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  5722
            self 
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  5723
                replace:patternHolder value
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  5724
                by:replacePatternHolder value
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  5725
                all:all
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  5726
                ignoreCase:caseHolder value
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  5727
        ].
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  5728
    bindings := IdentityDictionary new.
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  5729
    bindings at:#searchPattern put:patternHolder.
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  5730
    bindings at:#replacePattern put:replacePatternHolder.
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  5731
    modal ifTrue:[
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  5732
        bindings at:#nextAction
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  5733
            put:[
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  5734
                flag := true.
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  5735
                action := search.
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  5736
                searchBox doAccept.
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  5737
            ].
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  5738
        bindings at:#prevAction
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  5739
            put:[
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  5740
                flag := false.
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  5741
                action := search.
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  5742
                searchBox doAccept.
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  5743
            ].
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  5744
        bindings at:#replaceAction
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  5745
            put:[
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  5746
                flag := false.
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  5747
                action := replace.
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  5748
                searchBox doAccept.
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  5749
            ].
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  5750
        bindings at:#replaceAllAction
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  5751
            put:[
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  5752
                flag := true.
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  5753
                action := replace.
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  5754
                searchBox doAccept.
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  5755
            ].
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  5756
    ] ifFalse:[
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  5757
        bindings at:#nextAction put:[ search value:true. ].
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  5758
        bindings at:#prevAction put:[ search value:false. ].
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  5759
        bindings at:#replaceAction put:[ replace value:false. ].
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  5760
        bindings at:#replaceAllAction put:[ replace value:true. ].
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  5761
    ].
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  5762
    bindings at:#ignoreCase put:caseHolder.
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  5763
    bindings at:#patternList put:LastSearchPatterns.
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  5764
    modal ifTrue:[
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  5765
        searchBox := SimpleDialog new.
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  5766
    ] ifFalse:[
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  5767
        searchBox := ApplicationModel new.
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  5768
        searchBox createBuilder.
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  5769
    ].
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  5770
    searchBox resources:(self resources).
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  5771
    bldr := searchBox builder.
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  5772
    bldr addBindings:bindings.
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  5773
    searchBox allButOpenFrom:(self class searchReplaceDialogSpec).
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  5774
    (bldr componentAt:#nextButton) cursor:(Cursor thumbsUp).
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  5775
    (bldr componentAt:#prevButton) cursor:(Cursor thumbsUp).
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  5776
    (bldr componentAt:#cancelButton) cursor:(Cursor thumbsDown).
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  5777
    modal ifTrue:[
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  5778
        searchBox openDialog.
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  5779
        searchBox accepted ifTrue:[
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  5780
            action value:flag
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  5781
        ].
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  5782
    ] ifFalse:[
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  5783
        (bldr componentAt:#nextButton) isReturnButton:false.
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  5784
        (bldr componentAt:#cancelButton)
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  5785
            label:(resources string:'Close');
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  5786
            action:[ searchBox closeRequest ].
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  5787
        
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  5788
        "/ searchBox masterApplication:self application.
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  5789
        
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  5790
        self topView beMaster.
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  5791
        (searchBox window)
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  5792
            beSlave;
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  5793
            openInGroup:(self windowGroup).
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  5794
        
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  5795
        "/ searchBox window open.
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  5796
        
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  5797
        searchBox window assignKeyboardFocusToFirstInputField.
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  5798
    ]
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  5799
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  5800
    "Modified: / 11-07-2006 / 11:20:06 / fm"
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  5801
!
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  5802
121
claus
parents: 118
diff changeset
  5803
showDeleted
claus
parents: 118
diff changeset
  5804
    "open a readonly editor on all deleted text"
claus
parents: 118
diff changeset
  5805
claus
parents: 118
diff changeset
  5806
    |v|
claus
parents: 118
diff changeset
  5807
claus
parents: 118
diff changeset
  5808
    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
  5809
    v readOnly:true.
121
claus
parents: 118
diff changeset
  5810
    v topView label:'deleted text'.
2624
22d352e56c27 preps for special characters
Claus Gittinger <cg@exept.de>
parents: 2617
diff changeset
  5811
!
22d352e56c27 preps for special characters
Claus Gittinger <cg@exept.de>
parents: 2617
diff changeset
  5812
3221
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  5813
sort:how ignoreCase:ignoreCase fromLine:start toLine:end
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  5814
    "sort the selected lines"
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  5815
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  5816
    |lines extractor fetcher lineWise nStr n s words|
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  5817
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  5818
    lineWise := true.
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  5819
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  5820
    how == #lines ifTrue:[
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  5821
        extractor := [:l | l withoutLeadingSeparators].
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  5822
    ] ifFalse:[ how == #linesByFirstWord ifTrue:[
3222
7910868ec31e sort functions
Claus Gittinger <cg@exept.de>
parents: 3221
diff changeset
  5823
        extractor := [:l | ((l asCollectionOfWords select:[:w | w isEmpty or:[w first isLetterOrDigit]]) at:1 ifAbsent:'')].
3221
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  5824
    ] ifFalse:[ how == #linesByNthWord ifTrue:[
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  5825
        nStr := Dialog request:'Word (1..)'.
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  5826
        nStr isEmptyOrNil ifTrue:[^ self].
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  5827
        n := Integer readFrom:nStr onError:[^ self].
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  5828
3227
49b97c45652a sort by nth word: do not skip non-alphanumeric words
Claus Gittinger <cg@exept.de>
parents: 3223
diff changeset
  5829
        extractor := [:l | ((l asCollectionOfWords) at:n ifAbsent:'')].
3221
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  5830
    ] ifFalse:[ how == #words ifTrue:[
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  5831
        lineWise := false.
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  5832
        extractor := [:w | w].
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  5833
    ] ifFalse:[
3296
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
  5834
        self error:'unknown sort criteria: ', how printString.
3221
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  5835
    ]]]].
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  5836
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  5837
    ignoreCase ifTrue:[
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  5838
        fetcher := [:l | (extractor value:l) asLowercase].
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  5839
    ] ifFalse:[
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  5840
        fetcher := extractor.
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  5841
    ].
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  5842
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  5843
    lineWise ifTrue:[
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  5844
        start == end ifTrue:[^ self ].
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  5845
        lines := (start to:end) collect:[:lineNr | (self listAt:lineNr) ? ''].
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  5846
        lines := lines sort:[:l1 :l2 | (fetcher value:l1) < (fetcher value:l2)].
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  5847
        (start to:end) with:lines do:[:lineNr :line | self replaceLine:lineNr with:line].
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  5848
        self textChanged.
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  5849
        ^ self.
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  5850
    ].
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  5851
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  5852
    s := self selectionAsString.
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  5853
    words := s asCollectionOfWords.
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  5854
    words := words sort:[:w1 :w2 | (fetcher value:w1) < (fetcher value:w2)].
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  5855
    s := words asStringCollection asStringWith:Character space.
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  5856
    self replace:s.
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  5857
    self textChanged.
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  5858
!
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  5859
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  5860
sortSelection:how ignoreCase:ignoreCase
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  5861
    "sort the selected lines"
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  5862
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  5863
    |start end|
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  5864
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  5865
    selectionStartLine isNil ifTrue:[^ self].
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  5866
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  5867
    start := selectionStartLine.
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  5868
    end := selectionEndLine.
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  5869
    (selectionEndCol == 0) ifTrue:[
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  5870
        end := end - 1
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  5871
    ].
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  5872
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  5873
    self
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  5874
        undoableDo:[
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  5875
            self sort:how ignoreCase:ignoreCase fromLine:start toLine:end.
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  5876
        ]
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  5877
        info:'sort'
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  5878
!
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  5879
2624
22d352e56c27 preps for special characters
Claus Gittinger <cg@exept.de>
parents: 2617
diff changeset
  5880
specialCharacters
2915
8db67a5d1ccb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2912
diff changeset
  5881
    CharacterSetView
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  5882
	openAsInputFor:self
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  5883
	label:'Special Character Input'
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  5884
	clickLabel:'Click to Insert Character'.
2866
9dd71df46f73 specialCharacters menu item
Claus Gittinger <cg@exept.de>
parents: 2857
diff changeset
  5885
!
9dd71df46f73 specialCharacters menu item
Claus Gittinger <cg@exept.de>
parents: 2857
diff changeset
  5886
2989
5dcc2912bcb6 undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents: 2984
diff changeset
  5887
undoablePaste:someText
3495
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  5888
    self undoablePaste:someText info:nil.
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  5889
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  5890
    "Modified: / 28-07-2007 / 13:25:46 / cg"
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  5891
!
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  5892
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  5893
undoablePaste:someText info:infoOrNil
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  5894
    self 
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  5895
        undoableDo:[
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  5896
            self paste:someText.
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  5897
        ]
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  5898
        info:infoOrNil
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  5899
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  5900
    "Created: / 28-07-2007 / 13:25:30 / cg"
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  5901
!
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  5902
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  5903
undoablePasteOrReplace:someText info:infoOrNil
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  5904
    self 
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  5905
        undoableDo:[
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  5906
            self pasteOrReplace:someText.
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  5907
        ]
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  5908
        info:infoOrNil
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  5909
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  5910
    "Created: / 28-07-2007 / 13:26:16 / cg"
2989
5dcc2912bcb6 undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents: 2984
diff changeset
  5911
!
5dcc2912bcb6 undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents: 2984
diff changeset
  5912
2724
23f4e16dc4f4 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2720
diff changeset
  5913
withSelfAndTextForPasteDo:aBlock
23f4e16dc4f4 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2720
diff changeset
  5914
    "common code for paste/replace of the copybuffer"
23f4e16dc4f4 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2720
diff changeset
  5915
23f4e16dc4f4 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2720
diff changeset
  5916
    |sel|
23f4e16dc4f4 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2720
diff changeset
  5917
23f4e16dc4f4 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2720
diff changeset
  5918
    self checkModificationsAllowed ifFalse:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  5919
	self flash.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  5920
	^ self
2724
23f4e16dc4f4 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2720
diff changeset
  5921
    ].
23f4e16dc4f4 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2720
diff changeset
  5922
23f4e16dc4f4 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2720
diff changeset
  5923
    sel := self getTextSelectionOrTextSelectionFromHistory.
23f4e16dc4f4 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2720
diff changeset
  5924
    sel notNil ifTrue:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  5925
	aBlock value:self value:sel.
2724
23f4e16dc4f4 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2720
diff changeset
  5926
    ]
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  5927
! !
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  5928
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5929
!EditTextView methodsFor:'private'!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5930
331
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
  5931
checkModificationsAllowed
1300
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  5932
    "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
  5933
     evaluate the exceptionBlock if not.
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  5934
     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
  5935
     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
  5936
1733
c5139b7402f0 use self isReadonly; readOnly may now be a valueHolder.
Claus Gittinger <cg@exept.de>
parents: 1732
diff changeset
  5937
    self isReadOnly ifTrue: [
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  5938
	exceptionBlock isNil ifTrue:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  5939
	    ^ false
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  5940
	].
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  5941
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  5942
	(exceptionBlock value:'Text may not be modified') ~~ true ifTrue:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  5943
	    ^ false
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  5944
	]
331
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
  5945
    ].
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
  5946
    ^ true
1300
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  5947
1577
4e487247ad33 dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents: 1568
diff changeset
  5948
    "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
  5949
!
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
  5950
2596
933689d5bd9c alternative selection color
Claus Gittinger <cg@exept.de>
parents: 2589
diff changeset
  5951
currentSelectionBgColor
933689d5bd9c alternative selection color
Claus Gittinger <cg@exept.de>
parents: 2589
diff changeset
  5952
    typeOfSelection == #paste ifTrue:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  5953
	^ DefaultAlternativeSelectionBackgroundColor ? selectionBgColor
2596
933689d5bd9c alternative selection color
Claus Gittinger <cg@exept.de>
parents: 2589
diff changeset
  5954
    ].
933689d5bd9c alternative selection color
Claus Gittinger <cg@exept.de>
parents: 2589
diff changeset
  5955
    ^ super currentSelectionBgColor
933689d5bd9c alternative selection color
Claus Gittinger <cg@exept.de>
parents: 2589
diff changeset
  5956
933689d5bd9c alternative selection color
Claus Gittinger <cg@exept.de>
parents: 2589
diff changeset
  5957
    "
933689d5bd9c alternative selection color
Claus Gittinger <cg@exept.de>
parents: 2589
diff changeset
  5958
     DefaultAlternativeSelectionBackgroundColor := Color yellow blendWith:Color green
933689d5bd9c alternative selection color
Claus Gittinger <cg@exept.de>
parents: 2589
diff changeset
  5959
    "
933689d5bd9c alternative selection color
Claus Gittinger <cg@exept.de>
parents: 2589
diff changeset
  5960
!
933689d5bd9c alternative selection color
Claus Gittinger <cg@exept.de>
parents: 2589
diff changeset
  5961
933689d5bd9c alternative selection color
Claus Gittinger <cg@exept.de>
parents: 2589
diff changeset
  5962
currentSelectionFgColor
933689d5bd9c alternative selection color
Claus Gittinger <cg@exept.de>
parents: 2589
diff changeset
  5963
    typeOfSelection == #paste ifTrue:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  5964
	^ DefaultAlternativeSelectionForegroundColor ? selectionFgColor
2596
933689d5bd9c alternative selection color
Claus Gittinger <cg@exept.de>
parents: 2589
diff changeset
  5965
    ].
933689d5bd9c alternative selection color
Claus Gittinger <cg@exept.de>
parents: 2589
diff changeset
  5966
    ^ super currentSelectionFgColor
933689d5bd9c alternative selection color
Claus Gittinger <cg@exept.de>
parents: 2589
diff changeset
  5967
!
933689d5bd9c alternative selection color
Claus Gittinger <cg@exept.de>
parents: 2589
diff changeset
  5968
2647
23dca8f032c3 changed st80Mode from classVar to userPreferences value
Claus Gittinger <cg@exept.de>
parents: 2627
diff changeset
  5969
st80EditMode
23dca8f032c3 changed st80Mode from classVar to userPreferences value
Claus Gittinger <cg@exept.de>
parents: 2627
diff changeset
  5970
    ^ st80Mode ? (UserPreferences current st80EditMode)
23dca8f032c3 changed st80Mode from classVar to userPreferences value
Claus Gittinger <cg@exept.de>
parents: 2627
diff changeset
  5971
!
23dca8f032c3 changed st80Mode from classVar to userPreferences value
Claus Gittinger <cg@exept.de>
parents: 2627
diff changeset
  5972
2225
65ac7cbffc60 added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents: 2213
diff changeset
  5973
suppressEmphasisInSelection
65ac7cbffc60 added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents: 2213
diff changeset
  5974
    "selection is shown without emphasis"
65ac7cbffc60 added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents: 2213
diff changeset
  5975
65ac7cbffc60 added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents: 2213
diff changeset
  5976
    ^ true
65ac7cbffc60 added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents: 2213
diff changeset
  5977
!
65ac7cbffc60 added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents: 2213
diff changeset
  5978
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5979
textChanged
522
aa9458e4643e indent/undent did not trigger a modify
ca
parents: 503
diff changeset
  5980
    "my text was modified (internally).
aa9458e4643e indent/undent did not trigger a modify
ca
parents: 503
diff changeset
  5981
     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
  5982
     contentsChanged, which is triggered when the size has changed, and
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5983
     is used to notify scrollers, other views etc.)"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5984
641
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  5985
    self contentsChanged.
1015
caf7265128b9 clear modified on accept.
Claus Gittinger <cg@exept.de>
parents: 1013
diff changeset
  5986
    self modified:true.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5987
    contentsWasSaved := false
641
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  5988
1015
caf7265128b9 clear modified on accept.
Claus Gittinger <cg@exept.de>
parents: 1013
diff changeset
  5989
    "Modified: 14.2.1997 / 16:58:38 / cg"
2207
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  5990
!
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  5991
2617
a9b1af787406 typo on method name
Claus Gittinger <cg@exept.de>
parents: 2606
diff changeset
  5992
textChangedButNoSizeChange
2207
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  5993
    "my text was modified (internally).
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  5994
     Sent whenever text has been edited (not to confuse with
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  5995
     contentsChanged, which is triggered when the size has changed, and
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  5996
     is used to notify scrollers, other views etc.)"
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  5997
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  5998
    self modified:true.
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  5999
    contentsWasSaved := false
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  6000
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  6001
    "Modified: 14.2.1997 / 16:58:38 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6002
! !
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6003
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6004
!EditTextView methodsFor:'queries'!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6005
1526
7676f301bb8f added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents: 1515
diff changeset
  6006
currentLine
7676f301bb8f added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents: 1515
diff changeset
  6007
    "the current line (for relative gotos)"
7676f301bb8f added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents: 1515
diff changeset
  6008
7676f301bb8f added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents: 1515
diff changeset
  6009
    ^ cursorLine
7676f301bb8f added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents: 1515
diff changeset
  6010
7676f301bb8f added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents: 1515
diff changeset
  6011
    "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
  6012
!
7676f301bb8f added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents: 1515
diff changeset
  6013
1878
d93809bda6c8 added #isKeyboardConsumer
Claus Gittinger <cg@exept.de>
parents: 1850
diff changeset
  6014
isKeyboardConsumer
d93809bda6c8 added #isKeyboardConsumer
Claus Gittinger <cg@exept.de>
parents: 1850
diff changeset
  6015
    "return true, if the receiver is a keyboard consumer;
d93809bda6c8 added #isKeyboardConsumer
Claus Gittinger <cg@exept.de>
parents: 1850
diff changeset
  6016
     Return true here, redefined from SimpleView."
d93809bda6c8 added #isKeyboardConsumer
Claus Gittinger <cg@exept.de>
parents: 1850
diff changeset
  6017
3476
41dde91ae706 isKeyboardConsumer: returns false if readOnly
ca
parents: 3474
diff changeset
  6018
    ^ self isReadOnly not
1878
d93809bda6c8 added #isKeyboardConsumer
Claus Gittinger <cg@exept.de>
parents: 1850
diff changeset
  6019
!
d93809bda6c8 added #isKeyboardConsumer
Claus Gittinger <cg@exept.de>
parents: 1850
diff changeset
  6020
997
615a5a19c5bf specClass
ca
parents: 991
diff changeset
  6021
specClass
1390
99674e1d9c85 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
  6022
    "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
  6023
997
615a5a19c5bf specClass
ca
parents: 991
diff changeset
  6024
    self class == EditTextView ifTrue:[^ TextEditorSpec].
1049
24360c8891d6 specClass query
Claus Gittinger <cg@exept.de>
parents: 1037
diff changeset
  6025
    ^ super specClass
24360c8891d6 specClass query
Claus Gittinger <cg@exept.de>
parents: 1037
diff changeset
  6026
1390
99674e1d9c85 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
  6027
    "Modified: / 31.10.1997 / 19:48:19 / cg"
997
615a5a19c5bf specClass
ca
parents: 991
diff changeset
  6028
!
615a5a19c5bf specClass
ca
parents: 991
diff changeset
  6029
324
9eec6d69e155 better Tab key handling
Claus Gittinger <cg@exept.de>
parents: 323
diff changeset
  6030
tabMeansNextField
323
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
  6031
    "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
  6032
313
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  6033
    "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
  6034
1733
c5139b7402f0 use self isReadonly; readOnly may now be a valueHolder.
Claus Gittinger <cg@exept.de>
parents: 1732
diff changeset
  6035
    ^ self isReadOnly or:[tabMeansNextField]
324
9eec6d69e155 better Tab key handling
Claus Gittinger <cg@exept.de>
parents: 323
diff changeset
  6036
9eec6d69e155 better Tab key handling
Claus Gittinger <cg@exept.de>
parents: 323
diff changeset
  6037
    "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
  6038
!
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  6039
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6040
widthOfContents
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6041
    "return the width of the contents in pixels
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6042
     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
  6043
     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
  6044
     line (and possibly see the cursor behind the line)"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6045
697
0f258f02e8ea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 693
diff changeset
  6046
    |w dev|
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6047
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6048
    w := super widthOfContents.
697
0f258f02e8ea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 693
diff changeset
  6049
    (dev := device) isNil ifTrue:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6050
	"/ really dont know ...
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6051
	dev := Screen current
606
682579fa3b62 fixed #widthOfContents if no device is known
Claus Gittinger <cg@exept.de>
parents: 597
diff changeset
  6052
    ].
697
0f258f02e8ea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 693
diff changeset
  6053
    ^ w + (font widthOn:dev)
0f258f02e8ea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 693
diff changeset
  6054
0f258f02e8ea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 693
diff changeset
  6055
    "Modified: 28.5.1996 / 19:32:25 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6056
! !
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6057
1588
e2e4ceeed3da category change
Claus Gittinger <cg@exept.de>
parents: 1585
diff changeset
  6058
!EditTextView methodsFor:'realization'!
e2e4ceeed3da category change
Claus Gittinger <cg@exept.de>
parents: 1585
diff changeset
  6059
e2e4ceeed3da category change
Claus Gittinger <cg@exept.de>
parents: 1585
diff changeset
  6060
realize
e2e4ceeed3da category change
Claus Gittinger <cg@exept.de>
parents: 1585
diff changeset
  6061
    "make the view visible - scroll to make the cursor visible."
e2e4ceeed3da category change
Claus Gittinger <cg@exept.de>
parents: 1585
diff changeset
  6062
e2e4ceeed3da category change
Claus Gittinger <cg@exept.de>
parents: 1585
diff changeset
  6063
    super realize.
e2e4ceeed3da category change
Claus Gittinger <cg@exept.de>
parents: 1585
diff changeset
  6064
e2e4ceeed3da category change
Claus Gittinger <cg@exept.de>
parents: 1585
diff changeset
  6065
    self makeCursorVisible.
1993
5ffe0b3943cd #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1967
diff changeset
  6066
    cursorFgColor := cursorFgColor onDevice:device.
5ffe0b3943cd #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1967
diff changeset
  6067
    cursorBgColor := cursorBgColor onDevice:device.
1588
e2e4ceeed3da category change
Claus Gittinger <cg@exept.de>
parents: 1585
diff changeset
  6068
e2e4ceeed3da category change
Claus Gittinger <cg@exept.de>
parents: 1585
diff changeset
  6069
    "Modified: 20.12.1996 / 14:16:05 / cg"
e2e4ceeed3da category change
Claus Gittinger <cg@exept.de>
parents: 1585
diff changeset
  6070
    "Created: 24.7.1997 / 18:24:12 / cg"
e2e4ceeed3da category change
Claus Gittinger <cg@exept.de>
parents: 1585
diff changeset
  6071
! !
e2e4ceeed3da category change
Claus Gittinger <cg@exept.de>
parents: 1585
diff changeset
  6072
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6073
!EditTextView methodsFor:'redrawing'!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6074
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6075
redrawCursorIfBetweenVisibleLine:startVisLine and:endVisLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6076
    "redraw the cursor, if it sits in a line range"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6077
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6078
    cursorShown ifTrue:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6079
	cursorVisibleLine notNil ifTrue:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6080
	    (cursorVisibleLine between:startVisLine and:endVisLine) ifTrue:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6081
		self drawCursorCharacter
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6082
	    ]
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6083
	]
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6084
    ]
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  6085
!
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  6086
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6087
redrawCursorIfInVisibleLine:visLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6088
    "redraw the cursor, if it sits in visible line"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6089
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6090
    cursorShown ifTrue:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6091
	(visLine == cursorVisibleLine) ifTrue:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6092
	    self drawCursorCharacter
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6093
	]
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6094
    ]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6095
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6096
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6097
redrawFromVisibleLine:startVisLine to:endVisLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6098
    "redraw a visible line range"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6099
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6100
    super redrawFromVisibleLine:startVisLine to:endVisLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6101
    self redrawCursorIfBetweenVisibleLine:startVisLine and:endVisLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6102
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6103
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6104
redrawVisibleLine:visLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6105
    "redraw a visible line"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6106
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6107
    super redrawVisibleLine:visLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6108
    self redrawCursorIfInVisibleLine:visLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6109
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6110
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6111
redrawVisibleLine:visLine col:colNr
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6112
    "redraw the single character in visibleline at colNr"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6113
3510
4bd0b20bd05d cursor-only redrawing, with vertical-insertion cursor
Claus Gittinger <cg@exept.de>
parents: 3495
diff changeset
  6114
    super redrawVisibleLine:visLine col:colNr.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6115
    cursorShown ifTrue:[
3510
4bd0b20bd05d cursor-only redrawing, with vertical-insertion cursor
Claus Gittinger <cg@exept.de>
parents: 3495
diff changeset
  6116
        (visLine == cursorVisibleLine) ifTrue:[
4bd0b20bd05d cursor-only redrawing, with vertical-insertion cursor
Claus Gittinger <cg@exept.de>
parents: 3495
diff changeset
  6117
            (colNr == cursorCol) ifTrue:[
4bd0b20bd05d cursor-only redrawing, with vertical-insertion cursor
Claus Gittinger <cg@exept.de>
parents: 3495
diff changeset
  6118
                self drawCursorCharacter.
4bd0b20bd05d cursor-only redrawing, with vertical-insertion cursor
Claus Gittinger <cg@exept.de>
parents: 3495
diff changeset
  6119
                ^ self
4bd0b20bd05d cursor-only redrawing, with vertical-insertion cursor
Claus Gittinger <cg@exept.de>
parents: 3495
diff changeset
  6120
            ]
4bd0b20bd05d cursor-only redrawing, with vertical-insertion cursor
Claus Gittinger <cg@exept.de>
parents: 3495
diff changeset
  6121
        ]
4bd0b20bd05d cursor-only redrawing, with vertical-insertion cursor
Claus Gittinger <cg@exept.de>
parents: 3495
diff changeset
  6122
    ].
4bd0b20bd05d cursor-only redrawing, with vertical-insertion cursor
Claus Gittinger <cg@exept.de>
parents: 3495
diff changeset
  6123
4bd0b20bd05d cursor-only redrawing, with vertical-insertion cursor
Claus Gittinger <cg@exept.de>
parents: 3495
diff changeset
  6124
    "Modified: / 05-11-2007 / 17:35:53 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6125
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6126
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6127
redrawVisibleLine:visLine from:startCol
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6128
    "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
  6129
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6130
    super redrawVisibleLine:visLine from:startCol.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6131
    self redrawCursorIfInVisibleLine:visLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6132
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6133
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6134
redrawVisibleLine:visLine from:startCol to:endCol
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6135
    "redraw a visible line from startCol to endCol"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6136
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6137
    super redrawVisibleLine:visLine from:startCol to:endCol.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6138
    self redrawCursorIfInVisibleLine:visLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6139
! !
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6140
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6141
!EditTextView methodsFor:'scrolling'!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6142
2331
218a017dc1f3 additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents: 2323
diff changeset
  6143
additionalMarginForHorizontalScroll
218a017dc1f3 additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents: 2323
diff changeset
  6144
    "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
  6145
     width of the document would allow.
218a017dc1f3 additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents: 2323
diff changeset
  6146
     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
  6147
     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
  6148
     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
  6149
218a017dc1f3 additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents: 2323
diff changeset
  6150
    ^ 10 max:font width
218a017dc1f3 additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents: 2323
diff changeset
  6151
!
218a017dc1f3 additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents: 2323
diff changeset
  6152
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6153
halfPageDown
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6154
    "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
  6155
     within the real text  "
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6156
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6157
    |prevCursorLine|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6158
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6159
    prevCursorLine := cursorVisibleLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6160
    super halfPageDown.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6161
    self cursorVisibleLine:prevCursorLine col:cursorCol
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6162
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6163
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6164
halfPageUp
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6165
    "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
  6166
     within the real text  "
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6167
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6168
    |prevCursorLine|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6169
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6170
    prevCursorLine := cursorVisibleLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6171
    super halfPageUp.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6172
    self cursorVisibleLine:prevCursorLine col:cursorCol
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6173
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6174
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6175
originChanged:delta
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6176
    "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
  6177
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6178
    super originChanged:delta.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6179
    "
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6180
     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
  6181
    "
2422
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  6182
    self updateCursorVisibleLine.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6183
    prevCursorState ifTrue:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6184
	self showCursor
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6185
    ]
1577
4e487247ad33 dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents: 1568
diff changeset
  6186
4e487247ad33 dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents: 1568
diff changeset
  6187
    "Modified: / 17.6.1998 / 16:13:24 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6188
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6189
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6190
originWillChange
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6191
    "sent before scrolling - have to hide the cursor"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6192
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6193
    prevCursorState := cursorShown.
1601
57dde4dfee7e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  6194
    "/ cursorShown := false.
1591
d84c117e71cc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1590
diff changeset
  6195
    cursorShown ifTrue:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6196
	self hideCursor
1591
d84c117e71cc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1590
diff changeset
  6197
    ]
d84c117e71cc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1590
diff changeset
  6198
1601
57dde4dfee7e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  6199
    "Modified: / 6.7.1998 / 13:07:23 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6200
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6201
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6202
pageDown
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6203
    "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
  6204
     within the real text  "
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6205
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6206
    |prevCursorLine|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6207
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6208
    prevCursorLine := cursorVisibleLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6209
    super pageDown.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6210
    self cursorVisibleLine:prevCursorLine col:cursorCol
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6211
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6212
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6213
pageUp
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6214
    "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
  6215
     within the real text  "
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6216
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6217
    |prevCursorLine|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6218
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6219
    prevCursorLine := cursorVisibleLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6220
    super pageUp.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6221
    self cursorVisibleLine:prevCursorLine col:cursorCol
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6222
! !
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6223
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6224
!EditTextView methodsFor:'searching'!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6225
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6226
searchBwd:pattern ifAbsent:aBlock
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6227
    "do a backward search"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6228
2822
08ceab3fc237 search refactored;
Claus Gittinger <cg@exept.de>
parents: 2819
diff changeset
  6229
    self searchBwd:pattern ignoreCase:false ifAbsent:aBlock
1339
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  6230
!
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  6231
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  6232
searchBwd:pattern ignoreCase:ign ifAbsent:aBlock
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  6233
    "do a backward search"
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  6234
2756
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
  6235
    |pos startLine startCol|
1339
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  6236
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  6237
    cursorLine isNil ifTrue:[^ self].
2756
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
  6238
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
  6239
    pos := self startPositionForSearchBackward.
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
  6240
    startLine := pos y.
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
  6241
    startCol := pos x.
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
  6242
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6243
    self
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6244
	searchBackwardFor:pattern
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6245
	ignoreCase:ign
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6246
	startingAtLine:startLine col:startCol
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6247
	ifFound:[:line :col |
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6248
	    self cursorMovementAllowed ifTrue:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6249
		self cursorLine:line col:col.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6250
	    ].
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6251
	    self showMatch:pattern atLine:line col:col.
1339
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  6252
"/            self makeLineVisible:cursorLine
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6253
	    typeOfSelection := #search]
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6254
	ifAbsent:aBlock
1339
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  6255
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  6256
    "Modified: 9.10.1997 / 13:02:13 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6257
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6258
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6259
searchForAndSelectMatchingParenthesis
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6260
    "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
  6261
2554
ec6aca20825f refactored
Claus Gittinger <cg@exept.de>
parents: 2544
diff changeset
  6262
    self searchForAndSelectMatchingParenthesisFromLine:cursorLine col:cursorCol
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6263
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6264
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6265
searchForMatchingParenthesis
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6266
    "search for a matching parenthesis starting at cursor position.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6267
     Search for the corresponding character is done forward if its an opening,
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6268
     backwards if its a closing parenthesis.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6269
     Positions the cursor if found, peeps if not"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6270
2822
08ceab3fc237 search refactored;
Claus Gittinger <cg@exept.de>
parents: 2819
diff changeset
  6271
    self cursorMovementAllowed ifFalse:[^ self].
08ceab3fc237 search refactored;
Claus Gittinger <cg@exept.de>
parents: 2819
diff changeset
  6272
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6273
    self
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6274
	searchForMatchingParenthesisFromLine:cursorLine col:cursorCol
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6275
	ifFound:[:line :col | self cursorLine:line col:col]
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6276
	ifNotFound:[self showNotFound]
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6277
	onError:[self beep]
1339
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  6278
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  6279
    "Modified: 9.10.1997 / 12:56:30 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6280
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6281
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6282
searchFwd:pattern ifAbsent:aBlock
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6283
    "do a forward search"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6284
2756
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
  6285
    |pos startLine startCol|
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
  6286
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
  6287
    pos := self startPositionForSearchForward.
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
  6288
    startLine := pos y.
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
  6289
    startCol := pos x.
1339
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  6290
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6291
    self
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6292
	searchFwd:pattern
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6293
	startingAtLine:startLine col:startCol
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6294
	ifAbsent:aBlock
1339
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  6295
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  6296
    "Modified: 9.10.1997 / 12:58:59 / cg"
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  6297
!
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  6298
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  6299
searchFwd:pattern ignoreCase:ign ifAbsent:aBlock
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  6300
    "do a forward search"
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  6301
2756
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
  6302
    |pos startLine startCol|
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
  6303
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
  6304
    pos := self startPositionForSearchForward.
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
  6305
    startLine := pos y.
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
  6306
    startCol := pos x.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6307
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6308
    self
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6309
	searchFwd:pattern
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6310
	ignoreCase:ign
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6311
	startingAtLine:startLine col:startCol
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6312
	ifAbsent:aBlock
1339
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  6313
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  6314
    "Modified: 9.10.1997 / 12:58:59 / cg"
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  6315
    "Created: 9.10.1997 / 13:04:10 / cg"
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  6316
!
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  6317
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  6318
searchFwd:pattern ignoreCase:ign startingAtLine:startLine col:startCol ifAbsent:aBlock
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  6319
    "do a forward search"
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  6320
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  6321
    cursorLine isNil ifTrue:[^ self].
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6322
    self
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6323
	searchForwardFor:pattern
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6324
	ignoreCase:ign
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6325
	startingAtLine:startLine col:startCol
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6326
	ifFound:[:line :col |
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6327
	    self cursorMovementAllowed ifTrue:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6328
		self cursorLine:line col:col.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6329
	    ].
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6330
	    self showMatch:pattern atLine:line col:col.
1339
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  6331
"/            self makeLineVisible:cursorLine
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6332
	    typeOfSelection := #search]
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6333
	ifAbsent:aBlock
1339
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  6334
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  6335
    "Modified: 9.10.1997 / 12:57:47 / cg"
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  6336
    "Created: 9.10.1997 / 13:01:12 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6337
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6338
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6339
searchFwd:pattern startingAtLine:startLine col:startCol ifAbsent:aBlock
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6340
    "do a forward search"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6341
2822
08ceab3fc237 search refactored;
Claus Gittinger <cg@exept.de>
parents: 2819
diff changeset
  6342
    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
  6343
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6344
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6345
setSearchPattern
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6346
    "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
  6347
     cursor to start of pattern"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6348
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6349
    |sel|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6350
559
3ff87e9447c6 keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents: 522
diff changeset
  6351
    "/
3ff87e9447c6 keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents: 522
diff changeset
  6352
    "/ 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
  6353
    "/ original string (for search after again)
3ff87e9447c6 keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents: 522
diff changeset
  6354
    "/
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6355
    (lastString notNil
565
f2a0499ba3d0 preserve search pattern
Claus Gittinger <cg@exept.de>
parents: 559
diff changeset
  6356
     and:[lastReplacement notNil
f2a0499ba3d0 preserve search pattern
Claus Gittinger <cg@exept.de>
parents: 559
diff changeset
  6357
     and:[typeOfSelection ~~ #search]]) ifTrue:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6358
	lastString isString ifTrue:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6359
	    lastSearchPattern := lastString.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6360
	] ifFalse:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6361
	    lastSearchPattern := lastString asStringWithoutFinalCR.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6362
	].
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6363
	^ self
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6364
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6365
559
3ff87e9447c6 keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents: 522
diff changeset
  6366
    "/
3ff87e9447c6 keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents: 522
diff changeset
  6367
    "/ if there is a selection:
3ff87e9447c6 keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents: 522
diff changeset
  6368
    "/    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
  6369
    "/    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
  6370
    "/    it did not result from a paste.
3ff87e9447c6 keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents: 522
diff changeset
  6371
    "/    (to allow search-paste to be repeated)
3ff87e9447c6 keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents: 522
diff changeset
  6372
    "/
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6373
    sel := self selection.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6374
    sel notNil ifTrue:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6375
	(lastSearchPattern isNil
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6376
	or:[typeOfSelection ~~ #paste]) ifTrue:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6377
	    self cursorLine:selectionStartLine col:selectionStartCol.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6378
	    lastSearchPattern := sel asStringWithoutFinalCR withMatchEscapes
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6379
	]
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6380
    ]
559
3ff87e9447c6 keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents: 522
diff changeset
  6381
565
f2a0499ba3d0 preserve search pattern
Claus Gittinger <cg@exept.de>
parents: 559
diff changeset
  6382
    "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
  6383
!
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
  6384
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
  6385
startPositionForSearchBackward
2822
08ceab3fc237 search refactored;
Claus Gittinger <cg@exept.de>
parents: 2819
diff changeset
  6386
    ^ self startPositionForSearchBackwardBasedOnCursorOrSelection
08ceab3fc237 search refactored;
Claus Gittinger <cg@exept.de>
parents: 2819
diff changeset
  6387
!
08ceab3fc237 search refactored;
Claus Gittinger <cg@exept.de>
parents: 2819
diff changeset
  6388
08ceab3fc237 search refactored;
Claus Gittinger <cg@exept.de>
parents: 2819
diff changeset
  6389
startPositionForSearchBackwardBasedOnCursorOrSelection
2756
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
  6390
    |startLine startCol|
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
  6391
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
  6392
    selectionStartLine notNil ifTrue:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6393
	startLine := selectionStartLine.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6394
	startCol := selectionStartCol
2756
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
  6395
    ] ifFalse:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6396
	cursorLine isNil ifTrue:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6397
	    startLine := list size.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6398
	    startCol := self listAt:startLine size.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6399
	] ifFalse:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6400
	    startLine := cursorLine min:list size.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6401
	    startCol := cursorCol
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6402
	]
2756
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
  6403
    ].
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
  6404
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
  6405
    ^ startCol @ cursorLine
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
  6406
!
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
  6407
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
  6408
startPositionForSearchForward
2822
08ceab3fc237 search refactored;
Claus Gittinger <cg@exept.de>
parents: 2819
diff changeset
  6409
    ^ self startPositionForSearchForwardBasedOnCursorOrSelection
08ceab3fc237 search refactored;
Claus Gittinger <cg@exept.de>
parents: 2819
diff changeset
  6410
!
08ceab3fc237 search refactored;
Claus Gittinger <cg@exept.de>
parents: 2819
diff changeset
  6411
08ceab3fc237 search refactored;
Claus Gittinger <cg@exept.de>
parents: 2819
diff changeset
  6412
startPositionForSearchForwardBasedOnCursorOrSelection
2756
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
  6413
    |startCol|
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
  6414
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6415
    "/ if there is no selection and the cursor is at the origin,
2756
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
  6416
    "/ 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
  6417
    startCol := cursorCol.
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
  6418
    self hasSelection ifFalse:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6419
	(cursorLine == 1 and:[cursorCol == 1]) ifTrue:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6420
	    startCol := 0
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6421
	]
2756
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
  6422
    ].
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
  6423
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
  6424
    ^ startCol @ cursorLine
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6425
! !
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6426
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6427
!EditTextView methodsFor:'selections'!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6428
3023
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  6429
addToSelectionAfter:aBlock
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  6430
    "Pokud existuje selekce, upravi ji
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  6431
     podle aktualni pozice kurzoru a pozice
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  6432
     po provedeni blocku.
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  6433
     Urceno k implementaci Shift-Home a Shift-End
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  6434
     Nejak nevim, jak to presneji popsat :-)"
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  6435
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  6436
    |startLine startCol endLine endCol |
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  6437
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  6438
    self hasSelection ifTrue: [
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6439
	startLine := selectionStartLine .
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6440
	startCol := selectionStartCol .
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6441
	endLine := selectionEndLine .
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6442
	endCol := selectionEndCol .
3023
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  6443
    ] ifFalse: [
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6444
	startLine := endLine :=  cursorLine .
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6445
	startCol := endCol := cursorCol .
3023
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  6446
    ].
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  6447
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  6448
    "deselectim a provedu presun kurzoru..."
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  6449
    self unselect .
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  6450
    aBlock value .
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  6451
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  6452
    "funguje dost mizerne, jen na jednom radku..."
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  6453
    (startCol - cursorCol) abs <= (endCol - cursorCol) abs
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6454
	ifTrue: [
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6455
	    startCol := cursorCol.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6456
	] ifFalse: [
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6457
	    endCol := cursorCol - 1.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6458
	].
3023
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  6459
    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
  6460
!
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  6461
1850
82516928e791 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1849
diff changeset
  6462
autoMoveCursorToEndOfSelection
82516928e791 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1849
diff changeset
  6463
    "return true, if the cursor should be automatically moved to the
82516928e791 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1849
diff changeset
  6464
     end of a selection.
82516928e791 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1849
diff changeset
  6465
     Redefined to return false in terminaViews, where the cursor should
82516928e791 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1849
diff changeset
  6466
     not be affected by selecting"
82516928e791 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1849
diff changeset
  6467
82516928e791 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1849
diff changeset
  6468
    ^ true
82516928e791 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1849
diff changeset
  6469
!
82516928e791 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1849
diff changeset
  6470
2606
6a3ab90d339f redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents: 2599
diff changeset
  6471
changeTypeOfSelectionTo:newType
6a3ab90d339f redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents: 2599
diff changeset
  6472
    typeOfSelection ~~ newType ifTrue:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6473
	typeOfSelection := newType.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6474
	selectionStartLine notNil ifTrue:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6475
	    self
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6476
		redrawFromLine:selectionStartLine col:selectionStartCol
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6477
		toLine:selectionEndLine col:selectionEndCol
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6478
	].
2606
6a3ab90d339f redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents: 2599
diff changeset
  6479
    ].
6a3ab90d339f redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents: 2599
diff changeset
  6480
!
6a3ab90d339f redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents: 2599
diff changeset
  6481
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6482
selectAll
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6483
    "select the whole text.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6484
     redefined to send super selectFrom... since we dont want the
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6485
     cursor to be moved in this case."
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6486
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6487
    list isNil ifTrue:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6488
	self unselect
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6489
    ] ifFalse:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6490
	super selectFromLine:1 col:1 toLine:(list size + 1) col:0.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6491
	typeOfSelection := nil
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6492
    ]
1082
ccc3aa4268c1 better #selectAll
Claus Gittinger <cg@exept.de>
parents: 1054
diff changeset
  6493
ccc3aa4268c1 better #selectAll
Claus Gittinger <cg@exept.de>
parents: 1054
diff changeset
  6494
    "Modified: 28.2.1997 / 19:14:54 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6495
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6496
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6497
selectCursorLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6498
    "select cursorline"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6499
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6500
    self selectFromLine:cursorLine col:1 toLine:cursorLine+1 col:0
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6501
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6502
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6503
selectCursorLineFromBeginning
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6504
    "select cursorline up to cursor position"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6505
823
fc61564f7832 escape selects up to previous character
Claus Gittinger <cg@exept.de>
parents: 785
diff changeset
  6506
    cursorCol > 1 ifTrue:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6507
	self selectFromLine:cursorLine col:1
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6508
		     toLine:cursorLine col:(cursorCol-1)
823
fc61564f7832 escape selects up to previous character
Claus Gittinger <cg@exept.de>
parents: 785
diff changeset
  6509
    ]
fc61564f7832 escape selects up to previous character
Claus Gittinger <cg@exept.de>
parents: 785
diff changeset
  6510
fc61564f7832 escape selects up to previous character
Claus Gittinger <cg@exept.de>
parents: 785
diff changeset
  6511
    "Modified: 16.8.1996 / 19:14:14 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6512
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6513
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6514
selectExpandCursorLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6515
    "expand selection by one line or select cursorline"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6516
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6517
    selectionStartLine isNil ifTrue:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6518
	self selectCursorLine
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6519
    ] ifFalse:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6520
	self selectFromLine:selectionStartLine col:selectionStartCol
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6521
		     toLine:cursorLine+1 col:0.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6522
	self makeLineVisible:selectionEndLine
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6523
    ]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6524
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6525
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6526
selectFromBeginning
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6527
    "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
  6528
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6529
    |col|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6530
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6531
    list isNil ifTrue:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6532
	self unselect
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6533
    ] ifFalse:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6534
	cursorCol == 0 ifTrue:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6535
	    col := 0
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6536
	] ifFalse:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6537
	    col := cursorCol - 1
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6538
	].
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6539
	super selectFromLine:1 col:1 toLine:cursorLine col:col.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6540
	typeOfSelection := nil
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6541
    ]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6542
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6543
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6544
selectFromLine:startLine col:startCol toLine:endLine col:endCol
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6545
    "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
  6546
     for easier editing. Also typeOfSelection is nilled here."
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6547
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6548
    super selectFromLine:startLine col:startCol toLine:endLine col:endCol.
1850
82516928e791 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1849
diff changeset
  6549
    (selectionEndLine notNil and:[self autoMoveCursorToEndOfSelection]) ifTrue:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6550
	self cursorLine:selectionEndLine col:(selectionEndCol + 1).
1198
1c5390d2d3fb care for failed selection when positioning cursor.
ca
parents: 1177
diff changeset
  6551
    ].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6552
    typeOfSelection := nil
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6553
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6554
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6555
selectUpToEnd
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6556
    "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
  6557
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6558
    list isNil ifTrue:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6559
	self unselect
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6560
    ] ifFalse:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6561
	super selectFromLine:cursorLine col:cursorCol toLine:(list size + 1) col:0.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6562
	typeOfSelection := nil
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6563
    ]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6564
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6565
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6566
selectWordUnderCursor
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6567
    "select the word under the cursor"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6568
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6569
    self selectWordAtLine:cursorLine col:cursorCol
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6570
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6571
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6572
unselect
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6573
    "forget and unhilight selection - must take care of cursor here"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6574
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6575
    |wasOn|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6576
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6577
    wasOn := self hideCursor.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6578
    super unselect.
2606
6a3ab90d339f redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents: 2599
diff changeset
  6579
    typeOfSelection := nil.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6580
    wasOn ifTrue:[self showCursor]
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  6581
! !
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  6582
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  6583
!EditTextView methodsFor:'undo & again'!
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  6584
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  6585
addUndo:action
2989
5dcc2912bcb6 undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents: 2984
diff changeset
  6586
    ^ undoSupport addUndo:action.
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  6587
!
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  6588
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  6589
again
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  6590
    "repeat the last action (which was a cut or replace).
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  6591
     If current selection is not last string, search forward to
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6592
     next occurrence of it before repeating the last operation."
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  6593
2323
ef201d5d0689 fixed search-again if cursor is at start of text, and
Claus Gittinger <cg@exept.de>
parents: 2310
diff changeset
  6594
    |s l c sel savedSelectStyle startColForSearch|
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  6595
2579
74d3798f4200 do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents: 2574
diff changeset
  6596
    lastString isNil ifTrue:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6597
	^ false
2579
74d3798f4200 do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents: 2574
diff changeset
  6598
    ].
74d3798f4200 do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents: 2574
diff changeset
  6599
3127
29767bf8a215 better info of replace action (compound-undo-action has info, too)
Claus Gittinger <cg@exept.de>
parents: 3115
diff changeset
  6600
    self undoableDo:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6601
	s := lastString asString.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6602
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6603
	"remove final cr"
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6604
	(s endsWith:Character cr) ifTrue:[s := s copyWithoutLast:1].
3127
29767bf8a215 better info of replace action (compound-undo-action has info, too)
Claus Gittinger <cg@exept.de>
parents: 3115
diff changeset
  6605
    "/        s := s withoutSpaces.        "XXX - replacing text with spaces ..."
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6606
	savedSelectStyle := selectStyle.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6607
	selectStyle := nil.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6608
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6609
	sel := self selection.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6610
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6611
	"if we are already there (after a find), ommit search"
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6612
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6613
	(sel notNil and:[sel asString withoutSeparators = s]) ifTrue:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6614
	    l := selectionStartLine "cursorLine".
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6615
	    c := selectionStartCol "cursorCol".
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6616
	    self deleteSelection.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6617
	    lastReplacement notNil ifTrue:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6618
		self insertLines:lastReplacement asStringCollection withCR:false.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6619
		self selectFromLine:l col:c toLine:cursorLine col:(cursorCol - 1).
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6620
	    ].
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6621
	    selectStyle := savedSelectStyle.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6622
	    ^ true
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6623
	].
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6624
	startColForSearch := cursorCol.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6625
	sel isNil ifTrue:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6626
	    startColForSearch := startColForSearch - 1
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6627
	].
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6628
	self searchForwardFor:s startingAtLine:cursorLine col:startColForSearch
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6629
	    ifFound:
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6630
		[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6631
		    :line :col |
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6632
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6633
		    |repl|
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6634
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6635
		    self selectFromLine:line col:col
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6636
				 toLine:line col:(col + s size - 1).
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6637
		    self makeLineVisible:line.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6638
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6639
		    self deleteSelection.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6640
		    lastReplacement notNil ifTrue:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6641
			lastReplacement isString ifFalse:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6642
			    repl := lastReplacement asString "withoutSpaces"
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6643
			] ifTrue:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6644
			    repl := lastReplacement "withoutSpaces".
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6645
			].
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6646
			self insertLines:repl asStringCollection withCR:false.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6647
			self selectFromLine:line col:col toLine:cursorLine col:(cursorCol - 1).
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6648
			undoSupport actionInfo:'replace'.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6649
		    ].
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6650
		    selectStyle := savedSelectStyle.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6651
		    ^ true
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6652
		]
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6653
	   ifAbsent:
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6654
		[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6655
		    self sensor compressKeyPressEventsWithKey:#Again.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6656
		    self showNotFound.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6657
		    selectStyle := savedSelectStyle.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6658
		    ^ false
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6659
		].
3127
29767bf8a215 better info of replace action (compound-undo-action has info, too)
Claus Gittinger <cg@exept.de>
parents: 3115
diff changeset
  6660
    ].
2730
61a2f1981ac6 Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents: 2725
diff changeset
  6661
61a2f1981ac6 Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents: 2725
diff changeset
  6662
    ^ true.
501
13fc7b9ce5cb fixed (?) again-replace
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  6663
840
b0071cea13fd fixed Again when spaces are replaced
Claus Gittinger <cg@exept.de>
parents: 828
diff changeset
  6664
    "Modified: 9.10.1996 / 16:14:11 / cg"
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  6665
!
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  6666
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  6667
hasRedoAction
2989
5dcc2912bcb6 undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents: 2984
diff changeset
  6668
    ^ undoSupport hasRedoAction.
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  6669
!
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  6670
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  6671
hasUndoAction
2989
5dcc2912bcb6 undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents: 2984
diff changeset
  6672
    ^ undoSupport hasUndoAction.
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  6673
!
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  6674
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6675
multipleAgain
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6676
    "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
  6677
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6678
    [self again] whileTrue:[]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6679
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6680
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  6681
nonUndoableDo:aBlock
2989
5dcc2912bcb6 undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents: 2984
diff changeset
  6682
    undoSupport nonUndoableDo:aBlock.
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  6683
!
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  6684
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  6685
redo
2989
5dcc2912bcb6 undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents: 2984
diff changeset
  6686
    undoSupport hasRedoAction ifFalse:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6687
	self beep
2989
5dcc2912bcb6 undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents: 2984
diff changeset
  6688
    ] ifTrue:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6689
	undoSupport redo.
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  6690
    ]
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  6691
!
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  6692
121
claus
parents: 118
diff changeset
  6693
undo
2989
5dcc2912bcb6 undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents: 2984
diff changeset
  6694
    undoSupport hasUndoAction ifFalse:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6695
	self beep
2989
5dcc2912bcb6 undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents: 2984
diff changeset
  6696
    ] ifTrue:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6697
	undoSupport undo.
121
claus
parents: 118
diff changeset
  6698
    ]
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  6699
!
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  6700
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  6701
undoableDo:aBlock
3495
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  6702
    self undoableDo:aBlock info:nil.
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  6703
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  6704
    "Modified: / 28-07-2007 / 13:20:14 / cg"
3130
c0f39f9f28d6 undoable keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3127
diff changeset
  6705
!
c0f39f9f28d6 undoable keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3127
diff changeset
  6706
c0f39f9f28d6 undoable keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3127
diff changeset
  6707
undoableDo:aBlock info:aString
3154
42bf7ebd54c8 refadctored intention revealing code:
Claus Gittinger <cg@exept.de>
parents: 3150
diff changeset
  6708
    self checkModificationsAllowed ifFalse:[
3495
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  6709
        "/ will trigger an error-dialog there (no need for undo-carekeeping)
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  6710
        aBlock value.
3154
42bf7ebd54c8 refadctored intention revealing code:
Claus Gittinger <cg@exept.de>
parents: 3150
diff changeset
  6711
    ] ifTrue:[
3495
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  6712
        undoSupport undoableDo:aBlock info:aString.
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  6713
    ].
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  6714
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  6715
    "Modified: / 28-07-2007 / 13:21:00 / cg"
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  6716
! !
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  6717
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  6718
!EditTextView::EditAction class methodsFor:'instance creation'!
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  6719
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  6720
line1:arg1 col1:arg2 line2:arg3 col2:arg4
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  6721
    ^ self new line1:arg1 col1:arg2 line2:arg3 col2:arg4
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  6722
!
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  6723
3115
b75128334006 info string in undo
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
  6724
line1:arg1 col1:arg2 line2:arg3 col2:arg4 info:info
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6725
    ^ (self new line1:arg1 col1:arg2 line2:arg3 col2:arg4) info:info
3115
b75128334006 info string in undo
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
  6726
!
b75128334006 info string in undo
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
  6727
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  6728
line:arg1 col:arg2 character:arg3
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  6729
    ^ self new line:arg1 col:arg2 character:arg3
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  6730
!
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  6731
3115
b75128334006 info string in undo
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
  6732
line:arg1 col:arg2 character:arg3 info:info
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6733
    ^ (self new line:arg1 col:arg2 character:arg3) info:info
3115
b75128334006 info string in undo
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
  6734
!
b75128334006 info string in undo
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
  6735
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  6736
line:arg1 col:arg2 characters:arg3 info:info
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  6737
    ^ (self new line:arg1 col:arg2 characters:arg3) info:info
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  6738
!
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  6739
3156
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  6740
line:arg1 col:arg2 info:arg3
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  6741
    ^ self new line:arg1 col:arg2 info:arg3
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  6742
!
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  6743
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  6744
line:arg1 col:arg2 string:arg3
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  6745
    ^ self new line:arg1 col:arg2 string:arg3
3115
b75128334006 info string in undo
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
  6746
!
b75128334006 info string in undo
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
  6747
b75128334006 info string in undo
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
  6748
line:arg1 col:arg2 string:arg3 info:info
b75128334006 info string in undo
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
  6749
    ^ (self new line:arg1 col:arg2 string:arg3) info:info
3130
c0f39f9f28d6 undoable keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3127
diff changeset
  6750
!
c0f39f9f28d6 undoable keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3127
diff changeset
  6751
c0f39f9f28d6 undoable keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3127
diff changeset
  6752
line:arg1 string:arg3 info:info
c0f39f9f28d6 undoable keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3127
diff changeset
  6753
    ^ (self new line:arg1 string:arg3) info:info
3131
8f21dba07d24 undoable format
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
  6754
!
8f21dba07d24 undoable format
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
  6755
8f21dba07d24 undoable format
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
  6756
text:arg info:info
8f21dba07d24 undoable format
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
  6757
    ^ (self new text:arg) info:info
3115
b75128334006 info string in undo
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
  6758
! !
b75128334006 info string in undo
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
  6759
b75128334006 info string in undo
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
  6760
!EditTextView::EditAction methodsFor:'accessing'!
b75128334006 info string in undo
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
  6761
b75128334006 info string in undo
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
  6762
info
b75128334006 info string in undo
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
  6763
    ^ userFriendlyInfo
b75128334006 info string in undo
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
  6764
!
b75128334006 info string in undo
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
  6765
b75128334006 info string in undo
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
  6766
info:aString
b75128334006 info string in undo
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
  6767
    userFriendlyInfo := aString
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  6768
! !
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  6769
3400
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  6770
!EditTextView::EditAction methodsFor:'combining'!
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  6771
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  6772
canCombineWithPreviousPasteStringAction: aPasteStringAction
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  6773
    ^ false.
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  6774
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  6775
    "Created: / 25-09-2006 / 12:16:25 / cg"
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  6776
! !
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  6777
3156
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  6778
!EditTextView::EditAction methodsFor:'queries'!
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  6779
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  6780
canCombineWithNext:nextAction
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  6781
    ^ false
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  6782
! !
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  6783
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  6784
!EditTextView::DeleteRange methodsFor:'accessing'!
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  6785
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6786
line1:line1Arg col1:col1Arg line2:line2Arg col2:col2Arg
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  6787
    "set instance variables (automatically generated)"
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  6788
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  6789
    self assert:(line1Arg notNil).
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  6790
    self assert:(col1Arg notNil).
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  6791
    self assert:(line2Arg notNil).
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  6792
    self assert:(col2Arg notNil).
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  6793
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  6794
    line1 := line1Arg.
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  6795
    col1 := col1Arg.
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  6796
    line2 := line2Arg.
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  6797
    col2 := col2Arg.
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  6798
! !
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  6799
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  6800
!EditTextView::DeleteRange methodsFor:'execution'!
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  6801
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6802
executeIn:editor
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  6803
    editor unselect.
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6804
    editor
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6805
	deleteFromLine:line1
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6806
	col:col1
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6807
	toLine:line2
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6808
	col:col2.
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  6809
    editor cursorLine:line1 col:col1.
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  6810
! !
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  6811
3156
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  6812
!EditTextView::DeleteCharacters methodsFor:'accessing'!
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  6813
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  6814
col1
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  6815
    ^ col1
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  6816
!
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  6817
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  6818
col2
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  6819
    ^ col2
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  6820
!
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  6821
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  6822
line
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  6823
    ^ line
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  6824
!
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  6825
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6826
line:lineArg col1:col1Arg col2:col2Arg
3156
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  6827
    "set instance variables (automatically generated)"
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  6828
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  6829
    self assert:(lineArg notNil).
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  6830
    self assert:(col1Arg notNil).
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  6831
    self assert:(col2Arg notNil).
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  6832
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  6833
    line := lineArg.
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  6834
    col1 := col1Arg.
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  6835
    col2 := col2Arg.
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  6836
!
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  6837
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6838
line:lineArg col:colArg info:infoArg
3156
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  6839
    self assert:(lineArg notNil).
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  6840
    self assert:(colArg notNil).
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  6841
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  6842
    line := lineArg.
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  6843
    col1 := col2 := colArg.
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  6844
    self info:infoArg.
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  6845
! !
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  6846
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  6847
!EditTextView::DeleteCharacters methodsFor:'combining'!
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  6848
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  6849
canCombineWithNext:anotherAction
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  6850
    ^ anotherAction perform:#canCombineWithPreviousDeleteCharactersAction: with:self ifNotUnderstood:false
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  6851
!
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  6852
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6853
canCombineWithPreviousDeleteCharactersAction:previousDeleteAction
3156
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  6854
    "I will combine only if we both are single character deletes,
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  6855
     and my col-to-delete is the next after anotherDeleteActions col-to-delete.
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  6856
     (i.e. single-character typing)"
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  6857
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  6858
    previousDeleteAction line == line ifTrue:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6859
	previousDeleteAction col2 == (col1-1) ifTrue:[
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6860
	    ^ true
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6861
	].
3156
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  6862
    ].
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  6863
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  6864
    ^ false
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  6865
!
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  6866
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6867
combineWithNext:nextDeleteAction
3156
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  6868
    self assert:(line == nextDeleteAction line).
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  6869
    self assert:(col2 == (nextDeleteAction col1 - 1)).
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  6870
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  6871
    col2 := nextDeleteAction col2.
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  6872
    userFriendlyInfo := 'insert ' , (col2 - col1 + 1) printString
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  6873
! !
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  6874
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  6875
!EditTextView::DeleteCharacters methodsFor:'execution'!
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  6876
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6877
executeIn:editor
3156
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  6878
    editor unselect.
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6879
    editor
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6880
	deleteFromLine:line
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6881
	col:col1
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6882
	toLine:line
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6883
	col:col2.
3156
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  6884
    editor cursorLine:line col:col1.
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  6885
! !
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  6886
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  6887
!EditTextView::EditMode class methodsFor:'constants'!
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  6888
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  6889
insertAndSelectMode
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  6890
    ^ InsertAndSelectMode
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  6891
!
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  6892
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  6893
insertMode
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  6894
    ^ InsertMode
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  6895
!
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  6896
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  6897
overwriteMode
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  6898
    ^ OverwriteMode
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  6899
! !
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  6900
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  6901
!EditTextView::EditMode class methodsFor:'queries'!
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  6902
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  6903
isInsertAndSelectMode
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  6904
    ^ false
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  6905
!
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  6906
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  6907
isInsertMode
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  6908
    ^ false
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  6909
!
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  6910
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  6911
symbolicName
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  6912
    self subclassResponsibility
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  6913
! !
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  6914
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  6915
!EditTextView::EditMode::InsertAndSelectMode class methodsFor:'info'!
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  6916
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  6917
infoPrintString
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  6918
    ^ 'IS'
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  6919
! !
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  6920
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  6921
!EditTextView::EditMode::InsertAndSelectMode class methodsFor:'queries'!
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  6922
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  6923
isInsertAndSelectMode
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  6924
    ^ true
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  6925
!
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  6926
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  6927
isInsertMode
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  6928
    ^ true
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  6929
! !
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  6930
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  6931
!EditTextView::EditMode::InsertMode class methodsFor:'info'!
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  6932
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  6933
infoPrintString
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  6934
    ^ 'I'
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  6935
! !
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  6936
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  6937
!EditTextView::EditMode::InsertMode class methodsFor:'queries'!
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  6938
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  6939
isInsertMode
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  6940
    ^ true
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  6941
! !
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  6942
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  6943
!EditTextView::EditMode::OverwriteMode class methodsFor:'info'!
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  6944
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  6945
infoPrintString
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  6946
    ^ 'O'
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  6947
! !
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  6948
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  6949
!EditTextView::PasteString methodsFor:'accessing'!
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  6950
3400
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  6951
col
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  6952
    ^ col
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  6953
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  6954
    "Created: / 25-09-2006 / 12:19:59 / cg"
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  6955
!
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  6956
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  6957
col2
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  6958
    ^ col + string size - 1
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  6959
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  6960
    "Created: / 25-09-2006 / 12:20:18 / cg"
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  6961
!
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  6962
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  6963
line
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  6964
    ^ line
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  6965
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  6966
    "Created: / 25-09-2006 / 12:21:08 / cg"
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  6967
!
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  6968
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6969
line:lineArg col:colArg string:stringArg
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  6970
    self assert:(lineArg notNil).
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  6971
    self assert:(colArg notNil).
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  6972
    self assert:(stringArg notNil).
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  6973
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  6974
    line := lineArg.
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  6975
    col := colArg.
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  6976
    string := stringArg.
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  6977
!
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  6978
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  6979
line:lineArg col:colArg string:stringArg selected:selectedArg
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  6980
    self assert:(lineArg notNil).
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  6981
    self assert:(colArg notNil).
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  6982
    self assert:(stringArg notNil).
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  6983
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  6984
    line := lineArg.
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  6985
    col := colArg.
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  6986
    string := stringArg.
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  6987
    selected := selectedArg.
3400
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  6988
!
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  6989
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  6990
string
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  6991
    ^ string
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  6992
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  6993
    "Created: / 25-09-2006 / 12:25:59 / cg"
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  6994
! !
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  6995
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  6996
!EditTextView::PasteString methodsFor:'combining'!
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  6997
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  6998
canCombineWithNext:anotherAction
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  6999
    ^ anotherAction canCombineWithPreviousPasteStringAction:self
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  7000
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  7001
    "Created: / 25-09-2006 / 12:15:59 / cg"
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  7002
!
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  7003
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  7004
canCombineWithPreviousPasteStringAction: previousPasteAction
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  7005
    "I will combine only if we both are single character inserts,
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  7006
     and my col-to-insert is the next after anotherInsertActions end-col.
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  7007
     (i.e. single-character deletes)"
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  7008
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  7009
    previousPasteAction line == line ifTrue:[
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  7010
        previousPasteAction col == (self col2+1) ifTrue:[
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  7011
            ^ true
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  7012
        ].
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  7013
    ].
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  7014
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  7015
    ^ false
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  7016
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  7017
    "Modified: / 25-09-2006 / 12:22:21 / cg"
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  7018
!
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  7019
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  7020
combineWithNext:nextPasteAction
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  7021
    |s1 s2|
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  7022
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  7023
    self assert:(line == nextPasteAction line).
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  7024
    self assert:((col - 1) == (nextPasteAction col2)).
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  7025
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  7026
    s1 := nextPasteAction string.
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  7027
    s1 isString ifFalse:[s1 := s1 asStringWith:nil].
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  7028
    s2 := string.
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  7029
    s2 isString ifFalse:[s2 := s2 asStringWith:nil].
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  7030
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  7031
    string := s1, s2. 
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  7032
    col := nextPasteAction col.
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  7033
    userFriendlyInfo := 'delete ' , string size printString
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  7034
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  7035
    "Created: / 25-09-2006 / 12:24:10 / cg"
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  7036
! !
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  7037
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  7038
!EditTextView::PasteString methodsFor:'execution'!
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  7039
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  7040
executeIn:editor
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  7041
    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
  7042
    editor paste:string.
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  7043
    selected ~~ true ifTrue:[
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  7044
	editor unselect
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  7045
    ].
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  7046
! !
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  7047
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  7048
!EditTextView::ReplaceCharacter methodsFor:'accessing'!
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  7049
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  7050
col
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  7051
    ^ col
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  7052
!
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  7053
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  7054
col1
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  7055
    ^ col
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  7056
!
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  7057
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  7058
col2
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  7059
    ^ col
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  7060
!
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  7061
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  7062
line
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  7063
    ^ line
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  7064
!
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  7065
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  7066
line:lineArg col:colArg character:characterArg
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  7067
    line := lineArg.
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  7068
    col := colArg.
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  7069
    character := characterArg.
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  7070
! !
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  7071
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  7072
!EditTextView::ReplaceCharacter methodsFor:'execution'!
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  7073
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  7074
executeIn:editor
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  7075
    editor
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  7076
	replace:character
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  7077
	atLine:line
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  7078
	col:col.
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  7079
    editor cursorLine:line col:col.
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  7080
! !
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  7081
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  7082
!EditTextView::ReplaceCharacters methodsFor:'accessing'!
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  7083
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  7084
characters
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  7085
    ^ characters
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  7086
!
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  7087
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  7088
col1
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  7089
    ^ col1
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  7090
!
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  7091
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  7092
col2
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  7093
    ^ col2
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  7094
!
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  7095
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  7096
line
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  7097
    ^ line
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  7098
!
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  7099
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  7100
line:lineArg col:colArg character:characterArg
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  7101
    line := lineArg.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  7102
    col1 := col2 := colArg.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  7103
    characters := characterArg asString.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  7104
!
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  7105
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  7106
line:lineArg col:colArg characters:charactersArg
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  7107
    line := lineArg.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  7108
    col1 := colArg.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  7109
    characters := charactersArg asString.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  7110
    col2 := col1 + charactersArg size - 1
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  7111
! !
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  7112
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  7113
!EditTextView::ReplaceCharacters methodsFor:'combining'!
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  7114
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  7115
canCombineWithNext:anotherAction
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  7116
    ^ anotherAction perform:#canCombineWithPreviousReplaceCharactersAction: with:self ifNotUnderstood:false
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  7117
!
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  7118
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  7119
canCombineWithPreviousReplaceCharactersAction:previousReplaceAction
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  7120
    "I will combine only if we both are single character deletes,
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  7121
     and my col-to-delete is the next after anotherDeleteActions col-to-delete.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  7122
     (i.e. single-character typing)"
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  7123
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  7124
    previousReplaceAction line == line ifTrue:[
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  7125
        previousReplaceAction col2 == (col1-1) ifTrue:[
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  7126
            ^ true
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  7127
        ].
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  7128
    ].
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  7129
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  7130
    ^ false
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  7131
!
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  7132
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  7133
combineWithNext:nextReplaceAction
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  7134
    self assert:(line == nextReplaceAction line).
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  7135
    self assert:(self col2 == (nextReplaceAction col1 - 1)).
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  7136
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  7137
    col2 := nextReplaceAction col2.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  7138
    userFriendlyInfo := 'replace ' , (col2 - col1 + 1) printString.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  7139
    characters := characters , nextReplaceAction characters.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  7140
! !
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  7141
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  7142
!EditTextView::ReplaceCharacters methodsFor:'execution'!
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  7143
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  7144
executeIn:editor
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  7145
    editor
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  7146
        replaceString:characters
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  7147
        atLine:line
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  7148
        col:col1.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  7149
    editor cursorLine:line col:col1.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  7150
! !
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  7151
3131
8f21dba07d24 undoable format
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
  7152
!EditTextView::ReplaceContents methodsFor:'accessing'!
8f21dba07d24 undoable format
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
  7153
8f21dba07d24 undoable format
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
  7154
text:something
8f21dba07d24 undoable format
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
  7155
    text := something.
8f21dba07d24 undoable format
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
  7156
! !
8f21dba07d24 undoable format
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
  7157
8f21dba07d24 undoable format
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
  7158
!EditTextView::ReplaceContents methodsFor:'execution'!
8f21dba07d24 undoable format
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
  7159
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  7160
executeIn:editor
3131
8f21dba07d24 undoable format
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
  7161
    editor contents:text
8f21dba07d24 undoable format
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
  7162
! !
8f21dba07d24 undoable format
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
  7163
3130
c0f39f9f28d6 undoable keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3127
diff changeset
  7164
!EditTextView::ReplaceLine methodsFor:'accessing'!
c0f39f9f28d6 undoable keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3127
diff changeset
  7165
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  7166
line:lineArg string:stringArg
3130
c0f39f9f28d6 undoable keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3127
diff changeset
  7167
    line := lineArg.
c0f39f9f28d6 undoable keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3127
diff changeset
  7168
    text := stringArg.
c0f39f9f28d6 undoable keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3127
diff changeset
  7169
! !
c0f39f9f28d6 undoable keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3127
diff changeset
  7170
c0f39f9f28d6 undoable keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3127
diff changeset
  7171
!EditTextView::ReplaceLine methodsFor:'execution'!
c0f39f9f28d6 undoable keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3127
diff changeset
  7172
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  7173
executeIn:editor
3130
c0f39f9f28d6 undoable keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3127
diff changeset
  7174
    editor list at:line put:text.
c0f39f9f28d6 undoable keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3127
diff changeset
  7175
    editor invalidateLine:line
c0f39f9f28d6 undoable keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3127
diff changeset
  7176
! !
c0f39f9f28d6 undoable keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3127
diff changeset
  7177
3402
d6545009a22b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3400
diff changeset
  7178
!EditTextView::ReplaceLines methodsFor:'accessing'!
d6545009a22b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3400
diff changeset
  7179
d6545009a22b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3400
diff changeset
  7180
line:lineArg lines:lineCollectionArg
d6545009a22b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3400
diff changeset
  7181
    line := lineArg.
d6545009a22b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3400
diff changeset
  7182
    text := lineCollectionArg.
d6545009a22b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3400
diff changeset
  7183
d6545009a22b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3400
diff changeset
  7184
    "Created: / 09-10-2006 / 10:35:22 / cg"
d6545009a22b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3400
diff changeset
  7185
! !
d6545009a22b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3400
diff changeset
  7186
d6545009a22b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3400
diff changeset
  7187
!EditTextView::ReplaceLines methodsFor:'execution'!
d6545009a22b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3400
diff changeset
  7188
d6545009a22b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3400
diff changeset
  7189
executeIn:editor
d6545009a22b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3400
diff changeset
  7190
    |lnr|
d6545009a22b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3400
diff changeset
  7191
d6545009a22b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3400
diff changeset
  7192
    lnr := line.
d6545009a22b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3400
diff changeset
  7193
    text do:[:eachLine |
d6545009a22b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3400
diff changeset
  7194
        editor list at:lnr put:eachLine.
d6545009a22b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3400
diff changeset
  7195
        editor invalidateLine:lnr.
d6545009a22b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3400
diff changeset
  7196
        lnr := lnr + 1.
d6545009a22b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3400
diff changeset
  7197
    ].
d6545009a22b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3400
diff changeset
  7198
d6545009a22b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3400
diff changeset
  7199
    "Modified: / 09-10-2006 / 10:39:16 / cg"
d6545009a22b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3400
diff changeset
  7200
! !
d6545009a22b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3400
diff changeset
  7201
865
d42c7c99e67d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 840
diff changeset
  7202
!EditTextView class methodsFor:'documentation'!
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  7203
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  7204
version
3542
30ed44ed0178 +joinLines (CTRL-j);
Claus Gittinger <cg@exept.de>
parents: 3517
diff changeset
  7205
    ^ '$Header: /cvs/stx/stx/libwidg/EditTextView.st,v 1.422 2008-02-04 12:19:29 cg Exp $'
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  7206
! !