EditTextView.st
author Claus Gittinger <cg@exept.de>
Sat, 28 Jan 2017 18:24:44 +0100
changeset 6068 01e28002daf7
parent 6050 4fb30794fc81
child 6070 18e8ef85aedf
permissions -rw-r--r--
#REFACTORING by cg class: EditTextView changed: #drawCursor:with:and: draw on gc
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
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
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
5239
0312ca8fd55e class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5226
diff changeset
    14
"{ NameSpace: Smalltalk }"
0312ca8fd55e class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5226
diff changeset
    15
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    16
TextView subclass:#EditTextView
4826
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
    17
	instanceVariableNames:'cursorLine cursorVisibleLine cursorCol cursorShown
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
    18
		prevCursorState readOnly modifiedChannel fixedSize exceptionBlock
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
    19
		cursorFgColor cursorBgColor cursorNoFocusFgColor cursorType
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
    20
		cursorTypeNoFocus typeOfSelection lastAction replacing
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
    21
		showMatchingParenthesis hasKeyboardFocus acceptAction lockUpdates
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
    22
		tabMeansNextField autoIndent insertMode editMode trimBlankLines
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
    23
		wordWrap replacementWordSelectStyle acceptChannel acceptEnabled
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
    24
		st80Mode disableIfInvisible cursorMovementWhenUpdating learnMode
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
    25
		learnedMacro cursorLineHolder cursorColHolder tabRequiresControl
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
    26
		undoSupport lastStringFromReplaceForNextSearch
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
    27
		lastReplacementInfo completionSupport codeAspectHolder'
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
    28
	classVariableNames:'DefaultCursorForegroundColor DefaultCursorBackgroundColor
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
    29
		DefaultCursorType DefaultCursorNoFocusForegroundColor
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
    30
		DefaultCursorTypeNoFocus LastColumnNumberForSort Macros'
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
    31
	poolDictionaries:''
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
    32
	category:'Views-Text'
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    33
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    34
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
    35
Object subclass:#EditAction
4826
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
    36
	instanceVariableNames:'userFriendlyInfo'
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
    37
	classVariableNames:''
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
    38
	poolDictionaries:''
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
    39
	privateIn:EditTextView
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
    40
!
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
    41
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
    42
EditTextView::EditAction subclass:#DeleteRange
4826
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
    43
	instanceVariableNames:'line1 col1 line2 col2'
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
    44
	classVariableNames:''
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
    45
	poolDictionaries:''
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
    46
	privateIn:EditTextView
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
    47
!
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
    48
3156
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
    49
EditTextView::EditAction subclass:#DeleteCharacters
4826
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
    50
	instanceVariableNames:'line col1 col2'
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
    51
	classVariableNames:''
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
    52
	poolDictionaries:''
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
    53
	privateIn:EditTextView
3156
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
    54
!
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
    55
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
    56
Object subclass:#EditMode
4826
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
    57
	instanceVariableNames:''
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
    58
	classVariableNames:''
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
    59
	poolDictionaries:''
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
    60
	privateIn:EditTextView
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
    61
!
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
    62
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
    63
EditTextView::EditMode subclass:#InsertAndSelectMode
4826
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
    64
	instanceVariableNames:''
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
    65
	classVariableNames:''
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
    66
	poolDictionaries:''
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
    67
	privateIn:EditTextView::EditMode
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
    68
!
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
    69
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
    70
EditTextView::EditMode subclass:#InsertMode
4826
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
    71
	instanceVariableNames:''
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
    72
	classVariableNames:''
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
    73
	poolDictionaries:''
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
    74
	privateIn:EditTextView::EditMode
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
    75
!
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
    76
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
    77
EditTextView::EditMode subclass:#OverwriteMode
4826
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
    78
	instanceVariableNames:''
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
    79
	classVariableNames:'InsertMode OverwriteMode InsertAndSelectMode'
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
    80
	poolDictionaries:''
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
    81
	privateIn:EditTextView::EditMode
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
    82
!
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
    83
3813
8d719ca5812d dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3811
diff changeset
    84
Query subclass:#ExecutingMacroQuery
4826
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
    85
	instanceVariableNames:''
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
    86
	classVariableNames:''
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
    87
	poolDictionaries:''
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
    88
	privateIn:EditTextView
3813
8d719ca5812d dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3811
diff changeset
    89
!
8d719ca5812d dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3811
diff changeset
    90
4048
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
    91
Object subclass:#LastReplacementInfo
4826
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
    92
	instanceVariableNames:'lastReplacement lastStringToReplace lastReplaceWasMatch
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
    93
		lastReplaceIgnoredCase stillCollectingInput previousReplacements'
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
    94
	classVariableNames:''
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
    95
	poolDictionaries:''
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
    96
	privateIn:EditTextView
4048
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
    97
!
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
    98
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
    99
EditTextView::EditAction subclass:#PasteString
4826
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
   100
	instanceVariableNames:'line col string selected'
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
   101
	classVariableNames:''
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
   102
	poolDictionaries:''
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
   103
	privateIn:EditTextView
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
   104
!
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
   105
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
   106
EditTextView::EditAction subclass:#ReplaceCharacter
4826
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
   107
	instanceVariableNames:'line col character'
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
   108
	classVariableNames:''
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
   109
	poolDictionaries:''
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
   110
	privateIn:EditTextView
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
   111
!
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
   112
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
   113
EditTextView::EditAction subclass:#ReplaceCharacters
4826
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
   114
	instanceVariableNames:'line col1 col2 characters'
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
   115
	classVariableNames:''
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
   116
	poolDictionaries:''
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
   117
	privateIn:EditTextView
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
   118
!
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
   119
3131
8f21dba07d24 undoable format
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
   120
EditTextView::EditAction subclass:#ReplaceContents
4826
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
   121
	instanceVariableNames:'text'
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
   122
	classVariableNames:''
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
   123
	poolDictionaries:''
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
   124
	privateIn:EditTextView
3131
8f21dba07d24 undoable format
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
   125
!
8f21dba07d24 undoable format
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
   126
3130
c0f39f9f28d6 undoable keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3127
diff changeset
   127
EditTextView::EditAction subclass:#ReplaceLine
4826
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
   128
	instanceVariableNames:'line text'
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
   129
	classVariableNames:''
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
   130
	poolDictionaries:''
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
   131
	privateIn:EditTextView
3130
c0f39f9f28d6 undoable keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3127
diff changeset
   132
!
c0f39f9f28d6 undoable keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3127
diff changeset
   133
3402
d6545009a22b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3400
diff changeset
   134
EditTextView::EditAction subclass:#ReplaceLines
4826
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
   135
	instanceVariableNames:'line text'
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
   136
	classVariableNames:''
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
   137
	poolDictionaries:''
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
   138
	privateIn:EditTextView
3402
d6545009a22b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3400
diff changeset
   139
!
d6545009a22b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3400
diff changeset
   140
5689
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
   141
EditTextView::EditAction subclass:#RestoreSelectionAndCursor
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
   142
	instanceVariableNames:'cursorLine cursorCol selectionStartLine selectionStartCol
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
   143
		selectionEndLine selectionEndCol'
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
   144
	classVariableNames:''
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
   145
	poolDictionaries:''
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
   146
	privateIn:EditTextView
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
   147
!
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
   148
865
d42c7c99e67d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 840
diff changeset
   149
!EditTextView class methodsFor:'documentation'!
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   150
33
5eeef3ea8ebd added access methods for cursorLine & cursorCol
claus
parents: 25
diff changeset
   151
copyright
5eeef3ea8ebd added access methods for cursorLine & cursorCol
claus
parents: 25
diff changeset
   152
"
5eeef3ea8ebd added access methods for cursorLine & cursorCol
claus
parents: 25
diff changeset
   153
 COPYRIGHT (c) 1989 by Claus Gittinger
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   154
	      All Rights Reserved
33
5eeef3ea8ebd added access methods for cursorLine & cursorCol
claus
parents: 25
diff changeset
   155
5eeef3ea8ebd added access methods for cursorLine & cursorCol
claus
parents: 25
diff changeset
   156
 This software is furnished under a license and may be used
5eeef3ea8ebd added access methods for cursorLine & cursorCol
claus
parents: 25
diff changeset
   157
 only in accordance with the terms of that license and with the
5eeef3ea8ebd added access methods for cursorLine & cursorCol
claus
parents: 25
diff changeset
   158
 inclusion of the above copyright notice.   This software may not
5eeef3ea8ebd added access methods for cursorLine & cursorCol
claus
parents: 25
diff changeset
   159
 be provided or otherwise made available to, or used by, any
5eeef3ea8ebd added access methods for cursorLine & cursorCol
claus
parents: 25
diff changeset
   160
 other person.  No title to or ownership of the software is
5eeef3ea8ebd added access methods for cursorLine & cursorCol
claus
parents: 25
diff changeset
   161
 hereby transferred.
5eeef3ea8ebd added access methods for cursorLine & cursorCol
claus
parents: 25
diff changeset
   162
"
5eeef3ea8ebd added access methods for cursorLine & cursorCol
claus
parents: 25
diff changeset
   163
!
5eeef3ea8ebd added access methods for cursorLine & cursorCol
claus
parents: 25
diff changeset
   164
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   165
documentation
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   166
"
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   167
    a view for editable text - adds editing functionality to TextView
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   168
    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
   169
    acceptAction to be performed for accept
125
claus
parents: 123
diff changeset
   170
claus
parents: 123
diff changeset
   171
    If used with a model, this is informed by sending it a changeMsg with
claus
parents: 123
diff changeset
   172
    the current contents as argument.
297
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   173
    (however, it is possible to define both changeMsg and acceptAction)
125
claus
parents: 123
diff changeset
   174
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
   175
    Please read the historic notice in the ListView class.
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   176
586
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 567
diff changeset
   177
    [Instance variables:]
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   178
5988
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   179
        cursorLine              <Number>        line where cursor sits (1..)
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   180
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   181
        cursorVisibleLine       <Number>        visible line where cursor sits (1..nLinesShown)
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   182
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   183
        cursorCol               <Number>        col where cursor sits (1..)
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   184
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   185
        cursorShown             <Boolean>       true, if cursor is currently shown
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   186
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   187
        readOnly                <Boolean>       true, if text may not be edited
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   188
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   189
        modifiedChannel         <ValueHolder>   holding true, if text has been modified.
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   190
                                                cleared on accept.
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   191
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   192
        acceptChannel           <ValueHolder>   holding true, if text has been accepted.
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   193
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   194
        fixedSize               <Boolean>       true, if no lines may be added/removed
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   195
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   196
        exceptionBlock          <Block>         block to be evaluated when readonly text is about to be modified
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   197
                                                if it returns true, the modification will be done anyway.
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   198
                                                if it returns anything else, the modification is not done.
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   199
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   200
        cursorFgColor           <Color>         color used for cursor drawing
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   201
        cursorBgColor           <Color>         color used for cursor drawing
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   202
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   203
        cursorType              <Symbol>        how the cursor is drawn; currently implemented
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   204
                                                are #none, #block (solid-block cursor), #ibeam
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   205
                                                (vertical bar at insertion point)
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   206
                                                and #caret (caret below insertion-point).
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   207
                                                see cursorType: for an up-to-date list.
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   208
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   209
        cursorTypeNoFocus       <Symbol>        like above, if view has no focus
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   210
                                                nil means: hide the cursor.
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   211
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   212
        undoAction              <Block>         block which undoes last cut, paste or replace
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   213
                                                (not yet fully implemented)
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   214
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   215
        typeOfSelection         <Symbol>        #paste, if selection created by paste, nil otherwise
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   216
                                                this affects the next keyPress: if #paste it does not
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   217
                                                replace; otherwise it replaces the selection.
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   218
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   219
        lastCut                 <String>        last cut or replaced string
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   220
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   221
        lastReplacementInfo     <LastReplacementInfo>        holds the information about the last replace action
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   222
                                                             lastStringToReplace is the string to be replaced by lastReplacement
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   223
                                                             lastReplacement is the string to replace lastStringToReplace
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   224
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   225
        lastStringFromReplaceForNextSearch   <String>        string to be taken be the next search action
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   226
                                                             (cleared after a new selection)
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   227
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   228
        replacing               <Boolean>       true if entered characters replace last selection
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   229
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   230
        showMatchingParenthesis <Boolean>       if true, shows matching parenthesis
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   231
                                                when entering one; this is the default.
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   232
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   233
        hasKeyboardFocus        <Boolean>       true if this view has the focus
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   234
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   235
        acceptAction            <Block>         accept action - evaluated passing the contents as
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   236
                                                argument
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   237
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   238
        tabMeansNextField       <Boolean>       if true, Tab is ignored as input and shifts keyboard
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   239
                                                focus to the next field. For editTextViews, this is false
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   240
                                                by default (i.e. tabs can be entered into the text).
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   241
                                                For some subclasses (inputFields), this may be true.
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   242
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   243
        trimBlankLines          <Boolean>       if true, trailing blanks are
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   244
                                                removed when editing.
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   245
                                                Also, empty lines are represented as nil in the lines collection.
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   246
                                                Default is true.
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   247
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   248
        wordWrap                <Boolean>       Currently not used.
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   249
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   250
        lockUpdates             <Boolean>       internal, private
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   251
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   252
        prevCursorState         <Boolean>       temporary, private
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   253
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   254
        cursorMovementWhenUpdating
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   255
                                <Symbol>        defines where the cursor is to be positioned if the
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   256
                                                model changes its value by some outside activity
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   257
                                                (i.e. not by user input into the field).
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   258
                                                Can be one of:
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   259
                                                    #keep / nil     -> stay where it was
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   260
                                                    #endOfText      -> cursor to the end
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   261
                                                    #endOfLine      -> stay in the line, but move to end
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   262
                                                    #beginOfText    -> cursor to the beginning
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   263
                                                    #beginOfLine    -> stay in the line, but move to begin
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   264
                                                The default is #beginOfText
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   265
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   266
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   267
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   268
        dropTarget              <DropTarget|nil> drop operation descriptor or nil (drop disabled)
2589
62794ae04446 support drop
ca
parents: 2580
diff changeset
   269
62794ae04446 support drop
ca
parents: 2580
diff changeset
   270
2712
e83d71c9bdec ST80Mode classVariables is now UserPreferences.st80EditMode
Claus Gittinger <cg@exept.de>
parents: 2707
diff changeset
   271
    userPreference values:
5988
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   272
        userPreferences.st80EditMode
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   273
                                <Boolean>       if true, cursor positioning is
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   274
                                                done as in vi or ST80; i.e.
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   275
                                                wysiwyg mode is somewhat relaxed,
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   276
                                                in that the cursor cannot be
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   277
                                                positioned behind a lines end.
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   278
                                                This is not yet completely implemented.
33
5eeef3ea8ebd added access methods for cursorLine & cursorCol
claus
parents: 25
diff changeset
   279
    used globals:
5eeef3ea8ebd added access methods for cursorLine & cursorCol
claus
parents: 25
diff changeset
   280
5988
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   281
        DeleteHistory           <Text>          last 1000 lines of deleted text
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   282
                                                (but only if this variable exists already)
586
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 567
diff changeset
   283
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 567
diff changeset
   284
    [styleSheet parameters:]
121
claus
parents: 118
diff changeset
   285
5988
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   286
        textCursorForegroundColor <Color>          cursor fg color; default: text background
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   287
        textCursorBackgroundColor <Color>          cursor bg color; default: text foreground
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   288
        textCursorNoFocusForegroundColor
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   289
                                  <Color>          cursor fg color if no focus; default: cursor fg color
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   290
        textCursorType            <Symbol>         cursor type; default:  #block
586
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 567
diff changeset
   291
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 567
diff changeset
   292
    [author:]
5988
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   293
        Claus Gittinger
586
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 567
diff changeset
   294
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 567
diff changeset
   295
    [see also:]
5988
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   296
        CodeView Workspace TextView ListView
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   297
        EditField
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   298
"
297
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   299
!
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   300
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   301
examples
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   302
"
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   303
  non MVC operation:
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   304
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   305
    basic setup:
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   306
									[exBegin]
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   307
	|top textView|
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   308
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   309
	top := StandardSystemView new.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   310
	top extent:300@200.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   311
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   312
	textView := EditTextView new.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   313
	textView origin:0.0 @ 0.0 corner:1.0 @ 1.0.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   314
	top addSubView:textView.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   315
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   316
	textView contents:('/etc/hosts' asFilename contentsOfEntireFile).
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   317
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   318
	top open.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   319
									[exEnd]
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   320
297
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   321
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   322
    with vertical scrollbar:
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   323
									[exBegin]
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   324
	|top scrollView textView|
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   325
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   326
	top := StandardSystemView new.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   327
	top extent:300@200.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   328
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   329
	scrollView := ScrollableView for:EditTextView.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   330
	textView := scrollView scrolledView.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   331
	scrollView origin:0.0 @ 0.0 corner:1.0 @ 1.0.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   332
	top addSubView:scrollView.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   333
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   334
	textView contents:('/etc/hosts' asFilename contentsOfEntireFile).
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   335
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   336
	top open.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   337
									[exEnd]
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   338
297
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   339
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   340
    with horizontal & vertical scrollbars:
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   341
									[exBegin]
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   342
	|top scrollView textView|
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   343
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   344
	top := StandardSystemView new.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   345
	top extent:300@200.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   346
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   347
	scrollView := HVScrollableView for:EditTextView.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   348
	textView := scrollView scrolledView.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   349
	scrollView origin:0.0 @ 0.0 corner:1.0 @ 1.0.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   350
	top addSubView:scrollView.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   351
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   352
	textView contents:('/etc/hosts' asFilename contentsOfEntireFile).
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   353
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   354
	top open.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   355
									[exEnd]
297
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   356
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   357
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   358
    set the action for accept:
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   359
									[exBegin]
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   360
	|top textView|
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   361
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   362
	top := StandardSystemView new.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   363
	top extent:300@200.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   364
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   365
	textView := EditTextView new.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   366
	textView origin:0.0 @ 0.0 corner:1.0 @ 1.0.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   367
	top addSubView:textView.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   368
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   369
	textView contents:('/etc/hosts' asFilename contentsOfEntireFile).
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   370
	textView acceptAction:[:contents |
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   371
				Transcript showCR:'will not overwrite the file with:'.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   372
				Transcript showCR:contents asString
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   373
			      ].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   374
	top open.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   375
									[exEnd]
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   376
297
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   377
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   378
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
   379
    non-string (text) items:
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   380
									[exBegin]
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   381
	|top textView list|
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   382
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   383
	list := '/etc/hosts' asFilename contentsOfEntireFile asStringCollection.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   384
	1 to:list size by:2 do:[:nr |
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   385
	    list at:nr put:(Text string:(list at:nr)
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   386
				 emphasis:(Array with:#bold with:(#color->Color red)))
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   387
	].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   388
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   389
	top := StandardSystemView new.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   390
	top extent:300@200.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   391
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   392
	textView := EditTextView new.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   393
	textView origin:0.0 @ 0.0 corner:1.0 @ 1.0.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   394
	top addSubView:textView.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   395
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   396
	textView contents:list.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   397
	top open.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   398
									[exEnd]
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
   399
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
   400
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
   401
297
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   402
  MVC operation:
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   403
    (the examples model here is a plug simulating a real model;
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   404
     real world applications would not use a plug ..)
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   405
									[exBegin]
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   406
	|top textView model|
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   407
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   408
	model := Plug new.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   409
	model respondTo:#accepted:
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   410
		   with:[:newContents |
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   411
				Transcript showCR:'will not overwrite the file with:'.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   412
				Transcript showCR:newContents asString
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   413
			].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   414
	model respondTo:#getList
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   415
		   with:['/etc/hosts' asFilename contentsOfEntireFile].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   416
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   417
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   418
	top := StandardSystemView new.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   419
	top extent:300@200.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   420
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   421
	textView := EditTextView new.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   422
	textView origin:0.0 @ 0.0 corner:1.0 @ 1.0.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   423
	top addSubView:textView.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   424
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   425
	textView listMessage:#getList;
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   426
		 model:model;
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   427
		 changeMessage:#accepted:;
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   428
		 aspect:#list.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   429
	top open.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   430
									[exEnd]
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   431
297
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   432
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   433
    two textViews on the same model:
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   434
									[exBegin]
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   435
	|top1 textView1 top2 textView2 model currentContents|
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   436
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   437
	model := Plug new.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   438
	model respondTo:#accepted:
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   439
		   with:[:newContents |
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   440
				Transcript showCR:'accepted:'.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   441
				Transcript showCR:newContents asString.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   442
				currentContents := newContents.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   443
				model changed:#contents
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   444
			].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   445
	model respondTo:#getList
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   446
		   with:[Transcript showCR:'query'.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   447
			 currentContents].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   448
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   449
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   450
	top1 := StandardSystemView new.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   451
	top1 extent:300@200.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   452
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   453
	textView1 := EditTextView new.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   454
	textView1 origin:0.0 @ 0.0 corner:1.0 @ 1.0.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   455
	top1 addSubView:textView1.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   456
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   457
	textView1 listMessage:#getList;
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   458
		  model:model;
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   459
		  aspect:#contents;
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   460
		  changeMessage:#accepted:.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   461
	top1 open.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   462
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   463
	top2 := StandardSystemView new.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   464
	top2 extent:300@200.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   465
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   466
	textView2 := EditTextView new.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   467
	textView2 origin:0.0 @ 0.0 corner:1.0 @ 1.0.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   468
	top2 addSubView:textView2.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   469
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   470
	textView2 listMessage:#getList;
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   471
		  model:model;
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   472
		  aspect:#contents;
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   473
		  changeMessage:#accepted:.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   474
	top2 open.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   475
									[exEnd]
297
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   476
"
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   477
! !
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   478
865
d42c7c99e67d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 840
diff changeset
   479
!EditTextView class methodsFor:'defaults'!
59
450ce95a72a4 *** empty log message ***
claus
parents: 46
diff changeset
   480
4801
69a5bff7b5cd Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4786
diff changeset
   481
defaultCompletionSupportClass
69a5bff7b5cd Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4786
diff changeset
   482
    ^ nil
69a5bff7b5cd Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4786
diff changeset
   483
69a5bff7b5cd Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4786
diff changeset
   484
    "Created: / 26-09-2013 / 17:59:27 / Jan Vrany <jan.vrany@fit.cvut.cz>"
4696
428c8bc44cfb refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents: 4694
diff changeset
   485
!
428c8bc44cfb refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents: 4694
diff changeset
   486
1419
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   487
st80Mode
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   488
    "return true, if the st80 editing mode is turned on.
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   489
     This setting affects the behavior of the cursor, when positioned
5909
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
   490
     beyond the end of a line or the end of the text.
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
   491
     This method is here for backward compatibility, when this flag was stored
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
   492
     in a class var. It is now in the user's settings.
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
   493
     Please do not call it, but go to the prefs directly, to make it easier to find those getters."
1419
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   494
2647
23dca8f032c3 changed st80Mode from classVar to userPreferences value
Claus Gittinger <cg@exept.de>
parents: 2627
diff changeset
   495
    ^ UserPreferences current st80EditMode
1419
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   496
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   497
   "
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   498
    EditTextView st80Mode:true
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   499
    EditTextView st80Mode:false
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   500
   "
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   501
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   502
    "Modified: / 16.1.1998 / 22:54:57 / cg"
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   503
!
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   504
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   505
st80Mode:aBoolean
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   506
    "turns on/off st80 behavior, where the cursor cannot be positioned
5909
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
   507
     beyond the end of a line or the last line.
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
   508
     This method is here for backward compatibility, when this flag was stored
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
   509
     in a class var. It is now in the user's settings.
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
   510
     Please do not call it, but go to the prefs directly, to make it easier to find those setters."
1419
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   511
2647
23dca8f032c3 changed st80Mode from classVar to userPreferences value
Claus Gittinger <cg@exept.de>
parents: 2627
diff changeset
   512
    UserPreferences current st80EditMode:aBoolean.
1419
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   513
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   514
   "
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   515
    EditTextView st80Mode:true
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   516
    EditTextView st80Mode:false
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   517
   "
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   518
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   519
    "Modified: / 16.1.1998 / 22:55:19 / cg"
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   520
!
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   521
59
450ce95a72a4 *** empty log message ***
claus
parents: 46
diff changeset
   522
updateStyleCache
440
2beb33cb0146 added style resource directive
Claus Gittinger <cg@exept.de>
parents: 428
diff changeset
   523
    "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
   524
1390
99674e1d9c85 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
   525
    <resource: #style (#'textCursor.foregroundColor' #'textCursor.backgroundColor'
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   526
		       #'textCursor.noFocusForegroundColor'
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   527
		       #'textCursor.type'
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   528
		       #'textCursor.typeNoFocus'
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   529
		       #'editText.st80Mode')>
1355
6725ab9cc6f5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
   530
6725ab9cc6f5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
   531
    DefaultCursorForegroundColor := StyleSheet colorAt:'textCursor.foregroundColor'.
6725ab9cc6f5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
   532
    DefaultCursorBackgroundColor := StyleSheet colorAt:'textCursor.backgroundColor'.
6725ab9cc6f5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
   533
    DefaultCursorNoFocusForegroundColor := StyleSheet colorAt:'textCursor.noFocusForegroundColor'.
6725ab9cc6f5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
   534
    DefaultCursorType := StyleSheet at:'textCursor.type' default:#block.
1534
bcb211e1b41a read noFocus cursorStyle from styleSheet
Claus Gittinger <cg@exept.de>
parents: 1533
diff changeset
   535
    DefaultCursorTypeNoFocus := StyleSheet at:'textCursor.typeNoFocus'.
bcb211e1b41a read noFocus cursorStyle from styleSheet
Claus Gittinger <cg@exept.de>
parents: 1533
diff changeset
   536
1419
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   537
    "
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   538
     self updateStyleCache
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   539
    "
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   540
1534
bcb211e1b41a read noFocus cursorStyle from styleSheet
Claus Gittinger <cg@exept.de>
parents: 1533
diff changeset
   541
    "Modified: / 20.5.1998 / 04:27:41 / cg"
59
450ce95a72a4 *** empty log message ***
claus
parents: 46
diff changeset
   542
! !
450ce95a72a4 *** empty log message ***
claus
parents: 46
diff changeset
   543
3431
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   544
!EditTextView class methodsFor:'specs'!
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   545
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   546
searchReplaceDialogSpec
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   547
    "This resource specification was automatically generated
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   548
     by the UIPainter of ST/X."
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   549
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   550
    "Do not manually edit this!! If it is corrupted,
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   551
     the UIPainter may not be able to read the specification."
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   552
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   553
    "
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   554
     UIPainter new openOnClass:DAPASX::ProjectEditorTextView andSelector:#searchReplaceDialogSpec
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   555
    "
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   556
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   557
    <resource: #canvas>
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   558
3683
5891af82a177 middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents: 3650
diff changeset
   559
    ^
3431
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   560
     #(FullSpec
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   561
	name: searchReplaceDialogSpec
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   562
	window:
3431
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   563
       (WindowSpec
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   564
	  label: 'String Search and Replace'
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   565
	  name: 'String Search and Replace'
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   566
	  min: (Point 283 196)
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   567
	  max: (Point 283 196)
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   568
	  bounds: (Rectangle 0 0 279 192)
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   569
	)
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   570
	component:
3431
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   571
       (SpecCollection
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   572
	  collection: (
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   573
	   (LabelSpec
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   574
	      label: 'Search Pattern:'
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   575
	      name: 'label'
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   576
	      layout: (LayoutFrame 1 0.0 3 0 -1 1.0 20 0)
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   577
	      level: 0
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   578
	      translateLabel: true
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   579
	      adjust: left
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   580
	    )
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   581
	   (ComboBoxSpec
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   582
	      name: 'patternComboBox'
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   583
	      layout: (LayoutFrame 3 0.0 26 0 -3 1.0 48 0)
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   584
	      tabable: true
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   585
	      model: searchPattern
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   586
	      immediateAccept: false
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   587
	      acceptOnLeave: true
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   588
	      acceptOnReturn: true
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   589
	      acceptOnTab: true
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   590
	      acceptOnLostFocus: true
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   591
	      acceptOnPointerLeave: false
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   592
	      autoSelectInitialText: true
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   593
	      comboList: patternList
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   594
	    )
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   595
	   (ComboBoxSpec
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   596
	      name: 'replaceComboBox'
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   597
	      layout: (LayoutFrame 3 0.0 76 0 -3 1.0 98 0)
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   598
	      tabable: true
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   599
	      model: replacePattern
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   600
	      immediateAccept: false
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   601
	      acceptOnLeave: true
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   602
	      acceptOnReturn: true
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   603
	      acceptOnTab: true
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   604
	      acceptOnLostFocus: true
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   605
	      acceptOnPointerLeave: false
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   606
	      autoSelectInitialText: true
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   607
	      comboList: patternList
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   608
	    )
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   609
	   (CheckBoxSpec
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   610
	      label: 'Ignore Case'
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   611
	      name: 'ignoreCaseCheckBox'
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   612
	      layout: (LayoutFrame 3 0.0 107 0 -3 1.0 130 0)
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   613
	      level: 0
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   614
	      tabable: true
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   615
	      model: ignoreCase
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   616
	      translateLabel: true
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   617
	    )
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   618
	   (VariableVerticalPanelSpec
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   619
	      name: 'VariableVerticalPanel1'
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   620
	      layout: (LayoutFrame 0 0 -64 1 0 1 -4 1)
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   621
	      component:
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   622
	     (SpecCollection
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   623
		collection: (
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   624
		 (HorizontalPanelViewSpec
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   625
		    name: 'HorizontalPanel1'
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   626
		    level: 0
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   627
		    horizontalLayout: fitSpace
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   628
		    verticalLayout: center
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   629
		    horizontalSpace: 3
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   630
		    verticalSpace: 3
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   631
		    ignoreInvisibleComponents: true
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   632
		    reverseOrderIfOKAtLeft: true
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   633
		    component:
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   634
		   (SpecCollection
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   635
		      collection: (
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   636
		       (ActionButtonSpec
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   637
			  label: 'Replace'
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   638
			  name: 'replaceButton'
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   639
			  level: 2
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   640
			  translateLabel: true
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   641
			  tabable: true
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   642
			  model: replaceAction
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   643
			  extent: (Point 134 21)
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   644
			)
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   645
		       (ActionButtonSpec
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   646
			  label: 'Replace All'
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   647
			  name: 'replaceAllButton'
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   648
			  level: 2
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   649
			  borderWidth: 1
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   650
			  translateLabel: true
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   651
			  tabable: true
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   652
			  model: replaceAllAction
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   653
			  extent: (Point 134 21)
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   654
			)
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   655
		       )
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   656
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   657
		    )
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   658
		  )
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   659
		 (HorizontalPanelViewSpec
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   660
		    name: 'horizontalPanelView'
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   661
		    level: 0
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   662
		    horizontalLayout: fitSpace
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   663
		    verticalLayout: center
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   664
		    horizontalSpace: 3
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   665
		    verticalSpace: 3
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   666
		    ignoreInvisibleComponents: true
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   667
		    reverseOrderIfOKAtLeft: true
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   668
		    component:
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   669
		   (SpecCollection
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   670
		      collection: (
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   671
		       (ActionButtonSpec
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   672
			  label: 'Cancel'
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   673
			  name: 'cancelButton'
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   674
			  level: 2
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   675
			  translateLabel: true
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   676
			  tabable: true
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   677
			  model: cancel
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   678
			  extent: (Point 88 21)
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   679
			)
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   680
		       (ActionButtonSpec
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   681
			  label: 'Prev'
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   682
			  name: 'prevButton'
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   683
			  level: 2
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   684
			  translateLabel: true
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   685
			  tabable: true
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   686
			  model: prevAction
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   687
			  extent: (Point 89 21)
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   688
			)
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   689
		       (ActionButtonSpec
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   690
			  label: 'Next'
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   691
			  name: 'nextButton'
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   692
			  level: 2
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   693
			  borderWidth: 1
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   694
			  translateLabel: true
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   695
			  tabable: true
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   696
			  model: nextAction
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   697
			  isDefault: true
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   698
			  extent: (Point 88 21)
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   699
			)
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   700
		       )
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   701
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   702
		    )
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   703
		  )
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   704
		 )
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   705
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   706
	      )
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   707
	      handles: (Any 0.5 1.0)
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   708
	    )
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   709
	   (LabelSpec
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   710
	      label: 'Replace By:'
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   711
	      name: 'ReplaceLabel'
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   712
	      layout: (LayoutFrame 1 0.0 53 0 -1 1.0 70 0)
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   713
	      level: 0
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   714
	      translateLabel: true
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   715
	      adjust: left
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   716
	    )
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   717
	   )
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   718
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   719
	)
3431
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   720
      )
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   721
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   722
    "Modified: / 11-10-2006 / 21:05:09 / cg"
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   723
! !
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   724
2744
cb920467a4b4 method category rename
Claus Gittinger <cg@exept.de>
parents: 2730
diff changeset
   725
!EditTextView methodsFor:'Compatibility-ST80'!
1552
d3d4afaf4c68 dummy ST80 compatibility: #autoAccept:
Claus Gittinger <cg@exept.de>
parents: 1548
diff changeset
   726
d3d4afaf4c68 dummy ST80 compatibility: #autoAccept:
Claus Gittinger <cg@exept.de>
parents: 1548
diff changeset
   727
autoAccept:aBoolean
d3d4afaf4c68 dummy ST80 compatibility: #autoAccept:
Claus Gittinger <cg@exept.de>
parents: 1548
diff changeset
   728
    "ignored for now"
d3d4afaf4c68 dummy ST80 compatibility: #autoAccept:
Claus Gittinger <cg@exept.de>
parents: 1548
diff changeset
   729
2019
b6b078ea3bbf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2018
diff changeset
   730
    "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
   731
!
9bf6cf249376 two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents: 1580
diff changeset
   732
9bf6cf249376 two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents: 1580
diff changeset
   733
continuousAccept:aBoolean
9bf6cf249376 two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents: 1580
diff changeset
   734
    "ignored for now"
9bf6cf249376 two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents: 1580
diff changeset
   735
9bf6cf249376 two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents: 1580
diff changeset
   736
    "Created: / 19.6.1998 / 00:03:49 / cg"
9bf6cf249376 two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents: 1580
diff changeset
   737
!
9bf6cf249376 two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents: 1580
diff changeset
   738
1390
99674e1d9c85 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
   739
cutSelection
99674e1d9c85 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
   740
    self cut
99674e1d9c85 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
   741
99674e1d9c85 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
   742
    "Created: / 31.10.1997 / 03:29:50 / cg"
99674e1d9c85 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
   743
!
99674e1d9c85 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
   744
1590
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   745
deselect
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   746
    "remove the selection"
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   747
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   748
    ^ self unselect
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   749
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   750
    "Created: / 19.6.1998 / 02:41:54 / cg"
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   751
!
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   752
2101
8f2fab818f71 category renamining
Claus Gittinger <cg@exept.de>
parents: 2088
diff changeset
   753
enabled:aBoolean
8f2fab818f71 category renamining
Claus Gittinger <cg@exept.de>
parents: 2088
diff changeset
   754
8f2fab818f71 category renamining
Claus Gittinger <cg@exept.de>
parents: 2088
diff changeset
   755
    self readOnly:aBoolean not
8f2fab818f71 category renamining
Claus Gittinger <cg@exept.de>
parents: 2088
diff changeset
   756
8f2fab818f71 category renamining
Claus Gittinger <cg@exept.de>
parents: 2088
diff changeset
   757
    "Created: / 30.3.1999 / 15:10:23 / stefan"
8f2fab818f71 category renamining
Claus Gittinger <cg@exept.de>
parents: 2088
diff changeset
   758
    "Modified: / 30.3.1999 / 15:10:53 / stefan"
8f2fab818f71 category renamining
Claus Gittinger <cg@exept.de>
parents: 2088
diff changeset
   759
!
8f2fab818f71 category renamining
Claus Gittinger <cg@exept.de>
parents: 2088
diff changeset
   760
1732
2d433e114bbc added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 1717
diff changeset
   761
find:pattern
2d433e114bbc added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 1717
diff changeset
   762
    self searchFwd:pattern ifAbsent:nil
2d433e114bbc added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 1717
diff changeset
   763
2d433e114bbc added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 1717
diff changeset
   764
    "Created: / 29.1.1999 / 19:09:42 / cg"
2d433e114bbc added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 1717
diff changeset
   765
    "Modified: / 29.1.1999 / 19:10:12 / cg"
2d433e114bbc added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 1717
diff changeset
   766
!
2d433e114bbc added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 1717
diff changeset
   767
1294
dac755d4acd3 added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   768
insert:aString at:aCharacterPosition
dac755d4acd3 added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   769
    "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
   770
dac755d4acd3 added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   771
    |line col|
dac755d4acd3 added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   772
dac755d4acd3 added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   773
    line := self lineOfCharacterPosition:aCharacterPosition.
dac755d4acd3 added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   774
    col := aCharacterPosition - (self characterPositionOfLine:line col:1) + 1.
1480
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
   775
    col < 1 ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   776
	col := 1
1480
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
   777
    ].
1294
dac755d4acd3 added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   778
    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
   779
dac755d4acd3 added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   780
    "
dac755d4acd3 added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   781
     |top v|
dac755d4acd3 added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   782
dac755d4acd3 added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   783
     top := StandardSystemView new.
dac755d4acd3 added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   784
     top extent:300@300.
dac755d4acd3 added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   785
     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
   786
     top openAndWait.
dac755d4acd3 added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   787
     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
   788
     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
   789
    "
dac755d4acd3 added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   790
1480
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
   791
    "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
   792
!
dac755d4acd3 added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   793
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   794
insertAndSelect:aString at:aCharacterPosition
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   795
    "insert a selected string at aCharacterPosition."
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   796
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   797
    |line col|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   798
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   799
    line := self lineOfCharacterPosition:aCharacterPosition.
2310
861ab02b13b9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2225
diff changeset
   800
    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
   801
    self insertString:aString atLine:line col:col.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   802
    self selectFromLine:line col:col toLine:line col:col + aString size - 1
125
claus
parents: 123
diff changeset
   803
    "
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   804
     |v|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   805
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   806
     v := EditTextView new openAndWait.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   807
     v contents:'1234567890\1234567890\1234567890\' withCRs.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   808
     v insertAndSelect:'<- hello there' at:5.
125
claus
parents: 123
diff changeset
   809
    "
1390
99674e1d9c85 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
   810
!
99674e1d9c85 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
   811
99674e1d9c85 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
   812
pasteSelection
99674e1d9c85 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
   813
    self paste
99674e1d9c85 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
   814
99674e1d9c85 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
   815
    "Created: / 31.10.1997 / 03:28:53 / cg"
1590
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   816
!
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   817
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   818
replaceSelectionWith:aString
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   819
    ^ self replaceSelectionBy:aString
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   820
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   821
    "Created: / 19.6.1998 / 02:42:32 / cg"
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   822
!
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   823
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   824
selectAt:pos
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   825
    "move the cursor before cursorPosition."
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   826
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   827
    self cursorToCharacterPosition:pos
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   828
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   829
    "Modified: / 19.6.1998 / 02:41:28 / cg"
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   830
    "Created: / 19.6.1998 / 02:43:39 / cg"
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   831
!
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   832
2101
8f2fab818f71 category renamining
Claus Gittinger <cg@exept.de>
parents: 2088
diff changeset
   833
textHasChanged
8f2fab818f71 category renamining
Claus Gittinger <cg@exept.de>
parents: 2088
diff changeset
   834
    ^ self modified
8f2fab818f71 category renamining
Claus Gittinger <cg@exept.de>
parents: 2088
diff changeset
   835
8f2fab818f71 category renamining
Claus Gittinger <cg@exept.de>
parents: 2088
diff changeset
   836
    "Created: / 19.6.1998 / 00:09:43 / cg"
2117
b50c6d182e28 added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 2107
diff changeset
   837
!
b50c6d182e28 added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 2107
diff changeset
   838
b50c6d182e28 added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 2107
diff changeset
   839
textHasChanged:aBoolean
b50c6d182e28 added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 2107
diff changeset
   840
    "ST-80 compatibility: set/clear the modified flag."
b50c6d182e28 added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 2107
diff changeset
   841
b50c6d182e28 added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 2107
diff changeset
   842
    self modified:aBoolean
b50c6d182e28 added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 2107
diff changeset
   843
b50c6d182e28 added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 2107
diff changeset
   844
    "Created: / 5.2.2000 / 17:07:59 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   845
! !
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   846
4585
7b31719bf07a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4580
diff changeset
   847
!EditTextView methodsFor:'accessing'!
7b31719bf07a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4580
diff changeset
   848
4803
87d60a4b098b Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4801
diff changeset
   849
codeAspect
87d60a4b098b Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4801
diff changeset
   850
    | codeAspect app |
87d60a4b098b Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4801
diff changeset
   851
87d60a4b098b Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4801
diff changeset
   852
    codeAspect := codeAspectHolder value.
87d60a4b098b Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4801
diff changeset
   853
    codeAspect notNil ifTrue:[^codeAspect].
87d60a4b098b Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4801
diff changeset
   854
    self editedMethod notNil ifTrue:[^SyntaxHighlighter codeAspectMethod].
87d60a4b098b Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4801
diff changeset
   855
87d60a4b098b Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4801
diff changeset
   856
    "/ Applications should set it explictly, however, to make it behavinh like
87d60a4b098b Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4801
diff changeset
   857
    "/ CodeView2, I kept fetching code here for now.
87d60a4b098b Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4801
diff changeset
   858
    ^((app := self topView application) notNil and:[app respondsTo: #codeAspect])
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   859
	ifTrue:[app codeAspect]
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   860
	ifFalse:[nil]
4803
87d60a4b098b Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4801
diff changeset
   861
87d60a4b098b Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4801
diff changeset
   862
    "Created: / 27-09-2013 / 09:53:40 / Jan Vrany <jan.vrany@fit.cvut.cz>"
87d60a4b098b Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4801
diff changeset
   863
!
87d60a4b098b Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4801
diff changeset
   864
87d60a4b098b Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4801
diff changeset
   865
codeAspect: aSymbol
87d60a4b098b Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4801
diff changeset
   866
    codeAspectHolder value: aSymbol
87d60a4b098b Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4801
diff changeset
   867
87d60a4b098b Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4801
diff changeset
   868
    "Created: / 27-09-2013 / 09:50:52 / Jan Vrany <jan.vrany@fit.cvut.cz>"
87d60a4b098b Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4801
diff changeset
   869
!
87d60a4b098b Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4801
diff changeset
   870
4801
69a5bff7b5cd Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4786
diff changeset
   871
completionSupport
69a5bff7b5cd Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4786
diff changeset
   872
    ^ completionSupport
69a5bff7b5cd Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4786
diff changeset
   873
!
69a5bff7b5cd Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4786
diff changeset
   874
69a5bff7b5cd Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4786
diff changeset
   875
completionSupport:anEditTextViewCompletionSupport
69a5bff7b5cd Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4786
diff changeset
   876
    completionSupport := anEditTextViewCompletionSupport.
69a5bff7b5cd Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4786
diff changeset
   877
!
69a5bff7b5cd Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4786
diff changeset
   878
69a5bff7b5cd Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4786
diff changeset
   879
completionSupportClass
69a5bff7b5cd Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4786
diff changeset
   880
    ^ self class defaultCompletionSupportClass
69a5bff7b5cd Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4786
diff changeset
   881
69a5bff7b5cd Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4786
diff changeset
   882
    "Created: / 26-09-2013 / 17:54:24 / Jan Vrany <jan.vrany@fit.cvut.cz>"
69a5bff7b5cd Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4786
diff changeset
   883
!
69a5bff7b5cd Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4786
diff changeset
   884
4609
8b3eb80d04d0 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4595
diff changeset
   885
editedClass
8b3eb80d04d0 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4595
diff changeset
   886
    |cm|
8b3eb80d04d0 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4595
diff changeset
   887
8b3eb80d04d0 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4595
diff changeset
   888
    cm := self editedMethodOrClass.
8b3eb80d04d0 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4595
diff changeset
   889
    cm isBehavior ifTrue:[^ cm].
8b3eb80d04d0 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4595
diff changeset
   890
    cm isMethod ifTrue:[^ cm mclass].
8b3eb80d04d0 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4595
diff changeset
   891
    ^ nil
8b3eb80d04d0 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4595
diff changeset
   892
!
8b3eb80d04d0 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4595
diff changeset
   893
4775
e34752e6214e Pass programming language when asking DWIM to complete code
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4771
diff changeset
   894
editedLanguage
e34752e6214e Pass programming language when asking DWIM to complete code
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4771
diff changeset
   895
    ^ nil
e34752e6214e Pass programming language when asking DWIM to complete code
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4771
diff changeset
   896
e34752e6214e Pass programming language when asking DWIM to complete code
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4771
diff changeset
   897
    "Created: / 18-09-2013 / 14:16:38 / Jan Vrany <jan.vrany@fit.cvut.cz>"
e34752e6214e Pass programming language when asking DWIM to complete code
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4771
diff changeset
   898
!
e34752e6214e Pass programming language when asking DWIM to complete code
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4771
diff changeset
   899
4803
87d60a4b098b Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4801
diff changeset
   900
editedLanguage: aProgrammingLanguage
87d60a4b098b Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4801
diff changeset
   901
    "Sets the edited language. Only defined here to make it polymorph with Workspace"
87d60a4b098b Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4801
diff changeset
   902
87d60a4b098b Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4801
diff changeset
   903
    "Created: / 27-09-2013 / 10:15:35 / Jan Vrany <jan.vrany@fit.cvut.cz>"
87d60a4b098b Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4801
diff changeset
   904
!
87d60a4b098b Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4801
diff changeset
   905
4609
8b3eb80d04d0 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4595
diff changeset
   906
editedMethod
8b3eb80d04d0 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4595
diff changeset
   907
    |cm|
8b3eb80d04d0 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4595
diff changeset
   908
8b3eb80d04d0 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4595
diff changeset
   909
    cm := self editedMethodOrClass.
8b3eb80d04d0 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4595
diff changeset
   910
    cm isMethod ifTrue:[^ cm].
8b3eb80d04d0 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4595
diff changeset
   911
    cm isBehavior ifTrue:[^ nil].
8b3eb80d04d0 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4595
diff changeset
   912
    ^ nil
8b3eb80d04d0 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4595
diff changeset
   913
!
8b3eb80d04d0 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4595
diff changeset
   914
8b3eb80d04d0 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4595
diff changeset
   915
editedMethodOrClass
8b3eb80d04d0 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4595
diff changeset
   916
    ^ nil
8b3eb80d04d0 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4595
diff changeset
   917
!
8b3eb80d04d0 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4595
diff changeset
   918
4803
87d60a4b098b Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4801
diff changeset
   919
editedMethodOrClass: methodOrClass
87d60a4b098b Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4801
diff changeset
   920
    "Sets the edited method or class. Only defined here to make it polymorph with Workspace"
87d60a4b098b Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4801
diff changeset
   921
87d60a4b098b Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4801
diff changeset
   922
    "Created: / 27-09-2013 / 10:10:14 / Jan Vrany <jan.vrany@fit.cvut.cz>"
87d60a4b098b Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4801
diff changeset
   923
!
87d60a4b098b Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4801
diff changeset
   924
4585
7b31719bf07a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4580
diff changeset
   925
hasSelectionOrTextInCursorLine
7b31719bf07a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4580
diff changeset
   926
    ^ (self selectionOrTextOfCursorLine:false) notNil
7b31719bf07a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4580
diff changeset
   927
!
7b31719bf07a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4580
diff changeset
   928
4589
f6da08d703f5 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4585
diff changeset
   929
selectionOrTextOfCursorLine
f6da08d703f5 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4585
diff changeset
   930
    ^ self selectionOrTextOfCursorLine:true
f6da08d703f5 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4585
diff changeset
   931
!
f6da08d703f5 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4585
diff changeset
   932
4585
7b31719bf07a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4580
diff changeset
   933
selectionOrTextOfCursorLine:doSelect
7b31719bf07a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4580
diff changeset
   934
    |sel lNr line|
7b31719bf07a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4580
diff changeset
   935
7b31719bf07a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4580
diff changeset
   936
    sel := self selectionAsString.
7b31719bf07a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4580
diff changeset
   937
    sel notNil ifTrue:[^ sel].
7b31719bf07a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4580
diff changeset
   938
7b31719bf07a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4580
diff changeset
   939
    lNr := self cursorLine.
7b31719bf07a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4580
diff changeset
   940
    line := self listAt:lNr.
7b31719bf07a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4580
diff changeset
   941
    line notEmptyOrNil ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   942
	doSelect ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   943
	    self selectLine:lNr.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   944
	].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
   945
	^ line
4585
7b31719bf07a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4580
diff changeset
   946
    ].
7b31719bf07a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4580
diff changeset
   947
7b31719bf07a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4580
diff changeset
   948
    ^ nil
7b31719bf07a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4580
diff changeset
   949
! !
7b31719bf07a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4580
diff changeset
   950
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   951
!EditTextView methodsFor:'accessing-behavior'!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   952
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   953
acceptAction
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   954
    "return the action to be performed on accept (or nil)"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   955
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   956
    ^ acceptAction
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
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   959
acceptAction:aBlock
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   960
    "set the action to be performed on accept"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   961
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   962
    acceptAction := aBlock
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   963
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   964
2792
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   965
acceptChannel
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   966
    "return the valueHolder holding true if text was accepted.
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   967
     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
   968
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   969
    ^ acceptChannel
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   970
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   971
    "Modified: / 30.1.1998 / 14:17:11 / cg"
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   972
!
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   973
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   974
acceptChannel:aValueHolder
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   975
    "set the valueHolder holding true if text was accepted.
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   976
     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
   977
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   978
    |prev|
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   979
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   980
    prev := acceptChannel.
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   981
    acceptChannel := aValueHolder.
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   982
    self setupChannel:aValueHolder for:nil withOld:prev
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   983
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   984
    "Created: / 30.1.1998 / 14:51:09 / cg"
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   985
!
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   986
1108
3d14bb6bceb7 added disableAccept
Claus Gittinger <cg@exept.de>
parents: 1082
diff changeset
   987
acceptEnabled:aBoolean
3d14bb6bceb7 added disableAccept
Claus Gittinger <cg@exept.de>
parents: 1082
diff changeset
   988
    "enable/disable accept. This greys the corresponding item in the menu"
3d14bb6bceb7 added disableAccept
Claus Gittinger <cg@exept.de>
parents: 1082
diff changeset
   989
3d14bb6bceb7 added disableAccept
Claus Gittinger <cg@exept.de>
parents: 1082
diff changeset
   990
    acceptEnabled := aBoolean
3d14bb6bceb7 added disableAccept
Claus Gittinger <cg@exept.de>
parents: 1082
diff changeset
   991
3d14bb6bceb7 added disableAccept
Claus Gittinger <cg@exept.de>
parents: 1082
diff changeset
   992
    "Created: 7.3.1997 / 11:04:34 / cg"
3d14bb6bceb7 added disableAccept
Claus Gittinger <cg@exept.de>
parents: 1082
diff changeset
   993
!
3d14bb6bceb7 added disableAccept
Claus Gittinger <cg@exept.de>
parents: 1082
diff changeset
   994
2792
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   995
accepted
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   996
    "return true if text was accepted"
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   997
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   998
    ^ acceptChannel value
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   999
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1000
    "Created: 14.2.1997 / 16:43:46 / cg"
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1001
!
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
accepted:aBoolean
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1004
    "set/clear the accepted flag.
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1005
     This may force my current contents to be placed into my model."
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1006
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1007
    acceptChannel value:aBoolean.
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1008
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1009
    "Created: / 14.2.1997 / 16:44:01 / cg"
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1010
    "Modified: / 30.1.1998 / 14:20:15 / cg"
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1011
!
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1012
474
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  1013
autoIndent:aBoolean
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  1014
    autoIndent := aBoolean
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  1015
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  1016
    "Created: 5.3.1996 / 14:37:50 / cg"
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  1017
!
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  1018
4803
87d60a4b098b Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4801
diff changeset
  1019
codeAspectHolder
87d60a4b098b Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4801
diff changeset
  1020
    ^ codeAspectHolder
87d60a4b098b Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4801
diff changeset
  1021
!
87d60a4b098b Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4801
diff changeset
  1022
87d60a4b098b Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4801
diff changeset
  1023
codeAspectHolder:something
87d60a4b098b Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4801
diff changeset
  1024
    codeAspectHolder := something.
87d60a4b098b Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4801
diff changeset
  1025
!
87d60a4b098b Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4801
diff changeset
  1026
2774
0415ba0f8cb5 cursorMovement getter
penk
parents: 2762
diff changeset
  1027
cursorMovementWhenUpdating
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1028
    "return what is be done with the cursor,
2774
0415ba0f8cb5 cursorMovement getter
penk
parents: 2762
diff changeset
  1029
     when I get a new text (via the model or the #contents/#list)
0415ba0f8cb5 cursorMovement getter
penk
parents: 2762
diff changeset
  1030
     Allowed arguments are:
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  1031
	#keep / nil     -> stay where it was
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  1032
	#endOfText      -> position cursor to the end
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  1033
	#beginOfText    -> position cursor to the beginning
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  1034
	#endOfLine      -> position cursor to the current lines end
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  1035
	#beginOfLine    -> position cursor to the current lines start
2774
0415ba0f8cb5 cursorMovement getter
penk
parents: 2762
diff changeset
  1036
     The default is #beginOfText.
0415ba0f8cb5 cursorMovement getter
penk
parents: 2762
diff changeset
  1037
     This may be useful for fields which get new values assigned from
0415ba0f8cb5 cursorMovement getter
penk
parents: 2762
diff changeset
  1038
     the program (i.e. not from the user)"
0415ba0f8cb5 cursorMovement getter
penk
parents: 2762
diff changeset
  1039
0415ba0f8cb5 cursorMovement getter
penk
parents: 2762
diff changeset
  1040
    ^ cursorMovementWhenUpdating
0415ba0f8cb5 cursorMovement getter
penk
parents: 2762
diff changeset
  1041
0415ba0f8cb5 cursorMovement getter
penk
parents: 2762
diff changeset
  1042
    "Modified: 16.12.1995 / 16:27:55 / cg"
0415ba0f8cb5 cursorMovement getter
penk
parents: 2762
diff changeset
  1043
!
0415ba0f8cb5 cursorMovement getter
penk
parents: 2762
diff changeset
  1044
2133
47a23fdfc83f comment
Claus Gittinger <cg@exept.de>
parents: 2131
diff changeset
  1045
cursorMovementWhenUpdating:aSymbolOrNil
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1046
    "define what should be done with the cursor,
2133
47a23fdfc83f comment
Claus Gittinger <cg@exept.de>
parents: 2131
diff changeset
  1047
     when I get a new text (via the model or the #contents/#list)
47a23fdfc83f comment
Claus Gittinger <cg@exept.de>
parents: 2131
diff changeset
  1048
     Allowed arguments are:
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  1049
	#keep / nil     -> stay where it was
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  1050
	#endOfText      -> position cursor to the end
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  1051
	#beginOfText    -> position cursor to the beginning
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  1052
	#endOfLine      -> position cursor to the current lines end
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  1053
	#beginOfLine    -> position cursor to the current lines start
2133
47a23fdfc83f comment
Claus Gittinger <cg@exept.de>
parents: 2131
diff changeset
  1054
     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
  1055
     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
  1056
     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
  1057
2133
47a23fdfc83f comment
Claus Gittinger <cg@exept.de>
parents: 2131
diff changeset
  1058
    cursorMovementWhenUpdating := aSymbolOrNil
2129
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  1059
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  1060
    "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
  1061
!
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  1062
2035
6924861adf08 added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents: 2029
diff changeset
  1063
disableIfInvisible:aBoolean
6924861adf08 added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents: 2029
diff changeset
  1064
    disableIfInvisible := aBoolean
6924861adf08 added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents: 2029
diff changeset
  1065
!
6924861adf08 added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents: 2029
diff changeset
  1066
2438
6406f4444ee4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2432
diff changeset
  1067
dontReplaceSelectionOnInput
4742
a00cb40ee392 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4738
diff changeset
  1068
    "remember that the current selection was created by a paste operation
a00cb40ee392 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4738
diff changeset
  1069
     (as opposed to an explicit selection by the user).
a00cb40ee392 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4738
diff changeset
  1070
     This selection will not be replaced by followup user input,
a00cb40ee392 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4738
diff changeset
  1071
     so multiple pastes will be possible."
a00cb40ee392 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4738
diff changeset
  1072
2438
6406f4444ee4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2432
diff changeset
  1073
    typeOfSelection := #paste
6406f4444ee4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2432
diff changeset
  1074
!
6406f4444ee4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2432
diff changeset
  1075
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  1076
editModeHolder
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  1077
    ^ editMode.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  1078
!
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  1079
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  1080
editModeInsert
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  1081
    editMode value:EditMode insertMode
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  1082
!
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  1083
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  1084
editModeInsertAndSelect
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  1085
    editMode value:EditMode insertAndSelectMode
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  1086
!
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  1087
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  1088
editModeOverwrite
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  1089
    editMode value:EditMode overwriteMode
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  1090
!
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  1091
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1092
exceptionBlock:aBlock
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1093
    "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
  1094
     readonly text"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1095
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1096
    exceptionBlock := aBlock
323
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
  1097
!
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
  1098
3296
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
  1099
fixedSize
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
  1100
    "make the texts size fixed (no lines may be added).
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
  1101
     OBSOLETE: use readOnly"
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
  1102
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
  1103
    <resource:#obsolete>
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
  1104
3683
5891af82a177 middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents: 3650
diff changeset
  1105
    |menu|
5891af82a177 middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents: 3650
diff changeset
  1106
3296
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
  1107
    self obsoleteMethodWarning:'use #readOnly:'.
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
  1108
    readOnly == true ifFalse:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  1109
	readOnly := true.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  1110
	(menu := self middleButtonMenu) notNil ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  1111
	    menu disableAll:#(cut paste replace indent)
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  1112
	]
3296
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
  1113
    ]
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
  1114
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
  1115
    "Modified: 14.2.1997 / 17:35:24 / cg"
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
  1116
!
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
  1117
5858
f281506fb025 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5857
diff changeset
  1118
generateTextAfterEndHook:aBlock
f281506fb025 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5857
diff changeset
  1119
    "some applications may want to dynamically generate lines below the bottom line,
f281506fb025 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5857
diff changeset
  1120
     when the cursor is moved there.
f281506fb025 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5857
diff changeset
  1121
     For example, disassembly views or memory dumps (hex-dumps),
f281506fb025 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5857
diff changeset
  1122
     which want to automatically generate additional lines lazily,
f281506fb025 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5857
diff changeset
  1123
     but which cannot afford to generate the whole text in advance
f281506fb025 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5857
diff changeset
  1124
     (eg: who wants to disassemble gigabytes?).
5890
5dc30fda9ebf #OTHER by mawalch
mawalch
parents: 5887
diff changeset
  1125
     If set, this hook is called whenever the cursor is about to be moved below the
5859
d824308630da #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5858
diff changeset
  1126
     last line, getting the new lineNr (i.e > contents size) as argument.
5858
f281506fb025 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5857
diff changeset
  1127
     It may generate more text (by setting my contents) and return a new cursor line
5890
5dc30fda9ebf #OTHER by mawalch
mawalch
parents: 5887
diff changeset
  1128
     number, into which the cursor should be moved
5dc30fda9ebf #OTHER by mawalch
mawalch
parents: 5887
diff changeset
  1129
     (eg. if 10 additional lines are generated, it may want to return oldSize+1,
5858
f281506fb025 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5857
diff changeset
  1130
     to make the cursor end in the last line which was inserted)"
5890
5dc30fda9ebf #OTHER by mawalch
mawalch
parents: 5887
diff changeset
  1131
5858
f281506fb025 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5857
diff changeset
  1132
    self setAttribute:#generateTextAfterEndHook to:aBlock
f281506fb025 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5857
diff changeset
  1133
!
f281506fb025 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5857
diff changeset
  1134
f281506fb025 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5857
diff changeset
  1135
generateTextBeforeStartHook:aBlock
f281506fb025 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5857
diff changeset
  1136
    "some applications may want to dynamically generate lines above the top
f281506fb025 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5857
diff changeset
  1137
     line, when the cursor is moved there.
f281506fb025 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5857
diff changeset
  1138
     For example, disassembly views or memory dumps (hex-dumps),
f281506fb025 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5857
diff changeset
  1139
     which want to automatically generate additional lines lazily,
f281506fb025 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5857
diff changeset
  1140
     but which cannot afford to generate the whole text in advance
f281506fb025 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5857
diff changeset
  1141
     (eg: who wants to disassemble gigabytes?).
5890
5dc30fda9ebf #OTHER by mawalch
mawalch
parents: 5887
diff changeset
  1142
     If set, this hook is called whenever the cursor is about to be moved above the
5859
d824308630da #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5858
diff changeset
  1143
     top, getting the new lineNr (i.e < 1) as argument.
5858
f281506fb025 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5857
diff changeset
  1144
     It may generate more text (by setting my contents) and return a new cursor line
5890
5dc30fda9ebf #OTHER by mawalch
mawalch
parents: 5887
diff changeset
  1145
     number, into which the cursor should be moved
5dc30fda9ebf #OTHER by mawalch
mawalch
parents: 5887
diff changeset
  1146
     (eg. if 10 additional lines are generated, it may want to return 10, to make the
5858
f281506fb025 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5857
diff changeset
  1147
     cursor end in the last line which was inserted)"
5890
5dc30fda9ebf #OTHER by mawalch
mawalch
parents: 5887
diff changeset
  1148
5858
f281506fb025 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5857
diff changeset
  1149
    self setAttribute:#generateTextBeforeStartHook to:aBlock
f281506fb025 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5857
diff changeset
  1150
!
f281506fb025 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5857
diff changeset
  1151
477
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  1152
insertMode:aBoolean
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  1153
    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
  1154
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  1155
    "Created: 6.3.1996 / 12:24:05 / cg"
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  1156
!
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  1157
2795
1f7b5f242eee learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents: 2792
diff changeset
  1158
insertModeHolder
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  1159
    ^ BlockValue
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  1160
	with:[:m | m isInsertMode]
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  1161
	argument:(editMode).
3465
a6eb20608b1f BlockValue usage cleanup
Claus Gittinger <cg@exept.de>
parents: 3439
diff changeset
  1162
a6eb20608b1f BlockValue usage cleanup
Claus Gittinger <cg@exept.de>
parents: 3439
diff changeset
  1163
    "Modified: / 08-03-2007 / 22:58:37 / cg"
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  1164
!
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  1165
3683
5891af82a177 middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents: 3650
diff changeset
  1166
isInInsertMode
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  1167
    ^ editMode value isInsertMode
2795
1f7b5f242eee learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents: 2792
diff changeset
  1168
!
1f7b5f242eee learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents: 2792
diff changeset
  1169
5216
8d6eef5d09c3 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5194
diff changeset
  1170
isNotReadOnly
8d6eef5d09c3 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5194
diff changeset
  1171
    "return true, if the text is not readonly."
8d6eef5d09c3 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5194
diff changeset
  1172
8d6eef5d09c3 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5194
diff changeset
  1173
    ^ self isReadOnly not
8d6eef5d09c3 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5194
diff changeset
  1174
!
8d6eef5d09c3 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5194
diff changeset
  1175
2792
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1176
isReadOnly
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1177
    "return true, if the text is readonly."
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1178
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1179
    ^ readOnly value
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1180
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1181
    "Modified: 14.2.1997 / 17:35:56 / cg"
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1182
!
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1183
2796
481d9e54434c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2795
diff changeset
  1184
modeLabelHolder
481d9e54434c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2795
diff changeset
  1185
    "a valueHolder, which contains 'L' (learnMode), I (insertMode) or empty"
481d9e54434c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2795
diff changeset
  1186
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1187
    ^ BlockValue
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  1188
	with:[:e :l |
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  1189
	    self isReadOnly ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  1190
		''
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  1191
	    ] ifFalse:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  1192
		l ifTrue:[ 'L' allBold withColor:#red]
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  1193
		  ifFalse:[ e infoPrintString]]]
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  1194
	argument:(self editModeHolder)
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  1195
	argument:(self learnModeHolder).
3465
a6eb20608b1f BlockValue usage cleanup
Claus Gittinger <cg@exept.de>
parents: 3439
diff changeset
  1196
a6eb20608b1f BlockValue usage cleanup
Claus Gittinger <cg@exept.de>
parents: 3439
diff changeset
  1197
    "Modified: / 08-03-2007 / 22:58:59 / cg"
2796
481d9e54434c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2795
diff changeset
  1198
!
481d9e54434c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2795
diff changeset
  1199
2792
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1200
modified
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1201
    "return true if text was modified"
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1202
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1203
    ^ modifiedChannel value
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1204
!
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1205
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1206
modified:aBoolean
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1207
    "set/clear the modified flag"
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1208
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1209
    modifiedChannel value:aBoolean
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1210
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1211
    "Modified: 14.2.1997 / 16:44:05 / cg"
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1212
!
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1213
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1214
modifiedChannel
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1215
    "return the valueHolder holding true if text was modified"
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1216
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1217
    ^ modifiedChannel
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1218
!
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1219
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1220
modifiedChannel:aValueHolder
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1221
    "set the valueHolder holding true if text was modified"
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1222
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1223
    |prev|
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1224
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1225
    prev := modifiedChannel.
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1226
    modifiedChannel := aValueHolder.
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1227
    self setupChannel:aValueHolder for:nil withOld:prev
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1228
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1229
    "Created: / 30.1.1998 / 14:51:32 / cg"
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1230
!
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1231
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1232
readOnly
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1233
    "make the text readonly.
4664
f09d5587253f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4661
diff changeset
  1234
     Obsolete because it is obfuscating (looks like a getter)
f09d5587253f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4661
diff changeset
  1235
     - use #readOnly:"
2792
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1236
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1237
    <resource:#obsolete>
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1238
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1239
    self obsoleteMethodWarning:'use #readOnly:'.
3705
a819d7204ee3 changed #readOnly
Stefan Vogel <sv@exept.de>
parents: 3683
diff changeset
  1240
    self readOnly:true.
2792
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1241
4664
f09d5587253f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4661
diff changeset
  1242
    "Modified: / 14-02-1997 / 17:35:56 / cg"
f09d5587253f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4661
diff changeset
  1243
    "Modified (comment): / 02-08-2013 / 16:46:57 / cg"
2792
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1244
!
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1245
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1246
readOnly:aBoolean
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1247
    "make the text readonly (aBoolean == true) or writable (aBoolean == false).
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1248
     The argument may also be a valueHolder."
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1249
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1250
    readOnly := aBoolean
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1251
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1252
    "Created: 14.2.1997 / 17:35:39 / cg"
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1253
!
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1254
4782
353079ce0c9d class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4781
diff changeset
  1255
reallyModifiedChannel
353079ce0c9d class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4781
diff changeset
  1256
    "return the valueHolder holding true if text was really modified.
353079ce0c9d class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4781
diff changeset
  1257
     For compatibility with views which use the modified flag for syntax highlighting."
353079ce0c9d class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4781
diff changeset
  1258
353079ce0c9d class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4781
diff changeset
  1259
    ^ self modifiedChannel
353079ce0c9d class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4781
diff changeset
  1260
!
353079ce0c9d class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4781
diff changeset
  1261
5909
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  1262
st80EditMode
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  1263
    "If on, the cursor wraps at the line end (like in vi or st80);
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  1264
     if off, we have the Rand-editor behavior (random access)"
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  1265
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  1266
    ^ st80Mode ? (UserPreferences current st80EditMode)
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  1267
!
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  1268
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  1269
st80EditMode:aBooleanOrNil
4192
0bc8b69bb610 added: #st80Mode:
Claus Gittinger <cg@exept.de>
parents: 4191
diff changeset
  1270
    "set/clear the st80Mode flag.
0bc8b69bb610 added: #st80Mode:
Claus Gittinger <cg@exept.de>
parents: 4191
diff changeset
  1271
     If on, the cursor wraps at the line end (like in vi or st80);
5255
c24842bec834 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5251
diff changeset
  1272
     if off, we have the Rand-editor behavior (random access)
c24842bec834 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5251
diff changeset
  1273
     if nil, the setting follows the current userPref setting."
c24842bec834 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5251
diff changeset
  1274
c24842bec834 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5251
diff changeset
  1275
    st80Mode := aBooleanOrNil
4192
0bc8b69bb610 added: #st80Mode:
Claus Gittinger <cg@exept.de>
parents: 4191
diff changeset
  1276
0bc8b69bb610 added: #st80Mode:
Claus Gittinger <cg@exept.de>
parents: 4191
diff changeset
  1277
    "Created: / 09-11-2010 / 13:55:50 / cg"
0bc8b69bb610 added: #st80Mode:
Claus Gittinger <cg@exept.de>
parents: 4191
diff changeset
  1278
!
0bc8b69bb610 added: #st80Mode:
Claus Gittinger <cg@exept.de>
parents: 4191
diff changeset
  1279
5909
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  1280
st80Mode:aBooleanOrNil
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  1281
    self obsoleteMethodWarning.
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  1282
    self st80EditMode:aBooleanOrNil
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  1283
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  1284
    "Created: / 09-11-2010 / 13:55:50 / cg"
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  1285
!
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  1286
323
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
  1287
tabMeansNextField:aBoolean
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
  1288
    "set/clear tabbing to the next field.
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
  1289
     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
  1290
     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
  1291
     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
  1292
     input fields."
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
  1293
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
  1294
    tabMeansNextField := aBoolean
2779
5ca530482fdd unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 2774
diff changeset
  1295
!
5ca530482fdd unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 2774
diff changeset
  1296
5ca530482fdd unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 2774
diff changeset
  1297
tabRequiresControl
5ca530482fdd unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 2774
diff changeset
  1298
    "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
  1299
     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
  1300
     to allow for easier text entry"
5ca530482fdd unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 2774
diff changeset
  1301
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1302
    ^ tabRequiresControl
2779
5ca530482fdd unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 2774
diff changeset
  1303
!
5ca530482fdd unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 2774
diff changeset
  1304
5ca530482fdd unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 2774
diff changeset
  1305
tabRequiresControl:aBoolean
5ca530482fdd unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 2774
diff changeset
  1306
    "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
  1307
     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
  1308
     to allow for easier text entry"
5ca530482fdd unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 2774
diff changeset
  1309
5ca530482fdd unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 2774
diff changeset
  1310
    tabRequiresControl := aBoolean
5909
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  1311
!
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  1312
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  1313
trimBlankLines
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  1314
    "If on, the blank lines are trimmed to zero size;
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  1315
     if nil, the setting follows the current userPref setting."
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  1316
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  1317
    ^ trimBlankLines ? (UserPreferences current trimBlankLines)
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  1318
!
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  1319
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  1320
trimBlankLines:aBooleanOrNil
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  1321
    "If on, the blank lines are trimmed to zero size;
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  1322
     if nil, the setting follows the current userPref setting."
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  1323
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  1324
    trimBlankLines := aBooleanOrNil.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1325
! !
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1326
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1327
!EditTextView methodsFor:'accessing-contents'!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1328
1902
302a68c2255e added #at:basicPut: to access a line without change notification.
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
  1329
at:lineNr basicPut:aLine
5413
b21cbb97c038 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5404
diff changeset
  1330
    "change a line without change notification.
b21cbb97c038 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5404
diff changeset
  1331
     this is not undoably, unless you care for yourself"
1902
302a68c2255e added #at:basicPut: to access a line without change notification.
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
  1332
302a68c2255e added #at:basicPut: to access a line without change notification.
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
  1333
    (self at:lineNr) = aLine ifFalse:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  1334
	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
  1335
    ].
302a68c2255e added #at:basicPut: to access a line without change notification.
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
  1336
!
302a68c2255e added #at:basicPut: to access a line without change notification.
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
  1337
522
aa9458e4643e indent/undent did not trigger a modify
ca
parents: 503
diff changeset
  1338
at:lineNr put:aLine
5413
b21cbb97c038 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5404
diff changeset
  1339
    "replace a line by something new.
b21cbb97c038 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5404
diff changeset
  1340
     this is not undoably, unless you care for yourself"
b21cbb97c038 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5404
diff changeset
  1341
5393
efb824b89cdf class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5390
diff changeset
  1342
    |oldLine|
efb824b89cdf class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5390
diff changeset
  1343
efb824b89cdf class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5390
diff changeset
  1344
    oldLine := (self at:lineNr) ? ''.
efb824b89cdf class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5390
diff changeset
  1345
    (oldLine sameStringAndEmphasisAs: (aLine? '')) ifFalse:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  1346
	super at:lineNr put:aLine.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  1347
	self textChanged
522
aa9458e4643e indent/undent did not trigger a modify
ca
parents: 503
diff changeset
  1348
    ].
aa9458e4643e indent/undent did not trigger a modify
ca
parents: 503
diff changeset
  1349
!
aa9458e4643e indent/undent did not trigger a modify
ca
parents: 503
diff changeset
  1350
4700
150468a2ea5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4697
diff changeset
  1351
characterAfterCursor
150468a2ea5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4697
diff changeset
  1352
    "return the character one after the cursor - space if beyond line."
150468a2ea5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4697
diff changeset
  1353
150468a2ea5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4697
diff changeset
  1354
    ^ self characterAtLine:cursorLine col:cursorCol+1
150468a2ea5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4697
diff changeset
  1355
!
150468a2ea5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4697
diff changeset
  1356
1577
4e487247ad33 dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents: 1568
diff changeset
  1357
characterBeforeCursor
4700
150468a2ea5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4697
diff changeset
  1358
    "return the character to the left of cursor - space if beyond line, nil if at the beginning."
1577
4e487247ad33 dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents: 1568
diff changeset
  1359
5142
54457633c096 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5134
diff changeset
  1360
    cursorCol <= 1 ifTrue:[^ nil].
1577
4e487247ad33 dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents: 1568
diff changeset
  1361
4e487247ad33 dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents: 1568
diff changeset
  1362
    ^ self characterAtLine:cursorLine col:cursorCol-1
4e487247ad33 dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents: 1568
diff changeset
  1363
4e487247ad33 dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents: 1568
diff changeset
  1364
    "Created: / 17.6.1998 / 15:16:41 / cg"
4e487247ad33 dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents: 1568
diff changeset
  1365
!
4e487247ad33 dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents: 1568
diff changeset
  1366
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1367
characterUnderCursor
2707
810c994db0b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2696
diff changeset
  1368
    "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
  1369
     For non-block cursors, this is the character immediately to the right
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  1370
     of the insertion-bar or caret.
5413
b21cbb97c038 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5404
diff changeset
  1371
     For block cursors, this is the highlighted cursor-character"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1372
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1373
    ^ self characterAtLine:cursorLine col:cursorCol
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1374
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1375
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1376
contents
2213
6068f2786bd6 added #contentsAsString
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1377
    "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
  1378
5988
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
  1379
    |numLines|
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
  1380
    
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
  1381
    list isNil ifTrue:[^ ''].    
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
  1382
    self trimBlankLines ifTrue:[
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
  1383
        self removeTrailingBlankLines.
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
  1384
    ] ifFalse:[
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
  1385
        "/ the last line does not count, if the cursor is at
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
  1386
        "/ the begining
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
  1387
        cursorCol == 1 ifTrue:[
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
  1388
            numLines := list size.    
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
  1389
            cursorLine == numLines ifTrue:[
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
  1390
                numLines > 1 ifTrue:[
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
  1391
                    (self listAt:numLines) isEmptyOrNil ifTrue:[
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
  1392
                        list grow:numLines-1.
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
  1393
                    ].    
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
  1394
                ].    
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
  1395
            ].    
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
  1396
        ].    
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
  1397
    ].    
3707
8f6bc68b9319 changed #contents - formatting and comments
Stefan Vogel <sv@exept.de>
parents: 3705
diff changeset
  1398
    ^ super contents.
3313
6c2fd7c5a02f CRLF management
fm
parents: 3310
diff changeset
  1399
6c2fd7c5a02f CRLF management
fm
parents: 3310
diff changeset
  1400
    "Modified: / 04-07-2006 / 19:22:32 / fm"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1401
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1402
5413
b21cbb97c038 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5404
diff changeset
  1403
contents:aStringOrStringCollectionOrNil
b21cbb97c038 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5404
diff changeset
  1404
    "replace the whole contents by something new.
5414
87ff3f9cbe55 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5413
diff changeset
  1405
     this is not undoably, unless you care for yourself.
87ff3f9cbe55 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5413
diff changeset
  1406
     See replaceContentsWith:newContents for an undoable version of this"
5413
b21cbb97c038 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5404
diff changeset
  1407
b21cbb97c038 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5404
diff changeset
  1408
    self contents:aStringOrStringCollectionOrNil keepUndoHistory:false.
3249
a4beb76b3f59 code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents: 3241
diff changeset
  1409
!
a4beb76b3f59 code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents: 3241
diff changeset
  1410
a4beb76b3f59 code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents: 3241
diff changeset
  1411
contents:something keepUndoHistory:keepUndoHistory
5414
87ff3f9cbe55 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5413
diff changeset
  1412
    "set the contents and optionally clear the undo history.
87ff3f9cbe55 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5413
diff changeset
  1413
     The contents-change is not undoable."
87ff3f9cbe55 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5413
diff changeset
  1414
3249
a4beb76b3f59 code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents: 3241
diff changeset
  1415
    super contents:something.
a4beb76b3f59 code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents: 3241
diff changeset
  1416
    keepUndoHistory ifFalse:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  1417
	undoSupport resetHistories.
3249
a4beb76b3f59 code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents: 3241
diff changeset
  1418
    ].
a4beb76b3f59 code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents: 3241
diff changeset
  1419
!
a4beb76b3f59 code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents: 3241
diff changeset
  1420
2213
6068f2786bd6 added #contentsAsString
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1421
contentsAsString
6068f2786bd6 added #contentsAsString
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1422
    "return the contents as a String (i.e. without emphasis)"
6068f2786bd6 added #contentsAsString
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1423
6068f2786bd6 added #contentsAsString
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1424
    list isNil ifTrue:[^ ''].
6068f2786bd6 added #contentsAsString
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1425
    self removeTrailingBlankLines.
6068f2786bd6 added #contentsAsString
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1426
    ^ (list collect:[:each | each isNil ifTrue:['']
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  1427
					ifFalse:[each string]
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  1428
		    ]) asStringWithCRs
2213
6068f2786bd6 added #contentsAsString
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1429
!
6068f2786bd6 added #contentsAsString
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1430
5067
a5298bf273fa class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5063
diff changeset
  1431
contentsAsStringWithTabs
a5298bf273fa class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5063
diff changeset
  1432
    "return the contents as a String (i.e. without emphasis)
a5298bf273fa class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5063
diff changeset
  1433
     and with leading spaces replaced by tab characters
a5298bf273fa class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5063
diff changeset
  1434
     (i.e. as would be written to a file)"
a5298bf273fa class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5063
diff changeset
  1435
a5298bf273fa class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5063
diff changeset
  1436
    list isNil ifTrue:[^ ''].
a5298bf273fa class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5063
diff changeset
  1437
    self removeTrailingBlankLines.
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  1438
    ^ (list collect:[:each |
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  1439
	each isNil
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  1440
	    ifTrue:['']
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  1441
	    ifFalse:[each string withTabs]
5067
a5298bf273fa class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5063
diff changeset
  1442
       ]) asStringWithCRs
a5298bf273fa class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5063
diff changeset
  1443
!
a5298bf273fa class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5063
diff changeset
  1444
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1445
cursorCol
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1446
    "return the cursors col (1..).
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1447
     This is the absolute col; NOT the visible col"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1448
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1449
    ^ cursorCol
125
claus
parents: 123
diff changeset
  1450
!
claus
parents: 123
diff changeset
  1451
2422
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1452
cursorColHolder
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1453
    "return a valueHolder for the cursors column (1..)."
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1454
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1455
    ^ cursorColHolder
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1456
!
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1457
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1458
cursorLine
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1459
    "return the cursors line (1..).
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1460
     This is the absolute line; NOT the visible line"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1461
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1462
    ^ cursorLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1463
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1464
5400
c8c25c1392f7 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5399
diff changeset
  1465
cursorLineAndColumnLabelHolder
5399
22d3682235f9 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5394
diff changeset
  1466
    "return a valueHolder for the cursors line and column as an info string
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  1467
     of the form 'line : col'.
5399
22d3682235f9 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5394
diff changeset
  1468
     This can be used directly as a model for a GUI label showing the cursor position (eg in the lower right)"
22d3682235f9 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5394
diff changeset
  1469
22d3682235f9 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5394
diff changeset
  1470
    ^ BlockValue
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  1471
	with:[:l :c | '%1 : %2' bindWith:l with:c]
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  1472
	argument:self cursorLineHolder
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  1473
	argument:self cursorColHolder
5399
22d3682235f9 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5394
diff changeset
  1474
!
22d3682235f9 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5394
diff changeset
  1475
2422
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1476
cursorLineHolder
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1477
    "return a valueHolder for the cursors line (1..).
2422
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1478
     This is the absolute line; NOT the visible line"
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1479
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1480
    ^ cursorLineHolder
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1481
!
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1482
4713
e8c9caf13e05 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4707
diff changeset
  1483
lineStringBeforeCursor
e8c9caf13e05 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4707
diff changeset
  1484
    "return the line's string before the cursor.
e8c9caf13e05 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4707
diff changeset
  1485
     Pad with spaces up to the cursor position if beyond the end of line"
e8c9caf13e05 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4707
diff changeset
  1486
e8c9caf13e05 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4707
diff changeset
  1487
    |line|
e8c9caf13e05 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4707
diff changeset
  1488
e8c9caf13e05 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4707
diff changeset
  1489
    line := ((self at:cursorLine) ? '') string.
e8c9caf13e05 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4707
diff changeset
  1490
    line size < (cursorCol-1) ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  1491
	^ line paddedTo:(cursorCol-1)
4713
e8c9caf13e05 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4707
diff changeset
  1492
    ].
e8c9caf13e05 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4707
diff changeset
  1493
    ^ line copyTo:(cursorCol-1)
e8c9caf13e05 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4707
diff changeset
  1494
!
e8c9caf13e05 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4707
diff changeset
  1495
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1496
list:something
5413
b21cbb97c038 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5404
diff changeset
  1497
    "replace the whole contents by something new.
b21cbb97c038 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5404
diff changeset
  1498
     this is not undoably, unless you care for yourself.
b21cbb97c038 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5404
diff changeset
  1499
     position cursor home when setting contents"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1500
2129
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  1501
    |prevCursorLine prevCursorCol|
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  1502
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  1503
    prevCursorLine := cursorLine.
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  1504
    prevCursorCol := cursorCol.
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  1505
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1506
    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
  1507
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  1508
    (cursorMovementWhenUpdating == #endOfText
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  1509
    or:[cursorMovementWhenUpdating == #end]) ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  1510
	^ self cursorToEndOfText
2129
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  1511
    ].
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  1512
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  1513
    (cursorMovementWhenUpdating == #endOfLine) ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  1514
	^ self cursorLine:prevCursorLine col:(self listAt:cursorLine) size + 1.
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1515
    ].
2129
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  1516
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  1517
    (cursorMovementWhenUpdating == #beginOfText
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  1518
    or:[cursorMovementWhenUpdating == #begin]) ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  1519
	^ self cursorHome
2129
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  1520
    ].
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  1521
    (cursorMovementWhenUpdating == #beginOfLine) ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  1522
	^ 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
  1523
    ].
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  1524
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  1525
    "/ 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
  1526
    "/ self cursorLine:prevCursorLine col:prevCursorCol.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1527
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1528
1476
ac38c8af8585 setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents: 1449
diff changeset
  1529
setContents:something
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  1530
    "replace the whole contents by something new
5413
b21cbb97c038 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5404
diff changeset
  1531
     AND clear the remembered undo actions"
b21cbb97c038 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5404
diff changeset
  1532
1476
ac38c8af8585 setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents: 1449
diff changeset
  1533
    |selType|
ac38c8af8585 setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents: 1449
diff changeset
  1534
2989
5dcc2912bcb6 undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents: 2984
diff changeset
  1535
    undoSupport resetHistories.
2955
Claus Gittinger <cg@exept.de>
parents: 2954
diff changeset
  1536
1476
ac38c8af8585 setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents: 1449
diff changeset
  1537
    selType := typeOfSelection.
ac38c8af8585 setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents: 1449
diff changeset
  1538
    super setContents:something.
ac38c8af8585 setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents: 1449
diff changeset
  1539
    typeOfSelection := selType.
ac38c8af8585 setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents: 1449
diff changeset
  1540
ac38c8af8585 setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents: 1449
diff changeset
  1541
    "Created: / 31.3.1998 / 23:35:06 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1542
! !
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1543
4609
8b3eb80d04d0 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4595
diff changeset
  1544
!EditTextView methodsFor:'accessing-dimensions'!
8b3eb80d04d0 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4595
diff changeset
  1545
8b3eb80d04d0 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4595
diff changeset
  1546
xOfCursor
4728
af70b9c1d04c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4721
diff changeset
  1547
    |point|
af70b9c1d04c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4721
diff changeset
  1548
af70b9c1d04c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4721
diff changeset
  1549
    cursorVisibleLine isNil ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  1550
	"/ take the end of the selection, if any
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  1551
	(selectionStartLine notNil
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  1552
	    and:[ self listLineIsVisible:selectionEndLine ])
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  1553
	ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  1554
	    ^ self xOfCol:selectionEndCol inVisibleLine:selectionEndLine.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  1555
	].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  1556
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  1557
"/        point := device
4728
af70b9c1d04c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4721
diff changeset
  1558
"/                    translatePoint:(device pointerPosition)
af70b9c1d04c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4721
diff changeset
  1559
"/                    fromView:nil
af70b9c1d04c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4721
diff changeset
  1560
"/                    toView:self.
af70b9c1d04c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4721
diff changeset
  1561
"/        ((self bounds) containsPoint:point) ifTrue:[
af70b9c1d04c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4721
diff changeset
  1562
"/            ^ point x
af70b9c1d04c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4721
diff changeset
  1563
"/        ].
af70b9c1d04c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4721
diff changeset
  1564
"/        ^ 0
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  1565
	^ nil
4728
af70b9c1d04c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4721
diff changeset
  1566
    ].
4609
8b3eb80d04d0 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4595
diff changeset
  1567
    ^self xOfCol:cursorCol inVisibleLine:cursorVisibleLine.
8b3eb80d04d0 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4595
diff changeset
  1568
8b3eb80d04d0 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4595
diff changeset
  1569
    "Created: / 27-05-2005 / 07:43:41 / janfrog"
8b3eb80d04d0 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4595
diff changeset
  1570
! !
4590
e28172cd6041 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4589
diff changeset
  1571
474
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  1572
!EditTextView methodsFor:'accessing-look'!
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  1573
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  1574
cursorForegroundColor:color1 backgroundColor:color2
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  1575
    "set both cursor foreground and cursor background colors"
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  1576
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  1577
    |wasOn|
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  1578
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  1579
    wasOn := self hideCursor.
5643
921578f80870 device access
Claus Gittinger <cg@exept.de>
parents: 5593
diff changeset
  1580
    cursorFgColor := color1 onDevice:device.
921578f80870 device access
Claus Gittinger <cg@exept.de>
parents: 5593
diff changeset
  1581
    cursorBgColor := color2 onDevice:device.
474
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  1582
    wasOn ifTrue:[self showCursor]
1333
56af09878b96 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1325
diff changeset
  1583
!
56af09878b96 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1325
diff changeset
  1584
1899
c98fc612bab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
  1585
cursorType
c98fc612bab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
  1586
    "return the style of the text cursor.
4721
59fc420ce5b0 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4715
diff changeset
  1587
     Currently, supported are: #none
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  1588
			       #block, #frame, #ibeam, #caret, #solidCaret
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  1589
			       #bigCaret and #bigSolidCaret"
1899
c98fc612bab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
  1590
c98fc612bab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
  1591
    ^ cursorType
c98fc612bab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
  1592
c98fc612bab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
  1593
    "Modified: / 5.5.1999 / 14:52:33 / cg"
c98fc612bab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
  1594
!
c98fc612bab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
  1595
1333
56af09878b96 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1325
diff changeset
  1596
cursorType:aCursorTypeSymbol
56af09878b96 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1325
diff changeset
  1597
    "set the style of the text cursor.
4721
59fc420ce5b0 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4715
diff changeset
  1598
     Currently, supported are: #none
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  1599
			       #block, #frame, #ibeam, #caret, #solidCaret
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  1600
			       #bigCaret and #bigSolidCaret"
1333
56af09878b96 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1325
diff changeset
  1601
1334
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  1602
    cursorType := aCursorTypeSymbol.
1333
56af09878b96 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1325
diff changeset
  1603
56af09878b96 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1325
diff changeset
  1604
    "Created: 21.9.1997 / 13:42:23 / cg"
56af09878b96 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1325
diff changeset
  1605
    "Modified: 21.9.1997 / 13:43:35 / cg"
1334
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  1606
!
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  1607
1899
c98fc612bab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
  1608
cursorTypeNoFocus
c98fc612bab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
  1609
    "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
  1610
     If left unspecified, this is the same as the regular cursorType."
c98fc612bab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
  1611
c98fc612bab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
  1612
    ^ cursorTypeNoFocus
c98fc612bab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
  1613
c98fc612bab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
  1614
    "Created: / 5.5.1999 / 14:52:46 / cg"
c98fc612bab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
  1615
!
c98fc612bab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
  1616
1334
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  1617
cursorTypeNoFocus:aCursorTypeSymbol
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  1618
    "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
  1619
     If left unspecified, this is the same as the regular cursorType."
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  1620
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  1621
    cursorTypeNoFocus := aCursorTypeSymbol
474
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  1622
! !
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  1623
4048
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
  1624
!EditTextView methodsFor:'accessing-replace'!
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
  1625
4746
39a5681e71ca class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4742
diff changeset
  1626
lastReplacementInfo
39a5681e71ca class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4742
diff changeset
  1627
    ^ lastReplacementInfo
39a5681e71ca class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4742
diff changeset
  1628
!
39a5681e71ca class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4742
diff changeset
  1629
4048
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
  1630
lastStringToReplace: aString
4818
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  1631
!
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  1632
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  1633
previousReplacements
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  1634
    "accessor for the code completion"
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  1635
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  1636
    ^ lastReplacementInfo previousReplacements
4048
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
  1637
! !
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
  1638
2119
2aa585fc62a3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2117
diff changeset
  1639
!EditTextView methodsFor:'change & update'!
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1640
125
claus
parents: 123
diff changeset
  1641
accept
claus
parents: 123
diff changeset
  1642
    "accept the current contents by executing the accept-action and/or
5937
c055e993c2f7 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5909
diff changeset
  1643
     changeMessage.
c055e993c2f7 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5909
diff changeset
  1644
     Historically, ST/X used a callBack (acceptAction);
c055e993c2f7 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5909
diff changeset
  1645
     and ST80/VW used the model, into which the text is stored.
c055e993c2f7 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5909
diff changeset
  1646
     We support both; if there is a mode, it gets a value: message,
c055e993c2f7 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5909
diff changeset
  1647
     If there is an acceptAction, it is called."
125
claus
parents: 123
diff changeset
  1648
1108
3d14bb6bceb7 added disableAccept
Claus Gittinger <cg@exept.de>
parents: 1082
diff changeset
  1649
    acceptEnabled == false ifTrue:[
5937
c055e993c2f7 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5909
diff changeset
  1650
        self beep.
c055e993c2f7 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5909
diff changeset
  1651
        ^ self
2035
6924861adf08 added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents: 2029
diff changeset
  1652
    ].
6924861adf08 added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents: 2029
diff changeset
  1653
    (disableIfInvisible == true and:[self reallyRealized not]) ifTrue:[
5937
c055e993c2f7 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5909
diff changeset
  1654
        ^ self
1108
3d14bb6bceb7 added disableAccept
Claus Gittinger <cg@exept.de>
parents: 1082
diff changeset
  1655
    ].
3d14bb6bceb7 added disableAccept
Claus Gittinger <cg@exept.de>
parents: 1082
diff changeset
  1656
125
claus
parents: 123
diff changeset
  1657
    lockUpdates := true.
1013
391290c747b3 added an acceptChannel
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
  1658
391290c747b3 added an acceptChannel
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
  1659
    "/
391290c747b3 added an acceptChannel
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
  1660
    "/ ST-80 way of doing it
391290c747b3 added an acceptChannel
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
  1661
    "/
391290c747b3 added an acceptChannel
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
  1662
    model notNil ifTrue:[
5937
c055e993c2f7 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5909
diff changeset
  1663
        self sendChangeMessage:changeMsg with:self argForChangeMessage.
c055e993c2f7 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5909
diff changeset
  1664
        acceptChannel notNil ifTrue:[
c055e993c2f7 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5909
diff changeset
  1665
            acceptChannel value:true withoutNotifying:self.
c055e993c2f7 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5909
diff changeset
  1666
        ].
2999
40d3a383e8db *** empty log message ***
ca
parents: 2989
diff changeset
  1667
    ].
40d3a383e8db *** empty log message ***
ca
parents: 2989
diff changeset
  1668
757
2cc7e423f0ef only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents: 730
diff changeset
  1669
    "/
2cc7e423f0ef only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents: 730
diff changeset
  1670
    "/ ST/X way of doing things
5937
c055e993c2f7 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5909
diff changeset
  1671
    "/ as a historic leftover,
757
2cc7e423f0ef only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents: 730
diff changeset
  1672
    "/ 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
  1673
    "/ - not with the actual string
2cc7e423f0ef only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents: 730
diff changeset
  1674
    "/
2cc7e423f0ef only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents: 730
diff changeset
  1675
    acceptAction notNil ifTrue:[
5937
c055e993c2f7 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5909
diff changeset
  1676
        acceptAction value:self list
757
2cc7e423f0ef only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents: 730
diff changeset
  1677
    ].
2cc7e423f0ef only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents: 730
diff changeset
  1678
125
claus
parents: 123
diff changeset
  1679
    lockUpdates := false.
757
2cc7e423f0ef only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents: 730
diff changeset
  1680
1437
ab84b08a9f9c allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
  1681
    "Modified: / 30.1.1998 / 14:19:00 / cg"
131
claus
parents: 130
diff changeset
  1682
!
claus
parents: 130
diff changeset
  1683
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1684
argForChangeMessage
597
fb42c94a042e commentary
Claus Gittinger <cg@exept.de>
parents: 594
diff changeset
  1685
    "return the argument to be passed with the change notification.
fb42c94a042e commentary
Claus Gittinger <cg@exept.de>
parents: 594
diff changeset
  1686
     Defined as separate method for easier subclassability."
fb42c94a042e commentary
Claus Gittinger <cg@exept.de>
parents: 594
diff changeset
  1687
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1688
    ^ self contents
597
fb42c94a042e commentary
Claus Gittinger <cg@exept.de>
parents: 594
diff changeset
  1689
fb42c94a042e commentary
Claus Gittinger <cg@exept.de>
parents: 594
diff changeset
  1690
    "Modified: 29.4.1996 / 12:42:14 / cg"
121
claus
parents: 118
diff changeset
  1691
!
claus
parents: 118
diff changeset
  1692
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1693
getListFromModel
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1694
    "get my contents from the model.
597
fb42c94a042e commentary
Claus Gittinger <cg@exept.de>
parents: 594
diff changeset
  1695
     Redefined to ignore updates resulting from my own changes
fb42c94a042e commentary
Claus Gittinger <cg@exept.de>
parents: 594
diff changeset
  1696
     (i.e. if lockUpdates is true)."
121
claus
parents: 118
diff changeset
  1697
claus
parents: 118
diff changeset
  1698
    "
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1699
     ignore updates from my own change
121
claus
parents: 118
diff changeset
  1700
    "
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1701
    lockUpdates ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  1702
	lockUpdates := false.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  1703
	^ self
121
claus
parents: 118
diff changeset
  1704
    ].
2196
f8c955dd6eb9 validate the cursorLine, when updating from a changed model
Claus Gittinger <cg@exept.de>
parents: 2186
diff changeset
  1705
    super getListFromModel.
3249
a4beb76b3f59 code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents: 3241
diff changeset
  1706
    undoSupport resetHistories.
2196
f8c955dd6eb9 validate the cursorLine, when updating from a changed model
Claus Gittinger <cg@exept.de>
parents: 2186
diff changeset
  1707
f8c955dd6eb9 validate the cursorLine, when updating from a changed model
Claus Gittinger <cg@exept.de>
parents: 2186
diff changeset
  1708
    "/ validate the cursorLine
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1709
    (cursorLine notNil
2310
861ab02b13b9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2225
diff changeset
  1710
     and:[ cursorLine > list size ]) ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  1711
	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
  1712
    ].
1437
ab84b08a9f9c allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
  1713
!
ab84b08a9f9c allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
  1714
ab84b08a9f9c allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
  1715
update:something with:aParameter from:changedObject
1438
bed1564b0640 fixed update for acceptChannel
Claus Gittinger <cg@exept.de>
parents: 1437
diff changeset
  1716
    changedObject == acceptChannel ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  1717
	acceptChannel value == true ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  1718
	    self accept.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  1719
	].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  1720
	^ self.
1437
ab84b08a9f9c allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
  1721
    ].
ab84b08a9f9c allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
  1722
    super update:something with:aParameter from:changedObject
ab84b08a9f9c allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
  1723
ab84b08a9f9c allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
  1724
    "Created: / 30.1.1998 / 14:15:56 / cg"
1439
d1b3ca91ed8a fixed update for acceptChannel
Claus Gittinger <cg@exept.de>
parents: 1438
diff changeset
  1725
    "Modified: / 1.2.1998 / 13:15:55 / cg"
121
claus
parents: 118
diff changeset
  1726
! !
claus
parents: 118
diff changeset
  1727
6015
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1728
!EditTextView methodsFor:'commenting'!
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1729
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1730
commentFrom:line1 to:line2 commentStrings:commentStrings
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1731
    "helper function to comment out a block.
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1732
     All lines from line1 to line2 get an end-of-line comment
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1733
     in the first col
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1734
     (if no eol comment is available, a bracketing comment is used)."
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1735
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1736
    |eolComment opening closing|
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1737
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1738
    eolComment := commentStrings at:1.
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1739
    eolComment isNil ifTrue:[
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1740
        opening := (commentStrings at:2) at:1.
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1741
        closing := (commentStrings at:2) at:2.
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1742
        (opening isNil or:[closing isNil]) ifTrue:[^ self].
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1743
    ].
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1744
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1745
    line1 to:line2 do:[:lineNr |
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1746
        |l|
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1747
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1748
        l := self listAt:lineNr.
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1749
        l isNil ifTrue:[l := ''].
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1750
        eolComment notNil ifTrue:[
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1751
            l := eolComment , l
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1752
        ] ifFalse:[
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1753
            l := opening , l , closing
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1754
        ].
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1755
        self replaceLine:lineNr with:l.
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1756
        widthOfWidestLine notNil ifTrue:[
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1757
            widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:l).
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1758
        ].
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1759
    ].
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1760
    self textChanged.
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1761
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1762
    "Created: / 09-11-1997 / 01:05:35 / cg"
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1763
    "Modified: / 09-10-2006 / 10:46:44 / cg"
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1764
!
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1765
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1766
commentSelection:commentStrings
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1767
    "convenient function to comment out a block.
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1768
     All lines from line1 to line2 get an end-of-line comment
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1769
     in the first col."
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1770
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1771
    |e commentPair opening closing|
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1772
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1773
    (self checkModificationsAllowed) ifFalse:[ ^ self].
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1774
    commentStrings isNil ifTrue:[ self beep. ^ self].
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1775
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1776
    self
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1777
        undoableDo:[ 
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1778
            selectionStartLine isNil ifTrue:[
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1779
                self commentFrom:cursorLine to:cursorLine commentStrings:commentStrings
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1780
            ] ifFalse:[
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1781
                (selectionStartCol == 1 and:[selectionEndCol == 0]) ifTrue:[
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1782
                    self commentFrom:selectionStartLine to:selectionEndLine-1 commentStrings:commentStrings
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1783
                ] ifFalse:[
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1784
                    commentPair := commentStrings at:2 ifAbsent:nil.
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1785
                    commentPair isNil ifTrue:[
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1786
                        self beep.
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1787
                    ] ifFalse:[
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1788
                        opening := commentPair at:1.
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1789
                        closing := commentPair at:2.
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1790
                        (opening isNil or:[closing isNil]) ifTrue:[^ self].
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1791
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1792
                        e := selectionEndCol.
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1793
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1794
                        self insertString:closing atLine:selectionEndLine col:e+1.
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1795
                        self insertString:opening atLine:selectionStartLine col:selectionStartCol.
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1796
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1797
                        selectionStartLine == selectionEndLine ifTrue:[e := e + opening size].
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1798
                        self selectFromLine:selectionStartLine col:selectionStartCol
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1799
                                     toLine:selectionEndLine col:e+closing size.
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1800
                    ]
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1801
                ]
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1802
            ].    
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1803
        ]    
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1804
        info:'Comment'.
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1805
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1806
    "Created: / 9.11.1997 / 01:05:40 / cg"
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1807
    "Modified: / 5.4.1998 / 16:52:23 / cg"
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1808
!
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1809
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1810
uncommentFrom:line1 to:line2 commentStrings:commentStrings
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1811
    "helper function to comment out a block.
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1812
     All lines from line1 to line2 get an end-of-line comment
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1813
     in the first col.
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1814
     (if no eol comment is available, a bracketing comment is removed)."
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1815
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1816
    |eolComment opening closing rest|
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1817
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1818
    eolComment := commentStrings at:1.
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1819
    eolComment isNil ifTrue:[
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1820
        opening := (commentStrings at:2) at:1.
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1821
        closing := (commentStrings at:2) at:2.
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1822
        (opening isNil or:[closing isNil]) ifTrue:[^ self].
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1823
    ] ifFalse:[
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1824
        rest := eolComment size + 1.
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1825
    ].
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1826
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1827
    line1 to:line2 do:[:lineNr |
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1828
        |l|
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1829
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1830
        l := self listAt:lineNr.
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1831
        l notNil ifTrue:[
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1832
            eolComment notNil ifTrue:[
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1833
                (l startsWith:eolComment) ifTrue:[
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1834
                    l := l copyFrom:rest
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1835
                ] ifFalse:[
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1836
                    (l withoutLeadingSeparators startsWith:eolComment) ifTrue:[
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1837
                        "/ only for single lines?
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1838
                        true "line1 = line2" ifTrue:[
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1839
                            |numSpaces|
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1840
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1841
                            numSpaces := l indexOfNonSeparator - 1.
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1842
                            l := l copyFrom:numSpaces+1+rest.
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1843
                            l := (String new:numSpaces),l
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1844
                        ].    
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1845
                    ].    
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1846
                ]
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1847
            ] ifFalse:[
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1848
                ((l startsWith:opening) and:[l endsWith:closing]) ifTrue:[
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1849
                    l := l copyFrom:opening size + 1.
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1850
                    l := l copyButLast:closing size.
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1851
                ].    
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1852
            ].
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1853
            self replaceLine:lineNr with:l.
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1854
        ]
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1855
    ].
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1856
    
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1857
    widthOfWidestLine := nil. "/ i.e. unknown
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1858
    self textChanged.
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1859
!
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1860
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1861
uncommentSelection:commentStrings
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1862
    "convenient function to comment out a block.
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1863
     All lines from line1 to line2 get an end-of-line comment
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1864
     in the first col."
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1865
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1866
    |e commentPair opening closing sz1 sz2 l1 l2 c1 c2|
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1867
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1868
    (self checkModificationsAllowed) ifFalse:[ ^ self].
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1869
    commentStrings isNil ifTrue:[ self beep. ^ self].
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1870
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1871
    self
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1872
        undoableDo:[
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1873
            selectionStartLine isNil ifTrue:[
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1874
                self uncommentFrom:cursorLine to:cursorLine commentStrings:commentStrings
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1875
            ] ifFalse:[
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1876
                (selectionStartCol == 1 and:[selectionEndCol == 0]) ifTrue:[
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1877
                    self uncommentFrom:selectionStartLine to:selectionEndLine-1 commentStrings:commentStrings
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1878
                ] ifFalse:[
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1879
                    commentPair := commentStrings at:2.
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1880
                    opening := commentPair at:1.
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1881
                    closing := commentPair at:2.
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1882
                    (opening isNil or:[closing isNil]) ifTrue:[^ self].
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1883
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1884
                    sz1 := opening size.
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1885
                    sz2 := closing size.
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1886
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1887
                    ((self
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1888
                        stringAtLine:selectionStartLine
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1889
                        from:selectionStartCol
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1890
                        to:selectionStartCol+sz1 - 1) = opening
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1891
                    and:[(self
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1892
                        stringAtLine:selectionEndLine
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1893
                        from:selectionEndCol - sz2 + 1
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1894
                        to:selectionEndCol) = closing ]) ifTrue:[
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1895
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1896
                        l2 := selectionEndLine.   c2 := selectionEndCol.
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1897
                        l1 := selectionStartLine. c1 := selectionStartCol.
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1898
                        self deleteCharsAtLine:l2 fromCol:c2-sz2+1 toCol:c2.
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1899
                        self deleteCharsAtLine:l1 fromCol:c1 toCol:c1+sz1-1.
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1900
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1901
                        e := c2 - sz2.
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1902
                        l1 == l2 ifTrue:[e := e - sz1].
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1903
                        self selectFromLine:l1 col:c1 toLine:l2 col:e.
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1904
                    ]
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1905
                ]
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1906
            ].
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1907
        ]   
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1908
        info:'Uncomment'.
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1909
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1910
    "Modified: / 7.1.1997 / 20:13:32 / cg"
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1911
    "Created: / 9.11.1997 / 01:05:46 / cg"
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1912
! !
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1913
121
claus
parents: 118
diff changeset
  1914
!EditTextView methodsFor:'cursor handling'!
claus
parents: 118
diff changeset
  1915
4820
8640fa6f128f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4818
diff changeset
  1916
basicCursorReturn
8640fa6f128f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4818
diff changeset
  1917
    "move cursor to start of next line; scroll if at end of visible text"
8640fa6f128f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4818
diff changeset
  1918
8640fa6f128f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4818
diff changeset
  1919
    |wasOn|
8640fa6f128f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4818
diff changeset
  1920
8640fa6f128f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4818
diff changeset
  1921
    self checkForExistingLine:(cursorLine + 1).
8640fa6f128f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4818
diff changeset
  1922
    cursorVisibleLine notNil ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  1923
	nFullLinesShown notNil ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  1924
	    (cursorVisibleLine >= nFullLinesShown) ifTrue:[self scrollDown]
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  1925
	]
4820
8640fa6f128f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4818
diff changeset
  1926
    ].
8640fa6f128f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4818
diff changeset
  1927
8640fa6f128f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4818
diff changeset
  1928
    wasOn := self hideCursor.
8640fa6f128f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4818
diff changeset
  1929
    self setValidatedCursorLine:(cursorLine + 1) col:1.
8640fa6f128f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4818
diff changeset
  1930
    self makeCursorVisibleAndShowCursor:wasOn.
8640fa6f128f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4818
diff changeset
  1931
8640fa6f128f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4818
diff changeset
  1932
    "Modified: 22.5.1996 / 18:27:34 / cg"
8640fa6f128f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4818
diff changeset
  1933
!
8640fa6f128f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4818
diff changeset
  1934
2406
aeabb4ccf07c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2404
diff changeset
  1935
characterPositionOfCursor
aeabb4ccf07c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2404
diff changeset
  1936
    ^ self characterPositionOfLine:cursorLine col:cursorCol
aeabb4ccf07c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2404
diff changeset
  1937
!
aeabb4ccf07c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2404
diff changeset
  1938
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1939
cursorBacktab
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1940
    "move cursor to prev tabstop"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1941
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1942
    self cursorCol:(self prevTabBefore:cursorCol).
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1943
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1944
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1945
cursorCol:newCol
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1946
    "move cursor to some column in the current line"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1947
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1948
    |wasOn|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1949
2822
08ceab3fc237 search refactored;
Claus Gittinger <cg@exept.de>
parents: 2819
diff changeset
  1950
    (cursorCol == newCol) ifTrue:[^ self].
08ceab3fc237 search refactored;
Claus Gittinger <cg@exept.de>
parents: 2819
diff changeset
  1951
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1952
    wasOn := self hideCursor.
2422
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1953
    self setValidatedCursorCol:newCol.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1954
    self makeCursorVisibleAndShowCursor:wasOn.
672
065750d02339 added cursorCol-validation
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  1955
065750d02339 added cursorCol-validation
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  1956
    "Modified: 22.5.1996 / 14:25:53 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1957
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1958
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1959
cursorDown
632
5af2c22002e4 dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
  1960
    "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
  1961
     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
  1962
5af2c22002e4 dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
  1963
    |wasOn|
5af2c22002e4 dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
  1964
5af2c22002e4 dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
  1965
    self cursorDown:1.
5af2c22002e4 dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
  1966
2707
810c994db0b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2696
diff changeset
  1967
    "/ cursor beyond text ?
632
5af2c22002e4 dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
  1968
    cursorLine > list size ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  1969
	wasOn := self hideCursor.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  1970
	self setValidatedCursorLine:(list size + 1) col:cursorCol.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  1971
	self makeCursorVisibleAndShowCursor:wasOn.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  1972
	self beep.
632
5af2c22002e4 dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
  1973
    ].
5af2c22002e4 dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
  1974
1561
db5f27354172 make cursor correctly visible if in partial last line.
Claus Gittinger <cg@exept.de>
parents: 1560
diff changeset
  1975
    "Modified: / 10.6.1998 / 17:00:23 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1976
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1977
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1978
cursorDown:n
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1979
    "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
  1980
5857
006deb952a1e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5856
diff changeset
  1981
    |inLastLine wasOn nv nL cursorColBefore|
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1982
4595
2f1e71ea50ac class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4592
diff changeset
  1983
    (nL := cursorLine) isNil ifTrue:[
5857
006deb952a1e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5856
diff changeset
  1984
        nL := firstLineShown
006deb952a1e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5856
diff changeset
  1985
    ].
006deb952a1e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5856
diff changeset
  1986
006deb952a1e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5856
diff changeset
  1987
    inLastLine := (nL == list size).
5890
5dc30fda9ebf #OTHER by mawalch
mawalch
parents: 5887
diff changeset
  1988
5857
006deb952a1e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5856
diff changeset
  1989
    inLastLine ifTrue:[
5858
f281506fb025 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5857
diff changeset
  1990
        |generateTextAfterEndHook|
5857
006deb952a1e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5856
diff changeset
  1991
006deb952a1e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5856
diff changeset
  1992
        cursorColBefore := cursorCol.
5858
f281506fb025 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5857
diff changeset
  1993
        (generateTextAfterEndHook := self getAttribute:#generateTextAfterEndHook) notNil ifTrue:[
5860
acc60507b977 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5859
diff changeset
  1994
            wasOn := self hideCursor.
acc60507b977 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5859
diff changeset
  1995
            nL := generateTextAfterEndHook value:(nL + n).
acc60507b977 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5859
diff changeset
  1996
            self setValidatedCursorLine:nL col:cursorColBefore.
acc60507b977 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5859
diff changeset
  1997
            self makeCursorVisibleAndShowCursor:wasOn.
acc60507b977 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5859
diff changeset
  1998
            ^ self.
5890
5dc30fda9ebf #OTHER by mawalch
mawalch
parents: 5887
diff changeset
  1999
        ].
4595
2f1e71ea50ac class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4592
diff changeset
  2000
    ].
2f1e71ea50ac class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4592
diff changeset
  2001
2f1e71ea50ac class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4592
diff changeset
  2002
    self st80EditMode ifTrue:[
5857
006deb952a1e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5856
diff changeset
  2003
        nL == list size ifTrue:[
006deb952a1e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5856
diff changeset
  2004
            wasOn := self hideCursor.
006deb952a1e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5856
diff changeset
  2005
            self setValidatedCursorLine:nL col:(self listAt:nL) size + 1.
006deb952a1e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5856
diff changeset
  2006
            self makeCursorVisibleAndShowCursor:wasOn.
006deb952a1e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5856
diff changeset
  2007
            self beep.
006deb952a1e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5856
diff changeset
  2008
            ^ self.
006deb952a1e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5856
diff changeset
  2009
        ]
4595
2f1e71ea50ac class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4592
diff changeset
  2010
    ].
2f1e71ea50ac class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4592
diff changeset
  2011
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2012
    cursorVisibleLine notNil ifTrue:[
5857
006deb952a1e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5856
diff changeset
  2013
        wasOn := self hideCursor.
006deb952a1e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5856
diff changeset
  2014
        nv := cursorVisibleLine + n - 1.
006deb952a1e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5856
diff changeset
  2015
        (nv >= nFullLinesShown) ifTrue:[
006deb952a1e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5856
diff changeset
  2016
            self scrollDown:(nv - nFullLinesShown + 1)
006deb952a1e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5856
diff changeset
  2017
        ].
006deb952a1e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5856
diff changeset
  2018
        self setValidatedCursorLine:(cursorLine + n) col:(cursorColBefore ? cursorCol).
006deb952a1e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5856
diff changeset
  2019
        self makeCursorVisibleAndShowCursor:wasOn.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2020
    ] ifFalse:[
5857
006deb952a1e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5856
diff changeset
  2021
        self setValidatedCursorLine:(nL + n) col:(cursorColBefore ? cursorCol).
006deb952a1e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5856
diff changeset
  2022
        self makeCursorVisible.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2023
    ].
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2024
1561
db5f27354172 make cursor correctly visible if in partial last line.
Claus Gittinger <cg@exept.de>
parents: 1560
diff changeset
  2025
    "Modified: / 10.6.1998 / 16:59:17 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2026
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2027
121
claus
parents: 118
diff changeset
  2028
cursorHome
597
fb42c94a042e commentary
Claus Gittinger <cg@exept.de>
parents: 594
diff changeset
  2029
    "scroll to top AND move cursor to first line of text."
121
claus
parents: 118
diff changeset
  2030
674
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  2031
    self cursorLine:1 col:1
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  2032
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  2033
"/    |wasOn|
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  2034
"/
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  2035
"/    wasOn := self hideCursor.
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  2036
"/    self scrollToTop.
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  2037
"/    cursorLine := cursorVisibleLine := 1.
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  2038
"/    cursorCol := self validateCursorCol:1 inLine:cursorLine.
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  2039
"/    self makeCursorVisibleAndShowCursor:wasOn.
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  2040
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  2041
    "Modified: 22.5.1996 / 18:26:42 / cg"
121
claus
parents: 118
diff changeset
  2042
!
claus
parents: 118
diff changeset
  2043
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2044
cursorLeft
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2045
    "move cursor to left"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2046
1300
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  2047
    (cursorCol ~~ 1) ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2048
	self cursorCol:(cursorCol - 1)
1300
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  2049
    ] ifFalse:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2050
	cursorLine ~~ 1 ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2051
	    self st80EditMode ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2052
		self cursorUp.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2053
		self cursorToEndOfLine.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2054
	   ]
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2055
	]
1300
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  2056
    ]
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  2057
1426
de76570ba19e crsrLeft/crsrRight does not wrap to prev/next line in st80 mode
Claus Gittinger <cg@exept.de>
parents: 1419
diff changeset
  2058
    "Modified: / 23.1.1998 / 12:37:13 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2059
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2060
4126
Claus Gittinger <cg@exept.de>
parents: 4121
diff changeset
  2061
cursorLeft:n
Claus Gittinger <cg@exept.de>
parents: 4121
diff changeset
  2062
    "move cursor to left"
Claus Gittinger <cg@exept.de>
parents: 4121
diff changeset
  2063
Claus Gittinger <cg@exept.de>
parents: 4121
diff changeset
  2064
    n timesRepeat:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2065
	self cursorLeft
4126
Claus Gittinger <cg@exept.de>
parents: 4121
diff changeset
  2066
    ].
Claus Gittinger <cg@exept.de>
parents: 4121
diff changeset
  2067
!
Claus Gittinger <cg@exept.de>
parents: 4121
diff changeset
  2068
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2069
cursorLine:line col:col
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2070
    "this positions onto physical - not visible - line"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2071
5056
9984a425a389 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5050
diff changeset
  2072
    self cursorLine:line col:col makeVisible:true
9984a425a389 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5050
diff changeset
  2073
!
9984a425a389 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5050
diff changeset
  2074
9984a425a389 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5050
diff changeset
  2075
cursorLine:line col:col makeVisible:makeVisibleBoolean
9984a425a389 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5050
diff changeset
  2076
    "this positions onto physical - not visible - line"
9984a425a389 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5050
diff changeset
  2077
676
b65b82a1ffcb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
  2078
    |wasOn newCol|
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2079
2822
08ceab3fc237 search refactored;
Claus Gittinger <cg@exept.de>
parents: 2819
diff changeset
  2080
    ((line == cursorLine) and:[col == cursorCol]) ifTrue:[^ self].
08ceab3fc237 search refactored;
Claus Gittinger <cg@exept.de>
parents: 2819
diff changeset
  2081
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2082
    wasOn := self hideCursor.
2422
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2083
    self setValidatedCursorLine:line.
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2084
672
065750d02339 added cursorCol-validation
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  2085
    (col < 1) ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2086
	newCol := 1
672
065750d02339 added cursorCol-validation
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  2087
    ] ifFalse:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2088
	newCol := col.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2089
    ].
2647
23dca8f032c3 changed st80Mode from classVar to userPreferences value
Claus Gittinger <cg@exept.de>
parents: 2627
diff changeset
  2090
    self st80EditMode ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2091
	(cursorLine == list size
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2092
	and:[cursorLine ~~ line]) ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2093
	    newCol := (self listAt:(list size)) size + 1.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2094
	]
1419
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
  2095
    ].
2422
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2096
    self setValidatedCursorCol:newCol.
5056
9984a425a389 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5050
diff changeset
  2097
    makeVisibleBoolean ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2098
	self makeCursorVisibleAndShowCursor:wasOn.
5056
9984a425a389 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5050
diff changeset
  2099
    ] ifFalse:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2100
	wasOn ifTrue:[self showCursor]
5056
9984a425a389 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5050
diff changeset
  2101
    ].
672
065750d02339 added cursorCol-validation
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  2102
1596
0bbdb4e9fc43 made st80Mode also an inst-flag;
Claus Gittinger <cg@exept.de>
parents: 1591
diff changeset
  2103
    "Modified: / 20.6.1998 / 18:19:06 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2104
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2105
1580
d30e562bea15 allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
  2106
cursorMovementAllowed
d30e562bea15 allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
  2107
    "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
  2108
     (via button-click, or cursor-key with selection).
d30e562bea15 allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
  2109
     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
  2110
     in special subclasses (such as a terminal view), where
d30e562bea15 allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
  2111
     this is not wanted"
d30e562bea15 allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
  2112
d30e562bea15 allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
  2113
    ^ true
d30e562bea15 allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
  2114
d30e562bea15 allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
  2115
    "Created: / 18.6.1998 / 14:11:16 / cg"
d30e562bea15 allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
  2116
!
d30e562bea15 allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
  2117
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2118
cursorReturn
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2119
    "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
  2120
4820
8640fa6f128f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4818
diff changeset
  2121
    self basicCursorReturn
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2122
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2123
5529
0b33c7ac879d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 5525
diff changeset
  2124
cursorReturn:withPossibleAutoIndent
0b33c7ac879d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 5525
diff changeset
  2125
    "move cursor to start of next line; scroll if at end of visible text"
0b33c7ac879d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 5525
diff changeset
  2126
0b33c7ac879d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 5525
diff changeset
  2127
    self basicCursorReturn
0b33c7ac879d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 5525
diff changeset
  2128
!
0b33c7ac879d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 5525
diff changeset
  2129
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2130
cursorRight
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2131
    "move cursor to right"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2132
1300
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  2133
    |l|
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  2134
3023
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  2135
    self st80EditMode ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2136
	l := (self listAt:cursorLine).
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2137
	cursorCol >= (l size + 1) ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2138
	    cursorLine <= list size ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2139
		self cursorReturn:false. "/ no autoindent
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2140
	    ].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2141
	    ^ self
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2142
	]
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2143
    ].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2144
    self cursorCol:(cursorCol + 1)
1300
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  2145
1596
0bbdb4e9fc43 made st80Mode also an inst-flag;
Claus Gittinger <cg@exept.de>
parents: 1591
diff changeset
  2146
    "Modified: / 20.6.1998 / 18:19:07 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2147
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2148
4126
Claus Gittinger <cg@exept.de>
parents: 4121
diff changeset
  2149
cursorRight:n
Claus Gittinger <cg@exept.de>
parents: 4121
diff changeset
  2150
    "move cursor to right"
Claus Gittinger <cg@exept.de>
parents: 4121
diff changeset
  2151
Claus Gittinger <cg@exept.de>
parents: 4121
diff changeset
  2152
    n timesRepeat:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2153
	self cursorRight
4126
Claus Gittinger <cg@exept.de>
parents: 4121
diff changeset
  2154
    ].
Claus Gittinger <cg@exept.de>
parents: 4121
diff changeset
  2155
!
Claus Gittinger <cg@exept.de>
parents: 4121
diff changeset
  2156
1833
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  2157
cursorShown:aBoolean
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  2158
    "change cursor visibility
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  2159
     return true if cursor was visible before."
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  2160
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  2161
    |oldState|
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  2162
4494
dfe81ebdd5d6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
  2163
    aBoolean == cursorShown ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2164
	^ cursorShown
4494
dfe81ebdd5d6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
  2165
    ].
1833
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  2166
    oldState := cursorShown.
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  2167
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  2168
    aBoolean ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2169
	self drawCursor.
1833
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  2170
    ] ifFalse:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2171
	(cursorShown and:[shown]) ifTrue: [
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2172
	    self undrawCursor.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2173
	].
1833
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  2174
    ].
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  2175
    cursorShown := aBoolean.
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  2176
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  2177
    ^ oldState
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  2178
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  2179
    "Modified: / 30.3.1999 / 15:32:43 / stefan"
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  2180
    "Created: / 30.3.1999 / 15:59:30 / stefan"
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  2181
!
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  2182
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2183
cursorTab
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2184
    "move cursor to next tabstop"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2185
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2186
    self cursorCol:(self nextTabAfter:cursorCol).
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2187
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2188
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2189
cursorToBeginOfLine
3020
68a2dfad4e5e CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents: 2999
diff changeset
  2190
    "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
  2191
68a2dfad4e5e CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents: 2999
diff changeset
  2192
    |textStart l|
68a2dfad4e5e CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents: 2999
diff changeset
  2193
68a2dfad4e5e CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents: 2999
diff changeset
  2194
    l := self listAt:cursorLine.
68a2dfad4e5e CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents: 2999
diff changeset
  2195
    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
  2196
    cursorCol > textStart ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2197
	self cursorCol:textStart
3020
68a2dfad4e5e CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents: 2999
diff changeset
  2198
    ] ifFalse:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2199
	self cursorCol:1
3020
68a2dfad4e5e CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents: 2999
diff changeset
  2200
    ]
68a2dfad4e5e CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents: 2999
diff changeset
  2201
68a2dfad4e5e CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents: 2999
diff changeset
  2202
    "Created: / 8.8.2004 / 18:51:21 / janfrog"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2203
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2204
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2205
cursorToBottom
2129
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  2206
    "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
  2207
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2208
    |wasOn newTop|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2209
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2210
    wasOn := self hideCursor.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2211
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2212
    newTop := list size - nFullLinesShown.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2213
    (newTop < 1) ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2214
	newTop := 1
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2215
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2216
    self scrollToLine:newTop.
2422
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2217
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2218
    self setValidatedCursorLine:(list size) col:1.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2219
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2220
    self makeCursorVisibleAndShowCursor:wasOn.
672
065750d02339 added cursorCol-validation
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  2221
674
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  2222
    "Modified: 22.5.1996 / 18:27:45 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2223
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2224
1415
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2225
cursorToCharacterPosition:pos
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2226
    "compute line/col from character position (1..)
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2227
     and move the cursor onto that char"
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2228
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2229
    |line col|
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2230
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2231
    line := self lineOfCharacterPosition:pos.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2232
    col := pos - (self characterPositionOfLine:line col:1) + 1.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2233
    self cursorLine:line col:col
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2234
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2235
    "Created: / 15.1.1998 / 21:55:33 / cg"
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2236
!
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2237
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2238
cursorToEnd
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2239
    "move cursor down below last line of text"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2240
2422
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2241
    |wasOn newTop lineNr line|
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2242
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2243
    lineNr := list size.
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2244
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2245
    cursorLine >= lineNr ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2246
	line := self listAt:cursorLine.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2247
	(line isEmptyOrNil) ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2248
	    ^ self
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2249
	]
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2250
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2251
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2252
    wasOn := self hideCursor.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2253
2422
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2254
    lineNr := lineNr + 1.
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2255
    newTop :=  lineNr - nFullLinesShown.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2256
    (newTop < 1) ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2257
	newTop := 1
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2258
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2259
    self scrollToLine:newTop.
2422
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2260
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2261
    self setValidatedCursorLine:lineNr col:1.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2262
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2263
    self makeCursorVisibleAndShowCursor:wasOn.
672
065750d02339 added cursorCol-validation
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  2264
674
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  2265
    "Modified: 22.5.1996 / 18:27:53 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2266
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2267
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2268
cursorToEndOfLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2269
    "move cursor to end of current line"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2270
1300
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  2271
    |line|
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  2272
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  2273
    line := (self listAt:cursorLine).
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  2274
    self cursorCol:(line size + 1)
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  2275
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  2276
    "Modified: 13.8.1997 / 15:34:02 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2277
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2278
2129
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  2279
cursorToEndOfText
4288
f68354357ecc changed: #cursorToEndOfText
Claus Gittinger <cg@exept.de>
parents: 4287
diff changeset
  2280
    "move cursor to the end of the text (behind the last character in last line)"
f68354357ecc changed: #cursorToEndOfText
Claus Gittinger <cg@exept.de>
parents: 4287
diff changeset
  2281
f68354357ecc changed: #cursorToEndOfText
Claus Gittinger <cg@exept.de>
parents: 4287
diff changeset
  2282
    |wasOn newTop lastLineLength pos|
2129
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  2283
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  2284
    wasOn := self hideCursor.
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  2285
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  2286
    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
  2287
    (newTop < 1) ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2288
	newTop := 1
2129
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  2289
    ].
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  2290
    self scrollToLine:newTop.
2422
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2291
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2292
    self setValidatedCursorLine:list size.
4288
f68354357ecc changed: #cursorToEndOfText
Claus Gittinger <cg@exept.de>
parents: 4287
diff changeset
  2293
    lastLineLength := (self listAt:cursorLine) size.
f68354357ecc changed: #cursorToEndOfText
Claus Gittinger <cg@exept.de>
parents: 4287
diff changeset
  2294
    pos := (lastLineLength==0) ifTrue:[0] ifFalse:[lastLineLength+1].
f68354357ecc changed: #cursorToEndOfText
Claus Gittinger <cg@exept.de>
parents: 4287
diff changeset
  2295
    self setCursorCol:(self validateCursorCol:pos inLine:cursorLine).
2129
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  2296
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  2297
    self makeCursorVisibleAndShowCursor:wasOn.
4288
f68354357ecc changed: #cursorToEndOfText
Claus Gittinger <cg@exept.de>
parents: 4287
diff changeset
  2298
4289
d74f746d4c0d comment/format in: #cursorToEndOfText
Claus Gittinger <cg@exept.de>
parents: 4288
diff changeset
  2299
    "Modified: / 15-07-2011 / 20:14:43 / cg"
2129
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  2300
!
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  2301
3310
83368f9014a1 word check
Claus Gittinger <cg@exept.de>
parents: 3303
diff changeset
  2302
cursorToEndOfWord
83368f9014a1 word check
Claus Gittinger <cg@exept.de>
parents: 3303
diff changeset
  2303
    "move the cursor to the end of the word"
83368f9014a1 word check
Claus Gittinger <cg@exept.de>
parents: 3303
diff changeset
  2304
83368f9014a1 word check
Claus Gittinger <cg@exept.de>
parents: 3303
diff changeset
  2305
    (cursorLine > list size) ifTrue:[^ self].
83368f9014a1 word check
Claus Gittinger <cg@exept.de>
parents: 3303
diff changeset
  2306
83368f9014a1 word check
Claus Gittinger <cg@exept.de>
parents: 3303
diff changeset
  2307
    self wordAtLine:cursorLine col:cursorCol do:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2308
	:beginLine :beginCol :endLine :endCol :style |
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2309
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2310
	self cursorLine:endLine col:endCol+1
3310
83368f9014a1 word check
Claus Gittinger <cg@exept.de>
parents: 3303
diff changeset
  2311
    ]
83368f9014a1 word check
Claus Gittinger <cg@exept.de>
parents: 3303
diff changeset
  2312
83368f9014a1 word check
Claus Gittinger <cg@exept.de>
parents: 3303
diff changeset
  2313
    "Created: / 28-06-2006 / 19:16:30 / cg"
83368f9014a1 word check
Claus Gittinger <cg@exept.de>
parents: 3303
diff changeset
  2314
!
83368f9014a1 word check
Claus Gittinger <cg@exept.de>
parents: 3303
diff changeset
  2315
131
claus
parents: 130
diff changeset
  2316
cursorToFirstVisibleLine
claus
parents: 130
diff changeset
  2317
    "place cursor into the first visible line; do not scroll."
claus
parents: 130
diff changeset
  2318
claus
parents: 130
diff changeset
  2319
    self cursorLine:(self visibleLineToAbsoluteLine:1) col:1
claus
parents: 130
diff changeset
  2320
!
claus
parents: 130
diff changeset
  2321
claus
parents: 130
diff changeset
  2322
cursorToLastVisibleLine
claus
parents: 130
diff changeset
  2323
    "place cursor into the first visible line; do not scroll."
claus
parents: 130
diff changeset
  2324
claus
parents: 130
diff changeset
  2325
    self cursorLine:(self visibleLineToAbsoluteLine:nFullLinesShown) col:1
claus
parents: 130
diff changeset
  2326
!
claus
parents: 130
diff changeset
  2327
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2328
cursorToNextWord
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2329
    "move the cursor to the beginning of the next word"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2330
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2331
    |col line searching|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2332
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2333
    (cursorLine > list size) ifTrue:[^ self].
2422
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2334
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2335
    self
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2336
	wordAtLine:cursorLine col:cursorCol
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2337
	do:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2338
	    :beginLine :beginCol :endLine :endCol :style |
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2339
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2340
	    line := endLine.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2341
	    col := endCol + 1.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2342
	    searching := true.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2343
	    [searching and:[(self characterAtLine:line col:col) isSeparator]] whileTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2344
		self wordAtLine:line col:col do:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2345
		    :beginLine :beginCol :endLine :endCol :style |
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2346
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2347
		    (line > list size) ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2348
			"break out"
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2349
			searching := false
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2350
		    ] ifFalse:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2351
			line := endLine.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2352
			col := endCol + 1.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2353
		    ]
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2354
		]
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2355
	    ].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2356
	    self cursorLine:line col:col
4707
f6ac835a1cf6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4701
diff changeset
  2357
    ]
121
claus
parents: 118
diff changeset
  2358
!
claus
parents: 118
diff changeset
  2359
499
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
  2360
cursorToPreviousWord
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
  2361
    "move the cursor to the beginning of this or the previous word"
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
  2362
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
  2363
    |col line searching l|
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
  2364
2422
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2365
    (cursorLine > list size) ifTrue:[^ self].      "/ this is rubbish
499
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
  2366
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
  2367
    self wordAtLine:cursorLine col:cursorCol do:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2368
	:beginLine :beginCol :endLine :endCol :style |
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2369
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2370
	line := beginLine.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2371
	col := beginCol.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2372
	style == #wordLeft ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2373
	    col := col + 1
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2374
	].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2375
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2376
	(cursorLine == line
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2377
	and:[cursorCol == col]) ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2378
	    searching := true.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2379
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2380
	    col > 1 ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2381
		col := col - 1.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2382
	    ].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2383
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2384
	    [searching] whileTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2385
		(col == 1) ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2386
		    line == 1 ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2387
			searching := false
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2388
		    ] ifFalse:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2389
			line := line - 1.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2390
			l := list at:line.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2391
			col := l size + 1.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2392
		    ]
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2393
		] ifFalse:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2394
		    (self characterAtLine:line col:col) isSeparator ifFalse:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2395
			self wordAtLine:line col:col do:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2396
			    :beginLine :beginCol :endLine :endCol :style |
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2397
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2398
			    line := beginLine.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2399
			    col := beginCol.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2400
			    style == #wordLeft ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2401
				col := col + 1
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2402
			    ].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2403
			    searching := false.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2404
			]
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2405
		    ] ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2406
			col := col - 1
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2407
		    ]
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2408
		]
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2409
	    ]
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2410
	].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2411
	self cursorLine:line col:col
499
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
  2412
    ]
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
  2413
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
  2414
    "Created: 8.3.1996 / 21:52:48 / cg"
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
  2415
    "Modified: 8.3.1996 / 22:12:45 / cg"
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
  2416
!
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
  2417
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2418
cursorToTop
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2419
    "move cursor to absolute home"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2420
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2421
    self cursorLine:1 col:1
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2422
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2423
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2424
cursorUp
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2425
    "move cursor up; scroll if at start of visible text"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2426
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2427
    self cursorUp:1
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2428
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2429
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2430
cursorUp:n
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2431
    "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
  2432
5856
a4d4442497d6 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5850
diff changeset
  2433
    |wasOn nv nl cursorColBefore|
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2434
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2435
    cursorLine isNil ifTrue:[
5850
988655795073 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5834
diff changeset
  2436
        self setCursorLine:(firstLineShown + nFullLinesShown - 1).
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2437
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2438
    nl := cursorLine - n.
5850
988655795073 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5834
diff changeset
  2439
    nl < 1 ifTrue:[
5858
f281506fb025 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5857
diff changeset
  2440
        |generateTextBeforeStartHook|
5890
5dc30fda9ebf #OTHER by mawalch
mawalch
parents: 5887
diff changeset
  2441
5856
a4d4442497d6 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5850
diff changeset
  2442
        cursorColBefore := cursorCol.
5858
f281506fb025 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5857
diff changeset
  2443
        (generateTextBeforeStartHook := self getAttribute:#generateTextBeforeStartHook) notNil ifTrue:[
f281506fb025 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5857
diff changeset
  2444
            nl := generateTextBeforeStartHook value:nl
5890
5dc30fda9ebf #OTHER by mawalch
mawalch
parents: 5887
diff changeset
  2445
        ].
5850
988655795073 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5834
diff changeset
  2446
        nl := nl max:1
988655795073 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5834
diff changeset
  2447
    ].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2448
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2449
    (nl ~~ cursorLine) ifTrue: [
5850
988655795073 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5834
diff changeset
  2450
        wasOn := self hideCursor.
988655795073 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5834
diff changeset
  2451
        cursorVisibleLine notNil ifTrue:[
988655795073 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5834
diff changeset
  2452
            nv := cursorVisibleLine - n.
988655795073 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5834
diff changeset
  2453
            nv < 1 ifTrue:[
988655795073 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5834
diff changeset
  2454
                self scrollUp:(nv negated + 1)
988655795073 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5834
diff changeset
  2455
            ].
988655795073 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5834
diff changeset
  2456
        ].
5856
a4d4442497d6 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5850
diff changeset
  2457
        self setValidatedCursorLine:nl col:(cursorColBefore ? cursorCol).
3725
410e861ca010 also makeCursorVisible after cursorUp:
Claus Gittinger <cg@exept.de>
parents: 3707
diff changeset
  2458
"/        wasOn ifTrue:[self showCursor].
5850
988655795073 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5834
diff changeset
  2459
        self makeCursorVisibleAndShowCursor:wasOn.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2460
    ]
672
065750d02339 added cursorCol-validation
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  2461
674
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  2462
    "Modified: 22.5.1996 / 18:28:11 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2463
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2464
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2465
cursorVisibleLine:visibleLineNr col:colNr
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2466
    "put cursor to visibleline/col"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2467
2422
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2468
    |wasOn newCol listLine|
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2469
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2470
    wasOn := self hideCursor.
2422
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2471
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2472
    listLine := self visibleLineToAbsoluteLine:visibleLineNr.
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2473
    self setValidatedCursorLine:listLine.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2474
    cursorVisibleLine := visibleLineNr.
2422
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2475
676
b65b82a1ffcb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
  2476
    newCol := colNr.
b65b82a1ffcb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
  2477
    (newCol < 1) ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2478
	newCol := 1
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2479
    ].
2422
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2480
    self setValidatedCursorCol:newCol.
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2481
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2482
    self makeCursorVisibleAndShowCursor:wasOn.
672
065750d02339 added cursorCol-validation
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  2483
1597
5fdcfcedb91c fixed cursor positioning after replaceStringAtCursor.
Claus Gittinger <cg@exept.de>
parents: 1596
diff changeset
  2484
    "Modified: / 20.6.1998 / 18:40:28 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2485
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2486
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2487
cursorX:x y:y
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2488
    "put cursor to position next to x/y coordinate in view"
121
claus
parents: 118
diff changeset
  2489
claus
parents: 118
diff changeset
  2490
    |line col|
claus
parents: 118
diff changeset
  2491
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2492
    line := self visibleLineOfY:y.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2493
    col := self colOfX:x inVisibleLine:line.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2494
    self cursorVisibleLine:line col:col.
121
claus
parents: 118
diff changeset
  2495
!
claus
parents: 118
diff changeset
  2496
claus
parents: 118
diff changeset
  2497
drawCursor
claus
parents: 118
diff changeset
  2498
    "draw the cursor if shown and cursor is visible.
claus
parents: 118
diff changeset
  2499
     (but not, if there is a selection - to avoid confusion)"
claus
parents: 118
diff changeset
  2500
claus
parents: 118
diff changeset
  2501
    shown ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2502
	cursorVisibleLine notNil ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2503
	    self hasSelection ifFalse:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2504
		self drawCursorCharacter
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2505
	    ]
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2506
	]
121
claus
parents: 118
diff changeset
  2507
    ]
claus
parents: 118
diff changeset
  2508
!
claus
parents: 118
diff changeset
  2509
claus
parents: 118
diff changeset
  2510
drawCursor:cursorType with:fgColor and:bgColor
claus
parents: 118
diff changeset
  2511
    "draw a cursor; the argument cursorType specifies what type
125
claus
parents: 123
diff changeset
  2512
     of cursor should be drawn.
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2513
     Currently, supported are: #none,
6031
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2514
                               #block, #frame, #ibeam, #caret, #solidCaret
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2515
                               #bigCaret and #bigSolidCaret"
2085
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  2516
2570
590956e81610 Remove unused method vars.
Stefan Vogel <sv@exept.de>
parents: 2569
diff changeset
  2517
    |x y w char y2 x1 x2 oldPaint oldClip|
121
claus
parents: 118
diff changeset
  2518
claus
parents: 118
diff changeset
  2519
    self hasSelection ifTrue:[
6031
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2520
        "
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2521
         hide cursor, if there is a selection
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2522
        "
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2523
        ^ super redrawVisibleLine:cursorVisibleLine col:cursorCol.
121
claus
parents: 118
diff changeset
  2524
    ].
claus
parents: 118
diff changeset
  2525
1334
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  2526
    cursorType == #none ifTrue:[
6031
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2527
        ^ self
1334
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  2528
    ].
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  2529
121
claus
parents: 118
diff changeset
  2530
    cursorType == #block ifTrue:[
6031
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2531
        super drawVisibleLine:cursorVisibleLine col:cursorCol with:fgColor and:bgColor.
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2532
        ^ self
121
claus
parents: 118
diff changeset
  2533
    ].
2429
eed79a96e43b eliminated accesses to leftOffset
Claus Gittinger <cg@exept.de>
parents: 2427
diff changeset
  2534
    x := (self xOfCol:cursorCol inVisibleLine:cursorVisibleLine) - viewOrigin x.
121
claus
parents: 118
diff changeset
  2535
    y := self yOfVisibleLine:cursorVisibleLine.
claus
parents: 118
diff changeset
  2536
1449
2a54bdfff203 eliminated direct refs to paint instvar
Claus Gittinger <cg@exept.de>
parents: 1446
diff changeset
  2537
    oldPaint := self paint. "/ do not clobber GC
121
claus
parents: 118
diff changeset
  2538
    cursorType == #frame ifTrue:[
6031
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2539
        super redrawVisibleLine:cursorVisibleLine col:cursorCol.
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2540
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2541
        char := self characterUnderCursor asString.
6068
01e28002daf7 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6050
diff changeset
  2542
        gc paint:bgColor.
01e28002daf7 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6050
diff changeset
  2543
        gc displayRectangleX:x y:y width:(gc font widthOf:char) height:fontHeight-2.
133
claus
parents: 132
diff changeset
  2544
    ] ifFalse:[
6031
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2545
        self paint:bgColor.
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2546
        cursorType == #ibeam ifTrue:[
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2547
            x1 := x - 1.
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2548
            y2 := y + fontHeight - lineSpacing - 1.
6068
01e28002daf7 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6050
diff changeset
  2549
            gc displayLineFromX:x1 y:y toX:x1 y:y2.
01e28002daf7 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6050
diff changeset
  2550
            gc displayLineFromX:x y:y toX:x y:y2.
6031
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2551
            ^ self
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2552
        ].
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2553
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2554
        cursorType == #Ibeam ifTrue:[
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2555
            x1 := x - 1.
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2556
            y := y + 1.
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2557
            y2 := y + fontHeight - lineSpacing - 1.
6068
01e28002daf7 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6050
diff changeset
  2558
            gc displayLineFromX:x1 y:y toX:x1 y:y2.
01e28002daf7 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6050
diff changeset
  2559
            gc displayLineFromX:x y:y toX:x y:y2.
01e28002daf7 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6050
diff changeset
  2560
            gc displayLineFromX:x1-2 y:y toX:x+2 y:y.
01e28002daf7 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6050
diff changeset
  2561
            gc displayLineFromX:x1-2 y:y2 toX:x+2 y:y2.
6031
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2562
            ^ self
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2563
        ].
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2564
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2565
        y := y + fontHeight - 3.
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2566
        ((cursorType == #bigCaret) or:[cursorType == #bigSolidCaret]) ifTrue:[
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2567
            w := (fontWidth * 2 // 3) max:4.
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2568
            y2 := y + w + (w//2).
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2569
        ] ifFalse:[
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2570
            w := (fontWidth // 2) max:4.
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2571
            y2 := y + w.
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2572
        ].
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2573
        x1 := x - w.
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2574
        x2 := x + w.
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2575
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2576
        oldClip := self clippingBoundsOrNil.
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2577
        self clippingBounds:(margin@margin extent:(width-margin) @ (height-margin)).
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2578
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2579
        cursorType == #caret ifTrue:[
6068
01e28002daf7 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6050
diff changeset
  2580
            gc lineWidth:2.
01e28002daf7 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6050
diff changeset
  2581
            gc displayLineFromX:x1 y:y2 toX:x y:y.
01e28002daf7 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6050
diff changeset
  2582
            gc displayLineFromX:x y:y toX:x2 y:y2.
6031
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2583
        ] ifFalse:[
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2584
            "anything else: solidCaret"
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2585
6068
01e28002daf7 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6050
diff changeset
  2586
            gc fillPolygon:(Array with:(x1 @ y2)
01e28002daf7 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6050
diff changeset
  2587
                                  with:(x @ y)
01e28002daf7 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6050
diff changeset
  2588
                                  with:(x2 @ y2))
6031
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2589
        ].
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2590
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2591
        self clippingBounds:oldClip
121
claus
parents: 118
diff changeset
  2592
    ].
6068
01e28002daf7 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6050
diff changeset
  2593
    gc paint:oldPaint.
662
4bcdf0cce3a7 dont let caret cursor become too small (with small fonts)
Claus Gittinger <cg@exept.de>
parents: 655
diff changeset
  2594
2088
b2beb67b1a98 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2085
diff changeset
  2595
    "Modified: / 15.12.1999 / 22:24:17 / cg"
121
claus
parents: 118
diff changeset
  2596
!
claus
parents: 118
diff changeset
  2597
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2598
drawCursorCharacter
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2599
    "draw the cursor.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2600
     (i.e. the cursor if no selection)
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2601
     - helper for many cursor methods"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2602
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2603
    (hasKeyboardFocus
3296
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
  2604
     and:[self enabled
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
  2605
     and:[self isReadOnly not]]) ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2606
	self drawFocusCursor
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2607
    ] ifFalse:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2608
	self drawNoFocusCursor
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2609
    ]
1817
1a9e22f755c8 show non-focus cursor when disabled or readOnly
Claus Gittinger <cg@exept.de>
parents: 1816
diff changeset
  2610
1a9e22f755c8 show non-focus cursor when disabled or readOnly
Claus Gittinger <cg@exept.de>
parents: 1816
diff changeset
  2611
    "Modified: / 23.3.1999 / 13:52:48 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2612
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2613
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2614
drawFocusCursor
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2615
    "draw the cursor when the focus is in the view."
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2616
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2617
    self hasSelection ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2618
	^ super redrawVisibleLine:cursorVisibleLine col:(cursorCol max:1).
1334
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  2619
    ].
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  2620
    cursorType == #none ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2621
	^ self undrawCursor
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2622
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2623
    self drawCursor:cursorType with:cursorFgColor and:cursorBgColor.
1334
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  2624
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  2625
    "Modified: 22.9.1997 / 00:16:38 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2626
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2627
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2628
drawNoFocusCursor
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2629
    "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
  2630
1334
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  2631
    |cType|
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  2632
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2633
    self hasSelection ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2634
	^ super redrawVisibleLine:cursorVisibleLine col:cursorCol.
121
claus
parents: 118
diff changeset
  2635
    ].
1022
4362861fe15e allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents: 1018
diff changeset
  2636
1334
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  2637
    cType := cursorTypeNoFocus ? cursorType.
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  2638
    cType == #none ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2639
	^ self undrawCursor
1334
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  2640
    ].
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  2641
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  2642
    cType == #block ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2643
	^ self drawCursor:#frame with:cursorNoFocusFgColor and:cursorBgColor
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2644
    ].
1022
4362861fe15e allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents: 1018
diff changeset
  2645
1334
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  2646
    ^ self drawCursor:cType with:cursorNoFocusFgColor and:cursorNoFocusFgColor.
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  2647
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  2648
    "Modified: 22.9.1997 / 00:16:13 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2649
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2650
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2651
gotoLine:aLineNumber
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2652
    "position cursor onto line, aLineNumber.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2653
     Make certain that this line is visible"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2654
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2655
    self makeLineVisible:aLineNumber.
2951
eb820ef25acf unselect before gotoLine
Claus Gittinger <cg@exept.de>
parents: 2950
diff changeset
  2656
    self unselect.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2657
    self cursorLine:aLineNumber col:1
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2658
!
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
hideCursor
1833
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  2661
    "make cursor invisible if currently invisible"
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  2662
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  2663
    ^ self cursorShown:false
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  2664
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  2665
    "Modified: / 30.3.1999 / 16:02:28 / stefan"
121
claus
parents: 118
diff changeset
  2666
!
claus
parents: 118
diff changeset
  2667
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2668
makeCursorVisible
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2669
    "scroll text to make cursorline visible
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2670
     (i.e. to have cursorLine in visible area)"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2671
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2672
    |line col|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2673
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2674
    cursorLine notNil ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2675
	line := cursorLine.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2676
	col := cursorCol.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2677
	"
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2678
	 if there is a selection, its better to
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2679
	 have its start being visible, instead of the end
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2680
	"
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2681
	(selectionStartLine notNil
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2682
	and:[selectionEndLine notNil]) ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2683
	    expandingTop ~~ false ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2684
		line := selectionStartLine.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2685
		col := selectionStartCol.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2686
	    ] ifFalse:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2687
		line := selectionEndLine.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2688
		col := selectionEndCol
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2689
	    ]
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2690
	].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2691
	self makeLineVisible:line.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2692
	self makeColVisible:col inLine:line
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2693
    ]
479
fae6d1251888 fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 477
diff changeset
  2694
fae6d1251888 fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 477
diff changeset
  2695
    "Modified: 6.3.1996 / 13:46:46 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2696
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2697
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2698
makeCursorVisibleAndShowCursor:flag
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2699
    "scroll to make cursorLine visible;
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2700
     if flag is true, draw the cursor"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2701
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2702
    self makeCursorVisible.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2703
    flag ifTrue:[self showCursor]
121
claus
parents: 118
diff changeset
  2704
!
claus
parents: 118
diff changeset
  2705
2422
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2706
setCursorCol:colNr
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2707
    "strictly private: set the cursorCol"
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2708
2815
d71f43d7de3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2796
diff changeset
  2709
    cursorCol := (colNr max:1).
2422
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2710
    cursorColHolder value:cursorCol.
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2711
!
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2712
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2713
setCursorLine:lineNr
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2714
    "strictly private: set the cursorLine"
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2715
3303
add21df4dcb1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3296
diff changeset
  2716
    "/ self assert:(lineNr notNil).
add21df4dcb1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3296
diff changeset
  2717
add21df4dcb1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3296
diff changeset
  2718
    cursorLine := (lineNr ? 1).
2422
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2719
    cursorLineHolder value:cursorLine.
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2720
    self updateCursorVisibleLine.
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2721
!
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2722
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2723
setCursorLine:lineNr col:colNr
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2724
    "strictly private: set the cursorLine, col and update the visibleLine"
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2725
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2726
    self setCursorLine:lineNr.
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2727
    self setCursorCol:colNr.
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2728
!
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2729
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2730
setValidatedCursorCol:colNr
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2731
    "strictly private: set the cursorCol"
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2732
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2733
    self setCursorCol:(self validateCursorCol:colNr inLine:cursorLine).
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2734
!
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2735
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2736
setValidatedCursorLine:lineNr
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2737
    "strictly private: set the cursorLine and update the visibleLine"
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2738
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2739
    self setCursorLine:(self validateCursorLine:lineNr).
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2740
!
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2741
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2742
setValidatedCursorLine:lineNr col:colNr
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2743
    "strictly private: set the cursorLine, col and update the visibleLine"
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2744
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2745
    self setValidatedCursorLine:lineNr.
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2746
    self setValidatedCursorCol:colNr.
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2747
!
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2748
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2749
showCursor
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2750
    "make cursor visible if currently invisible"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2751
1833
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  2752
    ^ self cursorShown:true
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  2753
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  2754
    "Modified: / 30.3.1999 / 16:02:34 / stefan"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2755
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2756
5761
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  2757
singleQuoteSelection
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  2758
    "place single quotes around the selected text"
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  2759
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  2760
    |line1 col1 line2 col2|
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  2761
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  2762
    line1 := self selectionStartLine.
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  2763
    col1 := self selectionStartCol.
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  2764
    line2 := self selectionEndLine.
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  2765
    col2 := self selectionEndCol.
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  2766
    (line1 notNil
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2767
	and:[ col1 notNil
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2768
	and:[ line2 notNil
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2769
	and:[ col2 notNil ]]])
5761
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  2770
    ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2771
	self insertString:Character quote asString atLine:line2 col:col2+1.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2772
	self insertString:Character quote asString atLine:line1 col:col1.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2773
	self selectFromLine:line1 col:col1 toLine:line2 col:col2+2.
5761
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  2774
    ] ifFalse:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2775
	self beep.
5761
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  2776
    ]
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  2777
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  2778
    "Created: / 06-06-2016 / 11:03:36 / cg"
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  2779
!
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  2780
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2781
undrawCursor
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2782
    "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
  2783
2085
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  2784
    |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
  2785
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2786
    cursorVisibleLine notNil ifTrue:[
6031
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2787
        prevCol := cursorCol - 1.
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2788
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2789
        "/ if there is any italic stuff in the cursor line,
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2790
        "/ redraw it completely (because characters overlap).
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2791
        cursorCol > 1 ifTrue:[
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2792
            (line := self listAt:cursorLine) notNil ifTrue:[
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2793
                line hasChangeOfEmphasis ifTrue:[
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2794
                    line size >= (cursorCol-1) ifTrue:[
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2795
                        e1 := Text extractEmphasis:#italic from:(line emphasisAt:cursorCol-1).
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2796
                        line size >= (cursorCol) ifTrue:[
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2797
                            e2 := Text extractEmphasis:#italic from:(line emphasisAt:cursorCol).
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2798
                            line size >= (cursorCol+1) ifTrue:[
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2799
                                e3 := Text extractEmphasis:#italic from:(line emphasisAt:cursorCol+1)
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2800
                            ].
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2801
                        ].
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2802
                    ].
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2803
                    (e1 notNil or:[e2 notNil or:[e3 notNil]]) ifTrue:[
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2804
                        ^ super redrawVisibleLine:cursorVisibleLine
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2805
                    ]
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2806
                ]
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2807
            ]
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2808
        ].
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2809
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2810
        ((cursorType == #caret)
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2811
         or:[cursorType == #solidCaret
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2812
         or:[cursorType == #bigSolidCaret
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2813
         or:[cursorType == #bigCaret
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2814
         or:[cursorType == #Ibeam]]]]) ifTrue:[
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2815
            "caret-cursor touches 4 characters"
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2816
            ((cursorCol > 1) and:[fontIsFixedWidth]) ifTrue:[
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2817
                super redrawVisibleLine:cursorVisibleLine-1 from:prevCol to:cursorCol.
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2818
                super redrawVisibleLine:cursorVisibleLine from:prevCol to:cursorCol.
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2819
                super redrawVisibleLine:cursorVisibleLine+1 from:prevCol to:cursorCol.
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2820
            ] ifFalse:[
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2821
                "care for left margin"
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2822
                super redrawVisibleLine:cursorVisibleLine; redrawVisibleLine:cursorVisibleLine+1.
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2823
            ].
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2824
            ^ self
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2825
        ].
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2826
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2827
        cursorType == #ibeam ifTrue:[
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2828
            "ibeam-cursor touches 2 characters"
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2829
            cursorCol > 1 ifTrue:[
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2830
                super redrawVisibleLine:cursorVisibleLine from:prevCol to:cursorCol.
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2831
            ] ifFalse:[
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2832
                "care for left margin"
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2833
                super redrawVisibleLine:cursorVisibleLine.
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2834
            ].
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2835
            ^ self
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2836
        ].
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2837
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2838
        "block cursor is simple - just one character under cursor"
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2839
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2840
        "/ however, if italic characters are involved, we must care
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2841
        "/ for the chars before/after the cursor.
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2842
        "/ We redraw the part of the previous character which got
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2843
        "/ detroyed by the block cursor.
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2844
        "/ (must change the clip, to avoid destroying the prev-prev character)
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2845
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2846
        line := self visibleAt:cursorVisibleLine.
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2847
        (line notNil and:[line isText]) ifTrue:[
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2848
            cursorCol > 1 ifTrue:[
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2849
                oldClip := self clippingBoundsOrNil.
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2850
                x := (self xOfCol:cursorCol inVisibleLine:cursorVisibleLine) - viewOrigin x.
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2851
                y := self yOfVisibleLine:cursorVisibleLine.
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2852
                self clippingBounds:(x@y extent:((gc font width * 2) @ fontHeight)).
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2853
                super redrawVisibleLine:cursorVisibleLine from:cursorCol-1 to:cursorCol.
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2854
                self clippingBounds:oldClip.
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2855
                ^ self.
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2856
            ].
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2857
        ].
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2858
        super redrawVisibleLine:cursorVisibleLine col:cursorCol
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2859
    ]
728
3ef81000ee8c new cursorTypes: #bigCaret and #bigSolidCaret
Claus Gittinger <cg@exept.de>
parents: 698
diff changeset
  2860
2088
b2beb67b1a98 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2085
diff changeset
  2861
    "Modified: / 15.12.1999 / 22:25:59 / cg"
121
claus
parents: 118
diff changeset
  2862
!
claus
parents: 118
diff changeset
  2863
2422
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2864
updateCursorVisibleLine
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2865
    "strictly private: set the visibleLine from the cursorLine.
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2866
     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
  2867
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2868
    cursorVisibleLine := self listLineToVisibleLine:cursorLine.
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2869
!
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2870
672
065750d02339 added cursorCol-validation
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  2871
validateCursorCol:col inLine:line
674
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  2872
    "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
  2873
     Here, no limits are enforced (and col is returned),
5593
ad41e448d7a8 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 5581
diff changeset
  2874
     but it may be redefined in EditFields or views which don't like the
674
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  2875
     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
  2876
1300
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  2877
    |l max|
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  2878
1419
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
  2879
    "/ in ST80 mode,
2707
810c994db0b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2696
diff changeset
  2880
    "/ the cursor may not be positioned beyond the
810c994db0b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2696
diff changeset
  2881
    "/ 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
  2882
3023
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  2883
    self st80EditMode ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2884
	l := (self listAt:line).
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2885
	max := l size + 1.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2886
	col > max ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2887
	    ^ max
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2888
	]
1300
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  2889
    ].
672
065750d02339 added cursorCol-validation
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  2890
    ^ col
065750d02339 added cursorCol-validation
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  2891
1419
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
  2892
    "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
  2893
    "Modified: / 20.6.1998 / 18:19:24 / cg"
674
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  2894
!
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  2895
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  2896
validateCursorLine:line
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  2897
    "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
  2898
     Here, no limits are enforced (and line is returned), but it may be
5593
ad41e448d7a8 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 5581
diff changeset
  2899
     redefined in views which don't like the cursor to be positioned
674
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  2900
     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
  2901
     skip reserved regions"
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  2902
1419
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
  2903
    "/
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
  2904
    "/ in st80Mode, the cursor may not be positioned
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2905
    "/ beyond the last line
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2906
    "/ (but it must be posible to place it on one line below the last one
5367
7696ee76ebe8 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5361
diff changeset
  2907
    "/ - otherwise deleteSelection and some others fail to delete from previousToLastLine)
1419
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
  2908
    "/
3023
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  2909
    self st80EditMode ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2910
	^ (line min:(list size + 1)) max:1
1419
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
  2911
    ].
674
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  2912
    ^ line
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  2913
1419
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
  2914
    "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
  2915
    "Modified: / 20.6.1998 / 18:19:26 / cg"
672
065750d02339 added cursorCol-validation
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  2916
!
065750d02339 added cursorCol-validation
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  2917
121
claus
parents: 118
diff changeset
  2918
withCursorOffDo:aBlock
claus
parents: 118
diff changeset
  2919
    "evaluate aBlock with cursor off; turn it on afterwards."
claus
parents: 118
diff changeset
  2920
claus
parents: 118
diff changeset
  2921
    (shown not or:[cursorShown not]) ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2922
	^ aBlock value
121
claus
parents: 118
diff changeset
  2923
    ].
claus
parents: 118
diff changeset
  2924
    self hideCursor.
2522
d80496af7eaf #valueNowOrOnUnwindDo: -> #ensure:
Claus Gittinger <cg@exept.de>
parents: 2506
diff changeset
  2925
    aBlock ensure:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2926
	self showCursor
121
claus
parents: 118
diff changeset
  2927
    ]
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2928
! !
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2929
2589
62794ae04446 support drop
ca
parents: 2580
diff changeset
  2930
!EditTextView methodsFor:'drag & drop'!
62794ae04446 support drop
ca
parents: 2580
diff changeset
  2931
62794ae04446 support drop
ca
parents: 2580
diff changeset
  2932
allowDrop:aBoolean
3236
aeb1fe5a6ead drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3235
diff changeset
  2933
    "enable/disable drop support"
aeb1fe5a6ead drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3235
diff changeset
  2934
2589
62794ae04446 support drop
ca
parents: 2580
diff changeset
  2935
    aBoolean ifFalse:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2936
	dropTarget := nil.
2589
62794ae04446 support drop
ca
parents: 2580
diff changeset
  2937
    ] ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2938
	dropTarget isNil ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2939
	    dropTarget := DropTarget
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2940
				receiver:self
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2941
				argument:nil
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2942
				dropSelector:#'drop:'
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2943
				canDropSelector:#'canDrop:'
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2944
	]
3236
aeb1fe5a6ead drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3235
diff changeset
  2945
    ].
aeb1fe5a6ead drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3235
diff changeset
  2946
!
aeb1fe5a6ead drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3235
diff changeset
  2947
3412
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  2948
canDrop:aDropContext
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  2949
    "public from d&d.
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  2950
     I accept textObjects and fileObjects only."
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  2951
4089
c6567fb50316 comment/format in: #canDrop:
Claus Gittinger <cg@exept.de>
parents: 4064
diff changeset
  2952
    "/ cg: disabled to avoid unintended drop (is same as copy-past, anyway)
3412
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  2953
    aDropContext sourceWidget == self ifTrue:[^ false].
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  2954
    ^ self canDropObjects:aDropContext dropObjects
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  2955
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  2956
    "Modified: / 13-10-2006 / 17:41:09 / cg"
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  2957
!
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  2958
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  2959
canDropObjects:aCollectionOfDropObjects
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  2960
    "public from d&d.
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  2961
     I accept textObjects and fileObjects only."
2589
62794ae04446 support drop
ca
parents: 2580
diff changeset
  2962
62794ae04446 support drop
ca
parents: 2580
diff changeset
  2963
    self checkModificationsAllowed ifFalse:[^ false].
62794ae04446 support drop
ca
parents: 2580
diff changeset
  2964
3412
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  2965
    aCollectionOfDropObjects isEmpty ifTrue:[ ^ false ].
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  2966
    ^ aCollectionOfDropObjects conform:[:obj| (obj isTextObject or:[obj isFileObject])]
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  2967
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  2968
    "Created: / 13-10-2006 / 15:56:57 / cg"
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  2969
    "Modified: / 13-10-2006 / 17:41:14 / cg"
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  2970
!
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  2971
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  2972
drop:aDropContext
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  2973
    "public from d&d.
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  2974
     drop objects (new API)"
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  2975
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  2976
    self dropObjects:(aDropContext dropObjects)
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  2977
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  2978
    "Modified: / 13-10-2006 / 17:41:19 / cg"
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  2979
!
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  2980
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  2981
dropFileObject:aDropObject
2589
62794ae04446 support drop
ca
parents: 2580
diff changeset
  2982
    "drop objects
3236
aeb1fe5a6ead drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3235
diff changeset
  2983
     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
  2984
4136
fcce27dfc253 changed: #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  2985
    |answer text fn pasteWhat sensor dontAskAgainHolder enforcedDropMode app|
3907
e4be6bf71a98 Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents: 3890
diff changeset
  2986
e4be6bf71a98 Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents: 3890
diff changeset
  2987
    pasteWhat := #name.
3412
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  2988
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  2989
    fn := aDropObject asFilename.
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  2990
    (fn exists and:[fn isRegularFile]) ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2991
	enforcedDropMode := UserPreferences current enforcedDropModeForFiles.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2992
	(enforcedDropMode notNil
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2993
	and:[enforcedDropMode ~~ #name or:[fn fileSize <= (1024*1024)]]) ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2994
	    pasteWhat := enforcedDropMode.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2995
	] ifFalse:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2996
	    sensor := self sensor.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2997
	    (sensor shiftDown or:[sensor ctrlDown]) ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2998
		pasteWhat := #name.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2999
	    ] ifFalse:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3000
		(sensor metaDown) ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3001
		    pasteWhat := #contents.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3002
		] ifFalse:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3003
		    dontAskAgainHolder := false asValue.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3004
		    answer := Dialog
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3005
			confirmWithCancel:(resources
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3006
					    stringWithCRs:'Drop the Filename (%1)\or its Contents ?\\Hint: bypass this dialog by pressing SHIFT/CTRL or ALT during the next drop.\SHIFT/CTRL to drop the name, ALT for the contents.'
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3007
					    with:fn name allBold)
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3008
			labels:#( 'Cancel' 'Name' 'Contents' )
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3009
			values:#( nil #name #contents )
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3010
			default:#contents
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3011
			check:(resources string:'Do not ask again; instead, always paste the contents of small files.') on:dontAskAgainHolder
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3012
			title:(resources string:'Drop What').
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3013
		    answer isNil ifTrue:[ ^ self ].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3014
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3015
		    dontAskAgainHolder value ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3016
			UserPreferences current enforcedDropModeForFiles:#contents
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3017
		    ].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3018
		    pasteWhat := answer.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3019
		]
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3020
	    ]
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3021
	].
3886
b50c9304f1d1 better alien file drop
Claus Gittinger <cg@exept.de>
parents: 3880
diff changeset
  3022
    ].
b50c9304f1d1 better alien file drop
Claus Gittinger <cg@exept.de>
parents: 3880
diff changeset
  3023
3907
e4be6bf71a98 Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents: 3890
diff changeset
  3024
    pasteWhat == #name ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3025
	text := fn pathName
3886
b50c9304f1d1 better alien file drop
Claus Gittinger <cg@exept.de>
parents: 3880
diff changeset
  3026
    ] ifFalse:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3027
	self withWaitCursorDo:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3028
	    text := fn contentsAsString
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3029
	].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3030
	(app := self application) notNil ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3031
	    app droppedFile:fn in:self
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3032
	].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3033
    ].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3034
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3035
    self
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3036
	undoablePaste:text
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3037
	info:'Drop File'.
3412
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  3038
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  3039
    "Created: / 13-10-2006 / 17:38:31 / cg"
3495
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  3040
    "Modified: / 28-07-2007 / 13:27:09 / cg"
3412
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  3041
!
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  3042
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  3043
dropObject:aDropObject
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  3044
    "drop objects
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  3045
     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
  3046
3415
35ffbeec46d9 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3412
diff changeset
  3047
    |text|
35ffbeec46d9 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3412
diff changeset
  3048
3412
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  3049
    (aDropObject isFileObject) ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3050
	self dropFileObject:aDropObject
3412
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  3051
    ] ifFalse:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3052
	aDropObject isTextObject ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3053
	    text := aDropObject theObject.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3054
	    text isStringCollection ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3055
		text := text asStringWithoutFinalCR
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3056
	    ].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3057
	] ifFalse:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3058
	    text := aDropObject theObject asString
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3059
	].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3060
	self
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3061
	    undoablePaste:text
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3062
	    info:'Drop'.
3412
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  3063
    ].
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  3064
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  3065
    "Created: / 13-10-2006 / 17:37:05 / cg"
3495
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  3066
    "Modified: / 28-07-2007 / 13:26:53 / cg"
3412
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  3067
!
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  3068
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  3069
dropObjects:aCollectionOfDropObjects
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  3070
    "public from d&d.
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  3071
     drop objects (old API)"
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  3072
3868
664a888e9c6a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3855
diff changeset
  3073
    aCollectionOfDropObjects do:[:el |
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3074
	self dropObject:el
3412
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  3075
    ].
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  3076
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  3077
    "Created: / 13-10-2006 / 15:59:40 / cg"
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  3078
    "Modified: / 13-10-2006 / 17:41:23 / cg"
2589
62794ae04446 support drop
ca
parents: 2580
diff changeset
  3079
! !
62794ae04446 support drop
ca
parents: 2580
diff changeset
  3080
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3081
!EditTextView methodsFor:'editing'!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3082
5761
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3083
applyConverterToSelection:converter
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3084
    "apply a converter to the selected text"
4286
83ef1d9faf6d added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents: 4285
diff changeset
  3085
83ef1d9faf6d added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents: 4285
diff changeset
  3086
    |line1 line2|
83ef1d9faf6d added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents: 4285
diff changeset
  3087
83ef1d9faf6d added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents: 4285
diff changeset
  3088
    line1 := self selectionStartLine.
83ef1d9faf6d added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents: 4285
diff changeset
  3089
    line2 := self selectionEndLine.
83ef1d9faf6d added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents: 4285
diff changeset
  3090
    line1 isNil ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3091
	line1 := self perform:#cursorLine ifNotUnderstood:nil.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3092
	line1 notNil ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3093
	    line2 := line1
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3094
	]
4286
83ef1d9faf6d added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents: 4285
diff changeset
  3095
    ].
83ef1d9faf6d added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents: 4285
diff changeset
  3096
    line1 notNil ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3097
	line1 to:line2 do:[:lineNr |
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3098
	    |line col1 col2 newLine|
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3099
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3100
	    line := (self listAt:lineNr) copy.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3101
	    line size > 0 ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3102
		lineNr == line1 ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3103
		    col1 := selectionStartCol.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3104
		] ifFalse:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3105
		    col1 := 1.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3106
		].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3107
		lineNr == line2 ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3108
		    col2 := selectionEndCol.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3109
		] ifFalse:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3110
		    col2 := (self listAt:lineNr) size.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3111
		].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3112
		newLine := converter value:line value:lineNr value:col1 value:col2.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3113
		self withoutRedrawAt:lineNr put:newLine.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3114
		self invalidateLine:lineNr.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3115
	    ].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3116
	].
5761
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3117
    ]
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3118
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3119
    "Created: / 06-06-2016 / 10:53:17 / cg"
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3120
!
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3121
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3122
convertSelectionToLowercase
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3123
    "to-lower selected text"
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3124
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3125
    self applyConverterToSelection:[:line :lnr :col1 :col2 |
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3126
	col1 to:col2 do:[:col |
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3127
	    |ch|
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3128
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3129
	    ch := line at:col.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3130
	    line at:col put:ch asLowercase.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3131
	].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3132
	line.
5761
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3133
    ].
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3134
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3135
    "Created: / 06-06-2016 / 10:50:28 / cg"
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3136
!
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3137
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3138
convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3139
    "toLower/toUppercaseFirst/toUpper selected text"
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3140
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3141
    self applyConverterToSelection:[:line :lineNr :col1 :col2 |
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3142
	|isAllLower isLowerFirst isAllUpper isUpperFirst
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3143
	 makeLowercase makeUppercase makeUppercaseFirst makeLowercaseFirst|
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3144
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3145
	isAllLower := isAllUpper := isUpperFirst := isLowerFirst := true.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3146
	col1 to:col2 do:[:col |
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3147
	    |ch|
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3148
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3149
	    ch := line at:col.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3150
	    ch isUppercase ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3151
		isAllLower := false.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3152
		col == col1 ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3153
		    isLowerFirst := false.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3154
		].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3155
	    ] ifFalse:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3156
		ch isLowercase ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3157
		    isAllUpper := false.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3158
		    col == col1 ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3159
			isUpperFirst := false.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3160
		    ].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3161
		]
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3162
	    ].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3163
	].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3164
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3165
	makeLowercase := makeUppercase := makeUppercaseFirst := makeLowercaseFirst := false.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3166
	isLowerFirst ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3167
	    makeUppercaseFirst := true.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3168
	] ifFalse:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3169
	    "/ must remember where we come from - otherwise, we end up
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3170
	    "/ in upperFirst - lowerFirst cycle.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3171
	    "/ think about a good place to store this state
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3172
	    false "(isUpperFirst and:[isAllUpper not])" ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3173
		makeLowercaseFirst := true.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3174
	     ] ifFalse:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3175
		isAllUpper ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3176
		    makeLowercase := true.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3177
		] ifFalse:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3178
		    makeUppercase := true.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3179
		]
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3180
	    ]
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3181
	].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3182
	makeUppercaseFirst ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3183
	    line at:col1 put:(line at:col1) asUppercase.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3184
	] ifFalse:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3185
	    makeLowercaseFirst ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3186
		line at:col1 put:(line at:col1) asLowercase.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3187
	    ] ifFalse:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3188
		col1 to:col2 do:[:col |
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3189
		    |ch|
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3190
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3191
		    ch := line at:col.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3192
		    ch := makeLowercase
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3193
			    ifTrue:[ ch asLowercase ]
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3194
			    ifFalse:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3195
				makeUppercase
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3196
				    ifTrue:[ ch asUppercase ]
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3197
				    ifFalse:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3198
					col == col1
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3199
					    ifTrue:[ ch asUppercase ]
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3200
					    ifFalse:[ ch asLowercase ]
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3201
				    ]
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3202
			    ].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3203
		    line at:col put:ch.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3204
		].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3205
	    ].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3206
	].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3207
	line
4286
83ef1d9faf6d added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents: 4285
diff changeset
  3208
    ]
83ef1d9faf6d added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents: 4285
diff changeset
  3209
83ef1d9faf6d added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents: 4285
diff changeset
  3210
    "Created: / 14-07-2011 / 11:40:26 / cg"
5761
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3211
    "Modified: / 06-06-2016 / 10:57:15 / cg"
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3212
!
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3213
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3214
convertSelectionToUppercase
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3215
    "to-upper selected text"
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3216
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3217
    self applyConverterToSelection:[:line :lnr :col1 :col2 |
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3218
	col1 to:col2 do:[:col |
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3219
	    |ch|
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3220
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3221
	    ch := line at:col.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3222
	    line at:col put:ch asUppercase.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3223
	].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3224
	line.
5761
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3225
    ].
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3226
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3227
    "Created: / 06-06-2016 / 11:09:04 / cg"
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3228
!
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3229
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3230
convertSelectionToUppercaseFirst
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3231
    "to-upperFirst selected text"
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3232
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3233
    self applyConverterToSelection:[:line :lnr :col1 :col2 |
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3234
	|state|
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3235
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3236
	state := #first.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3237
	col1 to:col2 do:[:col |
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3238
	    |ch|
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3239
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3240
	    ch := line at:col.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3241
	    ch isSeparator ifFalse:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3242
		state == #first ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3243
		    line at:col put:ch asUppercase.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3244
		    state := #skipRest
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3245
		]
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3246
	    ] ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3247
		state := #first
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3248
	    ]
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3249
	].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3250
	line.
5761
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3251
    ].
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3252
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3253
    "Created: / 06-06-2016 / 10:50:52 / cg"
4286
83ef1d9faf6d added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents: 4285
diff changeset
  3254
!
83ef1d9faf6d added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents: 4285
diff changeset
  3255
313
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  3256
copyAndDeleteSelection
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  3257
    "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
  3258
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  3259
    selectionStartLine notNil ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3260
	self setClipboardText:(self selection).
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3261
	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
  3262
    ].
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  3263
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  3264
    "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
  3265
!
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  3266
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3267
deleteCharAtCursor
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3268
    "delete single character under cursor; does not merge lines"
121
claus
parents: 118
diff changeset
  3269
claus
parents: 118
diff changeset
  3270
    |wasOn|
claus
parents: 118
diff changeset
  3271
claus
parents: 118
diff changeset
  3272
    wasOn := self hideCursor.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3273
    self deleteCharAtLine:cursorLine col:cursorCol.
121
claus
parents: 118
diff changeset
  3274
    wasOn ifTrue:[self showCursor]
claus
parents: 118
diff changeset
  3275
!
claus
parents: 118
diff changeset
  3276
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3277
deleteCharAtLine:lineNr col:colNr
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3278
    "delete a single character at colNr in line lineNr"
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3279
3023
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  3280
    self st80EditMode ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3281
	(self listAt:cursorLine) size + 1 = colNr ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3282
	    | wasOn |
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3283
	    wasOn := self hideCursor.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3284
	    self
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3285
		cursorReturn;
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3286
		cursorCol:1;
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3287
		deleteCharBeforeCursor.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3288
	    wasOn ifTrue:[ self showCursor].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3289
	    ^ self.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3290
	].
3023
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  3291
    ].
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  3292
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3293
    self deleteCharsAtLine:lineNr fromCol:colNr toCol:colNr
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3294
!
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3295
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3296
deleteCharBeforeCursor
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3297
    "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
  3298
4592
60fc44d286f2 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4590
diff changeset
  3299
    |soCol wasOn lineNrAboveCursor ln originalLine prevTab|
121
claus
parents: 118
diff changeset
  3300
6050
4fb30794fc81 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6031
diff changeset
  3301
    list isEmptyOrNil ifTrue:[^ self]. "/ there is nothing to delete.
4fb30794fc81 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6031
diff changeset
  3302
    
121
claus
parents: 118
diff changeset
  3303
    wasOn := self hideCursor.
4814
6f9c85f3fbfb class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4812
diff changeset
  3304
    (autoIndent and:[ (tabPositions includes:cursorCol)]) ifTrue:[
6050
4fb30794fc81 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6031
diff changeset
  3305
        prevTab := (self prevTabBefore:cursorCol) max:1.
4fb30794fc81 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6031
diff changeset
  3306
        ln := originalLine := (list at:cursorLine ifAbsent:'') ? ''.
4fb30794fc81 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6031
diff changeset
  3307
        ln size < prevTab ifTrue:[
4fb30794fc81 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6031
diff changeset
  3308
            ln := ln , (String new:prevTab withAll:Character space).
4fb30794fc81 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6031
diff changeset
  3309
        ].
4fb30794fc81 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6031
diff changeset
  3310
        (ln copyTo:prevTab) isBlank ifTrue:[
4fb30794fc81 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6031
diff changeset
  3311
            (ln copyFrom:prevTab+1) isBlank ifTrue:[
4fb30794fc81 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6031
diff changeset
  3312
                cursorCol > prevTab ifTrue:[
4fb30794fc81 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6031
diff changeset
  3313
                    self st80EditMode ifTrue:[
4fb30794fc81 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6031
diff changeset
  3314
                        "/ ensure that there is no conflict here: st80EditMode will
4fb30794fc81 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6031
diff changeset
  3315
                        "/ not allow a cursor position beyond the end of line,
4fb30794fc81 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6031
diff changeset
  3316
                        "/ so ensure that cursorLine:col: will force us to the beginning of the line
4fb30794fc81 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6031
diff changeset
  3317
                        originalLine size < prevTab ifTrue:[
4fb30794fc81 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6031
diff changeset
  3318
                            self checkForExistingLine:cursorLine.
4fb30794fc81 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6031
diff changeset
  3319
                            self basicListAt:cursorLine put:ln
4fb30794fc81 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6031
diff changeset
  3320
                        ]
4fb30794fc81 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6031
diff changeset
  3321
                    ].
4fb30794fc81 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6031
diff changeset
  3322
                    self cursorLine:cursorLine col:prevTab.
4fb30794fc81 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6031
diff changeset
  3323
                    wasOn ifTrue:[ self showCursor ].
4fb30794fc81 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6031
diff changeset
  3324
                    ^  self
4fb30794fc81 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6031
diff changeset
  3325
                ].
4fb30794fc81 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6031
diff changeset
  3326
            ] ifFalse:[
4fb30794fc81 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6031
diff changeset
  3327
                self deleteFromLine:cursorLine col:prevTab toLine:cursorLine col:cursorCol-1.
4fb30794fc81 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6031
diff changeset
  3328
                self cursorLine:cursorLine col:prevTab.
4fb30794fc81 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6031
diff changeset
  3329
                wasOn ifTrue:[ self showCursor ].
4fb30794fc81 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6031
diff changeset
  3330
                ^  self.
4fb30794fc81 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6031
diff changeset
  3331
            ]
4fb30794fc81 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6031
diff changeset
  3332
        ].
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3333
    ].
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3334
2491
f3e207ae5156 auto indent fix
Claus Gittinger <cg@exept.de>
parents: 2461
diff changeset
  3335
"/        (autoIndent
f3e207ae5156 auto indent fix
Claus Gittinger <cg@exept.de>
parents: 2461
diff changeset
  3336
"/    and:[cursorCol  ~~ 1
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3337
"/    and:[cursorLine <= (list size)]])
2491
f3e207ae5156 auto indent fix
Claus Gittinger <cg@exept.de>
parents: 2461
diff changeset
  3338
"/     ifTrue:[
f3e207ae5156 auto indent fix
Claus Gittinger <cg@exept.de>
parents: 2461
diff changeset
  3339
"/        soCol := (self leftIndentForLine:cursorLine) + 1.
f3e207ae5156 auto indent fix
Claus Gittinger <cg@exept.de>
parents: 2461
diff changeset
  3340
"/
f3e207ae5156 auto indent fix
Claus Gittinger <cg@exept.de>
parents: 2461
diff changeset
  3341
"/        (cursorCol == soCol and:[soCol > 1]) ifTrue:[
f3e207ae5156 auto indent fix
Claus Gittinger <cg@exept.de>
parents: 2461
diff changeset
  3342
"/            ln := list at:cursorLine.
f3e207ae5156 auto indent fix
Claus Gittinger <cg@exept.de>
parents: 2461
diff changeset
  3343
"/            (ln notNil and:[(ln indexOfNonSeparatorStartingAt:1) < soCol]) ifTrue:[
f3e207ae5156 auto indent fix
Claus Gittinger <cg@exept.de>
parents: 2461
diff changeset
  3344
"/                soCol := 1
f3e207ae5156 auto indent fix
Claus Gittinger <cg@exept.de>
parents: 2461
diff changeset
  3345
"/            ]
f3e207ae5156 auto indent fix
Claus Gittinger <cg@exept.de>
parents: 2461
diff changeset
  3346
"/        ]
f3e207ae5156 auto indent fix
Claus Gittinger <cg@exept.de>
parents: 2461
diff changeset
  3347
"/    ] ifFalse:[
6050
4fb30794fc81 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6031
diff changeset
  3348
        soCol := 1.
2491
f3e207ae5156 auto indent fix
Claus Gittinger <cg@exept.de>
parents: 2461
diff changeset
  3349
"/    ].
f3e207ae5156 auto indent fix
Claus Gittinger <cg@exept.de>
parents: 2461
diff changeset
  3350
1419
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
  3351
    (cursorCol ~~ soCol and:[cursorCol ~~ 1]) ifTrue:[
6050
4fb30794fc81 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6031
diff changeset
  3352
        "
4fb30794fc81 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6031
diff changeset
  3353
         somewhere in the middle of a line
4fb30794fc81 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6031
diff changeset
  3354
        "
4fb30794fc81 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6031
diff changeset
  3355
        self cursorLeft.
4fb30794fc81 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6031
diff changeset
  3356
        self deleteCharAtLine:cursorLine col:cursorCol.
1419
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
  3357
    ] ifFalse:[
6050
4fb30794fc81 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6031
diff changeset
  3358
        "
4fb30794fc81 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6031
diff changeset
  3359
         at begin of line - merge with previous line;
4fb30794fc81 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6031
diff changeset
  3360
         except for the very first line.
4fb30794fc81 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6031
diff changeset
  3361
        "
4fb30794fc81 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6031
diff changeset
  3362
        (cursorLine == 1) ifFalse:[
4fb30794fc81 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6031
diff changeset
  3363
            lineNrAboveCursor := self validateCursorLine:(cursorLine - 1).
4fb30794fc81 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6031
diff changeset
  3364
            lineNrAboveCursor < cursorLine ifTrue:[
4fb30794fc81 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6031
diff changeset
  3365
                (lineNrAboveCursor > 0 and:[lineNrAboveCursor > list size]) ifTrue:[
4fb30794fc81 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6031
diff changeset
  3366
                    "/ we are beyond the end of the text.
4fb30794fc81 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6031
diff changeset
  3367
                    "/ move the cursor to the previous line.
4fb30794fc81 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6031
diff changeset
  3368
                    self cursorLine:lineNrAboveCursor col:1.
4fb30794fc81 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6031
diff changeset
  3369
                ] ifFalse:[
4fb30794fc81 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6031
diff changeset
  3370
                    self mergeLine:lineNrAboveCursor removeBlanks:false.
4fb30794fc81 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6031
diff changeset
  3371
                ]
4fb30794fc81 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6031
diff changeset
  3372
            ]
4fb30794fc81 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6031
diff changeset
  3373
        ]
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3374
    ].
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3375
    wasOn ifTrue:[ self showCursor ]
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3376
1419
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
  3377
    "Modified: / 16.1.1998 / 22:33:04 / cg"
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3378
!
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3379
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3380
deleteCharsAtLine:lineNr fromCol:colNr
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3381
    "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
  3382
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3383
    |line|
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3384
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3385
    (line := self listAt:lineNr) notNil ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3386
	self deleteCharsAtLine:lineNr fromCol:colNr toCol:(line size)
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3387
    ]
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3388
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3389
!
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3390
4458
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  3391
deleteCharsAtLine:lineNr fromCol:startCol toCol:endCol
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  3392
    "delete characters from startCol to endCol in line lineNr"
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  3393
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  3394
    |deleted|
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  3395
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  3396
    deleted := self textFromLine:lineNr col:startCol toLine:lineNr col:endCol.
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  3397
    self basicDeleteCharsAtLine:lineNr fromCol:startCol toCol:endCol.
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  3398
    self addUndo:(PasteString line:lineNr col:startCol string:deleted info:'delete').
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  3399
!
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  3400
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3401
deleteCharsAtLine:lineNr toCol:colNr
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3402
    "delete characters from start up to colNr in line lineNr"
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3403
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3404
    self deleteCharsAtLine:lineNr fromCol:1 toCol:colNr
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3405
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3406
121
claus
parents: 118
diff changeset
  3407
!
claus
parents: 118
diff changeset
  3408
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3409
deleteCursorLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3410
    "delete the line where the cursor sits"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3411
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3412
    self deleteLine:cursorLine
121
claus
parents: 118
diff changeset
  3413
!
claus
parents: 118
diff changeset
  3414
2385
357e8a1cb2b2 added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents: 2373
diff changeset
  3415
deleteFromCharacterPosition:charPos1 to:charPos2
357e8a1cb2b2 added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents: 2373
diff changeset
  3416
    "delete a substring at a character position"
357e8a1cb2b2 added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents: 2373
diff changeset
  3417
357e8a1cb2b2 added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents: 2373
diff changeset
  3418
    |line1 col1 line2 col2|
357e8a1cb2b2 added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents: 2373
diff changeset
  3419
357e8a1cb2b2 added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents: 2373
diff changeset
  3420
    line1 := self lineOfCharacterPosition:charPos1.
357e8a1cb2b2 added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents: 2373
diff changeset
  3421
    col1 := charPos1 - (self characterPositionOfLine:line1 col:1) + 1.
2725
eccf283b2efb deleteFromCharacterPos - fixed
Claus Gittinger <cg@exept.de>
parents: 2724
diff changeset
  3422
    col1 == 0 ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3423
	line1 := line1 - 1.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3424
	col1 := (self listAt:line1) size + 1.
2725
eccf283b2efb deleteFromCharacterPos - fixed
Claus Gittinger <cg@exept.de>
parents: 2724
diff changeset
  3425
    ].
2385
357e8a1cb2b2 added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents: 2373
diff changeset
  3426
357e8a1cb2b2 added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents: 2373
diff changeset
  3427
    line2 := self lineOfCharacterPosition:charPos2.
357e8a1cb2b2 added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents: 2373
diff changeset
  3428
    col2 := charPos2 - (self characterPositionOfLine:line2 col:1) + 1.
357e8a1cb2b2 added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents: 2373
diff changeset
  3429
357e8a1cb2b2 added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents: 2373
diff changeset
  3430
    self deleteFromLine:line1 col:col1 toLine:line2 col:col2.
357e8a1cb2b2 added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents: 2373
diff changeset
  3431
!
357e8a1cb2b2 added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents: 2373
diff changeset
  3432
2954
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3433
deleteFromLine:startLine col:startCol toLine:endLine col:endCol
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3434
    "delete all text from startLine/startCol to endLine/endCol -
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3435
     joining lines if nescessary"
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3436
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3437
    |line newLine lineSize nMore|
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3438
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3439
    self checkModificationsAllowed ifFalse:[ ^ self].
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3440
    list isNil ifTrue:[^ self].
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3441
    startLine > list size ifTrue:[ ^ self]. "/ deleted space below text
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3442
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3443
    (startLine == endLine) ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3444
	"/ delete chars within a line
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3445
	self deleteCharsAtLine:startLine fromCol:startCol toCol:endCol.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3446
	^ self
2954
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3447
    ].
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3448
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3449
    ((startCol == 1) and:[endCol == 0]) ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3450
	"/ delete full lines only
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3451
	endLine > startLine ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3452
	    self deleteFromLine:startLine toLine:(endLine - 1)
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3453
	].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3454
	^ self
2954
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3455
    ].
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3456
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3457
    "/ delete right rest of 1st line
4786
70fd2d143e7c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4782
diff changeset
  3458
    self deleteCharsAtLine:startLine fromCol:(startCol max:1).
2954
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3459
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3460
    "/ delete the inner lines ...
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3461
    endLine > (startLine + 1) ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3462
	self deleteFromLine:(startLine + 1) toLine:(endLine - 1)
2954
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3463
    ].
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3464
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3465
    (endCol ~~ 0) ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3466
	"/ delete the left rest of the last line
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3467
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3468
	self deleteCharsAtLine:(startLine + 1) toCol:endCol.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3469
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3470
	"/ must add blanks, if startCol lies beyond end of startLine
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3471
	startLine <= list size ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3472
	    line := list at:startLine.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3473
	    lineSize := line size.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3474
	    (startCol > lineSize) ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3475
		newLine := line.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3476
		line isNil ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3477
		    newLine := String new:(startCol - 1)
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3478
		] ifFalse:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3479
		    nMore := startCol - 1 - lineSize.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3480
		    nMore > 0 ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3481
			newLine := line , (line species new:nMore)
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3482
		    ]
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3483
		].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3484
		newLine ~~ line ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3485
		    self basicListAt:startLine put:newLine.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3486
		].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3487
		"/ TODO: remember old maxwidth of linerange,
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3488
		"/ only clear widthOfWidestLine, if this max
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3489
		"/ length was (one of) the longest.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3490
		"/ avoids slow delete with huge texts.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3491
		widthOfWidestLine := nil. "/ i.e. unknown
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3492
		self textChanged.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3493
	    ]
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3494
	]
2954
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3495
    ].
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3496
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3497
    "/ 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
  3498
    self mergeLine:startLine removeBlanks:false
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3499
4225
a0a83ed7368c changed: #deleteFromLine:col:toLine:col:
az
parents: 4213
diff changeset
  3500
    "Modified: / 10-11-1998 / 23:52:59 / cg"
a0a83ed7368c changed: #deleteFromLine:col:toLine:col:
az
parents: 4213
diff changeset
  3501
    "Modified: / 18-03-2011 / 18:25:01 / az"
2954
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3502
!
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3503
4458
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  3504
deleteFromLine:startLineNr toLine:endLineNr
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  3505
    "delete some lines"
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  3506
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  3507
    |deleted|
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  3508
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  3509
    deleted := self textFromLine:startLineNr col:1 toLine:endLineNr+1 col:0.
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  3510
    self basicDeleteFromLine:startLineNr toLine:endLineNr.
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  3511
    self addUndo:(PasteString line:startLineNr col:1 string:deleted info:'delete').
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  3512
!
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  3513
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3514
deleteLine:lineNr
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3515
    "delete line"
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3516
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3517
    self deleteFromLine:lineNr toLine:lineNr
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3518
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3519
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3520
!
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3521
4458
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  3522
deleteLineWithoutRedraw:lineNr
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  3523
    "delete line - no redraw;
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  3524
     return true, if something was really deleted"
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  3525
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  3526
    |deleted ret|
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  3527
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  3528
    deleted := self textFromLine:lineNr col:1 toLine:lineNr+1 col:0.
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  3529
    ret := self basicDeleteLineWithoutRedraw:lineNr.
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  3530
    self addUndo:(PasteString line:lineNr col:1 string:deleted info:'delete').
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  3531
    ^ ret.
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  3532
!
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  3533
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3534
deleteLinesWithoutRedrawFrom:startLine to:endLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3535
    "delete lines - no redraw;
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3536
     return true, if something was really deleted"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3537
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3538
    |lastLine|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3539
4771
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  3540
    self checkModificationsAllowed ifFalse:[^ false].
331
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
  3541
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3542
    (list isNil or:[startLine > list size]) ifTrue:[^ false].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3543
    (endLine > list size) ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3544
	lastLine := list size
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3545
    ] ifFalse:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3546
	lastLine := endLine
4771
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  3547
    ].
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  3548
    self basicListRemoveFromIndex:startLine toIndex:lastLine.
1717
83203096a851 dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  3549
    "/ TODO: remember old maxwidth of linerange,
83203096a851 dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  3550
    "/ only clear widthOfWidestLine, if this max
83203096a851 dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  3551
    "/ length was (one of) the longest.
83203096a851 dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  3552
    "/ avoids slow delete with huge texts.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3553
    widthOfWidestLine := nil. "/ i.e. unknown
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3554
    self textChanged.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3555
    ^ true
1717
83203096a851 dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  3556
83203096a851 dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  3557
    "Modified: / 10.11.1998 / 23:55:29 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3558
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3559
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3560
deleteSelection
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3561
    "delete the selection"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3562
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3563
    |wasOn startLine startCol endLine endCol|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3564
331
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
  3565
    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
  3566
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3567
    selectionStartLine notNil ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3568
	wasOn := self hideCursor.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3569
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3570
	startLine := selectionStartLine.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3571
	startCol := selectionStartCol.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3572
	endLine := selectionEndLine.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3573
	endCol := selectionEndCol.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3574
	self unselectWithoutRedraw.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3575
	self deleteFromLine:startLine col:startCol toLine:endLine col:endCol.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3576
	self setCursorLine:startLine col:startCol.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3577
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3578
	self makeCursorVisibleAndShowCursor:wasOn
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3579
    ]
121
claus
parents: 118
diff changeset
  3580
!
claus
parents: 118
diff changeset
  3581
2157
ba22c3cc278b added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
  3582
deleteWordBeforeCursor
ba22c3cc278b added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
  3583
    "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
  3584
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3585
    |wasOn beginCol beginLine endCol endLine|
2157
ba22c3cc278b added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
  3586
3799
f6cbe8d860d5 code formatting
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3587
    self checkModificationsAllowed ifFalse:[ ^ self].
5361
d39070e004c1 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5357
diff changeset
  3588
    cursorCol <= 1 ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3589
	self deleteCharBeforeCursor.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3590
	^ self
5361
d39070e004c1 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5357
diff changeset
  3591
    ].
3799
f6cbe8d860d5 code formatting
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3592
2157
ba22c3cc278b added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
  3593
    wasOn := self hideCursor.
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3594
    self
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3595
	undoableDo:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3596
	    endCol := cursorCol-1.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3597
	    endLine := cursorLine.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3598
	    self cursorToPreviousWord.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3599
	    beginCol := cursorCol.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3600
	    beginLine := cursorLine.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3601
	    self deleteFromLine:beginLine col:beginCol toLine:endLine col:endCol.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3602
	    self cursorLine:cursorLine col:beginCol.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3603
	]
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3604
	info:'Delete Word'.
2157
ba22c3cc278b added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
  3605
    wasOn ifTrue:[ self showCursor ].
ba22c3cc278b added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
  3606
ba22c3cc278b added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
  3607
    "Modified: / 22.2.2000 / 23:59:04 / cg"
ba22c3cc278b added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
  3608
!
ba22c3cc278b added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
  3609
5761
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3610
indentSelectionBy1
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3611
    "indent selected line-range
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3612
     by 1 space (i.e. to the right)"
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3613
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3614
    self indentBy:1
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3615
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3616
    "Created: / 06-06-2016 / 10:58:19 / cg"
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3617
!
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3618
4458
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  3619
insert:aCharacter atLine:lineNr col:colNr
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  3620
    "insert a single character at lineNr/colNr;
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  3621
     set emphasis to character at current position"
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  3622
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  3623
    self basicInsert:aCharacter atLine:lineNr col:colNr.
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  3624
    aCharacter ~~ Character cr ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3625
	self addUndo:(DeleteCharacters line:lineNr col:colNr info:'insert').
4458
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  3626
    ]
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  3627
!
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  3628
121
claus
parents: 118
diff changeset
  3629
insertCharAtCursor:aCharacter
1566
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  3630
    "insert a single character at cursor-position - advance cursor."
121
claus
parents: 118
diff changeset
  3631
claus
parents: 118
diff changeset
  3632
    |wasOn|
claus
parents: 118
diff changeset
  3633
claus
parents: 118
diff changeset
  3634
    wasOn := self hideCursor.
1566
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  3635
    aCharacter == Character tab ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3636
	"/ needs special care to advance cursor correctly
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3637
	self insertTabAtCursor
121
claus
parents: 118
diff changeset
  3638
    ] ifFalse:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3639
	self insert:aCharacter atLine:cursorLine col:cursorCol.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3640
	aCharacter == (Character cr) ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3641
	    self basicCursorReturn
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3642
	] ifFalse:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3643
	    self cursorRight.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3644
	].
121
claus
parents: 118
diff changeset
  3645
    ].
claus
parents: 118
diff changeset
  3646
    self makeCursorVisibleAndShowCursor:wasOn.
1566
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  3647
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  3648
    "Modified: / 12.6.1998 / 21:50:20 / cg"
121
claus
parents: 118
diff changeset
  3649
!
claus
parents: 118
diff changeset
  3650
641
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  3651
insertLine:aString before:lineNr
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  3652
    "insert the line aString before line lineNr"
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  3653
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  3654
    ^ self insertLines:(Array with:aString) from:1 to:1  before:lineNr.
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  3655
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  3656
    "Modified: 14.5.1996 / 13:42:54 / cg"
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  3657
!
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  3658
155
claus
parents: 133
diff changeset
  3659
insertLines:aStringCollection before:lineNr
claus
parents: 133
diff changeset
  3660
    "insert a bunch before line lineNr"
claus
parents: 133
diff changeset
  3661
claus
parents: 133
diff changeset
  3662
    self insertLines:aStringCollection from:1 to:aStringCollection size before:lineNr
claus
parents: 133
diff changeset
  3663
claus
parents: 133
diff changeset
  3664
    "Modified: 6.9.1995 / 20:51:03 / claus"
claus
parents: 133
diff changeset
  3665
!
claus
parents: 133
diff changeset
  3666
4771
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  3667
insertLines:someText from:start to:end before:lineNr
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  3668
    "insert a bunch of lines before line lineNr.
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  3669
     The cursor position is left unchanged."
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  3670
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  3671
    |text indent visLine w nLines "{ Class: SmallInteger }"
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  3672
     srcY "{ Class: SmallInteger }"
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  3673
     dstY "{ Class: SmallInteger }" |
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  3674
5357
d942c4152f03 class: EditTextView
ca
parents: 5331
diff changeset
  3675
    "wrong when pasting multiple lines"
d942c4152f03 class: EditTextView
ca
parents: 5331
diff changeset
  3676
    false "autoIndent" ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3677
	indent := self leftIndentForLine:lineNr.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3678
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3679
	text := someText
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3680
	    collect:[:ln||line|
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3681
		ln notNil ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3682
		    line := ln withoutLeadingSeparators.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3683
		    (line isEmpty or:[indent == 0]) ifFalse:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3684
			line := (String new:indent), line
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3685
		    ].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3686
		    line
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3687
		] ifFalse:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3688
		    nil
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3689
		]
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3690
	    ].
4771
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  3691
    ] ifFalse:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3692
	text := someText
4771
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  3693
    ].
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  3694
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  3695
    visLine := self listLineToVisibleLine:lineNr.
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  3696
    (shown not or:[visLine isNil]) ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3697
	self withoutRedrawInsertLines:text
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3698
	     from:start to:end
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3699
	     before:lineNr.
4771
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  3700
    ] ifFalse:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3701
	nLines := end - start + 1.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3702
	((visLine + nLines) >= nLinesShown) ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3703
	    self withoutRedrawInsertLines:text
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3704
		 from:start to:end
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3705
		 before:lineNr.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3706
	    self redrawFromVisibleLine:visLine to:nLinesShown
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3707
	] ifFalse:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3708
	    w := self widthForScrollBetween:(lineNr + nLines)
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3709
					and:(firstLineShown + nLines + nLinesShown).
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3710
	    srcY := topMargin + ((visLine - 1) * fontHeight).
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3711
	    dstY := srcY + (nLines * fontHeight).
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3712
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3713
	    "/
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3714
	    "/ scroll ...
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3715
	    "/
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3716
	    "
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3717
	     stupid: must catchExpose before inserting new
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3718
	     stuff - since catchExpose may perform redraws
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3719
	    "
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3720
	    self catchExpose.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3721
	    self withoutRedrawInsertLines:text
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3722
		 from:start to:end
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3723
		 before:lineNr.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3724
	    self
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3725
		copyFrom:self
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3726
		x:textStartLeft y:srcY
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3727
		toX:textStartLeft y:dstY
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3728
		width:w
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3729
		height:(height - dstY)
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3730
		async:true.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3731
	    self redrawFromVisibleLine:visLine to:(visLine + nLines - 1).
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3732
	    self waitForExpose
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3733
	].
4771
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  3734
    ].
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  3735
    widthOfWidestLine notNil ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3736
	text do:[:line |
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3737
	    widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:line).
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3738
	]
4771
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  3739
    ].
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  3740
    self textChanged.
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  3741
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  3742
    "Modified: 29.1.1997 / 13:02:39 / cg"
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  3743
!
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  3744
654
d621e63baaa5 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 641
diff changeset
  3745
insertLines:lines withCR:withCr
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3746
    "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
  3747
     Cursor is moved behind insertion.
641
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  3748
     If withCr is true, append cr after last line"
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  3749
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  3750
    |start end nLines wasOn|
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  3751
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  3752
    lines notNil ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3753
	nLines := lines size.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3754
	(nLines == 1) ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3755
	    self insertStringAtCursor:(lines at:1).
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3756
	    withCr ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3757
		self insertCharAtCursor:(Character cr)
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3758
	    ]
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3759
	] ifFalse:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3760
	    (cursorCol ~~ 1) ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3761
		self insertStringAtCursor:(lines at:1).
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3762
		self insertCharAtCursor:(Character cr).
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3763
		start := 2
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3764
	    ] ifFalse:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3765
		start := 1
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3766
	    ].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3767
	    withCr ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3768
		end := nLines
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3769
	    ] ifFalse:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3770
		end := nLines - 1
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3771
	    ].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3772
	    (start <= nLines) ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3773
		(end >= start) ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3774
		    wasOn := self hideCursor.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3775
		    self insertLines:lines from:start to:end before:cursorLine.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3776
		    self setCursorLine:(cursorLine + (end - start + 1)).
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3777
		    wasOn ifTrue:[self showCursor].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3778
		]
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3779
	    ].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3780
	    withCr ifFalse:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3781
		"last line without cr"
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3782
		self insertStringAtCursor:(lines at:nLines)
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3783
	    ]
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3784
	]
641
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  3785
    ]
654
d621e63baaa5 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 641
diff changeset
  3786
1566
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  3787
    "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
  3788
    "Modified: / 12.6.1998 / 21:51:16 / cg"
654
d621e63baaa5 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 641
diff changeset
  3789
!
d621e63baaa5 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 641
diff changeset
  3790
d621e63baaa5 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 641
diff changeset
  3791
insertLines:lines withCr:withCr
d621e63baaa5 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 641
diff changeset
  3792
    "insert a bunch of lines at cursor position. Cursor
d621e63baaa5 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 641
diff changeset
  3793
     is moved behind insertion.
d621e63baaa5 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 641
diff changeset
  3794
     If withCr is true, append cr after last line"
d621e63baaa5 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 641
diff changeset
  3795
2363
1982139b2c0b Use <resource:#obsolete>
Stefan Vogel <sv@exept.de>
parents: 2357
diff changeset
  3796
    <resource:#obsolete>
1982139b2c0b Use <resource:#obsolete>
Stefan Vogel <sv@exept.de>
parents: 2357
diff changeset
  3797
1292
ca4c9a957a32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1290
diff changeset
  3798
    self obsoleteMethodWarning:'use #insertLines:withCR:'.
ca4c9a957a32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1290
diff changeset
  3799
    self insertLines:lines withCR:withCr.
ca4c9a957a32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1290
diff changeset
  3800
ca4c9a957a32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1290
diff changeset
  3801
    "Modified: 31.7.1997 / 23:07:22 / cg"
641
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  3802
!
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  3803
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3804
insertSelectedStringAtCursor:aString
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3805
    "insert the argument, aString at cursor position and select it"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3806
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3807
    |startLine startCol|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3808
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3809
    startLine := cursorLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3810
    startCol := cursorCol.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3811
    self insertStringAtCursor:aString.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3812
    self selectFromLine:startLine col:startCol
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3813
		 toLine:cursorLine col:(cursorCol - 1).
3514
98e103cad51d insertSelectedStringAtCursor: - make selection visible afterwards;
Michael Beyl <mb@exept.de>
parents: 3510
diff changeset
  3814
    self makeSelectionVisible.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3815
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3816
1935
b59ff4681762 added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
  3817
insertString:aString atCharacterPosition:charPos
b59ff4681762 added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
  3818
    "insert the argument, aString at a character position"
b59ff4681762 added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
  3819
b59ff4681762 added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
  3820
    |line col|
b59ff4681762 added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
  3821
b59ff4681762 added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
  3822
    line := self lineOfCharacterPosition:charPos.
b59ff4681762 added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
  3823
    col := charPos - (self characterPositionOfLine:line col:1) + 1.
5060
669de456849b class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5057
diff changeset
  3824
    col == 0 ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3825
	line > 1 ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3826
	    line := line - 1.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3827
	    col := (self listAt:line) size + 1.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3828
	] ifFalse:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3829
	    col := 1.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3830
	]
5060
669de456849b class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5057
diff changeset
  3831
    ].
1935
b59ff4681762 added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
  3832
    self insertString:aString atLine:line col:col
b59ff4681762 added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
  3833
!
b59ff4681762 added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
  3834
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3835
insertString:aString atLine:lineNr col:colNr
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3836
    "insert the string, aString at line/col;
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3837
     handle cr's correctly"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3838
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3839
    |start           "{ Class: SmallInteger }"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3840
     stop            "{ Class: SmallInteger }"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3841
     end             "{ Class: SmallInteger }"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3842
     subString c
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3843
     l               "{ Class: SmallInteger }" |
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3844
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3845
    aString isNil ifTrue:[^ self].
1560
43d0f7c2143f use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents: 1559
diff changeset
  3846
    (aString includes:(Character cr)) ifFalse:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3847
	^ self insertStringWithoutCRs:aString atLine:lineNr col:colNr
121
claus
parents: 118
diff changeset
  3848
    ].
1560
43d0f7c2143f use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents: 1559
diff changeset
  3849
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3850
    l := lineNr.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3851
    c := colNr.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3852
    start := 1.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3853
    end := aString size.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3854
    [start <= end] whileTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3855
	stop := aString indexOf:(Character cr) startingAt:start.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3856
	stop == 0 ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3857
	    stop := end + 1
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3858
	].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3859
	subString := aString copyFrom:start to:(stop - 1).
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3860
	self insertStringWithoutCRs:subString atLine:l col:c.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3861
	(stop <= end) ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3862
	    c := c + subString size.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3863
	    self insert:(Character cr) atLine:l col:c.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3864
	    l := l + 1.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3865
	    c := 1
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3866
	].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3867
	start := stop + 1
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3868
    ]
1480
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  3869
1560
43d0f7c2143f use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents: 1559
diff changeset
  3870
    "Modified: / 10.6.1998 / 19:03:59 / cg"
121
claus
parents: 118
diff changeset
  3871
!
claus
parents: 118
diff changeset
  3872
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3873
insertStringAtCursor:aString
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3874
    "insert the argument, aString at cursor position
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3875
     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
  3876
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3877
    aString isNil ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3878
	"new:"
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3879
	self insertCharAtCursor:(Character cr).
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3880
	^ self
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  3881
    ].
1560
43d0f7c2143f use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents: 1559
diff changeset
  3882
    (aString includes:(Character cr)) ifFalse:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3883
	^ self insertStringWithoutCRsAtCursor:aString
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  3884
    ].
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  3885
654
d621e63baaa5 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 641
diff changeset
  3886
    self insertLines:aString asStringCollection withCR:false.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3887
1560
43d0f7c2143f use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents: 1559
diff changeset
  3888
    "Modified: / 10.6.1998 / 19:03:21 / cg"
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  3889
!
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  3890
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3891
insertStringWithoutCRs:aString atLine:lineNr col:colNr
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3892
    "insert aString (which has no crs) at lineNr/colNr"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3893
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3894
    self withoutRedrawInsertStringWithoutCRs:aString atLine:lineNr col:colNr.
4190
d79217c1317d changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4189
diff changeset
  3895
    shown ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3896
	gc font hasOverlappingCharacters ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3897
	    self invalidateLine:lineNr.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3898
	] ifFalse:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3899
	    self redrawLine:lineNr from:colNr
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3900
	]
4190
d79217c1317d changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4189
diff changeset
  3901
    ]
d79217c1317d changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4189
diff changeset
  3902
4191
8ac20ced2fbf changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4190
diff changeset
  3903
    "Modified: / 09-11-2010 / 13:43:03 / cg"
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  3904
!
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  3905
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3906
insertStringWithoutCRsAtCursor:aString
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3907
    "insert a string (which has no crs) at cursor position
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3908
     - advance cursor"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3909
2422
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  3910
    |wasOn oldLen newLen deltaLen|
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  3911
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  3912
    aString size > 0 ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3913
	wasOn := self hideCursor.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3914
	(aString includes:Character tab) ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3915
	    self checkForExistingLine:cursorLine.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3916
	    oldLen := (list at:cursorLine) size.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3917
	    self insertString:aString atLine:cursorLine col:cursorCol.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3918
	    newLen := (list at:cursorLine) size.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3919
	    deltaLen := newLen - oldLen.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3920
	] ifFalse:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3921
	    self insertString:aString atLine:(cursorLine ? 1) col:cursorCol.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3922
	    deltaLen := aString size.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3923
	].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3924
	self setCursorCol:(cursorCol + deltaLen).
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3925
	wasOn ifTrue:[self showCursor]
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3926
    ]
1563
b4eb49efdfcd fixed cursor positioning if inserting a string with tabs.
Claus Gittinger <cg@exept.de>
parents: 1561
diff changeset
  3927
b4eb49efdfcd fixed cursor positioning if inserting a string with tabs.
Claus Gittinger <cg@exept.de>
parents: 1561
diff changeset
  3928
    "Modified: / 10.6.1998 / 20:43:52 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3929
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3930
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3931
insertTabAtCursor
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3932
    "insert spaces to next tab"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3933
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3934
    |wasOn nextTab|
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  3935
121
claus
parents: 118
diff changeset
  3936
    wasOn := self hideCursor.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3937
    nextTab := self nextTabAfter:cursorCol.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3938
    self insertStringAtCursor:(String new:(nextTab - cursorCol)).
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3939
    self makeCursorVisibleAndShowCursor:wasOn.
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  3940
!
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  3941
3542
30ed44ed0178 +joinLines (CTRL-j);
Claus Gittinger <cg@exept.de>
parents: 3517
diff changeset
  3942
joinLines
3890
4c5c54cf856b +wrapLines
Claus Gittinger <cg@exept.de>
parents: 3886
diff changeset
  3943
    "join lines (remove line-break)"
4c5c54cf856b +wrapLines
Claus Gittinger <cg@exept.de>
parents: 3886
diff changeset
  3944
3583
fd5a924c8681 menu enablement
Claus Gittinger <cg@exept.de>
parents: 3580
diff changeset
  3945
    self checkModificationsAllowed ifFalse:[ ^ self].
fd5a924c8681 menu enablement
Claus Gittinger <cg@exept.de>
parents: 3580
diff changeset
  3946
3683
5891af82a177 middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents: 3650
diff changeset
  3947
    self
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3948
	undoableDo:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3949
	    |line col lineLen|
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3950
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3951
	    line := cursorLine.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3952
	    col := cursorCol.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3953
	    lineLen := (list at:line) size.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3954
	    col > lineLen ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3955
		self insertString:(String new:col-lineLen) atLine:line col:col+1.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3956
	    ] ifFalse:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3957
		self deleteCharsAtLine:line fromCol:col toCol:lineLen.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3958
	    ].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3959
	    self mergeLine:line removeBlanks:true.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3960
	    self cursorLine:line col:col.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3961
	]
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3962
	info:'Join'
3542
30ed44ed0178 +joinLines (CTRL-j);
Claus Gittinger <cg@exept.de>
parents: 3517
diff changeset
  3963
!
30ed44ed0178 +joinLines (CTRL-j);
Claus Gittinger <cg@exept.de>
parents: 3517
diff changeset
  3964
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3965
mergeLine:lineNr
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3966
    "merge line lineNr with line lineNr+1"
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3967
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3968
    self mergeLine:lineNr removeBlanks:true
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3969
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3970
    "Modified: 9.9.1997 / 09:28:03 / cg"
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3971
!
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3972
4458
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  3973
mergeLine:lineNr removeBlanks:removeBlanks
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  3974
    "merge line lineNr with line lineNr+1"
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  3975
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  3976
    |len|
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  3977
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  3978
    self checkModificationsAllowed ifFalse:[ ^ self].
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  3979
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  3980
    len := (self listAt:lineNr) size.
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  3981
    self nonUndoableDo:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3982
	self basicMergeLine:lineNr removeBlanks:removeBlanks.
4458
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  3983
    ].
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  3984
    self addUndo:(PasteString new line:lineNr col:len+1 string:(Character cr asString) selected:false).
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  3985
!
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  3986
5761
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3987
parenthizeSelection
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3988
    "place parenthesis around the selected text.
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3989
     if already parenthized, de-parenthize it"
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3990
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3991
    self parenthizeSelectionWith:$( and:$)
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3992
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3993
    "Created: / 06-06-2016 / 10:59:05 / cg"
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3994
!
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3995
2506
5568d67dbddd Ctrl-8 / Ctrl-9,
Claus Gittinger <cg@exept.de>
parents: 2505
diff changeset
  3996
parenthizeSelectionWith:openingCharacter and:closingCharacter
5761
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3997
    "if already parenthized, de-parenthize it"
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3998
5560
511e59f19726 #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 5529
diff changeset
  3999
    |newSelectionEnd startLine endLine startCol endCol|
2505
9204d5313979 Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents: 2491
diff changeset
  4000
9204d5313979 Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents: 2491
diff changeset
  4001
    self hasSelection ifFalse:[^ self].
5560
511e59f19726 #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 5529
diff changeset
  4002
    startLine := selectionStartLine.
511e59f19726 #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 5529
diff changeset
  4003
    endLine := selectionEndLine.
511e59f19726 #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 5529
diff changeset
  4004
    startCol := selectionStartCol.
511e59f19726 #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 5529
diff changeset
  4005
    endCol := selectionEndCol.
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4006
5560
511e59f19726 #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 5529
diff changeset
  4007
    newSelectionEnd := endCol.
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4008
5560
511e59f19726 #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 5529
diff changeset
  4009
    (self characterAtLine:startLine col:startCol) == openingCharacter ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4010
	(self characterAtLine:endLine col:endCol) == closingCharacter ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4011
	    self deleteCharAtLine:endLine col:endCol.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4012
	    newSelectionEnd := newSelectionEnd-1.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4013
	].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4014
	self deleteCharAtLine:startLine col:startCol.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4015
	startLine == endLine ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4016
	    newSelectionEnd := newSelectionEnd-1.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4017
	]
2505
9204d5313979 Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents: 2491
diff changeset
  4018
    ] ifFalse:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4019
	self insert:closingCharacter atLine:endLine col:endCol+1.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4020
	newSelectionEnd := newSelectionEnd+1.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4021
	self insert:openingCharacter atLine:startLine col:startCol.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4022
	startLine == endLine ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4023
	    newSelectionEnd := newSelectionEnd+1.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4024
	]
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  4025
    ].
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  4026
    self
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4027
	selectFromLine:startLine col:startCol
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4028
	toLine:endLine col:newSelectionEnd.
5761
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  4029
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  4030
    "Modified (comment): / 06-06-2016 / 11:00:37 / cg"
2505
9204d5313979 Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents: 2491
diff changeset
  4031
!
9204d5313979 Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents: 2491
diff changeset
  4032
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4033
removeTrailingBlankLines
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4034
    "remove all blank lines at end of text"
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
    |lastLine "{ Class: SmallInteger }"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4037
     line finished|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4038
5114
679cca16c072 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5112
diff changeset
  4039
    NoModificationError handle:[:ex |
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4040
	^ self
5114
679cca16c072 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5112
diff changeset
  4041
    ] do:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4042
	lastLine := list size.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4043
	finished := false.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4044
	[finished] whileFalse:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4045
	    (lastLine <= 1) ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4046
		finished := true
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4047
	    ] ifFalse:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4048
		line := list at:lastLine.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4049
		line notNil ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4050
		    line isBlank ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4051
			self basicListAt:lastLine put:nil.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4052
			line := nil
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4053
		    ]
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4054
		].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4055
		line notNil ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4056
		    finished := true
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4057
		] ifFalse:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4058
		    lastLine := lastLine - 1
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4059
		]
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4060
	    ]
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4061
	].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4062
	(lastLine ~~ list size) ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4063
	    list grow:lastLine.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4064
	    "/ self textChanged
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4065
	]
118
claus
parents: 105
diff changeset
  4066
    ].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4067
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4068
4458
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4069
replace:aCharacter atLine:lineNr col:colNr
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4070
    "replace a single character at lineNr/colNr"
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4071
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4072
    |originalChar|
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4073
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4074
    originalChar := self characterAtLine:lineNr col:colNr.
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4075
    self basicReplace:aCharacter atLine:lineNr col:colNr.
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4076
    self addUndo:(ReplaceCharacters line:lineNr col:colNr character:originalChar info:'replace').
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4077
!
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4078
4713
e8c9caf13e05 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4707
diff changeset
  4079
replace:patternArg by:replacePatternArg all:all ignoreCase:ignoreCase
3430
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  4080
    |pattern replacePattern|
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  4081
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  4082
    pattern := patternArg string.
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  4083
    replacePattern := replacePatternArg string.
4630
b043ca9e5060 class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 4623
diff changeset
  4084
    (pattern notEmpty and:[ replacePattern notEmpty ]) ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4085
	self rememberSearchPattern:pattern.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4086
	self rememberSearchPattern:replacePattern.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4087
	LastSearchIgnoredCase := ignoreCase.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4088
	self
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4089
	    undoableDo:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4090
		all ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4091
		    self
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4092
			replaceString:pattern
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4093
			to:replacePattern
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4094
			ignoreCase:ignoreCase
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4095
		] ifFalse:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4096
		    (self selectionAsString notNil
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4097
			and:[ self selectionAsString sameAs:pattern caseSensitive:ignoreCase not ])
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4098
			    ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4099
				self replaceSelectionBy:replacePattern.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4100
				self
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4101
				    search:pattern
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4102
				    ignoreCase:ignoreCase
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4103
				    forward:(lastSearchDirection = #forward).
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4104
			    ].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4105
		]
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4106
	    ]
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4107
	    info:'Replace'
3430
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  4108
    ]
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  4109
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  4110
    "Created: / 11-07-2006 / 11:19:57 / fm"
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  4111
!
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  4112
477
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  4113
replaceCharAtCursor:aCharacter
5413
b21cbb97c038 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5404
diff changeset
  4114
    "undoably replace a single character at cursor-position - advance cursor"
477
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  4115
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  4116
    |wasOn|
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  4117
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  4118
    wasOn := self hideCursor.
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  4119
    aCharacter == (Character cr) ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4120
	self cursorReturn
477
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  4121
    ] ifFalse:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4122
	self replace:aCharacter atLine:cursorLine col:cursorCol.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4123
	self cursorRight.
477
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  4124
    ].
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  4125
    self makeCursorVisibleAndShowCursor:wasOn.
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  4126
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  4127
    "Created: 6.3.1996 / 12:27:42 / cg"
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  4128
!
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  4129
4458
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4130
replaceContentsWith:newContents
5413
b21cbb97c038 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5404
diff changeset
  4131
    "undoably replace everything"
4458
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4132
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4133
    |originalContents|
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4134
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4135
    originalContents := self contents.
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4136
    self contents:newContents keepUndoHistory:true.
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4137
    self addUndo:(ReplaceContents text:originalContents info:'replace').
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4138
!
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4139
2427
43cc7ea39bac more editing stuff (xxx-characterPosition)
Claus Gittinger <cg@exept.de>
parents: 2422
diff changeset
  4140
replaceFromCharacterPosition:charPos1 to:charPos2 with:newString
5413
b21cbb97c038 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5404
diff changeset
  4141
    "undoably replace a substring at a character position"
2427
43cc7ea39bac more editing stuff (xxx-characterPosition)
Claus Gittinger <cg@exept.de>
parents: 2422
diff changeset
  4142
5216
8d6eef5d09c3 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5194
diff changeset
  4143
    "/ sigh - insert first, to avoid trouble due to shifing-in virtual line ends
2427
43cc7ea39bac more editing stuff (xxx-characterPosition)
Claus Gittinger <cg@exept.de>
parents: 2422
diff changeset
  4144
    self insertString:newString atCharacterPosition:charPos1.
43cc7ea39bac more editing stuff (xxx-characterPosition)
Claus Gittinger <cg@exept.de>
parents: 2422
diff changeset
  4145
    self deleteFromCharacterPosition:charPos1+newString size to:charPos2+newString size.
43cc7ea39bac more editing stuff (xxx-characterPosition)
Claus Gittinger <cg@exept.de>
parents: 2422
diff changeset
  4146
!
43cc7ea39bac more editing stuff (xxx-characterPosition)
Claus Gittinger <cg@exept.de>
parents: 2422
diff changeset
  4147
4458
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4148
replaceLine:lineNr with:newText
5413
b21cbb97c038 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5404
diff changeset
  4149
    "undoably replace a line at lineNr"
4458
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4150
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4151
    |originalLine|
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4152
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4153
    originalLine := self listAt:lineNr.
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4154
    originalLine isNil ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4155
	self checkForExistingLine:lineNr
4458
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4156
    ].
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4157
    self list at:lineNr put:newText.
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4158
    self addUndo:(ReplaceLine line:lineNr string:originalLine info:'replace').
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4159
    self invalidateLine:lineNr.
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4160
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4161
    "Modified: / 12-04-2007 / 09:31:33 / cg"
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4162
!
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4163
1564
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  4164
replaceLines:lines withCR:withCr
5413
b21cbb97c038 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5404
diff changeset
  4165
    "undoably a bunch of lines at cursor position. Cursor
1564
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  4166
     is moved behind replacement.
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  4167
     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
  4168
     after the last line"
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  4169
1809
111f603c0a1c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1807
diff changeset
  4170
    |line col nLines wasOn|
1564
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  4171
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  4172
    lines notNil ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4173
	wasOn := self hideCursor.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4174
	nLines := lines size.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4175
	line := cursorLine.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4176
	col := cursorCol.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4177
	lines keysAndValuesDo:[:i :l |
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4178
	    self replaceString:(l ? '') atLine:line col:col.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4179
	    (i ~~ nLines or:[withCr]) ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4180
		line := line + 1.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4181
		col := 1.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4182
	    ] ifFalse:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4183
		col := col + (l size).
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4184
	    ]
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4185
	].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4186
	self cursorLine:line col:col.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4187
	self makeCursorVisibleAndShowCursor:wasOn.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4188
	"/ wasOn ifTrue:[self showCursor].
1564
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  4189
    ]
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  4190
4661
c029273f7660 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4649
diff changeset
  4191
    "Created: / 18-05-1996 / 15:32:06 / cg"
c029273f7660 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4649
diff changeset
  4192
    "Modified: / 25-07-2013 / 17:00:53 / cg"
1564
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  4193
!
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  4194
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4195
replaceSelectionBy:something
5413
b21cbb97c038 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5404
diff changeset
  4196
    "undoably delete the selection (if any) and insert something, a character or string;
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4197
     leave cursor after insertion"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4198
4666
81e48e442abe class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4664
diff changeset
  4199
    self replaceSelectionBy:something keepCursor:false select:false
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  4200
!
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  4201
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  4202
replaceSelectionBy:something keepCursor:keep
5413
b21cbb97c038 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5404
diff changeset
  4203
    "undoably delete the selection (if any) and insert something, a character or string;
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  4204
     leave cursor after insertion or leave it, depending on keep"
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  4205
4666
81e48e442abe class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4664
diff changeset
  4206
    self replaceSelectionBy:something keepCursor:keep select:false
81e48e442abe class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4664
diff changeset
  4207
81e48e442abe class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4664
diff changeset
  4208
    "Modified: 9.10.1996 / 16:14:35 / cg"
81e48e442abe class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4664
diff changeset
  4209
!
81e48e442abe class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4664
diff changeset
  4210
81e48e442abe class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4664
diff changeset
  4211
replaceSelectionBy:something keepCursor:keep select:selectNewText
5413
b21cbb97c038 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5404
diff changeset
  4212
    "undoably delete the selection (if any) and insert something, a character or string;
4666
81e48e442abe class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4664
diff changeset
  4213
     leave cursor after insertion or leave it, depending on keep.
81e48e442abe class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4664
diff changeset
  4214
     If selectNewText is true, select the new text; otherwise deselect"
81e48e442abe class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4664
diff changeset
  4215
81e48e442abe class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4664
diff changeset
  4216
    |sel l c selStartLine selStartCol|
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  4217
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  4218
    l := cursorLine.
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  4219
    c := cursorCol.
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  4220
4818
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  4221
    sel := self selectionAsString.
4666
81e48e442abe class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4664
diff changeset
  4222
    sel isNil ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4223
	selStartLine := l.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4224
	selStartCol := c.
4666
81e48e442abe class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4664
diff changeset
  4225
    ] ifFalse:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4226
	selStartLine := selectionStartLine.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4227
	selStartCol := selectionStartCol.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4228
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4229
	self setLastStringToReplace: sel.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4230
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4231
	self deleteSelection.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4232
	replacing := true.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4233
	lastReplacementInfo rememberReplacement.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4234
	lastReplacementInfo lastReplacement: ''.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4235
	lastReplacementInfo stillCollectingInput:true.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4236
	undoSupport actionInfo:'replace'.
3161
982c2e416728 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3160
diff changeset
  4237
    ].
982c2e416728 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3160
diff changeset
  4238
982c2e416728 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3160
diff changeset
  4239
    something isCharacter ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4240
	lastReplacementInfo lastReplacement notNil ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4241
	    lastReplacementInfo stillCollectingInput ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4242
		lastReplacementInfo lastReplacement: (lastReplacementInfo lastReplacement copyWith:something).
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4243
	    ].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4244
	].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4245
	self isInInsertMode ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4246
	    self insertCharAtCursor:something
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4247
	] ifFalse:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4248
	    self replaceCharAtCursor:something
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4249
	]
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  4250
    ] ifFalse:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4251
	something isString ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4252
	    lastReplacementInfo lastReplacement: something.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4253
	    self isInInsertMode ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4254
		self insertStringAtCursor:something
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4255
	    ] ifFalse:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4256
		self replaceStringAtCursor:something
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4257
	    ]
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4258
	] ifFalse:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4259
	    Transcript showCR:'EditTextView: non String-or-Character in replace'.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4260
	].
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  4261
    ].
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  4262
    keep ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4263
	self cursorLine:l col:c
4666
81e48e442abe class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4664
diff changeset
  4264
    ].
81e48e442abe class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4664
diff changeset
  4265
    selectNewText ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4266
	self selectFromLine:selStartLine col:selStartCol toLine:cursorLine col:cursorCol-1
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  4267
    ]
477
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  4268
840
b0071cea13fd fixed Again when spaces are replaced
Claus Gittinger <cg@exept.de>
parents: 828
diff changeset
  4269
    "Modified: 9.10.1996 / 16:14:35 / cg"
1564
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  4270
!
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  4271
4458
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4272
replaceString:aString atLine:lineNr col:colNr
5413
b21cbb97c038 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5404
diff changeset
  4273
    "undoably replace multiple characters starting at lineNr/colNr.
4458
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4274
     This is not prepared to encounter special chars (except TAB) in the string."
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4275
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4276
    |originalString|
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4277
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4278
    self checkModificationsAllowed ifFalse:[ ^ self].
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4279
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4280
    originalString := self textFromLine:lineNr col:colNr toLine:lineNr col:colNr+aString size-1.
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4281
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4282
    self basicReplaceString:aString atLine:lineNr col:colNr.
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4283
    self addUndo:(ReplaceCharacters line:lineNr col:colNr characters:originalString info:'replace').
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4284
!
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4285
4713
e8c9caf13e05 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4707
diff changeset
  4286
replaceString:aString to:aNewString ignoreCase:ignoreCase
3549
569d0e4ab5a3 join at cursorposition
Claus Gittinger <cg@exept.de>
parents: 3542
diff changeset
  4287
    |continue count|
569d0e4ab5a3 join at cursorposition
Claus Gittinger <cg@exept.de>
parents: 3542
diff changeset
  4288
569d0e4ab5a3 join at cursorposition
Claus Gittinger <cg@exept.de>
parents: 3542
diff changeset
  4289
    self cursorToTop.
569d0e4ab5a3 join at cursorposition
Claus Gittinger <cg@exept.de>
parents: 3542
diff changeset
  4290
    self selectFromBeginning.
569d0e4ab5a3 join at cursorposition
Claus Gittinger <cg@exept.de>
parents: 3542
diff changeset
  4291
    count := 0.
569d0e4ab5a3 join at cursorposition
Claus Gittinger <cg@exept.de>
parents: 3542
diff changeset
  4292
    continue := true.
569d0e4ab5a3 join at cursorposition
Claus Gittinger <cg@exept.de>
parents: 3542
diff changeset
  4293
    [ continue ] whileTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4294
	(self selectionAsString notNil
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4295
	and:[ self selectionAsString sameAs:aString caseSensitive:ignoreCase not ])
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4296
	    ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4297
		self replaceSelectionBy:aNewString.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4298
		count := count + 1.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4299
	    ].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4300
	self
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4301
	    searchFwd:aString
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4302
	    ignoreCase:ignoreCase
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4303
	    ifAbsent:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4304
		Dialog information:('%1 has been replaced by %2 %3 times'
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4305
				    bindWith:aString with:aNewString with:count).
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4306
		continue := false.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4307
	    ].
3549
569d0e4ab5a3 join at cursorposition
Claus Gittinger <cg@exept.de>
parents: 3542
diff changeset
  4308
    ].
3430
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  4309
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  4310
    "Created: / 10-07-2006 / 16:42:48 / fm"
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  4311
!
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  4312
1564
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  4313
replaceStringAtCursor:aString
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  4314
    "replace multiple characters at cursor-position - advance cursor"
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  4315
1566
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  4316
    |wasOn i1 i2|
1564
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  4317
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  4318
    wasOn := self hideCursor.
1566
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  4319
    (aString includes:Character tab) ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4320
	"/ need special care for TAB (to move cursor correctly)
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4321
	i1 := 1.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4322
	[i1 ~~ 0] whileTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4323
	    i2 := aString indexOf:Character tab startingAt:i1.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4324
	    i2 ~~ 0 ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4325
		i1 ~~ i2 ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4326
		    self replaceString:(aString copyFrom:i1 to:i2-1) atLine:cursorLine col:cursorCol.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4327
		    self cursorCol:(cursorCol + (i2 - i1)).
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4328
		].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4329
		self replaceTABAtCursor.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4330
		i2 := i2 + 1.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4331
	    ] ifFalse:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4332
		self replaceString:(aString copyFrom:i1) atLine:cursorLine col:cursorCol.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4333
		self cursorCol:(cursorCol + (aString size - i1 + 1)).
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4334
	    ].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4335
	    i1 := i2.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4336
	]
1566
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  4337
    ] ifFalse:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4338
	self replaceString:aString atLine:cursorLine col:cursorCol.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4339
	self setValidatedCursorCol:(cursorCol + aString size).
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4340
	"/ self cursorCol:(cursorCol + aString size).
5325
b3d62a76761c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5283
diff changeset
  4341
    ].
b3d62a76761c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5283
diff changeset
  4342
    wasOn ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4343
	self sensor pushUserEvent:#makeCursorVisibleAndShowCursor: for:self withArguments:{ wasOn }
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4344
	"/ self makeCursorVisibleAndShowCursor:wasOn.
5325
b3d62a76761c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5283
diff changeset
  4345
    ].
1564
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  4346
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  4347
    "Created: / 9.6.1998 / 20:33:20 / cg"
1597
5fdcfcedb91c fixed cursor positioning after replaceStringAtCursor.
Claus Gittinger <cg@exept.de>
parents: 1596
diff changeset
  4348
    "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
  4349
!
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  4350
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  4351
replaceTABAtCursor
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  4352
    "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
  4353
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  4354
    |wasOn nextTab|
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  4355
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  4356
    wasOn := self hideCursor.
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  4357
    nextTab := self nextTabAfter:cursorCol.
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  4358
    self replaceStringAtCursor:(String new:(nextTab - cursorCol)).
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  4359
    self makeCursorVisibleAndShowCursor:wasOn.
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  4360
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  4361
    "Created: / 12.6.1998 / 21:53:23 / cg"
3890
4c5c54cf856b +wrapLines
Claus Gittinger <cg@exept.de>
parents: 3886
diff changeset
  4362
!
4c5c54cf856b +wrapLines
Claus Gittinger <cg@exept.de>
parents: 3886
diff changeset
  4363
4256
1e4bdc48136c added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents: 4253
diff changeset
  4364
selectWordBeforeCursor
1e4bdc48136c added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents: 4253
diff changeset
  4365
    "select the word to the left of cursor"
1e4bdc48136c added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents: 4253
diff changeset
  4366
1e4bdc48136c added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents: 4253
diff changeset
  4367
    |savCursorLine savCursorCol  beginCol beginLine endCol endLine|
1e4bdc48136c added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents: 4253
diff changeset
  4368
1e4bdc48136c added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents: 4253
diff changeset
  4369
    savCursorLine := cursorLine.
1e4bdc48136c added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents: 4253
diff changeset
  4370
    savCursorCol := cursorCol.
1e4bdc48136c added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents: 4253
diff changeset
  4371
1e4bdc48136c added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents: 4253
diff changeset
  4372
    endCol := cursorCol-1.
1e4bdc48136c added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents: 4253
diff changeset
  4373
    endLine := cursorLine.
1e4bdc48136c added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents: 4253
diff changeset
  4374
    self cursorToPreviousWord.
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4375
    beginCol := cursorCol.
4256
1e4bdc48136c added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents: 4253
diff changeset
  4376
    beginLine := cursorLine.
1e4bdc48136c added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents: 4253
diff changeset
  4377
    self cursorLine:savCursorLine col:savCursorCol.
1e4bdc48136c added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents: 4253
diff changeset
  4378
    self selectFromLine:beginLine col:beginCol toLine:endLine col:endCol.
1e4bdc48136c added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents: 4253
diff changeset
  4379
1e4bdc48136c added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents: 4253
diff changeset
  4380
    "Created: / 14-06-2011 / 14:46:35 / cg"
1e4bdc48136c added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents: 4253
diff changeset
  4381
!
1e4bdc48136c added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents: 4253
diff changeset
  4382
4458
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4383
splitLine:lineNr before:colNr
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4384
    "split the line linNr before colNr; the right part (from colNr)
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4385
     is cut off and inserted after lineNr; the view is redrawn"
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4386
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4387
    self basicSplitLine:lineNr before:colNr.
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4388
    self addUndo:(DeleteRange line1:lineNr col1:colNr line2:lineNr+1 col2:0 info:'split').
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4389
!
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4390
5761
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  4391
toggleTabSetting
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  4392
    "toggle between 4-col
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  4393
     and 8-col tabs"
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  4394
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  4395
    (tabPositions == self class tab4Positions)
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4396
	 ifTrue:[self setTab8]
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4397
	 ifFalse:[self setTab4]
5761
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  4398
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  4399
    "Created: / 06-06-2016 / 11:02:07 / cg"
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  4400
!
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  4401
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  4402
undentSelectionBy1
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  4403
    "undent selected line-range
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  4404
     by 1 space (i.e. to the left)"
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  4405
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  4406
    self undentBy:1
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  4407
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  4408
    "Created: / 06-06-2016 / 10:49:51 / cg"
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  4409
!
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  4410
5146
3169904851a4 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5145
diff changeset
  4411
withAutoIndent:aBoolean do:aBlock
3169904851a4 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5145
diff changeset
  4412
    |sav|
3169904851a4 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5145
diff changeset
  4413
3169904851a4 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5145
diff changeset
  4414
    sav := autoIndent.
3169904851a4 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5145
diff changeset
  4415
    autoIndent := aBoolean.
3169904851a4 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5145
diff changeset
  4416
    aBlock ensure:[ autoIndent := sav ].
3169904851a4 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5145
diff changeset
  4417
!
3169904851a4 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5145
diff changeset
  4418
4458
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4419
withoutRedrawAt:lineNr put:aString
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4420
    "replace a line at lineNr"
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4421
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4422
    |originalLine|
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4423
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4424
    originalLine := self listAt:lineNr.
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4425
    self addUndo:(ReplaceLine line:lineNr string:originalLine info:'replace').
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4426
    super withoutRedrawAt:lineNr put:aString.
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4427
!
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4428
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4429
withoutRedrawInsertLine:aString before:lineNr
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4430
    "insert the argument, aString before line lineNr; the string
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4431
     becomes line lineNr; everything else is moved down; the view
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4432
     is not redrawn"
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4433
4771
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  4434
    self basicWithoutRedrawInsertLines:{ aString } from:1 to:1 before:lineNr.
4458
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4435
    self addUndo:(DeleteRange line1:lineNr col1:1 line2:lineNr+1 col2:0 info:'insert').
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4436
!
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4437
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4438
withoutRedrawInsertLines:lines from:start to:end before:lineNr
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4439
    "insert a bunch of lines before line lineNr; the view is not redrawn"
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4440
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4441
    self basicWithoutRedrawInsertLines:lines from:start to:end before:lineNr.
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4442
    self isReadOnly ifFalse:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4443
	self addUndo:(DeleteRange line1:lineNr col1:1 line2:lineNr+end-start+1 col2:0 info:'insert').
4458
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4444
    ].
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4445
!
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4446
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4447
withoutRedrawInsertStringWithoutCRs:aString atLine:lineNr col:colNr
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4448
    "insert aString (which has no crs) at lineNr/colNr"
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4449
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4450
    self basicWithoutRedrawInsertStringWithoutCRs:aString atLine:lineNr col:colNr.
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4451
    self addUndo:(DeleteRange line1:lineNr col1:colNr line2:lineNr col2:colNr+aString size-1 info:'insert').
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4452
!
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4453
3890
4c5c54cf856b +wrapLines
Claus Gittinger <cg@exept.de>
parents: 3886
diff changeset
  4454
wrapLines
4c5c54cf856b +wrapLines
Claus Gittinger <cg@exept.de>
parents: 3886
diff changeset
  4455
    "wrap lines (insert line-break)"
4c5c54cf856b +wrapLines
Claus Gittinger <cg@exept.de>
parents: 3886
diff changeset
  4456
4c5c54cf856b +wrapLines
Claus Gittinger <cg@exept.de>
parents: 3886
diff changeset
  4457
    |lineLength answerString string|
4c5c54cf856b +wrapLines
Claus Gittinger <cg@exept.de>
parents: 3886
diff changeset
  4458
4c5c54cf856b +wrapLines
Claus Gittinger <cg@exept.de>
parents: 3886
diff changeset
  4459
    self checkModificationsAllowed ifFalse:[ ^ self].
4c5c54cf856b +wrapLines
Claus Gittinger <cg@exept.de>
parents: 3886
diff changeset
  4460
4c5c54cf856b +wrapLines
Claus Gittinger <cg@exept.de>
parents: 3886
diff changeset
  4461
    self hasSelection ifFalse:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4462
	self selectLine:cursorLine.
3890
4c5c54cf856b +wrapLines
Claus Gittinger <cg@exept.de>
parents: 3886
diff changeset
  4463
    ].
4c5c54cf856b +wrapLines
Claus Gittinger <cg@exept.de>
parents: 3886
diff changeset
  4464
    string := self selectionAsString.
4c5c54cf856b +wrapLines
Claus Gittinger <cg@exept.de>
parents: 3886
diff changeset
  4465
    string isEmptyOrNil ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4466
	Dialog information:(resources string:'Nothing selected.').
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4467
	^ self.
3890
4c5c54cf856b +wrapLines
Claus Gittinger <cg@exept.de>
parents: 3886
diff changeset
  4468
    ].
4c5c54cf856b +wrapLines
Claus Gittinger <cg@exept.de>
parents: 3886
diff changeset
  4469
4c5c54cf856b +wrapLines
Claus Gittinger <cg@exept.de>
parents: 3886
diff changeset
  4470
    answerString := Dialog request:(resources string:'Line length (wrap after how many chars)?') initialAnswer:80.
4c5c54cf856b +wrapLines
Claus Gittinger <cg@exept.de>
parents: 3886
diff changeset
  4471
    lineLength := Number readFrom:answerString onError:nil.
4388
558b4dbf5648 changed:
Claus Gittinger <cg@exept.de>
parents: 4373
diff changeset
  4472
    lineLength isNil ifTrue:[^ self].
3890
4c5c54cf856b +wrapLines
Claus Gittinger <cg@exept.de>
parents: 3886
diff changeset
  4473
    lineLength < 1 ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4474
	lineLength := 1.
3890
4c5c54cf856b +wrapLines
Claus Gittinger <cg@exept.de>
parents: 3886
diff changeset
  4475
    ].
4c5c54cf856b +wrapLines
Claus Gittinger <cg@exept.de>
parents: 3886
diff changeset
  4476
4c5c54cf856b +wrapLines
Claus Gittinger <cg@exept.de>
parents: 3886
diff changeset
  4477
    self
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4478
	undoableDo:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4479
	    |inStream line col lineLen lastGoodCol lastStartCol word|
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4480
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4481
	    line := selectionStartLine.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4482
	    col := selectionStartCol.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4483
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4484
	    self cutSelection.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4485
	    self cursorLine:line col:col.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4486
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4487
	    lastGoodCol := col.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4488
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4489
	    inStream := string readStream.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4490
	    [ inStream atEnd ] whileFalse:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4491
		[inStream atEnd not and:[inStream peek isSeparator]] whileTrue:[ inStream next ].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4492
		word := CharacterWriteStream new.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4493
		[inStream atEnd not and:[inStream peek isSeparator not]] whileTrue:[ word nextPut:inStream next ].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4494
		(col + 1 + word size > lineLength) ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4495
		    self insertCharAtCursor:(Character cr).
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4496
		    col := 1.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4497
		] ifFalse:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4498
		    col ~~ 1 ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4499
			self insertStringAtCursor:' '.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4500
			col := col + 1.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4501
		    ]
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4502
	       ].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4503
	       self insertStringAtCursor:word contents.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4504
	       col := col + word size.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4505
	    ].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4506
	]
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4507
	info:'Wrap'
4388
558b4dbf5648 changed:
Claus Gittinger <cg@exept.de>
parents: 4373
diff changeset
  4508
558b4dbf5648 changed:
Claus Gittinger <cg@exept.de>
parents: 4373
diff changeset
  4509
    "Modified: / 01-03-2012 / 19:56:22 / cg"
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4510
! !
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4511
2752
5650a9ab5935 method category rename
Claus Gittinger <cg@exept.de>
parents: 2744
diff changeset
  4512
!EditTextView methodsFor:'editing-basic'!
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4513
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4514
basicDeleteCharsAtLine:lineNr fromCol:startCol toCol:endCol
3549
569d0e4ab5a3 join at cursorposition
Claus Gittinger <cg@exept.de>
parents: 3542
diff changeset
  4515
    "delete characters from startCol to endCol in line lineNr"
569d0e4ab5a3 join at cursorposition
Claus Gittinger <cg@exept.de>
parents: 3542
diff changeset
  4516
1803
ac7cc1b99407 scroll left as required, if deleting characters of the longest line,
Claus Gittinger <cg@exept.de>
parents: 1796
diff changeset
  4517
    |line lineSize newLine start stop prevWidth newWidth|
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4518
4673
575d2d398823 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4666
diff changeset
  4519
    self unselect.
575d2d398823 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4666
diff changeset
  4520
575d2d398823 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4666
diff changeset
  4521
    cursorLine == lineNr ifTrue:[
5909
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4522
        cursorCol >= startCol ifTrue:[
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4523
            cursorCol >= endCol ifTrue:[
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4524
                cursorCol := startCol.
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4525
            ] ifFalse:[
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4526
                cursorCol := cursorCol - (endCol - startCol + 1).
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4527
                "/ self assert:(cursorCol >= 0).
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4528
                cursorCol := cursorCol max:1.
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4529
            ]
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4530
        ].
4673
575d2d398823 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4666
diff changeset
  4531
    ].
575d2d398823 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4666
diff changeset
  4532
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4533
    line := self listAt:lineNr.
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  4534
4673
575d2d398823 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4666
diff changeset
  4535
    (self checkModificationsAllowed and:[line notNil]) ifFalse:[^ self].
575d2d398823 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4666
diff changeset
  4536
575d2d398823 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4666
diff changeset
  4537
    lineSize := line size.
575d2d398823 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4666
diff changeset
  4538
575d2d398823 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4666
diff changeset
  4539
    startCol == 0 ifFalse:[ start := startCol ] ifTrue:[ start := 1 ].
575d2d398823 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4666
diff changeset
  4540
    endCol > lineSize ifFalse:[ stop  := endCol ] ifTrue:[ stop  := lineSize ].
575d2d398823 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4666
diff changeset
  4541
575d2d398823 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4666
diff changeset
  4542
    stop >= start ifTrue:[
5909
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4543
        start ~~ 1 ifTrue:[ newLine := line copyFrom:1 to:(start-1) ]
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4544
                  ifFalse:[ newLine := '' ].
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4545
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4546
        stop == lineSize ifFalse:[
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4547
            line bitsPerCharacter > newLine bitsPerCharacter ifTrue:[
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4548
                newLine := line string species fromString:newLine.
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4549
            ].
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4550
            newLine := newLine, (line copyFrom:(stop + 1) to:lineSize)
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4551
        ].
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4552
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4553
        (self trimBlankLines and:[newLine isBlank]) ifTrue:[
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4554
            newLine := nil
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4555
        ].
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4556
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4557
        prevWidth := self widthOfLine:lineNr.
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4558
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4559
        self basicListAt:lineNr put:newLine.
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4560
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4561
        (prevWidth = widthOfWidestLine) ifTrue:[
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4562
            "/ remember old width of this line,
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4563
            "/ only clear widthOfWidestLine, if this lines
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4564
            "/ length was (one of) the longest.
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4565
            "/ avoids slow delete with huge texts.
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4566
            widthOfWidestLine := nil.   "i.e. unknown"
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4567
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4568
            "/ scroll left if reqiured
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4569
            viewOrigin x > 0 ifTrue:[
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4570
                newWidth := self widthOfLine:lineNr.
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4571
                newWidth < (viewOrigin x + width) ifTrue:[
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4572
                    self scrollHorizontalTo:(newWidth
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4573
                                             - width
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4574
                                             + margin + margin
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4575
                                             + (gc font widthOf:'  '))
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4576
                ]
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4577
            ].
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4578
            self textChanged.
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4579
        ] ifFalse:[
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4580
            self textChanged "/ textChangedButNoSizeChange
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4581
        ].
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4582
        gc font hasOverlappingCharacters ifTrue:[
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4583
            self invalidateLine:lineNr.
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4584
        ] ifFalse:[
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4585
            self redrawLine:lineNr from:start.
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4586
        ].
4673
575d2d398823 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4666
diff changeset
  4587
    ].
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  4588
4191
8ac20ced2fbf changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4190
diff changeset
  4589
    "Modified: / 09-11-2010 / 13:42:45 / cg"
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4590
!
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4591
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4592
basicDeleteFromLine:startLineNr toLine:endLineNr
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4593
    "delete some lines"
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4594
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4595
    |wasOn nLines|
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4596
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4597
    self checkModificationsAllowed ifFalse:[ ^ self].
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4598
    list isNil ifTrue:[^ self].
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4599
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4600
    wasOn := self hideCursor.
1717
83203096a851 dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  4601
83203096a851 dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  4602
    "/ isnt this the same as:
83203096a851 dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  4603
    "/ self deleteLinesWithoutRedrawFrom:startLineNr to:endLineNr.
4226
a09775d899a6 changed: #basicDeleteFromLine:toLine:
az
parents: 4225
diff changeset
  4604
    startLineNr <= list size ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4605
	self basicListRemoveFromIndex:startLineNr toIndex:(endLineNr min:list size).
4226
a09775d899a6 changed: #basicDeleteFromLine:toLine:
az
parents: 4225
diff changeset
  4606
    ].
1717
83203096a851 dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  4607
    "/ TODO: remember old maxwidth of linerange,
83203096a851 dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  4608
    "/ only clear widthOfWidestLine, if this max
83203096a851 dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  4609
    "/ length was (one of) the longest.
83203096a851 dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  4610
    "/ avoids slow delete with huge texts.
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4611
    widthOfWidestLine := nil. "/ i.e. unknown
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4612
    self textChanged.
1717
83203096a851 dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  4613
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4614
    self redrawFromLine:startLineNr.
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4615
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4616
    nLines := list size.
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4617
    (firstLineShown >= nLines) ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4618
	self makeLineVisible:nLines
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4619
    ].
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4620
    wasOn ifTrue:[self showCursor].
1717
83203096a851 dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  4621
4226
a09775d899a6 changed: #basicDeleteFromLine:toLine:
az
parents: 4225
diff changeset
  4622
    "Modified: / 10-11-1998 / 23:55:05 / cg"
a09775d899a6 changed: #basicDeleteFromLine:toLine:
az
parents: 4225
diff changeset
  4623
    "Modified: / 18-03-2011 / 18:26:23 / az"
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4624
!
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4625
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4626
basicDeleteLineWithoutRedraw:lineNr
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4627
    "delete line - no redraw;
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4628
     return true, if something was really deleted"
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4629
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4630
    self checkModificationsAllowed ifFalse:[ ^ false].
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4631
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4632
    (list isNil or:[lineNr > list size]) ifTrue:[^ false].
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4633
    list removeIndex:lineNr.
1717
83203096a851 dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  4634
    "/ TODO: remember old maxwidth of linerange,
83203096a851 dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  4635
    "/ only clear widthOfWidestLine, if this max
83203096a851 dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  4636
    "/ length was (one of) the longest.
83203096a851 dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  4637
    "/ avoids slow delete with huge texts.
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4638
    widthOfWidestLine := nil. "/ i.e. unknown
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4639
    self textChanged.
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4640
    ^ true
1717
83203096a851 dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  4641
83203096a851 dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  4642
    "Modified: / 10.11.1998 / 23:53:24 / cg"
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4643
!
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4644
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4645
basicInsert:aCharacter atLine:lineNr col:colNr
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  4646
    "insert a single character at lineNr/colNr;
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  4647
     set emphasis to character at current position"
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  4648
1929
8e70fb7c9701 fixed handling of italic text when inserting
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  4649
    |line lineSize newLine drawCharacterOnly attribute oldClip x y|
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4650
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4651
    self checkModificationsAllowed ifFalse:[ ^ self].
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4652
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4653
    aCharacter == (Character cr) ifTrue:[
5909
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4654
        self splitLine:lineNr before:colNr.
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4655
        ^ self
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4656
    ].
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  4657
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4658
    drawCharacterOnly := false.
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4659
    self checkForExistingLine:lineNr.
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4660
    line := list at:lineNr.
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4661
    lineSize := line size.
671
f3fe0d8c604d added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents: 666
diff changeset
  4662
3023
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  4663
    self st80EditMode ifFalse:[
5909
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4664
        (self trimBlankLines
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4665
        and:[colNr > lineSize
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4666
        and:[aCharacter == Character space]]) ifTrue:[
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4667
            ^ self
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4668
        ]
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4669
    ].
671
f3fe0d8c604d added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents: 666
diff changeset
  4670
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4671
    (lineSize == 0) ifTrue:[
5909
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4672
        newLine := aCharacter asString species new:colNr.
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4673
        drawCharacterOnly := true
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4674
    ] ifFalse: [
5909
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4675
        (colNr > lineSize) ifTrue: [
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4676
            colNr == (lineSize +1) ifTrue:[
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4677
                attribute := line emphasisAt:lineSize
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4678
            ].
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4679
            newLine := line species new:colNr.
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4680
            newLine replaceFrom:1 to:lineSize with:line startingAt:1.
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4681
            drawCharacterOnly := true
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4682
        ] ifFalse: [
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4683
            attribute := line emphasisAt:colNr.
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4684
            newLine   := line species new:(lineSize + 1).
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4685
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4686
            newLine replaceFrom:1 to:(colNr - 1) with:line startingAt:1.
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4687
            newLine replaceFrom:(colNr + 1) to:(lineSize + 1) with:line startingAt:colNr
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4688
        ]
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4689
    ].
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  4690
2869
48d830f0aea5 insertCharacter: care for wide chars
Claus Gittinger <cg@exept.de>
parents: 2866
diff changeset
  4691
    aCharacter asString bitsPerCharacter > newLine bitsPerCharacter ifTrue:[
5909
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4692
        newLine := aCharacter asString species fromString:newLine.
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4693
        line isText ifTrue:[
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4694
            newLine := newLine asText
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4695
        ]
2869
48d830f0aea5 insertCharacter: care for wide chars
Claus Gittinger <cg@exept.de>
parents: 2866
diff changeset
  4696
    ].
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4697
    newLine at:colNr put:aCharacter.
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  4698
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  4699
    attribute notNil ifTrue:[
5909
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4700
        newLine emphasisAt:colNr put:attribute.
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  4701
    ].
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  4702
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4703
    aCharacter == (Character tab) ifTrue:[
5909
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4704
        newLine := self withTabsExpanded:newLine.
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4705
        drawCharacterOnly := false
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4706
    ].
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  4707
4771
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  4708
    self basicListAt:lineNr put:(newLine ifNil:[newLine] ifNotNil:[newLine asSingleByteStringIfPossible]).
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4709
    widthOfWidestLine notNil ifTrue:[
5909
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4710
        widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:newLine).
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4711
    ].
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4712
    self textChanged.
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4713
    shown ifTrue:[
5909
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4714
        "/ care for italic text - in this case, we must also
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4715
        "/ redraw the character before the insertion in order
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4716
        "/ to fix the slanted piece of the character.
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4717
        "/ (but we must clip, to avoid destoying the character before)
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4718
        (newLine notNil and:[newLine isText]) ifTrue:[
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4719
            colNr > 1 ifTrue:[
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4720
                cursorVisibleLine notNil ifTrue:[
6031
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  4721
                    oldClip := self clippingBoundsOrNil.
5909
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4722
                    x := (self xOfCol:colNr-1 inVisibleLine:cursorVisibleLine) - viewOrigin x.
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4723
                    y := self yOfVisibleLine:cursorVisibleLine.
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4724
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4725
                    gc font hasOverlappingCharacters ifTrue:[
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4726
                        self invalidateLine:lineNr.
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4727
                    ] ifFalse:[
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4728
                        drawCharacterOnly ifTrue:[
6031
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  4729
                            self clippingBounds:(x@y extent:((gc font width * 2) @ fontHeight)).
5909
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4730
                            self redrawLine:lineNr from:colNr-1 to:colNr
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4731
                        ] ifFalse:[
6031
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  4732
                            self clippingBounds:(x@y extent:((width - x) @ fontHeight)).
5909
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4733
                            self redrawLine:lineNr from:colNr-1
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4734
                        ].
6031
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  4735
                        self clippingBounds:oldClip.
5909
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4736
                    ].
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4737
                ].
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4738
                ^ self.
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4739
            ].
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4740
        ].
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4741
        gc font hasOverlappingCharacters ifTrue:[
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4742
            self invalidateLine:lineNr.
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4743
        ] ifFalse:[
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4744
            drawCharacterOnly ifTrue:[
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4745
                self redrawLine:lineNr col:colNr
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4746
            ] ifFalse:[
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4747
                self redrawLine:lineNr from:colNr
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4748
            ]
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4749
        ]
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4750
    ]
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4751
4191
8ac20ced2fbf changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4190
diff changeset
  4752
    "Modified: / 09-11-2010 / 13:43:18 / cg"
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4753
!
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4754
4771
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  4755
basicListAt:lineNr put:newLine
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  4756
    "redefinable for special subclasses (with virtual list)"
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  4757
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  4758
    list at:lineNr put:newLine.
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  4759
!
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  4760
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  4761
basicListRemoveFromIndex:startLineNr toIndex:endLineNr
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  4762
    "redefinable for special subclasses (with virtual list)"
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  4763
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  4764
    list removeFromIndex:startLineNr toIndex:(endLineNr min:list size).
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  4765
!
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  4766
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4767
basicMergeLine:lineNr removeBlanks:removeBlanks
1319
2739903e7a80 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  4768
    "merge line lineNr with line lineNr+1"
2739903e7a80 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  4769
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  4770
    |leftPart rightPart bothParts nextLineNr i|
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  4771
2356
6416beb0f23a backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents: 2350
diff changeset
  4772
    (list notNil and:[(list size) >= lineNr]) ifFalse:[
5909
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4773
        "/ empty list or beyond end of text
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4774
        ^ self
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  4775
    ].
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  4776
    leftPart := self listAt:lineNr.
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  4777
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  4778
    leftPart isNil ifTrue:[
5909
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4779
        leftPart := ''.
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4780
        autoIndent ifTrue:[
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4781
            (i := self leftIndentForLine:cursorLine) == 0 ifFalse:[
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4782
                leftPart := String new:i
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4783
            ]
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4784
        ]
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  4785
    ].
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  4786
    self cursorLine:lineNr col:((leftPart size) + 1).
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  4787
    nextLineNr := self validateCursorLine:(lineNr + 1).
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  4788
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  4789
    nextLineNr > (list size) ifFalse:[
5909
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4790
        (rightPart := self listAt:nextLineNr) isNil ifTrue:[
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4791
            rightPart := ''
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4792
        ] ifFalse:[
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4793
            removeBlanks ifTrue:[
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4794
                rightPart := rightPart withoutLeadingSeparators.
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4795
            ]
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4796
        ].
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4797
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4798
        bothParts := leftPart , rightPart.
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4799
        (self trimBlankLines and:[bothParts isBlank]) ifTrue:[bothParts := nil].
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4800
        self basicListAt:lineNr put:bothParts.
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4801
        self redrawLine:lineNr.
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4802
        self deleteLine:nextLineNr
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4803
    ]
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4804
1319
2739903e7a80 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  4805
    "Created: 9.9.1997 / 09:27:38 / cg"
2739903e7a80 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  4806
    "Modified: 9.9.1997 / 09:28:27 / cg"
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4807
!
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4808
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4809
basicReplace:aCharacter atLine:lineNr col:colNr
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4810
    "replace a single character at lineNr/colNr"
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4811
5045
6197bf1337fe class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4988
diff changeset
  4812
    |line lineSize newLineSpecies newLine drawCharacterOnly|
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4813
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4814
    self checkModificationsAllowed ifFalse:[ ^ self].
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4815
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4816
    aCharacter == (Character cr) ifTrue:[
5909
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4817
        ^ self
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4818
    ].
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4819
1558
abf35cc39757 minimize redraw in overwrite-replace;
Claus Gittinger <cg@exept.de>
parents: 1557
diff changeset
  4820
    drawCharacterOnly := true.
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4821
    self checkForExistingLine:lineNr.
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4822
    line := list at:lineNr.
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4823
    lineSize := line size.
671
f3fe0d8c604d added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents: 666
diff changeset
  4824
5909
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4825
    (self trimBlankLines
671
f3fe0d8c604d added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents: 666
diff changeset
  4826
    and:[colNr > lineSize
f3fe0d8c604d added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents: 666
diff changeset
  4827
    and:[aCharacter == Character space]]) ifTrue:[
5909
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4828
        ^ self
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4829
    ].
671
f3fe0d8c604d added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents: 666
diff changeset
  4830
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4831
    (lineSize == 0) ifTrue:[
5909
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4832
        newLine := aCharacter asString species new:colNr.
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4833
    ] ifFalse: [
5909
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4834
        (aCharacter bitsPerCharacter > line bitsPerCharacter) ifTrue:[
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4835
            newLineSpecies := aCharacter stringSpecies
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4836
        ] ifFalse:[
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4837
            newLineSpecies := line species
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4838
        ].
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4839
        newLine := newLineSpecies new:(colNr max:lineSize).
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4840
        newLine replaceFrom:1 to:lineSize with:line startingAt:1.
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4841
    ].
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4842
    newLine at:colNr put:aCharacter.
1558
abf35cc39757 minimize redraw in overwrite-replace;
Claus Gittinger <cg@exept.de>
parents: 1557
diff changeset
  4843
    aCharacter == (Character tab) ifTrue:[
5909
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4844
        newLine := self withTabsExpanded:newLine.
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4845
        drawCharacterOnly := false
1558
abf35cc39757 minimize redraw in overwrite-replace;
Claus Gittinger <cg@exept.de>
parents: 1557
diff changeset
  4846
    ].
4771
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  4847
    self basicListAt:lineNr put:(newLine ifNil:[newLine] ifNotNil:[newLine asSingleByteStringIfPossible]).
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4848
    widthOfWidestLine notNil ifTrue:[
5909
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4849
        widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:newLine).
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4850
    ].
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4851
    self textChanged.
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4852
    shown ifTrue:[
5909
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4853
        gc font hasOverlappingCharacters ifTrue:[
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4854
            self invalidateLine:lineNr.
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4855
        ] ifFalse:[
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4856
            drawCharacterOnly ifTrue:[
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4857
                self redrawLine:lineNr col:colNr
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4858
            ] ifFalse:[
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4859
                self redrawLine:lineNr from:colNr
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4860
            ]
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4861
        ]
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4862
    ]
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4863
4190
d79217c1317d changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4189
diff changeset
  4864
    "Created: / 06-03-1996 / 12:29:20 / cg"
4191
8ac20ced2fbf changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4190
diff changeset
  4865
    "Modified: / 09-11-2010 / 13:42:54 / cg"
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  4866
!
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  4867
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4868
basicReplaceString:aString atLine:lineNr col:colNr
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4869
    "replace multiple characters starting at lineNr/colNr.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4870
     This is not prepared to encounter special chars (except TAB)
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4871
     in the string."
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4872
5045
6197bf1337fe class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4988
diff changeset
  4873
    |line lineSize newLine newLineSpecies endCol|
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4874
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4875
    self checkModificationsAllowed ifFalse:[ ^ self].
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4876
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4877
    self checkForExistingLine:lineNr.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4878
    line := list at:lineNr.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4879
    lineSize := line size.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4880
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4881
    endCol := colNr + aString size - 1.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4882
    (lineSize == 0) ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4883
	newLine := aString species new:endCol.
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4884
    ] ifFalse: [
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4885
	(aString bitsPerCharacter > line bitsPerCharacter) ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4886
	    newLineSpecies := aString stringSpecies
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4887
	] ifFalse:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4888
	    newLineSpecies := line species
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4889
	].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4890
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4891
	newLine := newLineSpecies new:(endCol max:lineSize).
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4892
	newLine replaceFrom:1 to:lineSize with:line startingAt:1.
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4893
    ].
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4894
    newLine replaceFrom:colNr with:aString.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4895
    (aString includes:(Character tab)) ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4896
	newLine := self withTabsExpanded:newLine.
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4897
    ].
4771
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  4898
    self basicListAt:lineNr put:(newLine ifNil:[newLine] ifNotNil:[newLine asSingleByteStringIfPossible]).
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4899
    widthOfWidestLine notNil ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4900
	widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:newLine).
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4901
    ].
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4902
    self textChanged.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4903
    shown ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4904
	gc font hasOverlappingCharacters ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4905
	    self invalidateLine:lineNr.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4906
	] ifFalse:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4907
	    self redrawLine:lineNr from:colNr
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4908
	]
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4909
    ]
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4910
4190
d79217c1317d changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4189
diff changeset
  4911
    "Created: / 11-06-1998 / 10:38:32 / cg"
4191
8ac20ced2fbf changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4190
diff changeset
  4912
    "Modified: / 09-11-2010 / 13:42:56 / cg"
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4913
!
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4914
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4915
basicSplitLine:lineNr before:colNr
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4916
    "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
  4917
     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
  4918
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  4919
    |line lineSize leftRest rightRest visLine w h mustWait
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4920
     srcY    "{ Class: SmallInteger }" |
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4921
3027
0dd9657b8033 *** empty log message ***
ca
parents: 3024
diff changeset
  4922
    list isNil ifTrue:[ ^ self ].
0dd9657b8033 *** empty log message ***
ca
parents: 3024
diff changeset
  4923
    lineNr > (list size) ifTrue:[ ^ self ].
0dd9657b8033 *** empty log message ***
ca
parents: 3024
diff changeset
  4924
0dd9657b8033 *** empty log message ***
ca
parents: 3024
diff changeset
  4925
    (colNr == 1) ifTrue:[
5909
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4926
        self nonUndoableDo:[
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4927
            self insertLine:nil before:lineNr.
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4928
        ].
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4929
        ^ self
3027
0dd9657b8033 *** empty log message ***
ca
parents: 3024
diff changeset
  4930
    ].
0dd9657b8033 *** empty log message ***
ca
parents: 3024
diff changeset
  4931
0dd9657b8033 *** empty log message ***
ca
parents: 3024
diff changeset
  4932
    line := list at:lineNr.
4199
cd7069b3bc33 comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents: 4192
diff changeset
  4933
    line notNil ifTrue:[
5909
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4934
        lineSize := line size.
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4935
        (colNr <= lineSize) ifTrue:[
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4936
            rightRest := line copyFrom:colNr to:lineSize.
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4937
            (colNr > 1) ifTrue:[
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4938
                leftRest := line copyTo:(colNr - 1)
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4939
            ]
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4940
        ] ifFalse:[
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4941
            leftRest := line
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4942
        ]
3027
0dd9657b8033 *** empty log message ***
ca
parents: 3024
diff changeset
  4943
    ].
0dd9657b8033 *** empty log message ***
ca
parents: 3024
diff changeset
  4944
    leftRest notNil ifTrue:[
5909
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4945
        (self trimBlankLines and:[leftRest isBlank]) ifTrue:[leftRest := nil]
3027
0dd9657b8033 *** empty log message ***
ca
parents: 3024
diff changeset
  4946
    ].
4771
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  4947
    self basicListAt:lineNr put:leftRest.
3027
0dd9657b8033 *** empty log message ***
ca
parents: 3024
diff changeset
  4948
    self nonUndoableDo:[
5909
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4949
        self withoutRedrawInsertLine:rightRest before:(lineNr + 1).
3027
0dd9657b8033 *** empty log message ***
ca
parents: 3024
diff changeset
  4950
    ].
0dd9657b8033 *** empty log message ***
ca
parents: 3024
diff changeset
  4951
    visLine := self listLineToVisibleLine:(lineNr).
0dd9657b8033 *** empty log message ***
ca
parents: 3024
diff changeset
  4952
    visLine notNil ifTrue:[
5909
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4953
        w := self widthForScrollBetween:lineNr
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4954
                                    and:(firstLineShown + nLinesShown).
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4955
        srcY := topMargin + (visLine * fontHeight).
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4956
        h := ((nLinesShown - visLine - 1) * fontHeight).
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4957
        (mustWait := (w > 0 and:[h > 0])) ifTrue:[
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4958
            self catchExpose.
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4959
            self
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4960
                copyFrom:self
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4961
                x:textStartLeft y:srcY
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4962
                toX:textStartLeft y:(srcY + fontHeight)
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4963
                width:w
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4964
                height:((nLinesShown - visLine - 1) * fontHeight)
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4965
                async:true.
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4966
        ].
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4967
        self redrawLine:lineNr.
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4968
        self redrawLine:(lineNr + 1).
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4969
        mustWait ifTrue:[self waitForExpose]
3027
0dd9657b8033 *** empty log message ***
ca
parents: 3024
diff changeset
  4970
    ].
0dd9657b8033 *** empty log message ***
ca
parents: 3024
diff changeset
  4971
    widthOfWidestLine := nil. "/ unknown
0dd9657b8033 *** empty log message ***
ca
parents: 3024
diff changeset
  4972
    self textChanged.
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4973
4199
cd7069b3bc33 comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents: 4192
diff changeset
  4974
    "Modified: / 06-12-2010 / 13:12:55 / cg"
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4975
!
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4976
2954
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  4977
basicWithoutRedrawInsertLines:lines from:start to:end before:lineNr
4328
ea91d179b5f0 changed:
Claus Gittinger <cg@exept.de>
parents: 4289
diff changeset
  4978
    "insert a bunch of lines before line lineNr; the view is not redrawn.
ea91d179b5f0 changed:
Claus Gittinger <cg@exept.de>
parents: 4289
diff changeset
  4979
     Tabs are expanded here with a tab=8 setting (independent of any editor-setting,
ea91d179b5f0 changed:
Claus Gittinger <cg@exept.de>
parents: 4289
diff changeset
  4980
     because the text might have been pasted from an alien view."
2954
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  4981
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  4982
    |newLine newLines nLines|
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  4983
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  4984
    nLines := end - start + 1.
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  4985
    newLines := Array new:(lines size).
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  4986
    start to:end do:[:index |
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4987
	newLine := lines at:index.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4988
	newLine notNil ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4989
	    newLine isString ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4990
		newLine isBlank ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4991
		    newLine := nil
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4992
		] ifFalse:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4993
		    (newLine includes:(Character tab)) ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4994
			newLine := self withTabs:(ListView tab8Positions) expand:newLine
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4995
		    ]
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4996
		]
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4997
	    ]
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4998
	].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4999
	newLines at:index put:newLine
2954
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  5000
    ].
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  5001
    list isNil ifTrue: [
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5002
	list := StringCollection new:(lineNr + nLines + 1)
2954
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  5003
    ] ifFalse: [
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5004
	list grow:((list size + nLines) max:(lineNr + nLines - 1))
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  5005
    ].
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  5006
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  5007
    "I have changed 'replaceFrom:to:with:startingAt:' to correctly handle
2954
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  5008
     overlapping copy - if it didn't, we had to use:"
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  5009
"
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  5010
    index := list size.
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  5011
    [index > lineNr] whileTrue: [
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5012
	pIndex := index - 1.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5013
	list at:index put:(list at:pIndex).
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5014
	index := pIndex
2954
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  5015
    ].
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  5016
"
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  5017
    list replaceFrom:(lineNr + nLines) to:(list size) with:list startingAt:lineNr.
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  5018
    list replaceFrom:lineNr to:(lineNr + nLines - 1) with:newLines startingAt:start.
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  5019
    self contentsChanged
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  5020
4328
ea91d179b5f0 changed:
Claus Gittinger <cg@exept.de>
parents: 4289
diff changeset
  5021
    "Modified: / 07-10-2011 / 15:55:18 / cg"
2954
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  5022
!
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  5023
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  5024
basicWithoutRedrawInsertStringWithoutCRs:aString atLine:lineNr col:colNr
4328
ea91d179b5f0 changed:
Claus Gittinger <cg@exept.de>
parents: 4289
diff changeset
  5025
    "insert aString (which has no crs) at lineNr/colNr.
ea91d179b5f0 changed:
Claus Gittinger <cg@exept.de>
parents: 4289
diff changeset
  5026
     Tabs are expanded here with a tab=8 setting (independent of any editor-setting,
ea91d179b5f0 changed:
Claus Gittinger <cg@exept.de>
parents: 4289
diff changeset
  5027
     because the text might have been pasted from an alien view."
2954
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  5028
4360
fe77e479d95a comment/format in:
Claus Gittinger <cg@exept.de>
parents: 4328
diff changeset
  5029
    |isText strLen line lineSize newLine stringType sz lineCharWidth stringCharWidth|
2954
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  5030
4623
22047f737cb0 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4609
diff changeset
  5031
    (aString isNil) ifTrue:[ ^ self].
2954
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  5032
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  5033
    strLen := aString size.
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  5034
    self checkForExistingLine:lineNr.
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  5035
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  5036
    stringType := aString string species.
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  5037
    isText     := aString isText.
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  5038
    line       := list at:lineNr.
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  5039
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  5040
    line notNil ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5041
	lineSize := line size.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5042
	line isString ifFalse:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5043
	    stringType := line species
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5044
	] ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5045
	    lineCharWidth := line bitsPerCharacter.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5046
	    stringCharWidth := aString bitsPerCharacter.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5047
	    lineCharWidth > stringCharWidth ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5048
		stringType := line string species
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5049
	    ] ifFalse:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5050
		stringCharWidth > lineCharWidth ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5051
		    stringType := aString string species
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5052
		]
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5053
	    ].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5054
	    line isText ifTrue:[ isText := true ]
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5055
	].
2954
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  5056
    ] ifFalse:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5057
	lineSize := 0
2954
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  5058
    ].
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  5059
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  5060
    ((colNr == 1) and:[lineSize == 0]) ifTrue: [
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5061
	newLine := aString
2954
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  5062
    ] ifFalse:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5063
	(lineSize == 0 or:[colNr > lineSize]) ifTrue: [
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5064
	    sz := colNr + strLen - 1
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5065
	] ifFalse:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5066
	    sz := lineSize + strLen
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5067
	].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5068
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5069
	newLine := stringType new:sz.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5070
	isText ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5071
	    newLine := Text string:newLine
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5072
	].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5073
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5074
	(lineSize ~~ 0) ifTrue: [
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5075
	    (colNr > lineSize) ifTrue: [
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5076
		newLine replaceFrom:1 to:lineSize with:line startingAt:1
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5077
	    ] ifFalse: [
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5078
		newLine replaceFrom:1 to:(colNr - 1) with:line startingAt:1.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5079
		newLine replaceFrom:(colNr + strLen) to:(lineSize + strLen) with:line startingAt:colNr
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5080
	    ]
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5081
	].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5082
	newLine replaceFrom:(colNr max:1) to:(colNr + strLen - 1) with:aString startingAt:1
2954
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  5083
    ].
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  5084
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  5085
    (aString includes:(Character tab)) ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5086
	newLine := self withTabs:(ListView tab8Positions) expand:newLine
2954
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  5087
    ].
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  5088
4771
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  5089
    self basicListAt:lineNr put:(newLine ifNil:[newLine] ifNotNil:[newLine asSingleByteStringIfPossible]).
2954
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  5090
    widthOfWidestLine notNil ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5091
	widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:newLine).
2954
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  5092
    ].
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  5093
    self textChanged.
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  5094
4360
fe77e479d95a comment/format in:
Claus Gittinger <cg@exept.de>
parents: 4328
diff changeset
  5095
    "Modified: / 25-01-2012 / 00:37:29 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5096
! !
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5097
2752
5650a9ab5935 method category rename
Claus Gittinger <cg@exept.de>
parents: 2744
diff changeset
  5098
!EditTextView methodsFor:'event handling'!
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5099
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5100
buttonPress:button x:x y:y
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5101
    "hide the cursor when button is activated"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5102
5216
8d6eef5d09c3 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5194
diff changeset
  5103
    hasKeyboardFocus := true.   "/ cg: why is this needed?
2589
62794ae04446 support drop
ca
parents: 2580
diff changeset
  5104
    dragIsActive := false.
62794ae04446 support drop
ca
parents: 2580
diff changeset
  5105
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5106
    completionSupport notNil ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5107
	"/ also give that guy a chance to close its popup view
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5108
	completionSupport buttonPress:button x:x y:y
4696
428c8bc44cfb refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents: 4694
diff changeset
  5109
    ].
4609
8b3eb80d04d0 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4595
diff changeset
  5110
1817
1a9e22f755c8 show non-focus cursor when disabled or readOnly
Claus Gittinger <cg@exept.de>
parents: 1816
diff changeset
  5111
    cursorShown ifTrue: [
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5112
	self drawCursor
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5113
    ].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5114
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5115
    "On X11, be nice and paste PRIMARY when middle click.
4420
8f0164295ef8 changed:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4414
diff changeset
  5116
     Note, that middle button on X11 is translated to button
8f0164295ef8 changed:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4414
diff changeset
  5117
     128 in Smalltalk/X - see XWorkstation class>>initializeConstants"
5643
921578f80870 device access
Claus Gittinger <cg@exept.de>
parents: 5593
diff changeset
  5118
    (button == #paste and:[device platformName == #X11]) ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5119
	self undoableDo:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5120
	    self paste: (self getClipboardText:#selection).
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5121
	].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5122
	^self.
4420
8f0164295ef8 changed:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4414
diff changeset
  5123
    ].
8f0164295ef8 changed:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4414
diff changeset
  5124
3915
737e276852c8 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3907
diff changeset
  5125
    (button == 1) ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5126
	self hideCursor
3915
737e276852c8 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3907
diff changeset
  5127
    ].
737e276852c8 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3907
diff changeset
  5128
"/ some very old code from times, when a right-click was a paste in X11
737e276852c8 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3907
diff changeset
  5129
"/
737e276852c8 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3907
diff changeset
  5130
"/    (button == #paste) ifTrue:[
737e276852c8 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3907
diff changeset
  5131
"/        self pasteOrReplace.
737e276852c8 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3907
diff changeset
  5132
"/        ^ self
737e276852c8 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3907
diff changeset
  5133
"/    ].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5134
    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
  5135
4420
8f0164295ef8 changed:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4414
diff changeset
  5136
    "Modified: / 23-03-1999 / 13:51:40 / cg"
8f0164295ef8 changed:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4414
diff changeset
  5137
    "Modified (comment): / 17-04-2012 / 21:02:25 / Jan Vrany <jan.vrany@fit.cvut.cz>"
121
claus
parents: 118
diff changeset
  5138
!
claus
parents: 118
diff changeset
  5139
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5140
buttonRelease:button x:x y:y
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5141
    "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
  5142
3789
a9b4805e0754 when clicking on a character, position the cursor on the next
Claus Gittinger <cg@exept.de>
parents: 3788
diff changeset
  5143
    |x1 x2 x2_3 newCursorCol|
3788
b72271bf0bc2 when clicking on a character, position the cursor on the next
Claus Gittinger <cg@exept.de>
parents: 3786
diff changeset
  5144
3915
737e276852c8 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3907
diff changeset
  5145
    (button == 1) ifTrue:[
5882
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5146
        typeOfSelection := nil.
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5147
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5148
        dragIsActive ifTrue:[
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5149
            self unselect
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5150
        ].
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5151
        selectionStartLine isNil ifTrue:[
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5152
            clickCol notNil ifTrue:[
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5153
                self cursorMovementAllowed ifTrue:[
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5154
                    newCursorCol := clickCol.
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5155
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5156
                    cursorType ~~ #block ifTrue:[
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5157
                        clickPos notNil ifTrue:[
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5158
                            "/ we do something special, if the text-cursor's type is not a block-cursor
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5159
                            "/ (i.e. if its an ibeam).
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5160
                            "/ adjust clickCol if the user clicked in the right third of a character.
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5161
                            x1 := self xOfCol:clickCol inVisibleLine:clickLine.
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5162
                            x2 := self xOfCol:clickCol+1 inVisibleLine:clickLine.
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5163
                            x2_3 := x1 + ((x2-x1) * (2/3)).
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5164
                            (clickPos x >= x2_3) ifTrue:[ newCursorCol := clickCol+1 ].
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5165
                        ].
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5166
                    ].
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5167
                    "/ the following fixes the ugly select behavior when double clicking on
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5168
                    "/ a partially visible last line (where the first click used to
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5169
                    "/ scroll the text so that the second click was handled on another
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5170
                    "/ line. An alternative (possibly better) solution would be to
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5171
                    "/ remember the last click position and adjust in the double click
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5172
                    "/ event handling (i.e. subtract the number of scrolled lines in between)
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5173
                    "/ Time will show, if this hack works.
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5174
                    clickLine >= (self lastLineShown -1 ) ifTrue:[
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5175
                        self cursorLine:clickLine col:newCursorCol makeVisible:false.
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5176
                        Processor
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5177
                            addTimedBlock:[self sensor pushUserEvent:#makeCursorVisible for:self]
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5178
                            after:0.3 seconds.
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5179
                    ] ifFalse:[
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5180
                        self cursorLine:clickLine col:newCursorCol.
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5181
                    ].
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5182
                ].
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5183
                true "self hadSelectionBeforeClick not" ifTrue:[
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5184
                    list notEmptyOrNil ifTrue:[
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5185
                        UserPreferences current selectAllWhenClickingBeyondEnd ifTrue:[
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5186
                            (clickLine >= list size) ifTrue:[
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5187
                                (clickLine > (self list size + 2)
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5188
                                or:[ clickCol > (list last size + 5) ]) ifTrue:[
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5189
                                    self selectAll
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5190
                                ].
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5191
                            ].
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5192
                        ]
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5193
                    ]
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5194
                ]
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5195
            ]
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5196
        ] ifFalse:[
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5197
            lastStringFromReplaceForNextSearch := nil.  "new selection invalidates remembered string"
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5198
        ].
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5199
        self showCursor
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5200
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5201
    super buttonRelease:button x:x y:y
1580
d30e562bea15 allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
  5202
4396
7820ce5cac3d changed: #buttonRelease:x:y:
Claus Gittinger <cg@exept.de>
parents: 4394
diff changeset
  5203
    "Modified: / 07-03-2012 / 18:48:37 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5204
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5205
2580
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  5206
cursorKeyPress:key shifted:shifted
4492
088b5fba29d0 changed: #keyPress:x:y:view:
Claus Gittinger <cg@exept.de>
parents: 4484
diff changeset
  5207
    <resource: #keyboard (#CursorRight #CursorDown #CursorUp #CursorDown)>
088b5fba29d0 changed: #keyPress:x:y:view:
Claus Gittinger <cg@exept.de>
parents: 4484
diff changeset
  5208
2730
61a2f1981ac6 Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents: 2725
diff changeset
  5209
    |n|
61a2f1981ac6 Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents: 2725
diff changeset
  5210
2606
6a3ab90d339f redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents: 2599
diff changeset
  5211
    self changeTypeOfSelectionTo:nil.
2580
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  5212
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  5213
    (key == #CursorRight) ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5214
	(shifted and:[selectionStartLine isNil]) ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5215
	    selectionStartLine := selectionEndLine := clickStartLine := cursorLine.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5216
	    selectionStartCol := selectionEndCol := clickStartCol := cursorCol.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5217
	    expandingTop := false.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5218
	    self validateNewSelection.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5219
	    self setPrimarySelection.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5220
	    self selectionChanged.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5221
	    self redrawLine:selectionStartLine.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5222
	    ^ self.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5223
	].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5224
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5225
	selectionStartLine notNil ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5226
	    self cursorMovementAllowed ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5227
		"/
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5228
		"/ treat the whole selection as cursor
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5229
		"/
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5230
		self setCursorLine:(selectionEndLine ? selectionStartLine).
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5231
		selectionEndCol == 0 ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5232
		    selectionEndCol := 1.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5233
		].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5234
		self setCursorCol:selectionEndCol.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5235
		shifted ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5236
		    self expandSelectionRight.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5237
		    ^ self
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5238
		].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5239
		self unselect; makeCursorVisible.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5240
		cursorCol == 1 ifTrue:[^ self].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5241
	    ].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5242
	].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5243
	self cursorRight.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5244
	^ self
2580
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  5245
    ].
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  5246
    (key == #CursorDown) ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5247
	(shifted and:[selectionStartLine isNil]) ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5248
	    selectionStartLine := clickStartLine := cursorLine. selectionEndLine := cursorLine + 1.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5249
	    selectionStartCol := clickStartCol := selectionEndCol := cursorCol.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5250
	    selectionEndCol == 1 ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5251
		selectionEndCol := 0.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5252
	    ].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5253
	    self validateNewSelection.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5254
	    self selectionChanged.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5255
	    self redrawLine:selectionStartLine.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5256
	    expandingTop := false.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5257
	    self redrawLine:selectionEndLine.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5258
	    ^ self
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5259
	].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5260
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5261
	selectionStartLine notNil ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5262
	    self cursorMovementAllowed ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5263
		"/
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5264
		"/ treat the whole selection as cursor
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5265
		"/
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5266
		self setCursorLine:(selectionEndLine ? selectionStartLine).
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5267
		self setCursorCol:selectionStartCol.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5268
		(cursorCol == 0 or:[selectionEndCol == 0]) ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5269
		    self setCursorCol:1.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5270
		    self setCursorLine:(cursorLine - 1).
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5271
		].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5272
		self makeCursorVisible.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5273
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5274
		shifted ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5275
		    clickLine := cursorLine.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5276
		    clickCol := cursorCol.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5277
		    self expandSelectionDown.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5278
		    ^ self
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5279
		].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5280
		self unselect.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5281
	    ].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5282
	].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5283
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5284
	n := 1 + (self sensor compressKeyPressEventsWithKey:#CursorDown).
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5285
	self cursorDown:n.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5286
	"/
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5287
	"/ flush keyboard to avoid runaway cursor
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5288
	"/
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5289
	self sensor flushKeyboardFor:self.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5290
	^ self
2580
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  5291
    ].
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  5292
    (key == #CursorLeft or:[key == #CursorUp]) ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5293
	(shifted and:[selectionStartLine isNil]) ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5294
	    expandingTop := true.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5295
	    key == #CursorLeft ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5296
		cursorCol > 1 ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5297
		    selectionStartLine := selectionEndLine := clickStartLine := cursorLine.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5298
		    selectionEndCol := clickStartCol := cursorCol-1.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5299
		    selectionStartCol := cursorCol-1.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5300
		    self validateNewSelection.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5301
		    self selectionChanged.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5302
		    self redrawLine:selectionStartLine.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5303
		    ^ self
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5304
		]
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5305
	    ] ifFalse:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5306
		cursorLine > 1 ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5307
		    selectionEndLine := clickStartLine := cursorLine.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5308
		    selectionEndCol := selectionStartCol := clickStartCol := cursorCol.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5309
		    selectionStartLine := cursorLine - 1.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5310
		    selectionEndCol == 1 ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5311
			selectionEndCol := 0.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5312
		    ].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5313
		    self validateNewSelection.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5314
		    self selectionChanged.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5315
		    self redrawFromLine:selectionStartLine to:cursorLine.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5316
		    ^ self
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5317
		]
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5318
	    ]
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5319
	].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5320
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5321
	selectionStartLine notNil ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5322
	    self cursorMovementAllowed ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5323
		"/
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5324
		"/ treat the whole selection as cursor
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5325
		"/
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5326
		self setCursorLine:selectionStartLine.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5327
		self setCursorCol:selectionStartCol.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5328
		(key == #CursorLeft) ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5329
		    self setCursorCol:(cursorCol+1).  "/ compensate for followup crsr-left
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5330
		].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5331
		self makeCursorVisible.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5332
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5333
		shifted ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5334
		    (key == #CursorUp) ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5335
			clickLine := cursorLine.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5336
			self expandSelectionUp.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5337
		    ] ifFalse:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5338
			self expandSelectionLeft.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5339
		    ].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5340
		    ^ self
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5341
		].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5342
		self unselect.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5343
	    ].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5344
	].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5345
	(key == #CursorLeft) ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5346
	    self cursorLeft. ^self
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5347
	].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5348
	(key == #CursorUp)        ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5349
	    n := 1 + (self sensor compressKeyPressEventsWithKey:#CursorUp).
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5350
	    self cursorUp:n.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5351
	    "/
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5352
	    "/ flush keyboard to avoid runaway cursor
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5353
	    "/
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5354
	    self sensor flushKeyboardFor:self.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5355
	    ^ self
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5356
	].
2580
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  5357
    ].
4420
8f0164295ef8 changed:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4414
diff changeset
  5358
8f0164295ef8 changed:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4414
diff changeset
  5359
    "Modified: / 17-04-2012 / 21:01:15 / Jan Vrany <jan.vrany@fit.cvut.cz>"
2580
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  5360
!
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  5361
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5362
doKeyPress:key x:x y:y
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5363
    "handle keyboard input"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5364
4521
0b6740e2d1a7 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4494
diff changeset
  5365
    <resource: #keyboard (#Paste #Insert #PasteFromHistory #Cut #Again #AgainForAll
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5366
			  #Replace #Undo #Redo #Accept
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5367
			  #Delete #BasicDelete #BackSpace #BasicBackspace
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5368
			  #DeleteSpaces #Join
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5369
			  #SearchMatchingParent #SelectMatchingParents
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5370
			  #SelectWord #ExpandSelectionByWord
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5371
			  #SelectToEnd #SelectFromBeginning
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5372
			  #SelectLine #ExpandSelectionByLine
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5373
			  #BeginOfLine #EndOfLine #NextWord #PreviousWord
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5374
			  #CursorRight #CursorDown #CursorLeft #CursorUp
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5375
			  #Return #Tab #BackTab #NonInsertingTab #Escape
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5376
			  #GotoLine #BeginOfText #EndOfText
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5377
			  #InsertLine #DeleteLine
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5378
			  #SelectLineFromBeginning
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5379
			  #LearnKeyboardMacro #ExecuteKeyboardMacro #ToggleInsertMode
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5380
			  #OpenSpecialCharacterWindow #InsertUUID
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5381
			  #'F*' #'f*')>
2017
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  5382
4730
1f84a8cfec4e class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4728
diff changeset
  5383
    |fKeyMacros shiftPressed ctrlPressed i event macroName
5119
1ba5fb52a0e3 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5114
diff changeset
  5384
     immediateCompletion currentUserPrefs rawKey|
4818
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  5385
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  5386
    currentUserPrefs := UserPreferences current.
2184
fb634dc3e606 learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents: 2157
diff changeset
  5387
4701
fc3e667bcc01 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4700
diff changeset
  5388
    "/ experimental
4818
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  5389
    immediateCompletion := currentUserPrefs immediateCodeCompletion.
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5390
    (immediateCompletion
4818
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  5391
    or:[currentUserPrefs codeCompletionOnControlKey
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  5392
    or:[currentUserPrefs codeCompletionOnTabKey]]) ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5393
	completionSupport isNil ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5394
	    self initializeCompletionSupport.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5395
	].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5396
    ].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5397
4801
69a5bff7b5cd Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4786
diff changeset
  5398
    "/ JV: why setting it to nil here?
69a5bff7b5cd Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4786
diff changeset
  5399
"/    ifFalse:[
69a5bff7b5cd Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4786
diff changeset
  5400
"/        completionService := nil
69a5bff7b5cd Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4786
diff changeset
  5401
"/    ].
69a5bff7b5cd Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4786
diff changeset
  5402
    completionSupport notNil ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5403
	completionSupport stopCompletionProcess.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5404
	(completionSupport handleKeyPress:key x:x y:y) ifTrue:["eaten" ^ self].
4696
428c8bc44cfb refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents: 4694
diff changeset
  5405
    ].
428c8bc44cfb refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents: 4694
diff changeset
  5406
4818
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  5407
    key isSymbol ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5408
	(device modifierKeys includes:key) ifFalse:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5409
	    lastReplacementInfo stillCollectingInput:false.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5410
	]
4818
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  5411
    ].
3793
5a6074a257c1 learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents: 3790
diff changeset
  5412
    (key == #LearnKeyboardMacro) ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5413
	lastReplacementInfo stillCollectingInput:false.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5414
	self toggleLearnMode.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5415
	^ self
3793
5a6074a257c1 learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents: 3790
diff changeset
  5416
    ].
5a6074a257c1 learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents: 3790
diff changeset
  5417
    (key == #ExecuteKeyboardMacro) ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5418
	lastReplacementInfo stillCollectingInput:false.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5419
	self executeLearnedKeyboardMacro.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5420
	^ self.
3793
5a6074a257c1 learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents: 3790
diff changeset
  5421
    ].
3799
f6cbe8d860d5 code formatting
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  5422
    (key == #Undo) ifTrue:[self undo. ^self].
f6cbe8d860d5 code formatting
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  5423
    (key == #Redo) ifTrue:[self redo. ^self].
f6cbe8d860d5 code formatting
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  5424
3793
5a6074a257c1 learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents: 3790
diff changeset
  5425
    self learnMode ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5426
	event := WindowGroup lastEventQuerySignal query.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5427
	learnedMacro add:event.
3793
5a6074a257c1 learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents: 3790
diff changeset
  5428
    ].
5a6074a257c1 learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents: 3790
diff changeset
  5429
4238
5f7125996b44 changed:
Stefan Vogel <sv@exept.de>
parents: 4237
diff changeset
  5430
    (self executekeyboardMacroNamed:key) ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5431
	"the macro named key exists"
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5432
	^ self
2416
56acdd9e31b5 lifted mkeyboardMacro handling from Workspace to EditTextView
Claus Gittinger <cg@exept.de>
parents: 2406
diff changeset
  5433
    ].
56acdd9e31b5 lifted mkeyboardMacro handling from Workspace to EditTextView
Claus Gittinger <cg@exept.de>
parents: 2406
diff changeset
  5434
4482
0530a2d95b4b class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 4481
diff changeset
  5435
    key isSymbol ifFalse:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5436
	"the usual case: key is a character, but maybe a string also (in X11)"
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5437
	self handleNonCommandKey:key.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5438
	^ self
4482
0530a2d95b4b class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 4481
diff changeset
  5439
    ].
0530a2d95b4b class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 4481
diff changeset
  5440
0530a2d95b4b class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 4481
diff changeset
  5441
    event isNil ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5442
	event := WindowGroup lastEventQuerySignal query.
4482
0530a2d95b4b class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 4481
diff changeset
  5443
    ].
0530a2d95b4b class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 4481
diff changeset
  5444
    shiftPressed := event hasShift.
0530a2d95b4b class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 4481
diff changeset
  5445
    ctrlPressed := event hasCtrl and:[(event rawKey asString startsWith:'Ctrl') not].
5119
1ba5fb52a0e3 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5114
diff changeset
  5446
    rawKey := event rawKey.
4482
0530a2d95b4b class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 4481
diff changeset
  5447
5133
9d9d9845258f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5119
diff changeset
  5448
    key == #InsertUUID ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5449
	self insertUUID.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5450
	^ self.
5133
9d9d9845258f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5119
diff changeset
  5451
    ].
9d9d9845258f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5119
diff changeset
  5452
4253
adea55ecdb57 changed: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents: 4249
diff changeset
  5453
    (key == #DeleteWordBeforeCursor) ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5454
	self deleteWordBeforeCursor.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5455
	^ self.
4253
adea55ecdb57 changed: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents: 4249
diff changeset
  5456
    ].
adea55ecdb57 changed: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents: 4249
diff changeset
  5457
5119
1ba5fb52a0e3 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5114
diff changeset
  5458
    (rawKey == #BackSpace or:[key == #BasicBackspace]) ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5459
	selectionStartLine notNil ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5460
	    ((key == #BasicBackspace)
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5461
	    or:[ currentUserPrefs deleteSetsClipboardText not ])
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5462
	    ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5463
		self deleteSelection.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5464
	    ] ifFalse: [
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5465
		self copyAndDeleteSelection.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5466
	    ].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5467
	] ifFalse:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5468
	    self makeCursorVisible.
4609
8b3eb80d04d0 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4595
diff changeset
  5469
"/          (shiftPressed and:[ ctrlPressed ]) ifTrue:[
8b3eb80d04d0 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4595
diff changeset
  5470
"/            self deleteWordBeforeCursor.
8b3eb80d04d0 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4595
diff changeset
  5471
"/          ] ifFalse:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5472
	    self deleteCharBeforeCursor.
4609
8b3eb80d04d0 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4595
diff changeset
  5473
"/          ].
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5474
	].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5475
	true "immediateCompletion" ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5476
	    completionSupport notNil ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5477
		completionSupport postKeyPress:key
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5478
	    ].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5479
	].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5480
	^ self
2205
230cf9cef6c3 searchPatter, if from selection (escape meta characters)
Claus Gittinger <cg@exept.de>
parents: 2196
diff changeset
  5481
    ].
2184
fb634dc3e606 learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents: 2157
diff changeset
  5482
3782
79ae5dad28d4 Ctrl-Insert to toggle insert mode.
Claus Gittinger <cg@exept.de>
parents: 3781
diff changeset
  5483
    (key == #ToggleAutoIndent) ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5484
	self autoIndent:(autoIndent not).
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5485
	^ self.
3782
79ae5dad28d4 Ctrl-Insert to toggle insert mode.
Claus Gittinger <cg@exept.de>
parents: 3781
diff changeset
  5486
    ].
79ae5dad28d4 Ctrl-Insert to toggle insert mode.
Claus Gittinger <cg@exept.de>
parents: 3781
diff changeset
  5487
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  5488
    key == #ToggleInsertMode ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5489
	self insertMode:(editMode value == EditMode insertMode) not.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5490
	^ self.
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  5491
    ].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5492
4162
9c80c8f4ba45 changed:
Claus Gittinger <cg@exept.de>
parents: 4143
diff changeset
  5493
    key == #OpenSpecialCharacterWindow ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5494
	CharacterSetView notNil ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5495
	    self specialCharacters.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5496
	    ^ self.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5497
	]
4162
9c80c8f4ba45 changed:
Claus Gittinger <cg@exept.de>
parents: 4143
diff changeset
  5498
    ].
9c80c8f4ba45 changed:
Claus Gittinger <cg@exept.de>
parents: 4143
diff changeset
  5499
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5500
    replacing := false.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5501
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5502
    "
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5503
     Fn      pastes a key-sequence (but only if not overlayed with
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5504
	     another function in the keyboard map)
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5505
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5506
     see TextView>>:x:y
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5507
    "
1177
9d23e1241404 avoid match: if possible (to not clobber the previous matchString)
Claus Gittinger <cg@exept.de>
parents: 1108
diff changeset
  5508
    (key at:1) asLowercase == $f ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5509
	(('[fF][0-9]' match:key)
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5510
	or:['[fF][0-9][0-9]' match:key]) ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5511
	    shiftPressed ifFalse:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5512
		fKeyMacros := currentUserPrefs functionKeySequences.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5513
		fKeyMacros notNil ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5514
		    (fKeyMacros includesKey:key) ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5515
			self pasteOrReplace:(fKeyMacros at:key) asStringCollection.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5516
			^ self
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5517
		    ]
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5518
		]
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5519
	    ]
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5520
	].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5521
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5522
2506
5568d67dbddd Ctrl-8 / Ctrl-9,
Claus Gittinger <cg@exept.de>
parents: 2505
diff changeset
  5523
    (key == #'Ctrl8' or:[key == #'Ctrl9']) ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5524
	self parenthizeSelectionWith:$( and:$).
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5525
	^ self.
2506
5568d67dbddd Ctrl-8 / Ctrl-9,
Claus Gittinger <cg@exept.de>
parents: 2505
diff changeset
  5526
    ].
5568d67dbddd Ctrl-8 / Ctrl-9,
Claus Gittinger <cg@exept.de>
parents: 2505
diff changeset
  5527
    (key == #'Ctrl2') ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5528
	self parenthizeSelectionWith:$" and:$".
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5529
	^ self.
2506
5568d67dbddd Ctrl-8 / Ctrl-9,
Claus Gittinger <cg@exept.de>
parents: 2505
diff changeset
  5530
    ].
5568d67dbddd Ctrl-8 / Ctrl-9,
Claus Gittinger <cg@exept.de>
parents: 2505
diff changeset
  5531
    (key == #'Ctrl#') ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5532
	self parenthizeSelectionWith:$' and:$'.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5533
	^ self.
2505
9204d5313979 Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents: 2491
diff changeset
  5534
    ].
4286
83ef1d9faf6d added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents: 4285
diff changeset
  5535
    (key == #'ConvertSelectionToLowercaseOrUppercaseOrUppercaseFirst') ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5536
	self convertSelectionToLowercaseOrUppercaseOrUppercaseFirst.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5537
	^ self.
4286
83ef1d9faf6d added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents: 4285
diff changeset
  5538
    ].
2505
9204d5313979 Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents: 2491
diff changeset
  5539
274
6df4bb990f04 handle accept where acceptAction is define (this was a historic leftover)
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
  5540
    (key == #Accept)  ifTrue:[^ self accept].
5387
b94d35da3ad6 class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 5371
diff changeset
  5541
    (key == #PasteFromHistory) ifTrue:[self pasteOrReplaceFromHistory. ^self].
b94d35da3ad6 class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 5371
diff changeset
  5542
    (key == #Paste or:[key == #Insert]) ifTrue:[self pasteOrReplaceByKeyPress. ^self].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5543
    (key == #Cut) ifTrue:[self cut. ^self].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5544
    (key == #Again) ifTrue:[self again. ^self].
3781
36268d8303d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3780
diff changeset
  5545
    (key == #AgainForAll) ifTrue:[self multipleAgain. ^self].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5546
3542
30ed44ed0178 +joinLines (CTRL-j);
Claus Gittinger <cg@exept.de>
parents: 3517
diff changeset
  5547
    (key == #Join) ifTrue:[self joinLines. ^self].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5548
    (key == #Replace) ifTrue:[self replace. ^self].
4707
f6ac835a1cf6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4701
diff changeset
  5549
    (key == #ExpandSelectionByWord) ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5550
	self makeCursorVisible.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5551
	self findNextWordAfterSelectionAndAddToSelection.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5552
	^ self
4707
f6ac835a1cf6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4701
diff changeset
  5553
    ].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5554
    (key == #SelectWord) ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5555
	self makeCursorVisible.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5556
	self selectWordUnderCursor.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5557
	^ self
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5558
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5559
2505
9204d5313979 Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents: 2491
diff changeset
  5560
    (key == #SearchMatchingParent) ifTrue:[self searchForMatchingParenthesis. ^ self].
9204d5313979 Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents: 2491
diff changeset
  5561
    (key == #SelectMatchingParents) ifTrue:[self searchForAndSelectMatchingParenthesis. ^ self].
9204d5313979 Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents: 2491
diff changeset
  5562
    (key == #SelectToEnd) ifTrue:[self selectUpToEnd. ^ self].
9204d5313979 Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents: 2491
diff changeset
  5563
    (key == #SelectFromBeginning) ifTrue:[self selectFromBeginning. ^ self].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5564
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5565
" disabled - nobody liked it ...
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5566
  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
  5567
1304
173d00c195f9 flush pending keyboard events in cursor-up/down
Claus Gittinger <cg@exept.de>
parents: 1300
diff changeset
  5568
    (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
  5569
    (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
  5570
    (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
  5571
    (key == #Ctrlp) ifTrue:[self unselect. self cursorUp. ^ self].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5572
"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5573
1675
b1cba2341f95 EndOfLine / BeginOfLine unselect first.
Claus Gittinger <cg@exept.de>
parents: 1601
diff changeset
  5574
    (key == #BeginOfLine) ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5575
	"/ cg: this is complete rubbish - you have to define a mapping from
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5576
	"/ some shifted key to selectFromBeginOfLine
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5577
	"/ (otherwise, no shifted key could ever be mapped to BegnOfLine)
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5578
	"/ see code below.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5579
	false "shiftPressed" ifTrue: [
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5580
	    "/ "Original St/X code - now use Ctrl modifier"
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5581
	    "/ self unselect.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5582
	    "/ self cursorHome.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5583
	    "Jan's modification"
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5584
	    "/ self addToSelectionAfter:[ self cursorToBeginOfLine ].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5585
	    "/ Jan's modification modified by his own request ;-))
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5586
	    self selectFromBeginOfLine.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5587
	] ifFalse: [
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5588
	    self unselect.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5589
	    ctrlPressed ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5590
		self cursorHome.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5591
	    ] ifFalse:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5592
		self cursorToBeginOfLine.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5593
	    ]
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5594
	].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5595
	^ self
1675
b1cba2341f95 EndOfLine / BeginOfLine unselect first.
Claus Gittinger <cg@exept.de>
parents: 1601
diff changeset
  5596
    ].
5226
9194ed3bb118 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5216
diff changeset
  5597
    (key == #BSelectFromeginOfLine) ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5598
	self selectFromBeginOfLine.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5599
	^ self
5226
9194ed3bb118 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5216
diff changeset
  5600
    ].
9194ed3bb118 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5216
diff changeset
  5601
1675
b1cba2341f95 EndOfLine / BeginOfLine unselect first.
Claus Gittinger <cg@exept.de>
parents: 1601
diff changeset
  5602
    (key == #EndOfLine) ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5603
	"/ cg: this is complete rubbish - you have to define a mapping from
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5604
	"/ some shifted key to selectFromBeginOfLine
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5605
	"/ (otherwise, no shifted key could ever be mapped to BegnOfLine)
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5606
	"/ see code below.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5607
	false "shiftPressed" ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5608
	    "/ "Original St/X code - now use Ctrl modifier"
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5609
	    "/ self unselect.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5610
	    "/ self cursorToBottom
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5611
	    " Jan's modification"
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5612
	    "/ self addToSelectionAfter:[ self cursorToEndOfLine ] .
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5613
	    "/ Jan's modification modified by his own request ;-))
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5614
	    self selectToEndOfLine.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5615
	] ifFalse:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5616
	    self unselect.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5617
	    ctrlPressed ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5618
		self cursorToBottom
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5619
	    ] ifFalse:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5620
		self cursorToEndOfLine.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5621
	    ]
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5622
	].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5623
	^ self
1675
b1cba2341f95 EndOfLine / BeginOfLine unselect first.
Claus Gittinger <cg@exept.de>
parents: 1601
diff changeset
  5624
    ].
5226
9194ed3bb118 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5216
diff changeset
  5625
9194ed3bb118 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5216
diff changeset
  5626
    (key == #SelectToEndOfLine) ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5627
	self selectToEndOfLine.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5628
	^ self
5226
9194ed3bb118 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5216
diff changeset
  5629
    ].
9194ed3bb118 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5216
diff changeset
  5630
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5631
    (key == #NextWord) ifTrue:[self cursorToNextWord. ^self].
3310
83368f9014a1 word check
Claus Gittinger <cg@exept.de>
parents: 3303
diff changeset
  5632
    (key == #EndOfWord) ifTrue:[self cursorToEndOfWord. ^self].
499
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
  5633
    (key == #PreviousWord) ifTrue:[self cursorToPreviousWord. ^self].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5634
    (key == #GotoLine) ifTrue:[self gotoLine. ^self].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5635
5119
1ba5fb52a0e3 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5114
diff changeset
  5636
    (rawKey == #CursorRight
1ba5fb52a0e3 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5114
diff changeset
  5637
    or:[rawKey == #CursorDown
1ba5fb52a0e3 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5114
diff changeset
  5638
    or:[rawKey == #CursorLeft
1ba5fb52a0e3 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5114
diff changeset
  5639
    or:[rawKey == #CursorUp]]]) ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5640
	self cursorKeyPress:rawKey shifted:shiftPressed.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5641
	^ self.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5642
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5643
5119
1ba5fb52a0e3 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5114
diff changeset
  5644
    (key == #ShiftReturn or:[key == #NonInsertingReturn]) ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5645
	self unselect. self cursorReturn.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5646
	^ self
3257
628e1e05814d shift-Tab fix.
Claus Gittinger <cg@exept.de>
parents: 3252
diff changeset
  5647
    ].
628e1e05814d shift-Tab fix.
Claus Gittinger <cg@exept.de>
parents: 3252
diff changeset
  5648
628e1e05814d shift-Tab fix.
Claus Gittinger <cg@exept.de>
parents: 3252
diff changeset
  5649
    (key == #Return) ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5650
	shiftPressed ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5651
	    self unselect. self cursorReturn.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5652
	    ^ self
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5653
	].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5654
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5655
	self isReadOnly ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5656
	    self unselect; makeCursorVisible.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5657
	    self cursorReturn
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5658
	] ifFalse:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5659
	    self isInInsertMode ifFalse:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5660
		self cursorReturn:true.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5661
		autoIndent == true ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5662
		    i := self leftIndentForLine:(cursorLine + 1).
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5663
		    (self listAt:cursorLine) isEmptyOrNil ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5664
			self cursorCol:(i+1 max:1)
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5665
		    ]
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5666
		]
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5667
	    ] ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5668
		|left right oldIndent|
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5669
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5670
		"/ old version just unselected ...
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5671
		"/ self unselect; makeCursorVisible.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5672
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5673
		"/ new version deletes ...
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5674
		typeOfSelection == #paste ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5675
		    self unselect; makeCursorVisible.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5676
		] ifFalse:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5677
		    self copyAndDeleteSelection.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5678
		].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5679
		left := (self listAt:cursorLine to:cursorCol-1) ? ''.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5680
		right := (self listAt:cursorLine from:cursorCol) ? ''.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5681
		self insertCharAtCursor:(Character cr).
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5682
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5683
		autoIndent == true ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5684
		    (right isEmpty and:[cursorCol ~~ 1]) ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5685
			"/ nothing to do.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5686
		    ] ifFalse:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5687
			((self listAt:cursorLine) isEmptyOrNil
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5688
			or:[ false "cursorCol == 1" ]) ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5689
			    i := (self leftIndentForLine:cursorLine).
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5690
			    left := left withoutSeparators.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5691
			    right := right withoutSeparators.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5692
			    (left endsWith:'[') ifTrue:[
4823
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  5693
"/                                i := i + 4.
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5694
			    ] ifFalse:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5695
				(false "(left endsWith:']')" or:[(right startsWith:']')]) ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5696
				    i := i - 4.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5697
				].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5698
			    ].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5699
			    oldIndent := self leftIndentOfLine:cursorLine.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5700
			    self indentFromLine:cursorLine toLine:cursorLine by:(i-oldIndent).
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5701
			    self st80EditMode ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5702
				(self listAt:cursorLine) size < i ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5703
				    self insertStringAtCursor:(String new:((i-oldIndent) max:0)).
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5704
				].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5705
			    ].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5706
			    self cursorCol:(i+1 max:1)
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5707
			].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5708
		    ]
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5709
		].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5710
	    ].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5711
	].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5712
	^ self
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5713
    ].
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
  5714
2819
a7a41dfb9df7 BackTab / NonInsertingTab modifiers now defined in keyboard.rc
ca
parents: 2817
diff changeset
  5715
    (key == #NonInsertingTab) ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5716
	self unselect. self cursorTab.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5717
	^ self
2819
a7a41dfb9df7 BackTab / NonInsertingTab modifiers now defined in keyboard.rc
ca
parents: 2817
diff changeset
  5718
    ].
3422
a0c68e8bd56e tab with line selection means: indent/undent
Claus Gittinger <cg@exept.de>
parents: 3416
diff changeset
  5719
    ((key == #BackTab) or:[(key == #Tab)]) ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5720
	self tabMeansNextField ifTrue:[^ super keyPress:key x:x y:y].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5721
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5722
	self hasSelection ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5723
	    selectStyle == #line ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5724
		((key == #Tab) and:[shiftPressed not]) ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5725
		    macroName := #IndentBy4.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5726
		] ifFalse:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5727
		    macroName := #UndentBy4.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5728
		].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5729
		macroName notNil ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5730
		    self executekeyboardMacroNamed:macroName.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5731
		].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5732
	    ]
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5733
	].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5734
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5735
	self unselect.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5736
	(key == #Tab) ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5737
	    (shiftPressed or:[self isInInsertMode not]) ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5738
		self cursorTab.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5739
		^ self
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5740
	    ].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5741
	    self insertTabAtCursor.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5742
	    ^ self
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5743
	].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5744
	self cursorBacktab.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5745
	^ self
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5746
    ].
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
  5747
2883
6cdb4a5a7b5e shift-delete - delete whiteSpace
Claus Gittinger <cg@exept.de>
parents: 2880
diff changeset
  5748
    "/ key == #DeleteSpaces ifTrue:[
5119
1ba5fb52a0e3 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5114
diff changeset
  5749
    (rawKey == #Delete) ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5750
	shiftPressed ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5751
	    [(cursorCol <= (self listAt:cursorLine) size)
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5752
	     and:[self characterUnderCursor isSeparator]] whileTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5753
	     self makeCursorVisible.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5754
		self deleteCharAtCursor.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5755
	    ].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5756
	    ^ self
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5757
	]
2883
6cdb4a5a7b5e shift-delete - delete whiteSpace
Claus Gittinger <cg@exept.de>
parents: 2880
diff changeset
  5758
    ].
6cdb4a5a7b5e shift-delete - delete whiteSpace
Claus Gittinger <cg@exept.de>
parents: 2880
diff changeset
  5759
5119
1ba5fb52a0e3 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5114
diff changeset
  5760
    (rawKey == #Delete
870
c606f29db5d7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 865
diff changeset
  5761
     or:[key == #BasicDelete]) ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5762
	selectionStartLine notNil ifTrue:[
4130
87d51f65430e changed: #doKeyPress:x:y:
fm
parents: 4129
diff changeset
  5763
"/          Again function is not supporting Delete action (on purpose, to avoid replacing the next search string)
87d51f65430e changed: #doKeyPress:x:y:
fm
parents: 4129
diff changeset
  5764
"/          To remove text repetetively, use Cut instead.
87d51f65430e changed: #doKeyPress:x:y:
fm
parents: 4129
diff changeset
  5765
"/            self setLastStringToReplace: self selection asStringWithoutFinalCR.
87d51f65430e changed: #doKeyPress:x:y:
fm
parents: 4129
diff changeset
  5766
"/            lastReplacementInfo lastReplacement: nil.
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5767
	    ((key == #BasicDelete)
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5768
	    or:[currentUserPrefs deleteSetsClipboardText not]) ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5769
		self deleteSelection.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5770
	    ] ifFalse:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5771
		self copyAndDeleteSelection.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5772
	    ].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5773
	    ^ self
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5774
	].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5775
	self makeCursorVisible.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5776
	self deleteCharAtCursor.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5777
	^ self
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5778
    ].
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
  5779
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5780
    (key == #BeginOfText) ifTrue:[     "i.e. HOME"
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5781
	self unselect.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5782
	cursorVisibleLine == 1 ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5783
	    self cursorHome.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5784
	] ifFalse:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5785
	    self cursorToFirstVisibleLine
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5786
	].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5787
	^ self
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5788
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5789
    (key == #EndOfText) ifTrue:[       "i.e. END"
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5790
	self unselect.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5791
	cursorVisibleLine == nFullLinesShown ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5792
	    self cursorToBottom.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5793
	] ifFalse:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5794
	    self cursorToLastVisibleLine
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5795
	].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5796
	^ self
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5797
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5798
    ((key == #Escape)
3257
628e1e05814d shift-Tab fix.
Claus Gittinger <cg@exept.de>
parents: 3252
diff changeset
  5799
    or:[key == #SelectLineFromBeginning]) ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5800
	self makeCursorVisible.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5801
	self unselect. self selectCursorLineFromBeginning.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5802
	^ self
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5803
    ].
3257
628e1e05814d shift-Tab fix.
Claus Gittinger <cg@exept.de>
parents: 3252
diff changeset
  5804
    (key == #SelectLine) ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5805
	self makeCursorVisible.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5806
	self unselect. self selectCursorLine.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5807
	^ self
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5808
    ].
3257
628e1e05814d shift-Tab fix.
Claus Gittinger <cg@exept.de>
parents: 3252
diff changeset
  5809
    (key == #ExpandSelectionByLine) ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5810
	"/ self makeCursorVisible.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5811
	self selectExpandCursorLine.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5812
	^ self
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5813
    ].
3257
628e1e05814d shift-Tab fix.
Claus Gittinger <cg@exept.de>
parents: 3252
diff changeset
  5814
    (key == #DeleteLine) ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5815
	self makeCursorVisible.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5816
	self unselect. self deleteCursorLine.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5817
	^ self
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5818
    ].
3257
628e1e05814d shift-Tab fix.
Claus Gittinger <cg@exept.de>
parents: 3252
diff changeset
  5819
    (key == #InsertLine) ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5820
	self makeCursorVisible.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5821
	self unselect. self insertLine:nil before:cursorLine.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5822
	^ self
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5823
    ].
3781
36268d8303d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3780
diff changeset
  5824
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5825
    super keyPress:key x:x y:y
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5826
3310
83368f9014a1 word check
Claus Gittinger <cg@exept.de>
parents: 3303
diff changeset
  5827
    "Modified: / 06-02-1998 / 11:59:59 / stefan"
4286
83ef1d9faf6d added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents: 4285
diff changeset
  5828
    "Modified: / 14-07-2011 / 12:08:28 / cg"
4801
69a5bff7b5cd Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4786
diff changeset
  5829
    "Modified: / 26-09-2013 / 17:52:04 / Jan Vrany <jan.vrany@fit.cvut.cz>"
121
claus
parents: 118
diff changeset
  5830
!
claus
parents: 118
diff changeset
  5831
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5832
executeKeyboardMacro:cmdMacro
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5833
    Error handle:[:ex |
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5834
	self warn:'Error in keyboard macro: ' , ex description.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5835
	ex return.
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5836
    ] do:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5837
	AbortOperationRequest handle:[:ex |
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5838
	    self warn:'Keyboard macro aborted'.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5839
	    ex return.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5840
	] do:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5841
	    Parser
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5842
		evaluate:cmdMacro asString
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5843
		receiver:self
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5844
		notifying:nil
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5845
		compile:false.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5846
	].
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5847
    ].
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5848
!
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5849
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5850
handleNonCommandKey:keyArg
4700
150468a2ea5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4697
diff changeset
  5851
    |selStartLineBefore selStartColBefore selEndLineBefore selEndColBefore key|
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5852
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5853
    self isReadOnly ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5854
	self flashReadOnly.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5855
	^ self.
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5856
    ].
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5857
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5858
    key := keyArg.
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5859
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5860
    typeOfSelection == #paste ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5861
	"pasted selection will NOT be replaced by keystroke"
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5862
	self unselect
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5863
    ].
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5864
4700
150468a2ea5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4697
diff changeset
  5865
    selStartLineBefore := selectionStartLine.
150468a2ea5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4697
diff changeset
  5866
    selStartColBefore := self selectionStartCol.
150468a2ea5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4697
diff changeset
  5867
    selEndLineBefore := selectionEndLine.
150468a2ea5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4697
diff changeset
  5868
    selEndColBefore := self selectionEndCol.
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5869
4940
73e7031a4a85 class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 4889
diff changeset
  5870
    (gc characterEncoding ? #'iso10646-1') ~~ #'iso10646-1' ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5871
	key isCharacter ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5872
	    key := CharacterEncoder encode:key from:#'iso10646-1' into:gc characterEncoding.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5873
	] ifFalse:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5874
	    key := CharacterEncoder encodeString:key from:#'iso10646-1' into:gc characterEncoding.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5875
	].
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5876
    ].
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5877
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5878
    "replace selection by what is typed in -
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  5879
     if word was selected with a space, keep it.
4700
150468a2ea5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4697
diff changeset
  5880
     if there was no selection, the key's character is inserted"
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  5881
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  5882
    editMode value isInsertAndSelectMode ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5883
	selectionStartLine := selectionStartCol := selectionEndLine := selectionEndCol := nil.
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  5884
    ].
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5885
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5886
    (selectStyle == #wordLeft) ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5887
	self replaceSelectionBy:(' ' , key asString)
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5888
    ] ifFalse:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5889
	(selectStyle == #wordRight) ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5890
	    self replaceSelectionBy:(key asString , ' ').
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5891
	    self cursorLeft
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5892
	] ifFalse:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5893
	    self replaceSelectionBy:key
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5894
	]
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  5895
    ].
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5896
    selectStyle := nil.
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5897
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  5898
    editMode value isInsertAndSelectMode ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5899
	selectionStartLine := selStartLineBefore.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5900
	selectionStartCol := selStartColBefore.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5901
	selectionEndLine := selEndLineBefore.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5902
	selectionEndCol := selEndColBefore.
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  5903
    ].
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  5904
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5905
    showMatchingParenthesis ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5906
	"emacs style parenthesis shower"
3813
8d719ca5812d dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3811
diff changeset
  5907
      (ExecutingMacroQuery query ? false) ifFalse:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5908
	"claus: only do it for closing parenthesis -
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5909
		otherwise its too anoying.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5910
	"
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5911
"
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5912
	('()[]{}' includes:key) ifTrue:[
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5913
"
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5914
	(')]}' includes:key) ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5915
	self
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5916
	    searchForMatchingParenthesisFromLine:cursorLine col:(cursorCol - 1)
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5917
	    ifFound:[:line :col |
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5918
			 |savLine savCol sensor|
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5919
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5920
			 self withCursor:Cursor eye do:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5921
			     savLine := cursorLine.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5922
			     savCol := cursorCol.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5923
			     self cursorLine:line col:col.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5924
			     self flush.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5925
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5926
			     "/ want to wait 200ms, but not if another keyPress
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5927
			     "/ arrives in the meantime ...
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5928
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5929
			     sensor := self sensor.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5930
			     5 timesRepeat:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5931
				 (sensor hasKeyPressEventFor:self) ifFalse:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5932
				     Processor activeProcess millisecondDelay:40.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5933
				 ]
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5934
			     ].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5935
			     self cursorLine:savLine col:savCol
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5936
			 ]
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5937
		    ]
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5938
	    ifNotFound:[self showNotFound]
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5939
	    onError:[self beep]
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5940
	].
3813
8d719ca5812d dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3811
diff changeset
  5941
      ]
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5942
    ].
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5943
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5944
"/    true "autoExpandWhileTyping" ifTrue:[
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5945
"/        self wordAtLine:cursorLine col:cursorCol-1 do:[
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5946
"/            :beginLine :beginCol :endLine :endCol :style |
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5947
"/
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5948
"/            self selectFromLine:beginLine col:beginCol toLine:endLine col:endCol.
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5949
"/            self selection.
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5950
"/            typeOfSelection := #paste.
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  5951
"/        ].
3683
5891af82a177 middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents: 3650
diff changeset
  5952
"/    ].
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  5953
    editMode value isInsertAndSelectMode ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5954
	selectionStartLine isNil ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5955
	    self selectFromLine:cursorLine col:cursorCol-1 toLine:cursorLine col:cursorCol-1.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5956
	] ifFalse:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5957
	    self selectFromLine:selectionStartLine col:selectionStartCol toLine:cursorLine col:cursorCol-1.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5958
	].
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  5959
    ].
4801
69a5bff7b5cd Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4786
diff changeset
  5960
    completionSupport notNil ifTrue:[ completionSupport postKeyPress:keyArg ].
4360
fe77e479d95a comment/format in:
Claus Gittinger <cg@exept.de>
parents: 4328
diff changeset
  5961
fe77e479d95a comment/format in:
Claus Gittinger <cg@exept.de>
parents: 4328
diff changeset
  5962
    "Modified (comment): / 25-01-2012 / 00:30:11 / cg"
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5963
!
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5964
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5965
keyPress:key x:x y:y
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5966
    "handle keyboard input"
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5967
4771
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  5968
    |wasOn|
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  5969
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  5970
    wasOn := cursorShown.
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  5971
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5972
    NoModificationError
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5973
	handle:[:ex |
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5974
	    self flashReadOnly.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5975
	    (cursorShown not and:[wasOn]) ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5976
		self makeCursorVisibleAndShowCursor:wasOn.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5977
	    ].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5978
	]
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5979
	do:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5980
	    self undoableDo:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5981
		self doKeyPress:key x:x y:y
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5982
	    ].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5983
	].
5689
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  5984
4242
93363c9c43cd changed: #keyPress:x:y:
Claus Gittinger <cg@exept.de>
parents: 4238
diff changeset
  5985
    self repairDamage
93363c9c43cd changed: #keyPress:x:y:
Claus Gittinger <cg@exept.de>
parents: 4238
diff changeset
  5986
93363c9c43cd changed: #keyPress:x:y:
Claus Gittinger <cg@exept.de>
parents: 4238
diff changeset
  5987
    "Modified: / 18-04-2011 / 21:35:27 / cg"
5689
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  5988
    "Modified (format): / 30-04-2016 / 20:45:52 / cg"
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5989
!
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5990
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5991
mapped
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5992
    "view was made visible"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5993
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5994
    super mapped.
2422
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  5995
    self updateCursorVisibleLine.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5996
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5997
3268
d30df22739ca move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents: 3257
diff changeset
  5998
requestAutoAccept
5068
3ad3eb432172 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5067
diff changeset
  5999
    "request to accept: this is invoked when a dialog closes via accept or cancel.
3ad3eb432172 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5067
diff changeset
  6000
     This forces my value to be accepted into my model.
3ad3eb432172 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5067
diff changeset
  6001
     Any widget may suppress the ok/cancel, by returning false."
3268
d30df22739ca move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents: 3257
diff changeset
  6002
d30df22739ca move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents: 3257
diff changeset
  6003
    acceptEnabled == false ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6004
	"/ nope -
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6005
	^ false
3268
d30df22739ca move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents: 3257
diff changeset
  6006
    ].
5404
50b74416cbd4 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5400
diff changeset
  6007
    "/ cg: only do this if modified.
50b74416cbd4 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5400
diff changeset
  6008
    "/ otherwise, users would have to make sure that the contents is
50b74416cbd4 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5400
diff changeset
  6009
    "/ always correct (which they don't). If you change this back,
50b74416cbd4 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5400
diff changeset
  6010
    "/ please check the expecco file-save or file-reimport dialog,
50b74416cbd4 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5400
diff changeset
  6011
    "/ which has a problem with that behavior.
50b74416cbd4 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5400
diff changeset
  6012
    self modified ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6013
	self accept.
5404
50b74416cbd4 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5400
diff changeset
  6014
    ].
3268
d30df22739ca move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents: 3257
diff changeset
  6015
    ^ true.
d30df22739ca move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents: 3257
diff changeset
  6016
!
d30df22739ca move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents: 3257
diff changeset
  6017
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6018
sizeChanged:how
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6019
    "make certain, cursor is visible after the sizechange"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6020
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6021
    |cv|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6022
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6023
    cv := cursorVisibleLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6024
    super sizeChanged:how.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6025
    cv notNil ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6026
	self makeLineVisible:cursorLine
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6027
    ]
4967
5af7718d4f2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4966
diff changeset
  6028
!
5af7718d4f2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4966
diff changeset
  6029
5af7718d4f2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4966
diff changeset
  6030
unmapped
5af7718d4f2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4966
diff changeset
  6031
    super unmapped.
5af7718d4f2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4966
diff changeset
  6032
5af7718d4f2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4966
diff changeset
  6033
    completionSupport notNil ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6034
	completionSupport release.
4967
5af7718d4f2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4966
diff changeset
  6035
    ].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6036
! !
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6037
1807
30526cb1acfc category and comment
Claus Gittinger <cg@exept.de>
parents: 1804
diff changeset
  6038
!EditTextView methodsFor:'focus handling'!
30526cb1acfc category and comment
Claus Gittinger <cg@exept.de>
parents: 1804
diff changeset
  6039
4818
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  6040
focusOut
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  6041
    super focusOut.
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  6042
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  6043
    completionSupport notNil ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6044
	completionSupport release.
4818
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  6045
    ].
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  6046
!
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  6047
1807
30526cb1acfc category and comment
Claus Gittinger <cg@exept.de>
parents: 1804
diff changeset
  6048
hasKeyboardFocus:aBoolean
30526cb1acfc category and comment
Claus Gittinger <cg@exept.de>
parents: 1804
diff changeset
  6049
    "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
  6050
     (otherwise, I would not know about this)"
30526cb1acfc category and comment
Claus Gittinger <cg@exept.de>
parents: 1804
diff changeset
  6051
30526cb1acfc category and comment
Claus Gittinger <cg@exept.de>
parents: 1804
diff changeset
  6052
    hasKeyboardFocus := aBoolean.
4609
8b3eb80d04d0 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4595
diff changeset
  6053
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6054
    (cursorShown
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6055
    and:[self enabled
3296
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
  6056
    and:[self isReadOnly not]]) ifTrue:[
5890
5dc30fda9ebf #OTHER by mawalch
mawalch
parents: 5887
diff changeset
  6057
        self drawCursor
4609
8b3eb80d04d0 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4595
diff changeset
  6058
    ].
8b3eb80d04d0 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4595
diff changeset
  6059
8b3eb80d04d0 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4595
diff changeset
  6060
    hasKeyboardFocus ifFalse:[
5890
5dc30fda9ebf #OTHER by mawalch
mawalch
parents: 5887
diff changeset
  6061
        completionSupport notNil ifTrue:[
5dc30fda9ebf #OTHER by mawalch
mawalch
parents: 5887
diff changeset
  6062
            "/ this is a hack for Windows:
5dc30fda9ebf #OTHER by mawalch
mawalch
parents: 5887
diff changeset
  6063
            "/ on windows, an activate:false event is first sent to my textView,
5dc30fda9ebf #OTHER by mawalch
mawalch
parents: 5887
diff changeset
  6064
            "/ then an activate is sent to the completion popup.
5dc30fda9ebf #OTHER by mawalch
mawalch
parents: 5887
diff changeset
  6065
            "/ this is done BEFORE the buttonPress event is delivered.
5dc30fda9ebf #OTHER by mawalch
mawalch
parents: 5887
diff changeset
  6066
            "/ therefore, allow for the activate of the completionMenu and its button event to be processed.
5dc30fda9ebf #OTHER by mawalch
mawalch
parents: 5887
diff changeset
  6067
            "/ before forcing it to be closed...
5dc30fda9ebf #OTHER by mawalch
mawalch
parents: 5887
diff changeset
  6068
            completionSupport startTimeoutForEditViewLostFocus.
5dc30fda9ebf #OTHER by mawalch
mawalch
parents: 5887
diff changeset
  6069
        ].
1816
0b9380a0cc7e only take keyboardFocus (and show cursor)
Claus Gittinger <cg@exept.de>
parents: 1811
diff changeset
  6070
    ].
0b9380a0cc7e only take keyboardFocus (and show cursor)
Claus Gittinger <cg@exept.de>
parents: 1811
diff changeset
  6071
4821
b108cc2ff7e9 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4820
diff changeset
  6072
    "Modified (format): / 06-11-2013 / 15:37:31 / cg"
1807
30526cb1acfc category and comment
Claus Gittinger <cg@exept.de>
parents: 1804
diff changeset
  6073
!
30526cb1acfc category and comment
Claus Gittinger <cg@exept.de>
parents: 1804
diff changeset
  6074
30526cb1acfc category and comment
Claus Gittinger <cg@exept.de>
parents: 1804
diff changeset
  6075
showFocus:explicit
30526cb1acfc category and comment
Claus Gittinger <cg@exept.de>
parents: 1804
diff changeset
  6076
    "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
  6077
     displayed, show the cursor when I got the focus"
30526cb1acfc category and comment
Claus Gittinger <cg@exept.de>
parents: 1804
diff changeset
  6078
5239
0312ca8fd55e class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5226
diff changeset
  6079
    self hasKeyboardFocus:true.
1807
30526cb1acfc category and comment
Claus Gittinger <cg@exept.de>
parents: 1804
diff changeset
  6080
    self showCursor.
30526cb1acfc category and comment
Claus Gittinger <cg@exept.de>
parents: 1804
diff changeset
  6081
    super showFocus:explicit
30526cb1acfc category and comment
Claus Gittinger <cg@exept.de>
parents: 1804
diff changeset
  6082
30526cb1acfc category and comment
Claus Gittinger <cg@exept.de>
parents: 1804
diff changeset
  6083
    "Modified: 11.12.1996 / 16:56:54 / cg"
1918
3ac07b97b4f7 use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents: 1902
diff changeset
  6084
!
3ac07b97b4f7 use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents: 1902
diff changeset
  6085
4967
5af7718d4f2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4966
diff changeset
  6086
showNoFocus:explicit
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6087
    "the view lost the keyboard focus
4967
5af7718d4f2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4966
diff changeset
  6088
     (either explicit, via tabbing; or implicit, by pointer movement)
5af7718d4f2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4966
diff changeset
  6089
      - change any display attributes as req'd."
5af7718d4f2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4966
diff changeset
  6090
5af7718d4f2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4966
diff changeset
  6091
    super showNoFocus:explicit.
5149
cc14f4e4157d class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5146
diff changeset
  6092
cc14f4e4157d class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5146
diff changeset
  6093
    "/ cg: only do this for an explicit change (i.e. by tabbing),
cc14f4e4157d class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5146
diff changeset
  6094
    "/ not when the focus is lost normally (because this also happens when
cc14f4e4157d class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5146
diff changeset
  6095
    "/ the completion-menu is clicked on), and we don't want to kill the
cc14f4e4157d class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5146
diff changeset
  6096
    "/ completer. Otherwise, completion does not work when clocking into the list.
cc14f4e4157d class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5146
diff changeset
  6097
    explicit ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6098
	completionSupport notNil ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6099
	    completionSupport release.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6100
	].
4818
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  6101
    ].
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  6102
!
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  6103
1918
3ac07b97b4f7 use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents: 1902
diff changeset
  6104
wantsFocusWithPointerEnter
3ac07b97b4f7 use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents: 1902
diff changeset
  6105
    "return true, if I want the focus when
3ac07b97b4f7 use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents: 1902
diff changeset
  6106
     the mouse pointer enters"
3ac07b97b4f7 use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents: 1902
diff changeset
  6107
3296
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
  6108
    (UserPreferences current focusFollowsMouse ~~ false
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
  6109
     and:[(styleSheet at:#'editText.requestFocusOnPointerEnter' default:true)
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
  6110
     and:[self enabled
4781
11d53632e47e class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4775
diff changeset
  6111
     and:[true "self isReadOnly not"]]]
4097
233d27a2b0a0 comment/format in: #wantsFocusWithPointerEnter
Claus Gittinger <cg@exept.de>
parents: 4089
diff changeset
  6112
    ) ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6113
	^ true
1918
3ac07b97b4f7 use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents: 1902
diff changeset
  6114
    ].
3ac07b97b4f7 use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents: 1902
diff changeset
  6115
3ac07b97b4f7 use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents: 1902
diff changeset
  6116
    ^ false
1807
30526cb1acfc category and comment
Claus Gittinger <cg@exept.de>
parents: 1804
diff changeset
  6117
! !
30526cb1acfc category and comment
Claus Gittinger <cg@exept.de>
parents: 1804
diff changeset
  6118
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6119
!EditTextView methodsFor:'formatting'!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6120
4237
Claus Gittinger <cg@exept.de>
parents: 4226
diff changeset
  6121
executekeyboardMacroNamed:macroName
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6122
    "try to execute the keyboard macro;
4371
a631db2025af changed: #executekeyboardMacroNamed:
Claus Gittinger <cg@exept.de>
parents: 4360
diff changeset
  6123
     return true if that worked, false otherwise"
a631db2025af changed: #executekeyboardMacroNamed:
Claus Gittinger <cg@exept.de>
parents: 4360
diff changeset
  6124
4482
0530a2d95b4b class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 4481
diff changeset
  6125
    |cmdMacro|
0530a2d95b4b class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 4481
diff changeset
  6126
0530a2d95b4b class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 4481
diff changeset
  6127
    cmdMacro := UserPreferences current functionKeySequences at:macroName ifAbsent:[^ false].
4371
a631db2025af changed: #executekeyboardMacroNamed:
Claus Gittinger <cg@exept.de>
parents: 4360
diff changeset
  6128
    self
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6129
	undoableDo:[ self executeKeyboardMacro:cmdMacro ]
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6130
	info: macroName.
4371
a631db2025af changed: #executekeyboardMacroNamed:
Claus Gittinger <cg@exept.de>
parents: 4360
diff changeset
  6131
    ^ true
4238
5f7125996b44 changed:
Stefan Vogel <sv@exept.de>
parents: 4237
diff changeset
  6132
5f7125996b44 changed:
Stefan Vogel <sv@exept.de>
parents: 4237
diff changeset
  6133
    "
4483
5b71475eddbc class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 4482
diff changeset
  6134
      EditTextView open
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6135
		contents:'bla';
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6136
		selectAll;
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6137
		executekeyboardMacroNamed:#IndentBy4.
4483
5b71475eddbc class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 4482
diff changeset
  6138
      EditTextView open
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6139
		contents:'bla';
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6140
		selectAll;
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6141
		executekeyboardMacroNamed:#blabla.
4238
5f7125996b44 changed:
Stefan Vogel <sv@exept.de>
parents: 4237
diff changeset
  6142
    "
4371
a631db2025af changed: #executekeyboardMacroNamed:
Claus Gittinger <cg@exept.de>
parents: 4360
diff changeset
  6143
a631db2025af changed: #executekeyboardMacroNamed:
Claus Gittinger <cg@exept.de>
parents: 4360
diff changeset
  6144
    "Modified: / 14-02-2012 / 11:17:27 / cg"
4237
Claus Gittinger <cg@exept.de>
parents: 4226
diff changeset
  6145
!
Claus Gittinger <cg@exept.de>
parents: 4226
diff changeset
  6146
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6147
indent
3221
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  6148
    "indent a line-range - this is done by searching for the
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  6149
     last non-empty line before the selection, and changing the indent
4742
a00cb40ee392 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4738
diff changeset
  6150
     of the selected line-range based on that line's indent."
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6151
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6152
    |start end|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6153
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6154
    selectionStartLine isNil ifTrue:[^ self].
3221
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  6155
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6156
    start := selectionStartLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6157
    end := selectionEndLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6158
    (selectionEndCol == 0) ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6159
	end := end - 1
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6160
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6161
    self unselect.
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6162
    self
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6163
	undoableDo:[self indentFromLine:start toLine:end]
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6164
	info:'Indent'
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6165
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6166
4237
Claus Gittinger <cg@exept.de>
parents: 4226
diff changeset
  6167
indentBy4
5050
a1157f4a40ce class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5045
diff changeset
  6168
    self indentBy:4. "/ self executekeyboardMacroNamed:#IndentBy4.
a1157f4a40ce class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5045
diff changeset
  6169
a1157f4a40ce class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5045
diff changeset
  6170
    "Modified: / 06-04-2011 / 18:52:40 / cg"
a1157f4a40ce class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5045
diff changeset
  6171
!
a1157f4a40ce class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5045
diff changeset
  6172
a1157f4a40ce class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5045
diff changeset
  6173
indentBy8
a1157f4a40ce class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5045
diff changeset
  6174
    self indentBy:8. "/ self executekeyboardMacroNamed:#IndentBy4.
4237
Claus Gittinger <cg@exept.de>
parents: 4226
diff changeset
  6175
Claus Gittinger <cg@exept.de>
parents: 4226
diff changeset
  6176
    "Modified: / 06-04-2011 / 18:52:40 / cg"
Claus Gittinger <cg@exept.de>
parents: 4226
diff changeset
  6177
!
Claus Gittinger <cg@exept.de>
parents: 4226
diff changeset
  6178
5050
a1157f4a40ce class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5045
diff changeset
  6179
indentBy:n
a1157f4a40ce class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5045
diff changeset
  6180
    |line1 line2|
a1157f4a40ce class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5045
diff changeset
  6181
a1157f4a40ce class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5045
diff changeset
  6182
    line1 := self selectionStartLine.
a1157f4a40ce class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5045
diff changeset
  6183
    line2 := self selectionEndLine.
a1157f4a40ce class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5045
diff changeset
  6184
    line1 isNil ifTrue:[
5833
584a6e4d283a #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 5826
diff changeset
  6185
        line1 := self cursorLine.
584a6e4d283a #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 5826
diff changeset
  6186
        line1 notNil ifTrue:[
584a6e4d283a #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 5826
diff changeset
  6187
            line2 := line1
584a6e4d283a #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 5826
diff changeset
  6188
        ]
5769
32db0c4a851c #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 5761
diff changeset
  6189
    ] ifFalse:[
5833
584a6e4d283a #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 5826
diff changeset
  6190
        line2 notNil ifTrue:[
584a6e4d283a #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 5826
diff changeset
  6191
            self selectionEndCol == 0 ifTrue:[ line2 := line2 - 1 ].
584a6e4d283a #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 5826
diff changeset
  6192
        ].
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6193
    ].
5050
a1157f4a40ce class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5045
diff changeset
  6194
    line1 notNil ifTrue:[
5833
584a6e4d283a #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 5826
diff changeset
  6195
        self indentFromLine:line1 toLine:line2 by:n.
5050
a1157f4a40ce class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5045
diff changeset
  6196
    ]
a1157f4a40ce class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5045
diff changeset
  6197
!
a1157f4a40ce class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5045
diff changeset
  6198
a1157f4a40ce class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5045
diff changeset
  6199
indentByTab
a1157f4a40ce class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5045
diff changeset
  6200
    self indentBy:((tabPositions == self class tab4Positions) ifTrue:4 ifFalse:8)
a1157f4a40ce class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5045
diff changeset
  6201
!
a1157f4a40ce class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5045
diff changeset
  6202
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6203
indentFromLine:start toLine:end
3221
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  6204
    "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
  6205
     last non-empty line before start, and change the indent
4742
a00cb40ee392 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4738
diff changeset
  6206
     of the selected line-range based on that line's indent."
a00cb40ee392 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4738
diff changeset
  6207
4811
e868808b229e class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4803
diff changeset
  6208
    |leftStart delta|
474
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  6209
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  6210
    leftStart := self leftIndentForLine:start.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6211
    (leftStart == 0) ifTrue:[^ self].
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
    delta := leftStart - (self leftIndentOfLine:start).
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6214
    (delta == 0) ifTrue:[^ self].
4811
e868808b229e class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4803
diff changeset
  6215
    self indentFromLine:start toLine:end by:delta
e868808b229e class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4803
diff changeset
  6216
!
e868808b229e class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4803
diff changeset
  6217
e868808b229e class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4803
diff changeset
  6218
indentFromLine:start toLine:end by:delta
e868808b229e class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4803
diff changeset
  6219
    "indent a line-range - this is done by searching for the
e868808b229e class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4803
diff changeset
  6220
     last non-empty line before start, and change the indent
e868808b229e class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4803
diff changeset
  6221
     of the selected line-range based on that line's indent."
e868808b229e class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4803
diff changeset
  6222
e868808b229e class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4803
diff changeset
  6223
    |d line spaces anyChange|
e868808b229e class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4803
diff changeset
  6224
e868808b229e class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4803
diff changeset
  6225
    (delta == 0) ifTrue:[^ self].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6226
    (delta > 0) ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6227
	spaces := String new:delta
4742
a00cb40ee392 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4738
diff changeset
  6228
    ].
a00cb40ee392 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4738
diff changeset
  6229
a00cb40ee392 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4738
diff changeset
  6230
    anyChange := false.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6231
    start to:end do:[:lineNr |
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6232
	line := self listAt:lineNr.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6233
	line notNil ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6234
	    line isBlank ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6235
		self basicListAt:lineNr put:nil
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6236
	    ] ifFalse:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6237
		(delta > 0) ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6238
		    line := spaces , line.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6239
		    widthOfWidestLine notNil ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6240
			widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:line).
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6241
		    ]
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6242
		] ifFalse:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6243
		    "check if deletion is ok"
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6244
		    d := delta negated + 1.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6245
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6246
		    line size > d ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6247
			(line copyTo:(d - 1)) withoutSeparators isEmpty ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6248
			    line := line copyFrom:d
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6249
			]
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6250
		    ].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6251
		    widthOfWidestLine := nil
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6252
		].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6253
		self replaceLine:lineNr with:line.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6254
		anyChange := true.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6255
	    ]
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6256
	]
4742
a00cb40ee392 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4738
diff changeset
  6257
    ].
a00cb40ee392 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4738
diff changeset
  6258
a00cb40ee392 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4738
diff changeset
  6259
    anyChange ifTrue:[ self textChanged ].
a00cb40ee392 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4738
diff changeset
  6260
3221
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  6261
    "/ self redrawFromLine:start to:end
474
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  6262
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  6263
    "Modified: 5.3.1996 / 14:59:18 / cg"
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  6264
!
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  6265
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  6266
leftIndentForLine:lineNr
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  6267
    "find an appropriate indent for a line.
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  6268
     this is done by searching for the last non-empty line before it
4823
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  6269
     and returning its indent.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  6270
     cg: changed: only look for the single previous line."
474
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  6271
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  6272
    "SHOULD GO TO ListView"
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  6273
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  6274
    |line lnr indent|
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  6275
474
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  6276
    lnr := lineNr.
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  6277
4823
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  6278
    "/ [lnr ~~ 1] whileTrue:[
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  6279
    (lnr ~~ 1) ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6280
	lnr  := lnr - 1.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6281
	line := self listAt:lnr.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6282
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6283
	line notNil ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6284
	    indent := line indexOfNonSeparatorStartingAt:1.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6285
	    indent ~~ 0 ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6286
		(line endsWith:$[) ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6287
		    ^ indent + 4 - 1
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6288
		].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6289
		^ indent - 1
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6290
	    ]
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6291
	]
474
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  6292
    ].
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  6293
    ^ 0
474
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  6294
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  6295
    "Created: 5.3.1996 / 14:58:53 / cg"
4237
Claus Gittinger <cg@exept.de>
parents: 4226
diff changeset
  6296
!
Claus Gittinger <cg@exept.de>
parents: 4226
diff changeset
  6297
Claus Gittinger <cg@exept.de>
parents: 4226
diff changeset
  6298
undentBy4
5050
a1157f4a40ce class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5045
diff changeset
  6299
    self undentBy:4. "/ self executekeyboardMacroNamed:#UndentBy4.
a1157f4a40ce class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5045
diff changeset
  6300
a1157f4a40ce class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5045
diff changeset
  6301
    "Modified: / 06-04-2011 / 18:52:49 / cg"
a1157f4a40ce class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5045
diff changeset
  6302
!
a1157f4a40ce class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5045
diff changeset
  6303
a1157f4a40ce class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5045
diff changeset
  6304
undentBy8
a1157f4a40ce class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5045
diff changeset
  6305
    self undentBy:8. "/ self executekeyboardMacroNamed:#UndentBy4.
4237
Claus Gittinger <cg@exept.de>
parents: 4226
diff changeset
  6306
Claus Gittinger <cg@exept.de>
parents: 4226
diff changeset
  6307
    "Modified: / 06-04-2011 / 18:52:49 / cg"
5050
a1157f4a40ce class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5045
diff changeset
  6308
!
a1157f4a40ce class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5045
diff changeset
  6309
a1157f4a40ce class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5045
diff changeset
  6310
undentBy:n
a1157f4a40ce class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5045
diff changeset
  6311
    self indentBy:(n negated)
a1157f4a40ce class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5045
diff changeset
  6312
!
a1157f4a40ce class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5045
diff changeset
  6313
a1157f4a40ce class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5045
diff changeset
  6314
undentByTab
a1157f4a40ce class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5045
diff changeset
  6315
    self undentBy:((tabPositions == self class tab4Positions) ifTrue:4 ifFalse:8).
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  6316
! !
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  6317
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  6318
!EditTextView methodsFor:'initialization'!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  6319
941
f06fa4d47f26 fetch device resources early
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  6320
fetchDeviceResources
f06fa4d47f26 fetch device resources early
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  6321
    "fetch device colors, to avoid reallocation at redraw time"
f06fa4d47f26 fetch device resources early
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  6322
f06fa4d47f26 fetch device resources early
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  6323
    super fetchDeviceResources.
f06fa4d47f26 fetch device resources early
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  6324
5643
921578f80870 device access
Claus Gittinger <cg@exept.de>
parents: 5593
diff changeset
  6325
    cursorFgColor notNil ifTrue:[cursorFgColor := cursorFgColor onDevice:device].
921578f80870 device access
Claus Gittinger <cg@exept.de>
parents: 5593
diff changeset
  6326
    cursorBgColor notNil ifTrue:[cursorBgColor := cursorBgColor onDevice:device].
921578f80870 device access
Claus Gittinger <cg@exept.de>
parents: 5593
diff changeset
  6327
    cursorNoFocusFgColor notNil ifTrue:[cursorNoFocusFgColor := cursorNoFocusFgColor onDevice:device].
941
f06fa4d47f26 fetch device resources early
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  6328
f06fa4d47f26 fetch device resources early
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  6329
    "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
  6330
    "Modified: 18.2.1997 / 15:02:46 / cg"
941
f06fa4d47f26 fetch device resources early
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  6331
!
f06fa4d47f26 fetch device resources early
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  6332
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6333
initEvents
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6334
    "enable enter/leave events in addition"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6335
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6336
    super initEvents.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6337
    self enableEnterLeaveEvents
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
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6340
initStyle
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6341
    "initialize style specific stuff"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6342
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6343
    super initStyle.
4576
c9d937d20173 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4566
diff changeset
  6344
    "/ lineSpacing := 2.       "/ for underwave - also looks better
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6345
    lockUpdates := false.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6346
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6347
    cursorFgColor := DefaultCursorForegroundColor.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6348
    cursorFgColor isNil ifTrue:[cursorFgColor := bgColor].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6349
    cursorBgColor := DefaultCursorBackgroundColor.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6350
    cursorBgColor isNil ifTrue:[cursorBgColor := fgColor].
4721
59fc420ce5b0 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4715
diff changeset
  6351
    cursorType isNil ifTrue:[cursorType := DefaultCursorType].
59fc420ce5b0 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4715
diff changeset
  6352
    cursorTypeNoFocus isNil ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6353
	cursorTypeNoFocus := cursorType.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6354
	DefaultCursorTypeNoFocus notNil ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6355
	    cursorTypeNoFocus := DefaultCursorTypeNoFocus.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6356
	]
1534
bcb211e1b41a read noFocus cursorStyle from styleSheet
Claus Gittinger <cg@exept.de>
parents: 1533
diff changeset
  6357
    ].
1022
4362861fe15e allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents: 1018
diff changeset
  6358
    cursorNoFocusFgColor := DefaultCursorNoFocusForegroundColor.
4362861fe15e allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents: 1018
diff changeset
  6359
    cursorNoFocusFgColor isNil ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6360
	cursorType ~~ #block ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6361
	    cursorNoFocusFgColor := cursorBgColor
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6362
	] ifFalse:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6363
	    cursorNoFocusFgColor := cursorFgColor
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6364
	]
1022
4362861fe15e allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents: 1018
diff changeset
  6365
    ].
4362861fe15e allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents: 1018
diff changeset
  6366
2088
b2beb67b1a98 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2085
diff changeset
  6367
    "Modified: / 15.12.1999 / 22:27:45 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6368
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6369
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6370
initialize
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6371
    "initialize a new EditTextView;
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6372
     setup some instance variables"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6373
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6374
    super initialize.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6375
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6376
    self level:-1.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6377
    readOnly := false.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6378
    fixedSize := false.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6379
    exceptionBlock := [:errorText | ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6380
    cursorShown := prevCursorState := true.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6381
    cursorLine := 1.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6382
    cursorVisibleLine := 1.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6383
    cursorCol := 1.
5251
259d72b38bd7 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5244
diff changeset
  6384
    cursorLineHolder := ValueHolder with:1.
259d72b38bd7 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5244
diff changeset
  6385
    cursorColHolder := ValueHolder with:1.
2119
2aa585fc62a3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2117
diff changeset
  6386
    modifiedChannel := ValueHolder with:false.
2aa585fc62a3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2117
diff changeset
  6387
    acceptChannel := ValueHolder with:false.
1437
ab84b08a9f9c allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
  6388
    acceptChannel addDependent:self.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6389
    showMatchingParenthesis := false.
3296
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
  6390
    hasKeyboardFocus := false.
323
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
  6391
    tabMeansNextField := false.
5106
7376f2c47d5f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5104
diff changeset
  6392
    "/ autoIndent := UserPreferences current autoIndentInCodeView.
7376f2c47d5f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5104
diff changeset
  6393
    autoIndent := false.
5251
259d72b38bd7 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5244
diff changeset
  6394
    editMode := ValueHolder with:EditMode insertMode.
259d72b38bd7 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5244
diff changeset
  6395
    learnMode := ValueHolder with:false.
2131
858209ba8509 cursor movement default
Claus Gittinger <cg@exept.de>
parents: 2129
diff changeset
  6396
    cursorMovementWhenUpdating := #beginOfText.
4048
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
  6397
    lastReplacementInfo := LastReplacementInfo new.
1596
0bbdb4e9fc43 made st80Mode also an inst-flag;
Claus Gittinger <cg@exept.de>
parents: 1591
diff changeset
  6398
3683
5891af82a177 middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents: 3650
diff changeset
  6399
    "/ enable drop by default
2589
62794ae04446 support drop
ca
parents: 2580
diff changeset
  6400
    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
  6401
5dcc2912bcb6 undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents: 2984
diff changeset
  6402
    undoSupport := UndoSupport for:self.
5251
259d72b38bd7 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5244
diff changeset
  6403
    codeAspectHolder := ValueHolder with:nil.
4803
87d60a4b098b Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4801
diff changeset
  6404
87d60a4b098b Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4801
diff changeset
  6405
    "Modified: / 27-09-2013 / 09:41:32 / Jan Vrany <jan.vrany@fit.cvut.cz>"
4696
428c8bc44cfb refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents: 4694
diff changeset
  6406
!
428c8bc44cfb refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents: 4694
diff changeset
  6407
4801
69a5bff7b5cd Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4786
diff changeset
  6408
initializeCompletionSupport
69a5bff7b5cd Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4786
diff changeset
  6409
    |supportClass|
69a5bff7b5cd Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4786
diff changeset
  6410
69a5bff7b5cd Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4786
diff changeset
  6411
    completionSupport isNil ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6412
	(supportClass := self completionSupportClass) notNil ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6413
	    completionSupport := supportClass for:self.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6414
	].
4696
428c8bc44cfb refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents: 4694
diff changeset
  6415
    ].
4801
69a5bff7b5cd Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4786
diff changeset
  6416
69a5bff7b5cd Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4786
diff changeset
  6417
    "Created: / 26-09-2013 / 17:51:45 / Jan Vrany <jan.vrany@fit.cvut.cz>"
4771
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  6418
!
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  6419
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  6420
release
4801
69a5bff7b5cd Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4786
diff changeset
  6421
    completionSupport notNil ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6422
	completionSupport release
4771
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  6423
    ].
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  6424
    super release
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  6425
! !
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  6426
2580
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  6427
!EditTextView methodsFor:'macros'!
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  6428
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  6429
executeLearnedKeyboardMacro
4673
575d2d398823 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4666
diff changeset
  6430
    "replay the characters as learned previously"
575d2d398823 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4666
diff changeset
  6431
2795
1f7b5f242eee learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents: 2792
diff changeset
  6432
    (self learnMode not and:[learnedMacro size > 0]) ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6433
	ExecutingMacroQuery
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6434
	    answer:true
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6435
	    do:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6436
		learnedMacro do:[:event |
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6437
			    WindowGroup lastEventQuerySignal answer:event
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6438
			    do:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6439
				self
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6440
				    dispatchEvent:event
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6441
				    withFocusOn:nil
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6442
				    delegate:false
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6443
			    ]
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6444
		]
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6445
	    ].
2580
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  6446
    ] ifFalse:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6447
	self flash:'no macro'.
2580
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  6448
    ].
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  6449
!
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  6450
2795
1f7b5f242eee learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents: 2792
diff changeset
  6451
learnMode
3793
5a6074a257c1 learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents: 3790
diff changeset
  6452
    "true if currently learning"
5a6074a257c1 learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents: 3790
diff changeset
  6453
2795
1f7b5f242eee learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents: 2792
diff changeset
  6454
    ^ (learnMode value ? false).
1f7b5f242eee learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents: 2792
diff changeset
  6455
!
1f7b5f242eee learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents: 2792
diff changeset
  6456
2580
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  6457
learnMode:aBoolean
3793
5a6074a257c1 learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents: 3790
diff changeset
  6458
    "toggle the learn-mode"
5a6074a257c1 learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents: 3790
diff changeset
  6459
2580
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  6460
    |fg bg|
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  6461
2795
1f7b5f242eee learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents: 2792
diff changeset
  6462
    self learnModeHolder value:aBoolean.
1f7b5f242eee learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents: 2792
diff changeset
  6463
1f7b5f242eee learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents: 2792
diff changeset
  6464
    aBoolean ifTrue:[
5795
ee8125645546 #OTHER by stefan
Stefan Vogel <sv@exept.de>
parents: 5787
diff changeset
  6465
        learnedMacro := OrderedCollection new.
ee8125645546 #OTHER by stefan
Stefan Vogel <sv@exept.de>
parents: 5787
diff changeset
  6466
        fg := self whiteColor.
ee8125645546 #OTHER by stefan
Stefan Vogel <sv@exept.de>
parents: 5787
diff changeset
  6467
        bg := self blackColor.
2580
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  6468
    ] ifFalse:[
5795
ee8125645546 #OTHER by stefan
Stefan Vogel <sv@exept.de>
parents: 5787
diff changeset
  6469
        cursorFgColor := fg := (DefaultCursorForegroundColor ? bgColor).
ee8125645546 #OTHER by stefan
Stefan Vogel <sv@exept.de>
parents: 5787
diff changeset
  6470
        cursorBgColor := bg := (DefaultCursorBackgroundColor ? fgColor).
2580
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  6471
    ].
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  6472
    self cursorForegroundColor:fg backgroundColor:bg.
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  6473
!
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  6474
2795
1f7b5f242eee learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents: 2792
diff changeset
  6475
learnModeHolder
4673
575d2d398823 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4666
diff changeset
  6476
    "a holder returning true, if in learn mode"
575d2d398823 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4666
diff changeset
  6477
2795
1f7b5f242eee learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents: 2792
diff changeset
  6478
    learnMode isNil ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6479
	learnMode := ValueHolder with:false
2795
1f7b5f242eee learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents: 2792
diff changeset
  6480
    ].
1f7b5f242eee learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents: 2792
diff changeset
  6481
    ^ learnMode
1f7b5f242eee learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents: 2792
diff changeset
  6482
!
1f7b5f242eee learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents: 2792
diff changeset
  6483
4673
575d2d398823 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4666
diff changeset
  6484
rememberLearnedMacroAs: nameString
575d2d398823 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4666
diff changeset
  6485
    Macros isNil ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6486
	Macros := Dictionary new.
4673
575d2d398823 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4666
diff changeset
  6487
    ].
575d2d398823 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4666
diff changeset
  6488
    Macros at:nameString put:learnedMacro
575d2d398823 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4666
diff changeset
  6489
!
575d2d398823 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4666
diff changeset
  6490
2580
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  6491
toggleLearnMode
3793
5a6074a257c1 learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents: 3790
diff changeset
  6492
    "toggle the learn-mode"
5a6074a257c1 learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents: 3790
diff changeset
  6493
5a6074a257c1 learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents: 3790
diff changeset
  6494
    self learnMode:(self learnMode not).
2580
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  6495
! !
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  6496
4449
59fe55c937ea changed: #openFileBrowserOnIt
Claus Gittinger <cg@exept.de>
parents: 4430
diff changeset
  6497
!EditTextView methodsFor:'menu & menu actions'!
121
claus
parents: 118
diff changeset
  6498
2680
208d99c47d7c babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents: 2677
diff changeset
  6499
babelFishTranslate:fromToModeString
5962
0636ffb5a147 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5937
diff changeset
  6500
    "translate the selected text and paste it after the selection.
0636ffb5a147 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5937
diff changeset
  6501
     This is now obsolete, as that web service no longer exists (sigh)"
2680
208d99c47d7c babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents: 2677
diff changeset
  6502
208d99c47d7c babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents: 2677
diff changeset
  6503
    |original translated|
208d99c47d7c babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents: 2677
diff changeset
  6504
208d99c47d7c babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents: 2677
diff changeset
  6505
    original := self selectionAsString.
208d99c47d7c babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents: 2677
diff changeset
  6506
    original size == 0 ifTrue:[^ self].
208d99c47d7c babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents: 2677
diff changeset
  6507
208d99c47d7c babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents: 2677
diff changeset
  6508
    self withWaitCursorDo:[
5962
0636ffb5a147 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5937
diff changeset
  6509
        (HostNameLookupError , SOAP::SoapImplError) handle:[:ex |
0636ffb5a147 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5937
diff changeset
  6510
            Dialog warn:('Translation failed - WEB Service error:\\%1.' bindWith:ex description allBold) withCRs
0636ffb5a147 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5937
diff changeset
  6511
        ] do:[
0636ffb5a147 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5937
diff changeset
  6512
            translated := SOAP::BabelFishClient new 
0636ffb5a147 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5937
diff changeset
  6513
                            translate:original mode:fromToModeString.
0636ffb5a147 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5937
diff changeset
  6514
        ]
2680
208d99c47d7c babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents: 2677
diff changeset
  6515
    ].
208d99c47d7c babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents: 2677
diff changeset
  6516
208d99c47d7c babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents: 2677
diff changeset
  6517
    "/ v pasteOrReplace:translated
208d99c47d7c babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents: 2677
diff changeset
  6518
    self cursorLine:(self selectionEndLine) col:(self selectionEndCol + 1).
208d99c47d7c babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents: 2677
diff changeset
  6519
    self unselect.
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6520
    self
5962
0636ffb5a147 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5937
diff changeset
  6521
        undoablePaste:translated
0636ffb5a147 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5937
diff changeset
  6522
        info:'Translate'
3495
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  6523
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  6524
    "Modified: / 28-07-2007 / 13:27:21 / cg"
2680
208d99c47d7c babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents: 2677
diff changeset
  6525
!
208d99c47d7c babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents: 2677
diff changeset
  6526
3517
0a2f117c2fb8 +compare menu item
Claus Gittinger <cg@exept.de>
parents: 3514
diff changeset
  6527
compareWithClipboard
0a2f117c2fb8 +compare menu item
Claus Gittinger <cg@exept.de>
parents: 3514
diff changeset
  6528
    "compare the selection against the clipboard contents"
0a2f117c2fb8 +compare menu item
Claus Gittinger <cg@exept.de>
parents: 3514
diff changeset
  6529
0a2f117c2fb8 +compare menu item
Claus Gittinger <cg@exept.de>
parents: 3514
diff changeset
  6530
    |t1 t2|
0a2f117c2fb8 +compare menu item
Claus Gittinger <cg@exept.de>
parents: 3514
diff changeset
  6531
0a2f117c2fb8 +compare menu item
Claus Gittinger <cg@exept.de>
parents: 3514
diff changeset
  6532
    t2 := self getClipboardText.
3683
5891af82a177 middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents: 3650
diff changeset
  6533
    t2 isEmptyOrNil ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6534
	Dialog information:'Clipboard is empty.'.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6535
	^ self.
3517
0a2f117c2fb8 +compare menu item
Claus Gittinger <cg@exept.de>
parents: 3514
diff changeset
  6536
    ].
0a2f117c2fb8 +compare menu item
Claus Gittinger <cg@exept.de>
parents: 3514
diff changeset
  6537
0a2f117c2fb8 +compare menu item
Claus Gittinger <cg@exept.de>
parents: 3514
diff changeset
  6538
    self hasSelection ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6539
	t1 := self selectionAsString.
3517
0a2f117c2fb8 +compare menu item
Claus Gittinger <cg@exept.de>
parents: 3514
diff changeset
  6540
    ] ifFalse:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6541
	t1 := self contents asString
3517
0a2f117c2fb8 +compare menu item
Claus Gittinger <cg@exept.de>
parents: 3514
diff changeset
  6542
    ].
0a2f117c2fb8 +compare menu item
Claus Gittinger <cg@exept.de>
parents: 3514
diff changeset
  6543
    t1 := t1 string.
0a2f117c2fb8 +compare menu item
Claus Gittinger <cg@exept.de>
parents: 3514
diff changeset
  6544
0a2f117c2fb8 +compare menu item
Claus Gittinger <cg@exept.de>
parents: 3514
diff changeset
  6545
    t1 = t2 ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6546
	Dialog information:'Strings are equal.'.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6547
	^ self.
3517
0a2f117c2fb8 +compare menu item
Claus Gittinger <cg@exept.de>
parents: 3514
diff changeset
  6548
    ].
0a2f117c2fb8 +compare menu item
Claus Gittinger <cg@exept.de>
parents: 3514
diff changeset
  6549
    DiffTextView
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6550
	openOn:t1 label:'Editor'
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6551
	and:t2 label:'Clipboard'
3517
0a2f117c2fb8 +compare menu item
Claus Gittinger <cg@exept.de>
parents: 3514
diff changeset
  6552
!
0a2f117c2fb8 +compare menu item
Claus Gittinger <cg@exept.de>
parents: 3514
diff changeset
  6553
5826
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6554
compareWithFile
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6555
    "compare the selection or the whole text against the contents of a file"
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6556
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6557
    |fn t1 t2|
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6558
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6559
    fn := Dialog requestFileName:'Compare against file:' default:defaultFileNameForFileDialog.
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6560
    fn isEmptyOrNil ifTrue:[^ self].
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6561
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6562
    t2 := fn asFilename contentsOfEntireFile.
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6563
    t2 isEmptyOrNil ifTrue:[
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6564
        Dialog information:'File is empty.'.
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6565
        ^ self.
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6566
    ].
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6567
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6568
    self hasSelection ifTrue:[
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6569
        t1 := self selectionAsString.
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6570
    ] ifFalse:[
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6571
        t1 := self contents asString
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6572
    ].
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6573
    t1 := t1 string.
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6574
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6575
    t1 = t2 ifTrue:[
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6576
        Dialog information:'Same contents.'.
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6577
        ^ self.
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6578
    ].
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6579
    DiffTextView
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6580
        openOn:t1 label:'Editor'
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6581
        and:t2 label:'File'
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6582
!
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6583
5689
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  6584
copySelection
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  6585
    "copy contents into smalltalk copybuffer.
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  6586
     Redefined to move the (currently hidden cursor) to the selection's end"
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  6587
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  6588
    self hasSelection ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6589
	self setCursorLine:selectionEndLine col:selectionEndCol+1
5689
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  6590
    ].
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  6591
    super copySelection.
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  6592
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  6593
    "Created: / 30-04-2016 / 21:07:10 / cg"
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  6594
!
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  6595
121
claus
parents: 118
diff changeset
  6596
cut
claus
parents: 118
diff changeset
  6597
    "cut selection into copybuffer"
claus
parents: 118
diff changeset
  6598
3324
1297aecf6699 delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents: 3313
diff changeset
  6599
    self deleteCopyToClipboard:true
121
claus
parents: 118
diff changeset
  6600
!
claus
parents: 118
diff changeset
  6601
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6602
defaultForGotoLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6603
    "return a default value to show in the gotoLine box"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6604
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6605
    cursorLine notNil ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6606
	^ cursorLine
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6607
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6608
    ^ super defaultForGotoLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6609
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6610
3324
1297aecf6699 delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents: 3313
diff changeset
  6611
deleteCopyToClipboard:toClipboard
1297aecf6699 delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents: 3313
diff changeset
  6612
    "cut selection into copybuffer"
1297aecf6699 delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents: 3313
diff changeset
  6613
4129
34908a157d21 changed: #deleteCopyToClipboard:
fm
parents: 4126
diff changeset
  6614
    |line col history sel |
3324
1297aecf6699 delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents: 3313
diff changeset
  6615
1297aecf6699 delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents: 3313
diff changeset
  6616
    (self checkModificationsAllowed) ifFalse:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6617
	self flashReadOnly.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6618
	^ self
3324
1297aecf6699 delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents: 3313
diff changeset
  6619
    ].
1297aecf6699 delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents: 3313
diff changeset
  6620
1297aecf6699 delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents: 3313
diff changeset
  6621
    sel := self selection.
1297aecf6699 delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents: 3313
diff changeset
  6622
    sel notNil ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6623
	self setLastStringToReplace: sel.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6624
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6625
	line := selectionStartLine.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6626
	col := selectionStartCol.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6627
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6628
	toClipboard ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6629
	    "
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6630
	     remember in CopyBuffer
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6631
	    "
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6632
	    self setClipboardText:sel. "/ lastString.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6633
	].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6634
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6635
	"
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6636
	 append to DeleteHistory (if there is one)
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6637
	"
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6638
	history := Smalltalk at:#DeleteHistory.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6639
	history notNil ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6640
	    history addAll:(sel asStringCollection).
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6641
	    history size > 1000 ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6642
		history := history copyFrom:(history size - 1000)
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6643
	    ].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6644
	].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6645
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6646
	"
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6647
	 now, delete it
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6648
	"
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6649
	self
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6650
	    undoableDo:[self deleteSelection]
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6651
	    info:'Delete'.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6652
	lastReplacementInfo lastReplacement: nil
3324
1297aecf6699 delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents: 3313
diff changeset
  6653
    ] ifFalse:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6654
	"
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6655
	 a cut without selection will search&cut again
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6656
	"
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6657
	self undoableDo:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6658
	    self again
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6659
	]
3324
1297aecf6699 delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents: 3313
diff changeset
  6660
    ]
1297aecf6699 delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents: 3313
diff changeset
  6661
1297aecf6699 delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents: 3313
diff changeset
  6662
    "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
  6663
!
1297aecf6699 delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents: 3313
diff changeset
  6664
428
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  6665
editMenu
5977
a1ac33c0e445 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5972
diff changeset
  6666
    "return the view's middleButtonMenu"
428
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  6667
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6668
    <resource: #keyboard (#Again #AgainForAll #Copy #Cut #Paste #Accept
5826
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6669
                          #Find #GotoLine #SaveAs #Print
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6670
                          #PasteFromHistory #Join #Wrap #Undo #Redo
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6671
                          #ToggleAutoIndent #ToggleInsertMode
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6672
                          #LearnKeyboardMacro #ExecuteKeyboardMacro )>
1261
bdb18f73205c resource flag: #menu -> #programMenu
Claus Gittinger <cg@exept.de>
parents: 1198
diff changeset
  6673
    <resource: #programMenu>
1054
d699ecd13e60 menu resource
Claus Gittinger <cg@exept.de>
parents: 1049
diff changeset
  6674
3683
5891af82a177 middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents: 3650
diff changeset
  6675
    |items m sub translateItems sortItems miscItems toolItems subSub toolSub
3569
d3eec21d0ece also show \"what-would-be-done\" in redo item
Claus Gittinger <cg@exept.de>
parents: 3566
diff changeset
  6676
     transSub sortSub what undoIdx redoIdx sensor main mainItems|
1515
9e9b65bd6efb care for nil sensor
Claus Gittinger <cg@exept.de>
parents: 1495
diff changeset
  6677
2460
Claus Gittinger <cg@exept.de>
parents: 2438
diff changeset
  6678
    items := #(
5826
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6679
                    ('Redo'             redo           Redo        )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6680
                    ('Again (for All)'  multipleAgain  AgainForAll )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6681
                    ('-'                                        )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6682
                    ('Search...'        search         Find     )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6683
                    ('Goto Line...'     gotoLine       GotoLine )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6684
                    ('-'                                        )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6685
                    ('Tools'            tools                   )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6686
                    ('Font...'           changeFont             )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6687
                    ('Insert Unicode...' insertUnicode )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6688
            ).
4213
6045bffe7299 changed: #editMenu
Claus Gittinger <cg@exept.de>
parents: 4199
diff changeset
  6689
    CharacterSetView notNil ifTrue:[
5826
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6690
        items := items ,
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6691
                    #(
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6692
                        ('Special Characters...'    specialCharacters  OpenSpecialCharacterWindow )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6693
                    ).
4213
6045bffe7299 changed: #editMenu
Claus Gittinger <cg@exept.de>
parents: 4199
diff changeset
  6694
    ].
6045bffe7299 changed: #editMenu
Claus Gittinger <cg@exept.de>
parents: 4199
diff changeset
  6695
    items := items , #(
5826
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6696
                    ('-'                                        )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6697
                    ('Save As...'       save           SaveAs   )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6698
                    ('Print'            doPrint        Print    )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6699
                    ('='                                        )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6700
                    ('Misc'             misc           ShiftCtrl) ).
2460
Claus Gittinger <cg@exept.de>
parents: 2438
diff changeset
  6701
2866
9dd71df46f73 specialCharacters menu item
Claus Gittinger <cg@exept.de>
parents: 2857
diff changeset
  6702
    miscItems := #(
5826
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6703
                    ('AutoIndent \c'    autoIndent:                  ToggleAutoIndent )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6704
                    ('InsertMode \c'    insertMode:                  ToggleInsertMode )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6705
                    ('-'                                        )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6706
                    ('Paste Previous...'   pasteOrReplaceFromHistory PasteFromHistory )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6707
                    ('Join Lines'       joinLines                    Join )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6708
                    ('Wrap Lines...'    wrapLines                    Wrap )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6709
                    ('-'                                        )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6710
                    ('Learn Macro'      learnMode:                   LearnKeyboardMacro)
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6711
                    ('Execute Macro'    executeLearnedKeyboardMacro  ExecuteKeyboardMacro )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6712
                    ('-'                                        )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6713
                    ('Insert File...'           insertFile          )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6714
                    ('Insert URL Contents...'   insertURL           )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6715
                    ('Insert new UUID'      insertUUID          )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6716
                    ('Insert Date && Time'  insertDateAndTime   )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6717
                    ('-'                                        )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6718
                    ('Insert File as String Literal...' insertFileAsStringLiteral  )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6719
                    ('Paste as String Literal'          pasteAsStringLiteral       )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6720
                ).
4213
6045bffe7299 changed: #editMenu
Claus Gittinger <cg@exept.de>
parents: 4199
diff changeset
  6721
"/    CharacterSetView notNil ifTrue:[
6045bffe7299 changed: #editMenu
Claus Gittinger <cg@exept.de>
parents: 4199
diff changeset
  6722
"/        miscItems := miscItems ,
6045bffe7299 changed: #editMenu
Claus Gittinger <cg@exept.de>
parents: 4199
diff changeset
  6723
"/                    #(
5529
0b33c7ac879d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 5525
diff changeset
  6724
"/                        ('-'                                        )
4213
6045bffe7299 changed: #editMenu
Claus Gittinger <cg@exept.de>
parents: 4199
diff changeset
  6725
"/                        ('Special Characters...'    specialCharacters  OpenSpecialCharacterWindow )
5529
0b33c7ac879d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 5525
diff changeset
  6726
"/                        ('Font...'                  changeFont              )
4213
6045bffe7299 changed: #editMenu
Claus Gittinger <cg@exept.de>
parents: 4199
diff changeset
  6727
"/                    ).
5529
0b33c7ac879d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 5525
diff changeset
  6728
"/    ] ifFalse:[
0b33c7ac879d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 5525
diff changeset
  6729
"/        miscItems := miscItems ,
0b33c7ac879d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 5525
diff changeset
  6730
"/                #(
0b33c7ac879d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 5525
diff changeset
  6731
"/                    ('Font...'                  changeFont              )
0b33c7ac879d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 5525
diff changeset
  6732
"/"/                    ('Encoding...'      changeEncoding          )
0b33c7ac879d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 5525
diff changeset
  6733
"/                ).
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6734
"/    ].
2866
9dd71df46f73 specialCharacters menu item
Claus Gittinger <cg@exept.de>
parents: 2857
diff changeset
  6735
2680
208d99c47d7c babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents: 2677
diff changeset
  6736
    translateItems := #(
5826
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6737
                    ('English -> German'      (babelFishTranslate: 'en_de')   )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6738
                    ('English -> French'      (babelFishTranslate: 'en_fr')   )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6739
                    ('English -> Italian'     (babelFishTranslate: 'en_it')   )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6740
                    ('English -> Spanish'     (babelFishTranslate: 'en_es')   )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6741
                    ('English -> Portuguese'  (babelFishTranslate: 'en_pt')   )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6742
                    ('-'                                        )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6743
                    ('German -> English'      (babelFishTranslate: 'de_en')   )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6744
                    ('French -> English'      (babelFishTranslate: 'fr_en')   )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6745
                    ('Italian -> English'     (babelFishTranslate: 'it_en')   )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6746
                    ('Spanish -> English'     (babelFishTranslate: 'es_en')   )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6747
                    ('Portuguese -> English'  (babelFishTranslate: 'pt_en')   )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6748
              ).
3221
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  6749
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  6750
    sortItems := #(
5826
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6751
                    ('Lines'                            (sortSelection:ignoreCase: #lines false)        )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6752
                    ('Lines by First Word'              (sortSelection:ignoreCase: #linesByFirstWord false)     )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6753
                    ('Lines by n''th Word'              (sortSelection:ignoreCase: #linesByNthWord false)       )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6754
                    ('Lines by n''th Number'            (sortSelection:ignoreCase: #linesByNthNumber false)     )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6755
                    ('Lines by n''th Hex Number'        (sortSelection:ignoreCase: #linesByNthHexNumber false)     )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6756
                    ('Words'                            (sortSelection:ignoreCase: #words false)        )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6757
                    ('-'                                                      )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6758
                    ('Lines (ignore case)'               (sortSelection:ignoreCase: #lines true)         )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6759
                    ('Lines by First Word (ignore case)' (sortSelection:ignoreCase: #linesByFirstWord true)      )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6760
                    ('Lines by n''th Word (ignore case)' (sortSelection:ignoreCase: #linesByNthWord true)        )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6761
                    ('Words (ignore case)'               (sortSelection:ignoreCase: #words true)         )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6762
                    ('-'                                                      )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6763
                    ('By Line Length'                    (sortSelection:ignoreCase: #linesByLength nil)         )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6764
                    ('Reverse'                           (sortSelection:ignoreCase: #reverse       nil)         )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6765
              ).
2680
208d99c47d7c babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents: 2677
diff changeset
  6766
2762
e29673db4ddb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2757
diff changeset
  6767
    toolItems := #(
5826
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6768
                    ('Indent'                      indent                     )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6769
                    ('Toggle Case'      convertSelectionToLowercaseOrUppercaseOrUppercaseFirst   ConvertSelectionToLowercaseOrUppercaseOrUppercaseFirst)
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6770
                    ('Sort'                        sort                       )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6771
                    ('Split...'                    splitLinesAtCharacterOrString )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6772
                    ('-'                                                      )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6773
                    ('Google Spell Check'          googleSpellingSuggestion   )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6774
                    ('Builtin Spell Check'         internalSpellingSuggestion   )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6775
                    ('Translate'                   babelFishTranslate         )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6776
                    ('Compare with Clipboard...'   compareWithClipboard       )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6777
                    ('Compare with File...'        compareWithFile            )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6778
              ).
2762
e29673db4ddb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2757
diff changeset
  6779
3623
f99c70d99425 close door to fileBrowser and workspace
Claus Gittinger <cg@exept.de>
parents: 3595
diff changeset
  6780
    Smalltalk isStandAloneApp ifFalse:[
5826
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6781
        toolItems := toolItems , #(
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6782
                        ('-'                                                      )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6783
                        ('Open FileBrowser on It'      openFileBrowserOnIt        )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6784
                        ('Open Workspace with It'      openWorkspaceWithIt        )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6785
                        ('Inspect Selected String'     inspectSelectedString      )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6786
                  ).
3623
f99c70d99425 close door to fileBrowser and workspace
Claus Gittinger <cg@exept.de>
parents: 3595
diff changeset
  6787
    ].
f99c70d99425 close door to fileBrowser and workspace
Claus Gittinger <cg@exept.de>
parents: 3595
diff changeset
  6788
2460
Claus Gittinger <cg@exept.de>
parents: 2438
diff changeset
  6789
    sub := PopUpMenu itemList:items resources:resources performer:model.
2461
54d220735048 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2460
diff changeset
  6790
    sub receiver:self.
2460
Claus Gittinger <cg@exept.de>
parents: 2438
diff changeset
  6791
2919
Claus Gittinger <cg@exept.de>
parents: 2916
diff changeset
  6792
    toolSub := PopUpMenu itemList:toolItems resources:resources performer:model.
Claus Gittinger <cg@exept.de>
parents: 2916
diff changeset
  6793
    toolSub receiver:self.
Claus Gittinger <cg@exept.de>
parents: 2916
diff changeset
  6794
    sub subMenuAt:#tools put:toolSub.
Claus Gittinger <cg@exept.de>
parents: 2916
diff changeset
  6795
3495
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  6796
    transSub := PopUpMenu itemList:translateItems resources:resources performer:model.
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  6797
    transSub receiver:self.
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  6798
    toolSub subMenuAt:#babelFishTranslate put:transSub.
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  6799
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  6800
    sortSub := PopUpMenu itemList:sortItems resources:resources performer:model.
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  6801
    sortSub receiver:self.
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  6802
    toolSub subMenuAt:#sort put:sortSub.
3221
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  6803
2866
9dd71df46f73 specialCharacters menu item
Claus Gittinger <cg@exept.de>
parents: 2857
diff changeset
  6804
    subSub := PopUpMenu itemList:miscItems resources:resources performer:model.
9dd71df46f73 specialCharacters menu item
Claus Gittinger <cg@exept.de>
parents: 2857
diff changeset
  6805
    subSub receiver:self.
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  6806
    subSub checkToggleAt:#autoIndent: put:autoIndent.
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  6807
    subSub checkToggleAt:#insertMode: put:(self isInInsertMode).
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  6808
    subSub checkToggleAt:#learnMode: put:(self learnModeHolder value).
3907
e4be6bf71a98 Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents: 3890
diff changeset
  6809
2866
9dd71df46f73 specialCharacters menu item
Claus Gittinger <cg@exept.de>
parents: 2857
diff changeset
  6810
    sub subMenuAt:#misc put:subSub.
9dd71df46f73 specialCharacters menu item
Claus Gittinger <cg@exept.de>
parents: 2857
diff changeset
  6811
3495
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  6812
    mainItems := #(
5826
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6813
                    ('Undo'    undo             Undo   )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6814
                    ('Again'   again            Again  )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6815
                    ('-'                               )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6816
                    ('Cut'     cut              Cut    )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6817
                    ('Copy'    copySelection    Copy   )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6818
                    ('Paste'   pasteOrReplace   Paste  )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6819
                    ('-'                               )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6820
                    ('Accept'  accept           Accept )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6821
                    ('='                               )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6822
                    ('More'    others           Ctrl   )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6823
              ).
3495
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  6824
    main := PopUpMenu itemList:mainItems resources:resources.
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  6825
    main subMenuAt:#others put:sub.
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  6826
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  6827
    sensor := self sensor.
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  6828
    (sensor notNil and:[sensor ctrlDown]) ifTrue:[
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  6829
       sensor shiftDown ifTrue:[
5826
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6830
            m := subSub
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6831
        ] ifFalse:[
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6832
            m := sub
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6833
        ]
428
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  6834
    ] ifFalse:[
5826
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6835
        m := main
428
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  6836
    ].
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  6837
4742
a00cb40ee392 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4738
diff changeset
  6838
    "/ the 'Smalltalk at:' code is here to
a00cb40ee392 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4738
diff changeset
  6839
    "/ avoid making the SOAP package a prerequisite for this package (libwidg)
4373
22fb03e6d08a class definition
Claus Gittinger <cg@exept.de>
parents: 4371
diff changeset
  6840
    (Smalltalk at:#'SOAP::GoogleClient') isNil ifTrue:[
5826
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6841
        "/ GoogleClient new spellingSuggestionOf: 'Smmalltlaak and Soaap'.
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6842
        m disable:#googleSpellingSuggestion
2676
cc61fa88a3fb google spelling;
Claus Gittinger <cg@exept.de>
parents: 2660
diff changeset
  6843
    ].
4742
a00cb40ee392 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4738
diff changeset
  6844
    (Smalltalk at:#'RBSpellChecker') isNil ifTrue:[
5826
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6845
        m disable:#internalSpellingSuggestion
4742
a00cb40ee392 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4738
diff changeset
  6846
    ].
2676
cc61fa88a3fb google spelling;
Claus Gittinger <cg@exept.de>
parents: 2660
diff changeset
  6847
3811
a56e6f74ee4d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3801
diff changeset
  6848
    HTTPInterface isNil ifTrue:[
5826
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6849
        m disableAll:#(insertURL)
3811
a56e6f74ee4d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3801
diff changeset
  6850
    ].
a56e6f74ee4d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3801
diff changeset
  6851
1733
c5139b7402f0 use self isReadonly; readOnly may now be a valueHolder.
Claus Gittinger <cg@exept.de>
parents: 1732
diff changeset
  6852
    self isReadOnly ifTrue:[
5826
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6853
        m disableAll:#(accept undo again multipleAgain redo
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6854
                       paste pasteOrReplace pasteOrReplaceFromHistory
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6855
                       cut indent autoIndent: insertMode:
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6856
                       insertFile insertFileAsStringLiteral insertURL
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6857
                       babelFishTranslate googleSpellingSuggestion sort
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6858
                       convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6859
                       joinLines wrapLines insertUUID insertDateAndTime pasteAsStringLiteral
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6860
                       insertUnicode specialCharacters)
428
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  6861
    ].
2817
7c82a9535b96 not ifTrue -> ifFalse
Claus Gittinger <cg@exept.de>
parents: 2815
diff changeset
  6862
    self hasSelectionForCopy ifFalse:[
5826
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6863
        m disable:#copySelection.
428
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  6864
    ].
2416
56acdd9e31b5 lifted mkeyboardMacro handling from Workspace to EditTextView
Claus Gittinger <cg@exept.de>
parents: 2406
diff changeset
  6865
    self hasSelection ifFalse:[
5826
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6866
        m disableAll:#(cut googleSpellingSuggestion babelFishTranslate openFileBrowserOnIt
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6867
                       openWorkspaceWithIt sort indent splitLinesAtCharacterOrString inspectSelectedString).
2762
e29673db4ddb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2757
diff changeset
  6868
    ] ifTrue:[
5826
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6869
        (Error handle:[:ex |
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6870
            ex return:false
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6871
        ] do:[
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6872
            |fn|
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6873
            fn := self selectionAsString.
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6874
            fn asFilename exists or:[ fn withoutSeparators withoutQuotes asFilename exists ]
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6875
        ]) ifFalse:[
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6876
            m disableAll:#(openFileBrowserOnIt).
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6877
        ]
428
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  6878
    ].
2569
b499c81c58ae added hasUndoAction query.
Claus Gittinger <cg@exept.de>
parents: 2560
diff changeset
  6879
    self hasUndoAction ifFalse:[
5826
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6880
        m disable:#undo.
3115
b75128334006 info string in undo
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
  6881
    ] ifTrue:[
5826
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6882
        what := undoSupport undoActionInfo.
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6883
        what notNil ifTrue:[
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6884
            undoIdx := m indexOf:#undo.
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6885
            m labelAt:undoIdx put:(resources string:'Undo (%1)' with:what).
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6886
        ]
1818
aa16d9b96e40 fixed cut to not compress multiple blanks.
Claus Gittinger <cg@exept.de>
parents: 1817
diff changeset
  6887
    ].
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  6888
    self hasRedoAction ifFalse:[
5826
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6889
        sub disable:#redo.
3569
d3eec21d0ece also show \"what-would-be-done\" in redo item
Claus Gittinger <cg@exept.de>
parents: 3566
diff changeset
  6890
    ] ifTrue:[
5826
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6891
        what := undoSupport redoActionInfo.
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6892
        what notNil ifTrue:[
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6893
            redoIdx := sub indexOf:#redo.
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6894
            sub labelAt:redoIdx put:(resources string:'Redo (%1)' with:what).
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6895
        ]
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  6896
    ].
5216
8d6eef5d09c3 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5194
diff changeset
  6897
    self canAccept ifFalse:[
5826
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6898
        m disable:#accept
1108
3d14bb6bceb7 added disableAccept
Claus Gittinger <cg@exept.de>
parents: 1082
diff changeset
  6899
    ].
428
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  6900
    ^ m.
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  6901
4388
558b4dbf5648 changed:
Claus Gittinger <cg@exept.de>
parents: 4373
diff changeset
  6902
    "Modified: / 01-03-2012 / 19:56:58 / cg"
428
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  6903
!
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  6904
2544
48ab4ed67816 shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  6905
getTextSelectionFromHistory
48ab4ed67816 shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  6906
    |sel list box history|
48ab4ed67816 shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  6907
5643
921578f80870 device access
Claus Gittinger <cg@exept.de>
parents: 5593
diff changeset
  6908
    history := device getCopyBufferHistory copy.
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6909
    list := history collect:[:entry |
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6910
		|text shown|
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6911
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6912
		text := entry asString string asCollectionOfLines.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6913
		shown := text detect:[:line| line notEmptyOrNil] ifNone:['      '].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6914
		text size > 1 ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6915
		    shown := shown,(resources string:' ... [%1 lines]' with:text size).
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6916
		].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6917
		shown
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6918
	    ].
4165
869b207a6964 changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents: 4162
diff changeset
  6919
2544
48ab4ed67816 shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  6920
    box := ListSelectionBox
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6921
		title:(resources string:'Clipboard History')
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6922
		okText:(resources string:'Paste')
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6923
		abortText:(resources string:'Cancel')
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6924
		list:list
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6925
		action:[:idx | idx notNil ifTrue:[sel := history at:idx]].
4165
869b207a6964 changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents: 4162
diff changeset
  6926
    box label:(resources string:'Select Previous Copybuffer String').
2544
48ab4ed67816 shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  6927
    box useIndex:true.
48ab4ed67816 shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  6928
    box show.
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6929
    ^ sel.
4165
869b207a6964 changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents: 4162
diff changeset
  6930
869b207a6964 changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents: 4162
diff changeset
  6931
    "Modified: / 25-08-2010 / 22:02:14 / cg"
2544
48ab4ed67816 shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  6932
!
48ab4ed67816 shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  6933
48ab4ed67816 shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  6934
getTextSelectionOrTextSelectionFromHistory
2730
61a2f1981ac6 Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents: 2725
diff changeset
  6935
61a2f1981ac6 Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents: 2725
diff changeset
  6936
    self sensor shiftDown ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6937
	^ self getTextSelectionFromHistory
2544
48ab4ed67816 shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  6938
    ].
2724
23f4e16dc4f4 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2720
diff changeset
  6939
4285
8487c7a8fab0 changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents: 4275
diff changeset
  6940
    "/ return either the (xterm-) selection or the clipBoard depending on
8487c7a8fab0 changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents: 4275
diff changeset
  6941
    "/ the Ctrl-Key state.
8487c7a8fab0 changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents: 4275
diff changeset
  6942
8487c7a8fab0 changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents: 4275
diff changeset
  6943
    "/ ouch - this used to be ok for ALT-c / ALT-v,
8487c7a8fab0 changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents: 4275
diff changeset
  6944
    "/ but no longer works with CTRL-c / CTRL-v.
8487c7a8fab0 changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents: 4275
diff changeset
  6945
    ^ self getClipboardText:#clipboard
8487c7a8fab0 changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents: 4275
diff changeset
  6946
8487c7a8fab0 changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents: 4275
diff changeset
  6947
"/    ^ self
8487c7a8fab0 changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents: 4275
diff changeset
  6948
"/        getClipboardText:(self sensor ctrlDown
8487c7a8fab0 changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents: 4275
diff changeset
  6949
"/                            ifTrue:[#selection]
8487c7a8fab0 changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents: 4275
diff changeset
  6950
"/                            ifFalse:[#clipboard])
8487c7a8fab0 changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents: 4275
diff changeset
  6951
8487c7a8fab0 changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents: 4275
diff changeset
  6952
    "Modified: / 13-07-2011 / 14:55:58 / cg"
2544
48ab4ed67816 shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  6953
!
48ab4ed67816 shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  6954
2676
cc61fa88a3fb google spelling;
Claus Gittinger <cg@exept.de>
parents: 2660
diff changeset
  6955
googleSpellingSuggestion
cc61fa88a3fb google spelling;
Claus Gittinger <cg@exept.de>
parents: 2660
diff changeset
  6956
    "insert the google-spelling suggestion for the selected text.
cc61fa88a3fb google spelling;
Claus Gittinger <cg@exept.de>
parents: 2660
diff changeset
  6957
     Requires that the SOAP stuff is loaded and working."
cc61fa88a3fb google spelling;
Claus Gittinger <cg@exept.de>
parents: 2660
diff changeset
  6958
2677
afb234f8b822 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2676
diff changeset
  6959
    |text suggestion|
2676
cc61fa88a3fb google spelling;
Claus Gittinger <cg@exept.de>
parents: 2660
diff changeset
  6960
cc61fa88a3fb google spelling;
Claus Gittinger <cg@exept.de>
parents: 2660
diff changeset
  6961
    self withWaitCursorDo:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6962
	text := self selection asString string withoutSeparators.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6963
	text size == 0 ifTrue:[^ self].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6964
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6965
	"/ the 'Smalltalk at:' code is here to
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6966
	"/ avoid making the SOAP package a prerequisite for this package (libwidg)
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6967
	(Smalltalk at:#'SOAP::SoapImplError') handle:[:ex |
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6968
	    Dialog warn:('Spelling correction failed - WEB Service error:\\%1.' bindWith:ex description allBold) withCRs.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6969
	    ^ self.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6970
	] do:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6971
	    suggestion := (Smalltalk at:#'SOAP::GoogleClient') new spellingSuggestionOf:text.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6972
	].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6973
	suggestion size == 0 ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6974
	    self information:('No spelling suggestion from Google for: ' , text).
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6975
	    Transcript showCR:('No spelling suggestion from Google for: ' , text).
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6976
	    ^ self.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6977
	].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6978
    ].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6979
    self
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6980
	undoablePaste:suggestion
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6981
	info:'Spelling Suggestion'.
3495
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  6982
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  6983
    "Modified: / 28-07-2007 / 13:25:10 / cg"
2676
cc61fa88a3fb google spelling;
Claus Gittinger <cg@exept.de>
parents: 2660
diff changeset
  6984
!
cc61fa88a3fb google spelling;
Claus Gittinger <cg@exept.de>
parents: 2660
diff changeset
  6985
3595
9277e3a4d2e9 paste date and time added
Claus Gittinger <cg@exept.de>
parents: 3583
diff changeset
  6986
insertDateAndTime
9277e3a4d2e9 paste date and time added
Claus Gittinger <cg@exept.de>
parents: 3583
diff changeset
  6987
    "insert the curent date and time string"
9277e3a4d2e9 paste date and time added
Claus Gittinger <cg@exept.de>
parents: 3583
diff changeset
  6988
9277e3a4d2e9 paste date and time added
Claus Gittinger <cg@exept.de>
parents: 3583
diff changeset
  6989
    typeOfSelection := nil.
3683
5891af82a177 middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents: 3650
diff changeset
  6990
    self
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6991
	undoableDo:[ self pasteOrReplace:(Timestamp now printStringRFC1123Format)]
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6992
	info:'Paste Date and Time'
3595
9277e3a4d2e9 paste date and time added
Claus Gittinger <cg@exept.de>
parents: 3583
diff changeset
  6993
!
9277e3a4d2e9 paste date and time added
Claus Gittinger <cg@exept.de>
parents: 3583
diff changeset
  6994
2676
cc61fa88a3fb google spelling;
Claus Gittinger <cg@exept.de>
parents: 2660
diff changeset
  6995
insertFile
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6996
    "insert contents of a file
2676
cc61fa88a3fb google spelling;
Claus Gittinger <cg@exept.de>
parents: 2660
diff changeset
  6997
     - ask user for filename using a fileSelectionBox."
cc61fa88a3fb google spelling;
Claus Gittinger <cg@exept.de>
parents: 2660
diff changeset
  6998
3731
041b0c7ad557 +insert as literal
Claus Gittinger <cg@exept.de>
parents: 3725
diff changeset
  6999
    self insertFileAsStringLiteral:false
041b0c7ad557 +insert as literal
Claus Gittinger <cg@exept.de>
parents: 3725
diff changeset
  7000
!
041b0c7ad557 +insert as literal
Claus Gittinger <cg@exept.de>
parents: 3725
diff changeset
  7001
041b0c7ad557 +insert as literal
Claus Gittinger <cg@exept.de>
parents: 3725
diff changeset
  7002
insertFileAsStringLiteral
041b0c7ad557 +insert as literal
Claus Gittinger <cg@exept.de>
parents: 3725
diff changeset
  7003
    "insert a file's contents as a string literal.
041b0c7ad557 +insert as literal
Claus Gittinger <cg@exept.de>
parents: 3725
diff changeset
  7004
     Almost the same as the insert file, but single-quotes are doubled,
041b0c7ad557 +insert as literal
Claus Gittinger <cg@exept.de>
parents: 3725
diff changeset
  7005
     to make it a legal string literal"
041b0c7ad557 +insert as literal
Claus Gittinger <cg@exept.de>
parents: 3725
diff changeset
  7006
041b0c7ad557 +insert as literal
Claus Gittinger <cg@exept.de>
parents: 3725
diff changeset
  7007
    self insertFileAsStringLiteral:true
041b0c7ad557 +insert as literal
Claus Gittinger <cg@exept.de>
parents: 3725
diff changeset
  7008
!
041b0c7ad557 +insert as literal
Claus Gittinger <cg@exept.de>
parents: 3725
diff changeset
  7009
041b0c7ad557 +insert as literal
Claus Gittinger <cg@exept.de>
parents: 3725
diff changeset
  7010
insertFileAsStringLiteral:asStringLiteral
041b0c7ad557 +insert as literal
Claus Gittinger <cg@exept.de>
parents: 3725
diff changeset
  7011
    "insert contents of a file; either as-is or as a string literal.
041b0c7ad557 +insert as literal
Claus Gittinger <cg@exept.de>
parents: 3725
diff changeset
  7012
     - ask user for filename using a fileSelectionBox."
041b0c7ad557 +insert as literal
Claus Gittinger <cg@exept.de>
parents: 3725
diff changeset
  7013
3409
d650e3ae9085 insert-file menu item cares for current selection being a filename
Claus Gittinger <cg@exept.de>
parents: 3406
diff changeset
  7014
    |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
  7015
d650e3ae9085 insert-file menu item cares for current selection being a filename
Claus Gittinger <cg@exept.de>
parents: 3406
diff changeset
  7016
    ((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
  7017
    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
  7018
    and:[ selFn isRegularFile ]])
d650e3ae9085 insert-file menu item cares for current selection being a filename
Claus Gittinger <cg@exept.de>
parents: 3406
diff changeset
  7019
    ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7020
	initial := selFn pathName.
3409
d650e3ae9085 insert-file menu item cares for current selection being a filename
Claus Gittinger <cg@exept.de>
parents: 3406
diff changeset
  7021
    ].
2757
b98097eaf8dc Stc cannot handle thisContext restart in true-Block.
Stefan Vogel <sv@exept.de>
parents: 2756
diff changeset
  7022
b98097eaf8dc Stc cannot handle thisContext restart in true-Block.
Stefan Vogel <sv@exept.de>
parents: 2756
diff changeset
  7023
    [
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7024
	|why|
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7025
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7026
	file := Dialog
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7027
	    requestFileName:(resources string:'Insert Contents Of:')
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7028
	    default:initial
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7029
	    ok:(resources string:'Insert')
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7030
	    abort:(resources string:'Cancel')
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7031
	    pattern:nil
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7032
	    fromDirectory:directoryForFileDialog.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7033
	file isNil ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7034
	    "cancel"
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7035
	    ^ self.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7036
	].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7037
	file := file asFilename.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7038
	directoryForFileDialog := file.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7039
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7040
	ok := file isReadable and:[file isDirectory not].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7041
	ok ifFalse:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7042
	    file isReadable ifFalse:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7043
		why := '%1 is unreadable.\\Please try again.'
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7044
	    ] ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7045
		why := '%1 is a directory.\\Please try again.'
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7046
	    ].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7047
	    Dialog warn:(resources stringWithCRs:why with:file pathName).
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7048
	].
2909
a43e1343718f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2901
diff changeset
  7049
    ] doUntil:[ok].
2757
b98097eaf8dc Stc cannot handle thisContext restart in true-Block.
Stefan Vogel <sv@exept.de>
parents: 2756
diff changeset
  7050
5063
103ce513648a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5060
diff changeset
  7051
    text := file contentsAsString.
3683
5891af82a177 middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents: 3650
diff changeset
  7052
    self
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7053
	undoableDo:[ self paste:(asStringLiteral ifTrue:[text storeString] ifFalse:[text]) ]
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7054
	info:'Paste File'
3495
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  7055
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  7056
    "Modified: / 28-07-2007 / 13:23:32 / cg"
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  7057
!
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  7058
3811
a56e6f74ee4d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3801
diff changeset
  7059
insertURL
a56e6f74ee4d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3801
diff changeset
  7060
    "insert contents of a URL
a56e6f74ee4d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3801
diff changeset
  7061
     - ask user for URL using a dialog."
a56e6f74ee4d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3801
diff changeset
  7062
a56e6f74ee4d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3801
diff changeset
  7063
    self insertURLAsStringLiteral:false
a56e6f74ee4d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3801
diff changeset
  7064
!
a56e6f74ee4d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3801
diff changeset
  7065
a56e6f74ee4d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3801
diff changeset
  7066
insertURLAsStringLiteral:asStringLiteral
a56e6f74ee4d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3801
diff changeset
  7067
    "insert contents of a file; either as-is or as a string literal.
a56e6f74ee4d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3801
diff changeset
  7068
     - ask user for filename using a fileSelectionBox."
a56e6f74ee4d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3801
diff changeset
  7069
a56e6f74ee4d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3801
diff changeset
  7070
    |sel url text response initial|
a56e6f74ee4d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3801
diff changeset
  7071
a56e6f74ee4d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3801
diff changeset
  7072
    (sel := self selectionAsString) notEmptyOrNil
a56e6f74ee4d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3801
diff changeset
  7073
    ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7074
	initial := sel.
3811
a56e6f74ee4d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3801
diff changeset
  7075
    ].
a56e6f74ee4d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3801
diff changeset
  7076
a56e6f74ee4d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3801
diff changeset
  7077
    url := Dialog
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7078
	request:(resources string:'Insert Contents of URL:')
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7079
	initialAnswer:initial
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7080
	okLabel:(resources string:'Insert')
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7081
	title:(resources string:'URL').
3811
a56e6f74ee4d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3801
diff changeset
  7082
    url isNil ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7083
	"cancel"
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7084
	^ self.
3811
a56e6f74ee4d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3801
diff changeset
  7085
    ].
a56e6f74ee4d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3801
diff changeset
  7086
    response := HTTPInterface get:url.
a56e6f74ee4d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3801
diff changeset
  7087
    response isErrorResponse ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7088
	Dialog warn:(resources string:'Could not fetch the document: %1' with:url).
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7089
	^ self.
3811
a56e6f74ee4d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3801
diff changeset
  7090
    ].
a56e6f74ee4d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3801
diff changeset
  7091
    text := response data asString.
a56e6f74ee4d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3801
diff changeset
  7092
a56e6f74ee4d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3801
diff changeset
  7093
    self
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7094
	undoableDo:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7095
	    self paste:(asStringLiteral ifTrue:[text storeString] ifFalse:[text])
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7096
	]
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7097
	info:'Insert Contents of URL'
3811
a56e6f74ee4d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3801
diff changeset
  7098
!
a56e6f74ee4d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3801
diff changeset
  7099
3495
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  7100
insertUUID
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  7101
    "insert a new UUID's string"
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  7102
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  7103
    typeOfSelection := nil.
3683
5891af82a177 middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents: 3650
diff changeset
  7104
    self
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7105
	undoableDo:[ self pasteOrReplace:(UUID genUUID printString)]
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7106
	info:'Paste New UUID'
3495
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  7107
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  7108
    "Created: / 28-07-2007 / 13:01:16 / cg"
2676
cc61fa88a3fb google spelling;
Claus Gittinger <cg@exept.de>
parents: 2660
diff changeset
  7109
!
cc61fa88a3fb google spelling;
Claus Gittinger <cg@exept.de>
parents: 2660
diff changeset
  7110
4940
73e7031a4a85 class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 4889
diff changeset
  7111
insertUnicode
73e7031a4a85 class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 4889
diff changeset
  7112
    "open a Dialog requesting an integer value and insert it as unicode character"
73e7031a4a85 class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 4889
diff changeset
  7113
73e7031a4a85 class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 4889
diff changeset
  7114
    |unicodePoint unicodeChar unicodeString|
73e7031a4a85 class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 4889
diff changeset
  7115
5904
76febd97d52d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5890
diff changeset
  7116
    unicodeString := Dialog request:(resources string:'Enter Unicode (U+01FF or Decimal Number):').
4940
73e7031a4a85 class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 4889
diff changeset
  7117
    unicodeString size < 2 ifTrue:[
5904
76febd97d52d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5890
diff changeset
  7118
        ^ self.
4940
73e7031a4a85 class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 4889
diff changeset
  7119
    ].
73e7031a4a85 class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 4889
diff changeset
  7120
    (unicodeString second = $+ and:['Uu' includes:unicodeString first]) ifTrue:[
5904
76febd97d52d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5890
diff changeset
  7121
        unicodePoint := Integer readFrom:(unicodeString copyFrom:3) radix:16 onError:[^ self].
4940
73e7031a4a85 class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 4889
diff changeset
  7122
    ] ifFalse:[
5904
76febd97d52d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5890
diff changeset
  7123
        unicodePoint := Integer readFrom:unicodeString onError:[^ self].
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7124
    ].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7125
4940
73e7031a4a85 class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 4889
diff changeset
  7126
    unicodeChar := Character value:unicodePoint.
73e7031a4a85 class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 4889
diff changeset
  7127
    self keyPress:unicodeChar x:0 y:0.
73e7031a4a85 class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 4889
diff changeset
  7128
    self keyRelease:unicodeChar x:0 y:0.
73e7031a4a85 class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 4889
diff changeset
  7129
!
73e7031a4a85 class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 4889
diff changeset
  7130
5331
1d78ee0cb88b class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5325
diff changeset
  7131
inspectSelectedString
1d78ee0cb88b class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5325
diff changeset
  7132
    "inspect the selected text"
1d78ee0cb88b class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5325
diff changeset
  7133
1d78ee0cb88b class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5325
diff changeset
  7134
    self selectionAsString inspect.
1d78ee0cb88b class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5325
diff changeset
  7135
!
1d78ee0cb88b class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5325
diff changeset
  7136
4742
a00cb40ee392 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4738
diff changeset
  7137
internalSpellingSuggestion
a00cb40ee392 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4738
diff changeset
  7138
    "insert the internal-spelling suggestion for the selected text.
a00cb40ee392 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4738
diff changeset
  7139
     Requires that the RefactoryBrowser/line/spelCheck stuff is loaded."
a00cb40ee392 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4738
diff changeset
  7140
a00cb40ee392 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4738
diff changeset
  7141
    |text suggestions best|
a00cb40ee392 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4738
diff changeset
  7142
a00cb40ee392 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4738
diff changeset
  7143
    self withWaitCursorDo:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7144
	text := self selection asString string withoutSeparators.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7145
	text size == 0 ifTrue:[^ self].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7146
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7147
	suggestions := RBSpellChecker default bestMatchesFor:text.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7148
	suggestions size == 0 ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7149
	    self information:('No spelling suggestion from builtin checker for: ' , text).
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7150
	    Transcript showCR:('No spelling suggestion from builtin checker for: ' , text).
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7151
	    ^ self.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7152
	].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7153
	Transcript showCR:suggestions.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7154
	best := suggestions first.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7155
    ].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7156
    self
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7157
	undoablePaste:best
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7158
	info:'Spelling Suggestion'.
4742
a00cb40ee392 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4738
diff changeset
  7159
!
a00cb40ee392 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4738
diff changeset
  7160
4884
9b12ee7ca951 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4829
diff changeset
  7161
openFileBrowserOnFileNamed:fileNameString
9b12ee7ca951 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4829
diff changeset
  7162
    "open a fileBrowser on the given fileNameString"
2762
e29673db4ddb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2757
diff changeset
  7163
4630
b043ca9e5060 class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 4623
diff changeset
  7164
    |fn|
2762
e29673db4ddb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2757
diff changeset
  7165
4884
9b12ee7ca951 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4829
diff changeset
  7166
    fn := fileNameString asFilename.
2762
e29673db4ddb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2757
diff changeset
  7167
    fn exists ifFalse:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7168
	fn := fileNameString withoutSeparators withoutQuotes asFilename.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7169
	fn exists ifFalse:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7170
	    ^ self warn:(resources
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7171
			    string:'Sorry - file "%1" was not found in directory "%2"'
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7172
			    with:fn baseName allBold
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7173
			    with:fn directory baseName allBold).
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7174
	].
2762
e29673db4ddb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2757
diff changeset
  7175
    ].
4449
59fe55c937ea changed: #openFileBrowserOnIt
Claus Gittinger <cg@exept.de>
parents: 4430
diff changeset
  7176
    UserPreferences fileBrowserClass openOn:fn
59fe55c937ea changed: #openFileBrowserOnIt
Claus Gittinger <cg@exept.de>
parents: 4430
diff changeset
  7177
59fe55c937ea changed: #openFileBrowserOnIt
Claus Gittinger <cg@exept.de>
parents: 4430
diff changeset
  7178
    "Modified: / 06-09-2012 / 14:47:22 / cg"
2762
e29673db4ddb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2757
diff changeset
  7179
!
e29673db4ddb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2757
diff changeset
  7180
4884
9b12ee7ca951 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4829
diff changeset
  7181
openFileBrowserOnIt
9b12ee7ca951 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4829
diff changeset
  7182
    "open a fileBrowser on the selected fileName"
9b12ee7ca951 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4829
diff changeset
  7183
9b12ee7ca951 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4829
diff changeset
  7184
    |fileNameString|
9b12ee7ca951 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4829
diff changeset
  7185
9b12ee7ca951 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4829
diff changeset
  7186
    fileNameString := self selectionAsString.
9b12ee7ca951 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4829
diff changeset
  7187
    self openFileBrowserOnFileNamed:fileNameString
9b12ee7ca951 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4829
diff changeset
  7188
9b12ee7ca951 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4829
diff changeset
  7189
    "Modified: / 06-09-2012 / 14:47:22 / cg"
9b12ee7ca951 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4829
diff changeset
  7190
!
9b12ee7ca951 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4829
diff changeset
  7191
3483
8ef0f9a0737f +openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents: 3482
diff changeset
  7192
openWorkspaceWithIt
8ef0f9a0737f +openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents: 3482
diff changeset
  7193
    "open a workspace containing the selected text"
8ef0f9a0737f +openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents: 3482
diff changeset
  7194
8ef0f9a0737f +openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents: 3482
diff changeset
  7195
    |text|
8ef0f9a0737f +openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents: 3482
diff changeset
  7196
8ef0f9a0737f +openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents: 3482
diff changeset
  7197
    text := self selectionAsString.
8ef0f9a0737f +openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents: 3482
diff changeset
  7198
    WorkspaceApplication openWith:text selected:true
8ef0f9a0737f +openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents: 3482
diff changeset
  7199
8ef0f9a0737f +openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents: 3482
diff changeset
  7200
    "Created: / 26-05-2007 / 06:05:22 / cg"
8ef0f9a0737f +openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents: 3482
diff changeset
  7201
!
8ef0f9a0737f +openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents: 3482
diff changeset
  7202
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  7203
paste
1289
e2dcc5fe612c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1287
diff changeset
  7204
    "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
  7205
     Then paste at cursor position."
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  7206
2989
5dcc2912bcb6 undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents: 2984
diff changeset
  7207
    self checkModificationsAllowed ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7208
	self withSelfAndTextForPasteDo:[:me :text |
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7209
	    me unselect.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7210
	    me undoablePaste:text
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7211
	]
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  7212
    ]
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  7213
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  7214
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  7215
paste:someText
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  7216
    "paste someText at cursor"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  7217
3825
184c9b081973 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3816
diff changeset
  7218
    self paste:someText withCR:false
184c9b081973 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3816
diff changeset
  7219
!
184c9b081973 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3816
diff changeset
  7220
184c9b081973 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3816
diff changeset
  7221
paste:someText withCR:withCR
184c9b081973 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3816
diff changeset
  7222
    "paste someText at cursor"
184c9b081973 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3816
diff changeset
  7223
2856
bc6bb86d4d2e character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents: 2854
diff changeset
  7224
    |s nLines startLine startCol l1 l2 c1 c2 codingErrorReported|
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  7225
1480
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  7226
    self checkModificationsAllowed ifFalse:[^ self].
2853
f8c1d3963b49 preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents: 2846
diff changeset
  7227
    someText isNil ifTrue:[^ self].
f8c1d3963b49 preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents: 2846
diff changeset
  7228
f8c1d3963b49 preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents: 2846
diff changeset
  7229
    s := someText.
2856
bc6bb86d4d2e character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents: 2854
diff changeset
  7230
    codingErrorReported := false.
bc6bb86d4d2e character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents: 2854
diff changeset
  7231
    CharacterEncoderError handle:[:ex |
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7232
	|code msg|
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7233
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7234
	code := ex parameter.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7235
	codingErrorReported ifFalse:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7236
	    msg := 'Cannot represent pasted string in this Views encoding (',gc characterEncoding,').'.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7237
	    code notNil ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7238
		msg := msg , '\\Reason: No representation for ' , (code radixPrintStringRadix:16).
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7239
	    ].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7240
	    Dialog warn:(resources stringWithCRs:msg).
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7241
	    codingErrorReported := true.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7242
	].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7243
	ex proceedWith:ex defaultValue
2856
bc6bb86d4d2e character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents: 2854
diff changeset
  7244
    ] do:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7245
	s isString ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7246
	    s encoding ~~ gc characterEncoding ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7247
		s := s encodeFrom:(s encoding) into:gc characterEncoding.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7248
	    ].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7249
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7250
	    s := s asStringCollection.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7251
	    (someText endsWith:Character cr) ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7252
		"/ s := s copyWith:nil.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7253
		s := s copyWith:'' "/ an empty line at the end
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7254
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7255
	    ]
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7256
	] ifFalse:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7257
	    s isStringCollection ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7258
		s := s encodeFrom:(s encoding) into:gc characterEncoding.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7259
	    ] ifFalse:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7260
		(self
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7261
		    confirm:(resources
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7262
			stringWithCRs:'Selection (%1) is not convertable to Text.\\Paste storeString ?'
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7263
			with:s class name)) ifFalse:[^ self].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7264
		s := StringCollection with:s storeString .
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7265
		"/ ^ self
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7266
	    ].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7267
	].
2856
bc6bb86d4d2e character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents: 2854
diff changeset
  7268
    ].
bc6bb86d4d2e character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents: 2854
diff changeset
  7269
2853
f8c1d3963b49 preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents: 2846
diff changeset
  7270
    (nLines := s size) == 0 ifTrue:[^ self].
f8c1d3963b49 preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents: 2846
diff changeset
  7271
    (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
  7272
f8c1d3963b49 preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents: 2846
diff changeset
  7273
    typeOfSelection := #paste.
f8c1d3963b49 preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents: 2846
diff changeset
  7274
f8c1d3963b49 preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents: 2846
diff changeset
  7275
    startLine := l1 := cursorLine.
f8c1d3963b49 preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents: 2846
diff changeset
  7276
    startCol := c1 := cursorCol.
3180
609f340fd96c paste - do not expand tabs!
Michael Beyl <mb@exept.de>
parents: 3161
diff changeset
  7277
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7278
    "do not autoindent here.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7279
     It does make things very ugly, in the inspector
5194
24c790b5d279 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5153
diff changeset
  7280
     (try inspecting a multiline string)..."
24c790b5d279 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5153
diff changeset
  7281
    self withAutoIndent:false do:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7282
	"do not expand tabs into spaces here -
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7283
	 they get expanded in basicWithoutRedrawInsertStringWithoutCRs:aString atLine:lineNr col:colNr.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7284
	 Some Subviews want to paste with unexpanded tabs!!"
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7285
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7286
	self insertLines:s withCR:withCR.
5194
24c790b5d279 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5153
diff changeset
  7287
    ].
2853
f8c1d3963b49 preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents: 2846
diff changeset
  7288
    l2 := cursorLine.
f8c1d3963b49 preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents: 2846
diff changeset
  7289
    c2 := (cursorCol - 1).
f8c1d3963b49 preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents: 2846
diff changeset
  7290
    self selectFromLine:l1 col:c1 toLine:l2 col:c2.
f8c1d3963b49 preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents: 2846
diff changeset
  7291
    typeOfSelection := #paste. "/ sigh - cleared by #selectFromLine:
f8c1d3963b49 preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents: 2846
diff changeset
  7292
4328
ea91d179b5f0 changed:
Claus Gittinger <cg@exept.de>
parents: 4289
diff changeset
  7293
    "Modified: / 14-02-1996 / 11:14:14 / stefan"
4360
fe77e479d95a comment/format in:
Claus Gittinger <cg@exept.de>
parents: 4328
diff changeset
  7294
    "Modified: / 25-01-2012 / 00:31:30 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  7295
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  7296
3731
041b0c7ad557 +insert as literal
Claus Gittinger <cg@exept.de>
parents: 3725
diff changeset
  7297
pasteAsStringLiteral
041b0c7ad557 +insert as literal
Claus Gittinger <cg@exept.de>
parents: 3725
diff changeset
  7298
    "insert clipboard string as a string literal.
041b0c7ad557 +insert as literal
Claus Gittinger <cg@exept.de>
parents: 3725
diff changeset
  7299
     Almost the same as a normal paste, but single-quotes are doubled,
041b0c7ad557 +insert as literal
Claus Gittinger <cg@exept.de>
parents: 3725
diff changeset
  7300
     to make it a legal string literal"
041b0c7ad557 +insert as literal
Claus Gittinger <cg@exept.de>
parents: 3725
diff changeset
  7301
041b0c7ad557 +insert as literal
Claus Gittinger <cg@exept.de>
parents: 3725
diff changeset
  7302
    typeOfSelection := nil.
041b0c7ad557 +insert as literal
Claus Gittinger <cg@exept.de>
parents: 3725
diff changeset
  7303
    self
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7304
	undoableDo:[ self pasteOrReplace:(self getClipboardText asString string storeString) ]
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7305
	info:'Paste as String Literal'
3731
041b0c7ad557 +insert as literal
Claus Gittinger <cg@exept.de>
parents: 3725
diff changeset
  7306
!
041b0c7ad557 +insert as literal
Claus Gittinger <cg@exept.de>
parents: 3725
diff changeset
  7307
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  7308
pasteOrReplace
1289
e2dcc5fe612c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1287
diff changeset
  7309
    "paste the copybuffer; if there is a selection, replace it.
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  7310
     otherwise paste at cursor position.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  7311
     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
  7312
     to allow multiple paste operations in a row."
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  7313
2724
23f4e16dc4f4 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2720
diff changeset
  7314
    self withSelfAndTextForPasteDo:[:me :text | me pasteOrReplace:text]
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  7315
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  7316
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  7317
pasteOrReplace:someText
1289
e2dcc5fe612c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1287
diff changeset
  7318
    "paste someText; if there is a selection, replace it.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  7319
     otherwise paste at cursor position. Replace is not done
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  7320
     for originating by a paste, to allow multiple
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  7321
     paste."
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  7322
1480
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  7323
    self checkModificationsAllowed ifFalse:[^ self].
2989
5dcc2912bcb6 undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents: 2984
diff changeset
  7324
5dcc2912bcb6 undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents: 2984
diff changeset
  7325
    self undoableDo:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7326
	((self hasSelection == true) and:[typeOfSelection ~~ #paste]) ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7327
	    self replace:someText
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7328
	] ifFalse:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7329
	    self paste:someText.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7330
	]
3542
30ed44ed0178 +joinLines (CTRL-j);
Claus Gittinger <cg@exept.de>
parents: 3517
diff changeset
  7331
    ] info:'Paste/Replace'.
1289
e2dcc5fe612c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1287
diff changeset
  7332
2107
9d44232af0a0 textSelection fixes (added newLine) for MSDOS;
Claus Gittinger <cg@exept.de>
parents: 2101
diff changeset
  7333
    "Modified: / 30.1.2000 / 02:33:00 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  7334
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  7335
5387
b94d35da3ad6 class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 5371
diff changeset
  7336
pasteOrReplaceByKeyPress
b94d35da3ad6 class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 5371
diff changeset
  7337
    "paste a previous item from the copybuffer history.
b94d35da3ad6 class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 5371
diff changeset
  7338
     (i.e. repaste some previously deleted or copied text)"
b94d35da3ad6 class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 5371
diff changeset
  7339
b94d35da3ad6 class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 5371
diff changeset
  7340
    |text|
b94d35da3ad6 class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 5371
diff changeset
  7341
b94d35da3ad6 class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 5371
diff changeset
  7342
    self checkModificationsAllowed ifFalse:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7343
	self flashReadOnly.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7344
	^ self
5387
b94d35da3ad6 class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 5371
diff changeset
  7345
    ].
b94d35da3ad6 class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 5371
diff changeset
  7346
    text := self getClipboardText:#clipboard.
b94d35da3ad6 class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 5371
diff changeset
  7347
    text notNil ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7348
	self pasteOrReplace:text
5387
b94d35da3ad6 class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 5371
diff changeset
  7349
    ]
b94d35da3ad6 class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 5371
diff changeset
  7350
!
b94d35da3ad6 class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 5371
diff changeset
  7351
3474
357e16440725 slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents: 3473
diff changeset
  7352
pasteOrReplaceFromHistory
357e16440725 slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents: 3473
diff changeset
  7353
    "paste a previous item from the copybuffer history.
357e16440725 slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents: 3473
diff changeset
  7354
     (i.e. repaste some previously deleted or copied text)"
357e16440725 slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents: 3473
diff changeset
  7355
357e16440725 slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents: 3473
diff changeset
  7356
    |text|
357e16440725 slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents: 3473
diff changeset
  7357
357e16440725 slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents: 3473
diff changeset
  7358
    self checkModificationsAllowed ifFalse:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7359
	self flashReadOnly.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7360
	^ self
3474
357e16440725 slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents: 3473
diff changeset
  7361
    ].
357e16440725 slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents: 3473
diff changeset
  7362
    text := self getTextSelectionFromHistory.
357e16440725 slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents: 3473
diff changeset
  7363
    text notNil ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7364
	self pasteOrReplace:text
3474
357e16440725 slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents: 3473
diff changeset
  7365
    ]
357e16440725 slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents: 3473
diff changeset
  7366
!
357e16440725 slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents: 3473
diff changeset
  7367
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  7368
replace
1289
e2dcc5fe612c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1287
diff changeset
  7369
    "replace the selection by the contents of the copybuffer"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  7370
3269
03d04670a5d2 replace is a no op, if there is no selection
Claus Gittinger <cg@exept.de>
parents: 3268
diff changeset
  7371
    self hasSelection ifFalse:[^ self].
03d04670a5d2 replace is a no op, if there is no selection
Claus Gittinger <cg@exept.de>
parents: 3268
diff changeset
  7372
    self checkModificationsAllowed ifFalse:[^ self].
03d04670a5d2 replace is a no op, if there is no selection
Claus Gittinger <cg@exept.de>
parents: 3268
diff changeset
  7373
03d04670a5d2 replace is a no op, if there is no selection
Claus Gittinger <cg@exept.de>
parents: 3268
diff changeset
  7374
    self withSelfAndTextForPasteDo:[:me :text |
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7375
	me undoableDo:[ me replace:text ]
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7376
	info:'Replace'
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  7377
    ]
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  7378
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  7379
121
claus
parents: 118
diff changeset
  7380
replace:someText
1289
e2dcc5fe612c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1287
diff changeset
  7381
    "replace the selection by someText"
121
claus
parents: 118
diff changeset
  7382
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  7383
    |selected selectedString
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  7384
     selStartLine selStartCol selEndLine selEndCol|
121
claus
parents: 118
diff changeset
  7385
1480
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  7386
    self checkModificationsAllowed ifFalse:[^ self].
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  7387
3130
c0f39f9f28d6 undoable keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3127
diff changeset
  7388
    self undoableDo:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7389
	selected := self selection.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7390
	selected isNil ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7391
	    ^ self paste:someText
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7392
	].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7393
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7394
	self deleteSelection.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7395
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7396
	"take care, if we replace a selection without space by a word selected
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7397
	 with one - in this case we usually do not want the space.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7398
	 But, if we replace a word-selected selection by something without a
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7399
	 space, we DO want the space added."
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7400
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7401
	selected size == 1 ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7402
	    selectedString := selected at:1.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7403
	].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7404
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7405
	someText size == 1 ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7406
	    |cutOffSpace addSpace replacement replacementString|
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7407
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7408
	    cutOffSpace := false.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7409
	    addSpace := false.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7410
	    replacement := someText copyFrom:1.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7411
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7412
	    selectedString notNil ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7413
		((selectedString startsWith:' ') or:[selectedString endsWith:' ']) ifFalse:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7414
		   "selection has no space"
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7415
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7416
		    ((selectStyle == #wordleft) or:[selectStyle == #wordRight]) ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7417
			cutOffSpace := true
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7418
		    ]
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7419
		] ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7420
		    addSpace := true
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7421
		]
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7422
	    ].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7423
	    replacementString := replacement at:1.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7424
	    cutOffSpace ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7425
		(replacementString startsWith:' ') ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7426
		    replacementString := replacementString withoutSpaces
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7427
		].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7428
	    ] ifFalse:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7429
		selectStyle == #wordLeft ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7430
		    "want a space at left"
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7431
		    (replacementString startsWith:' ') ifFalse:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7432
			replacementString := replacementString withoutSpaces.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7433
			replacementString := ' ' , replacementString
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7434
		    ]
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7435
		].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7436
		selectStyle == #wordRight ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7437
		    "want a space at right"
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7438
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7439
		    (replacementString endsWith:' ') ifFalse:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7440
			replacementString := replacementString withoutSpaces.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7441
			replacementString := replacementString , ' '
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7442
		    ]
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7443
		].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7444
	    ].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7445
	    replacement at:1 put: replacementString.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7446
	    self paste:replacement.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7447
	] ifFalse:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7448
	    self paste:someText
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7449
	].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7450
	self setLastStringToReplace: selectedString.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7451
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7452
	lastReplacementInfo lastReplacement: someText.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7453
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7454
	selStartLine := selectionStartLine.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7455
	selStartCol := self selectionStartCol.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7456
	selEndLine := selectionEndLine.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7457
	selEndCol := self selectionEndCol.
3130
c0f39f9f28d6 undoable keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3127
diff changeset
  7458
    ]
3542
30ed44ed0178 +joinLines (CTRL-j);
Claus Gittinger <cg@exept.de>
parents: 3517
diff changeset
  7459
    info:'Replace'
362
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  7460
1480
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  7461
    "Modified: / 14.2.1996 / 10:37:02 / stefan"
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  7462
    "Modified: / 5.4.1998 / 16:55:28 / cg"
121
claus
parents: 118
diff changeset
  7463
!
claus
parents: 118
diff changeset
  7464
3430
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  7465
searchReplace
3683
5891af82a177 middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents: 3650
diff changeset
  7466
    "search for a string - show a box to enter searchpattern
3430
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  7467
     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
  7468
     - currently no regular expressions are handled."
3683
5891af82a177 middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents: 3650
diff changeset
  7469
3430
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  7470
    |searchBox patternHolder replacePatternHolder caseHolder flag ign initialString bindings bldr search modal replace action|
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  7471
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  7472
    modal := false "(UserPreferences current searchDialogIsModal)".
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  7473
    lastSearchDirection := #forward.
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  7474
    ign := lastSearchIgnoredCase ? LastSearchIgnoredCase ? true.
5251
259d72b38bd7 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5244
diff changeset
  7475
    caseHolder := ValueHolder with:ign.
259d72b38bd7 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5244
diff changeset
  7476
    patternHolder := ValueHolder with:''.
259d72b38bd7 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5244
diff changeset
  7477
    replacePatternHolder := ValueHolder with:''.
3430
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  7478
    lastSearchPattern notNil ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7479
	initialString := lastSearchPattern
3430
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  7480
    ].
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  7481
    self hasSelectionWithinSingleLine ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7482
	initialString := self selectionAsString
3430
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  7483
    ].
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  7484
    initialString isNil ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7485
	LastSearchPatterns size > 0 ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7486
	    initialString := LastSearchPatterns first
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7487
	]
3430
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  7488
    ].
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  7489
    initialString notNil ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7490
	patternHolder value:initialString.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7491
	replacePatternHolder value:initialString.
3430
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  7492
    ].
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  7493
    flag := true.
3683
5891af82a177 middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents: 3650
diff changeset
  7494
    search := [:fwd |
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7495
	    self
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7496
		search:patternHolder value
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7497
		ignoreCase:caseHolder value
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7498
		forward:fwd.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7499
	].
3683
5891af82a177 middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents: 3650
diff changeset
  7500
    replace := [:all |
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7501
	    self
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7502
		replace:patternHolder value
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7503
		by:replacePatternHolder value
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7504
		all:all
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7505
		ignoreCase:caseHolder value
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7506
	].
3430
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  7507
    bindings := IdentityDictionary new.
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  7508
    bindings at:#searchPattern put:patternHolder.
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  7509
    bindings at:#replacePattern put:replacePatternHolder.
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  7510
    modal ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7511
	bindings at:#nextAction
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7512
	    put:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7513
		flag := true.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7514
		action := search.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7515
		searchBox doAccept.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7516
	    ].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7517
	bindings at:#prevAction
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7518
	    put:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7519
		flag := false.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7520
		action := search.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7521
		searchBox doAccept.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7522
	    ].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7523
	bindings at:#replaceAction
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7524
	    put:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7525
		flag := false.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7526
		action := replace.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7527
		searchBox doAccept.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7528
	    ].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7529
	bindings at:#replaceAllAction
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7530
	    put:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7531
		flag := true.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7532
		action := replace.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7533
		searchBox doAccept.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7534
	    ].
3430
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  7535
    ] ifFalse:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7536
	bindings at:#nextAction put:[ search value:true. ].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7537
	bindings at:#prevAction put:[ search value:false. ].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7538
	bindings at:#replaceAction put:[ replace value:false. ].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7539
	bindings at:#replaceAllAction put:[ replace value:true. ].
3430
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  7540
    ].
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  7541
    bindings at:#ignoreCase put:caseHolder.
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  7542
    bindings at:#patternList put:LastSearchPatterns.
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  7543
    modal ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7544
	searchBox := SimpleDialog new.
3430
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  7545
    ] ifFalse:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7546
	searchBox := ApplicationModel new.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7547
	searchBox createBuilder.
3430
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  7548
    ].
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  7549
    searchBox resources:(self resources).
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  7550
    bldr := searchBox builder.
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  7551
    bldr addBindings:bindings.
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  7552
    searchBox allButOpenFrom:(self class searchReplaceDialogSpec).
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  7553
    (bldr componentAt:#nextButton) cursor:(Cursor thumbsUp).
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  7554
    (bldr componentAt:#prevButton) cursor:(Cursor thumbsUp).
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  7555
    (bldr componentAt:#cancelButton) cursor:(Cursor thumbsDown).
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  7556
    modal ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7557
	searchBox openDialog.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7558
	searchBox accepted ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7559
	    action value:flag
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7560
	].
3430
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  7561
    ] ifFalse:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7562
	(bldr componentAt:#nextButton) isReturnButton:false.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7563
	(bldr componentAt:#cancelButton)
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7564
	    label:(resources string:'Close');
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7565
	    action:[ searchBox closeRequest ].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7566
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7567
	"/ searchBox masterApplication:self application.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7568
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7569
	self topView beMaster.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7570
	(searchBox window)
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7571
	    beSlave;
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7572
	    openInGroup:(self windowGroup).
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7573
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7574
	"/ searchBox window open.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7575
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7576
	searchBox window assignKeyboardFocusToFirstKeyboardConsumer.
3430
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  7577
    ]
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  7578
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  7579
    "Modified: / 11-07-2006 / 11:20:06 / fm"
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  7580
!
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  7581
121
claus
parents: 118
diff changeset
  7582
showDeleted
claus
parents: 118
diff changeset
  7583
    "open a readonly editor on all deleted text"
claus
parents: 118
diff changeset
  7584
claus
parents: 118
diff changeset
  7585
    |v|
claus
parents: 118
diff changeset
  7586
claus
parents: 118
diff changeset
  7587
    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
  7588
    v readOnly:true.
121
claus
parents: 118
diff changeset
  7589
    v topView label:'deleted text'.
2624
22d352e56c27 preps for special characters
Claus Gittinger <cg@exept.de>
parents: 2617
diff changeset
  7590
!
22d352e56c27 preps for special characters
Claus Gittinger <cg@exept.de>
parents: 2617
diff changeset
  7591
3221
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  7592
sort:how ignoreCase:ignoreCase fromLine:start toLine:end
4763
89bf20c2e8f5 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4753
diff changeset
  7593
    "sort/reorder the selected lines.
89bf20c2e8f5 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4753
diff changeset
  7594
     how:
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7595
	#lines
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7596
	#linesByFirstWord
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7597
	#linesByNthWord
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7598
	#linesByNthNumber
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7599
	#linesByNthHexNumber
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7600
	#words
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7601
	#linesByLength
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7602
	#reverse
4763
89bf20c2e8f5 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4753
diff changeset
  7603
    "
89bf20c2e8f5 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4753
diff changeset
  7604
89bf20c2e8f5 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4753
diff changeset
  7605
    |lines extractor innerExtractor fetcher operation lineWise nStr n s words|
3221
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  7606
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  7607
    lineWise := true.
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  7608
4763
89bf20c2e8f5 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4753
diff changeset
  7609
    how == #reverse ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7610
	operation := [:lines | lines reverse].
4763
89bf20c2e8f5 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4753
diff changeset
  7611
    ] ifFalse:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7612
	operation := [:linesOrWords |
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7613
			linesOrWords sort:[:item1 :item2 | (fetcher value:item1) < (fetcher value:item2)]
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7614
		     ].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7615
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7616
	how == #linesByLength ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7617
	    fetcher := [:l | l size].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7618
	] ifFalse:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7619
	    how == #lines ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7620
		extractor := [:l | l withoutLeadingSeparators].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7621
	    ] ifFalse:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7622
		how == #linesByFirstWord ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7623
		    extractor := [:l | ((l asCollectionOfWords select:[:w | w isEmpty or:[w first isLetterOrDigit]]) at:1 ifAbsent:'')].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7624
		] ifFalse:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7625
		    ((how == #linesByNthWord) or:[ how == #linesByNthNumber  or:[ how == #linesByNthHexNumber]]) ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7626
			nStr := Dialog request:'Word/Column (1..)' initialAnswer:(LastColumnNumberForSort ? 2).
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7627
			nStr isEmptyOrNil ifTrue:[^ self].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7628
			n := Integer readFrom:nStr onError:[^ self].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7629
			LastColumnNumberForSort := n.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7630
			extractor := [:l | ((l string asCollectionOfWords) at:n ifAbsent:'')].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7631
			how == #linesByNthNumber ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7632
			    innerExtractor := extractor.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7633
			    extractor := [:l | Integer readFrom:(innerExtractor value:l) onError:0]
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7634
			] ifFalse:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7635
			    how == #linesByNthHexNumber ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7636
				innerExtractor := extractor.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7637
				extractor := [:l |
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7638
				    |s|
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7639
				    s := innerExtractor value:l.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7640
				    (s startsWith:'16r') ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7641
					(Integer readSmalltalkSyntaxFrom:s) ? 0
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7642
				    ] ifFalse:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7643
					Integer readFrom:s radix:16 onError:[ 0 ]
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7644
				    ]
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7645
				]
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7646
			    ]
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7647
			].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7648
		    ] ifFalse:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7649
			how == #words ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7650
			    lineWise := false.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7651
			    extractor := [:w | w].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7652
			] ifFalse:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7653
			    self error:'unknown sort criteria: ', how printString.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7654
			]
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7655
		    ]
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7656
		]
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7657
	    ].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7658
	    ignoreCase ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7659
		fetcher := [:l | (extractor value:l) asLowercase].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7660
	    ] ifFalse:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7661
		fetcher := extractor.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7662
	    ].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7663
	].
3221
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  7664
    ].
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  7665
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  7666
    lineWise ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7667
	"process the lines of the selection (aka a collection of lines)"
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7668
	start == end ifTrue:[^ self ].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7669
	lines := (start to:end) collect:[:lineNr | (self listAt:lineNr) ? ''].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7670
	lines := operation value:lines.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7671
	(start to:end) with:lines do:[:lineNr :line | self replaceLine:lineNr with:line].
4763
89bf20c2e8f5 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4753
diff changeset
  7672
    ] ifFalse:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7673
	"process the whole selection as a string"
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7674
	s := self selectionAsString.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7675
	words := s asCollectionOfWords.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7676
	words := operation value:words.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7677
	s := words asStringCollection asStringWith:Character space.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7678
	self replace:s.
4763
89bf20c2e8f5 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4753
diff changeset
  7679
    ].
3221
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  7680
    self textChanged.
4373
22fb03e6d08a class definition
Claus Gittinger <cg@exept.de>
parents: 4371
diff changeset
  7681
4414
308d40ee857b changed: #sort:ignoreCase:fromLine:toLine:
Claus Gittinger <cg@exept.de>
parents: 4396
diff changeset
  7682
    "Modified: / 31-03-2012 / 10:59:28 / cg"
3221
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  7683
!
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  7684
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  7685
sortSelection:how ignoreCase:ignoreCase
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  7686
    "sort the selected lines"
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  7687
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  7688
    |start end|
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  7689
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  7690
    selectionStartLine isNil ifTrue:[^ self].
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  7691
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  7692
    start := selectionStartLine.
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  7693
    end := selectionEndLine.
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  7694
    (selectionEndCol == 0) ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7695
	end := end - 1
3221
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  7696
    ].
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  7697
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  7698
    self
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7699
	undoableDo:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7700
	    self sort:how ignoreCase:ignoreCase fromLine:start toLine:end
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7701
	]
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7702
	info:'Sort'
4373
22fb03e6d08a class definition
Claus Gittinger <cg@exept.de>
parents: 4371
diff changeset
  7703
22fb03e6d08a class definition
Claus Gittinger <cg@exept.de>
parents: 4371
diff changeset
  7704
    "Modified (format): / 15-02-2012 / 16:52:53 / cg"
3221
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  7705
!
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  7706
2624
22d352e56c27 preps for special characters
Claus Gittinger <cg@exept.de>
parents: 2617
diff changeset
  7707
specialCharacters
2915
8db67a5d1ccb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2912
diff changeset
  7708
    CharacterSetView
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7709
	openAsInputFor:self
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7710
	label:'Special Character Input'
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7711
	clickLabel:'Click to Insert Character'.
2866
9dd71df46f73 specialCharacters menu item
Claus Gittinger <cg@exept.de>
parents: 2857
diff changeset
  7712
!
9dd71df46f73 specialCharacters menu item
Claus Gittinger <cg@exept.de>
parents: 2857
diff changeset
  7713
5370
9b04537dc868 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5367
diff changeset
  7714
splitLinesAtCharacterOrString
9b04537dc868 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5367
diff changeset
  7715
    "ask user for the character and split after it"
9b04537dc868 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5367
diff changeset
  7716
9b04537dc868 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5367
diff changeset
  7717
    |sel in out separator record|
9b04537dc868 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5367
diff changeset
  7718
9b04537dc868 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5367
diff changeset
  7719
    selectionStartLine isNil ifTrue:[^ self].
9b04537dc868 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5367
diff changeset
  7720
9b04537dc868 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5367
diff changeset
  7721
    separator := Dialog request:(resources string:'Split selected lines after which separator character or string:').
9b04537dc868 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5367
diff changeset
  7722
    separator isEmptyOrNil ifTrue:[^ self].
9b04537dc868 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5367
diff changeset
  7723
9b04537dc868 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5367
diff changeset
  7724
    sel := self selectionAsString.
9b04537dc868 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5367
diff changeset
  7725
    in := sel readStream.
5887
46f1b58748aa #OTHER by stefan
Stefan Vogel <sv@exept.de>
parents: 5882
diff changeset
  7726
    out := CharacterWriteStream on:''.
5370
9b04537dc868 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5367
diff changeset
  7727
    [in atEnd] whileFalse:[
5887
46f1b58748aa #OTHER by stefan
Stefan Vogel <sv@exept.de>
parents: 5882
diff changeset
  7728
        record := in throughAll:separator.
46f1b58748aa #OTHER by stefan
Stefan Vogel <sv@exept.de>
parents: 5882
diff changeset
  7729
        out nextPutLine:record.
5370
9b04537dc868 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5367
diff changeset
  7730
    ].
9b04537dc868 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5367
diff changeset
  7731
    self
5887
46f1b58748aa #OTHER by stefan
Stefan Vogel <sv@exept.de>
parents: 5882
diff changeset
  7732
        undoableDo:[
46f1b58748aa #OTHER by stefan
Stefan Vogel <sv@exept.de>
parents: 5882
diff changeset
  7733
            self replaceSelectionBy:(out contents).
46f1b58748aa #OTHER by stefan
Stefan Vogel <sv@exept.de>
parents: 5882
diff changeset
  7734
        ]
46f1b58748aa #OTHER by stefan
Stefan Vogel <sv@exept.de>
parents: 5882
diff changeset
  7735
        info:'Split Selection'
5370
9b04537dc868 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5367
diff changeset
  7736
!
9b04537dc868 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5367
diff changeset
  7737
2989
5dcc2912bcb6 undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents: 2984
diff changeset
  7738
undoablePaste:someText
3495
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  7739
    self undoablePaste:someText info:nil.
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  7740
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  7741
    "Modified: / 28-07-2007 / 13:25:46 / cg"
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  7742
!
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  7743
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  7744
undoablePaste:someText info:infoOrNil
3683
5891af82a177 middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents: 3650
diff changeset
  7745
    self
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7746
	undoableDo:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7747
	    self paste:someText.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7748
	]
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7749
	info:infoOrNil
3495
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  7750
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  7751
    "Created: / 28-07-2007 / 13:25:30 / cg"
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  7752
!
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  7753
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  7754
undoablePasteOrReplace:someText info:infoOrNil
3683
5891af82a177 middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents: 3650
diff changeset
  7755
    self
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7756
	undoableDo:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7757
	    self pasteOrReplace:someText.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7758
	]
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7759
	info:infoOrNil
3495
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  7760
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  7761
    "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
  7762
!
5dcc2912bcb6 undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents: 2984
diff changeset
  7763
4114
321416257cc5 added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents: 4110
diff changeset
  7764
undoablePasteReplacingAll:someText info:infoOrNil
321416257cc5 added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents: 4110
diff changeset
  7765
    self
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7766
	undoableDo:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7767
	    self selectAll.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7768
	    self pasteOrReplace:someText.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7769
	]
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7770
	info:infoOrNil
4114
321416257cc5 added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents: 4110
diff changeset
  7771
321416257cc5 added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents: 4110
diff changeset
  7772
    "Created: / 28-07-2007 / 13:25:30 / cg"
321416257cc5 added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents: 4110
diff changeset
  7773
!
321416257cc5 added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents: 4110
diff changeset
  7774
2724
23f4e16dc4f4 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2720
diff changeset
  7775
withSelfAndTextForPasteDo:aBlock
23f4e16dc4f4 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2720
diff changeset
  7776
    "common code for paste/replace of the copybuffer"
23f4e16dc4f4 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2720
diff changeset
  7777
23f4e16dc4f4 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2720
diff changeset
  7778
    |sel|
23f4e16dc4f4 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2720
diff changeset
  7779
23f4e16dc4f4 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2720
diff changeset
  7780
    self checkModificationsAllowed ifFalse:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7781
	self flashReadOnly.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7782
	^ self
2724
23f4e16dc4f4 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2720
diff changeset
  7783
    ].
23f4e16dc4f4 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2720
diff changeset
  7784
23f4e16dc4f4 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2720
diff changeset
  7785
    sel := self getTextSelectionOrTextSelectionFromHistory.
23f4e16dc4f4 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2720
diff changeset
  7786
    sel notNil ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7787
	aBlock value:self value:sel.
2724
23f4e16dc4f4 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2720
diff changeset
  7788
    ]
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  7789
! !
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  7790
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  7791
!EditTextView methodsFor:'private'!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  7792
3880
d8882158de6b beepInEditor flag
Claus Gittinger <cg@exept.de>
parents: 3868
diff changeset
  7793
beep
5244
261cf00fc93b class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5239
diff changeset
  7794
    "output an audible beep or bell on my screen device"
261cf00fc93b class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5239
diff changeset
  7795
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7796
    UserPreferences current beepInEditor ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7797
	super beep
3880
d8882158de6b beepInEditor flag
Claus Gittinger <cg@exept.de>
parents: 3868
diff changeset
  7798
    ]
d8882158de6b beepInEditor flag
Claus Gittinger <cg@exept.de>
parents: 3868
diff changeset
  7799
!
d8882158de6b beepInEditor flag
Claus Gittinger <cg@exept.de>
parents: 3868
diff changeset
  7800
331
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
  7801
checkModificationsAllowed
1300
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  7802
    "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
  7803
     evaluate the exceptionBlock if not.
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  7804
     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
  7805
     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
  7806
1733
c5139b7402f0 use self isReadonly; readOnly may now be a valueHolder.
Claus Gittinger <cg@exept.de>
parents: 1732
diff changeset
  7807
    self isReadOnly ifTrue: [
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7808
	exceptionBlock isNil ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7809
	    ^ false
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7810
	].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7811
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7812
	(exceptionBlock value:'Text may not be modified') ~~ true ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7813
	    ^ false
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7814
	]
331
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
  7815
    ].
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
  7816
    ^ true
1300
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  7817
1577
4e487247ad33 dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents: 1568
diff changeset
  7818
    "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
  7819
!
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
  7820
2596
933689d5bd9c alternative selection color
Claus Gittinger <cg@exept.de>
parents: 2589
diff changeset
  7821
currentSelectionBgColor
933689d5bd9c alternative selection color
Claus Gittinger <cg@exept.de>
parents: 2589
diff changeset
  7822
    typeOfSelection == #paste ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7823
	^ DefaultAlternativeSelectionBackgroundColor ? selectionBgColor
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7824
    ].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7825
    "/ hasKeyboardFocus ifFalse:[^ Color lightGrey].
2596
933689d5bd9c alternative selection color
Claus Gittinger <cg@exept.de>
parents: 2589
diff changeset
  7826
    ^ super currentSelectionBgColor
933689d5bd9c alternative selection color
Claus Gittinger <cg@exept.de>
parents: 2589
diff changeset
  7827
933689d5bd9c alternative selection color
Claus Gittinger <cg@exept.de>
parents: 2589
diff changeset
  7828
    "
933689d5bd9c alternative selection color
Claus Gittinger <cg@exept.de>
parents: 2589
diff changeset
  7829
     DefaultAlternativeSelectionBackgroundColor := Color yellow blendWith:Color green
933689d5bd9c alternative selection color
Claus Gittinger <cg@exept.de>
parents: 2589
diff changeset
  7830
    "
933689d5bd9c alternative selection color
Claus Gittinger <cg@exept.de>
parents: 2589
diff changeset
  7831
!
933689d5bd9c alternative selection color
Claus Gittinger <cg@exept.de>
parents: 2589
diff changeset
  7832
933689d5bd9c alternative selection color
Claus Gittinger <cg@exept.de>
parents: 2589
diff changeset
  7833
currentSelectionFgColor
933689d5bd9c alternative selection color
Claus Gittinger <cg@exept.de>
parents: 2589
diff changeset
  7834
    typeOfSelection == #paste ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7835
	^ DefaultAlternativeSelectionForegroundColor ? selectionFgColor
2596
933689d5bd9c alternative selection color
Claus Gittinger <cg@exept.de>
parents: 2589
diff changeset
  7836
    ].
933689d5bd9c alternative selection color
Claus Gittinger <cg@exept.de>
parents: 2589
diff changeset
  7837
    ^ super currentSelectionFgColor
933689d5bd9c alternative selection color
Claus Gittinger <cg@exept.de>
parents: 2589
diff changeset
  7838
!
933689d5bd9c alternative selection color
Claus Gittinger <cg@exept.de>
parents: 2589
diff changeset
  7839
3996
d0b0d69334ed added: #resetVariablesBeforeNewSearch
fm
parents: 3982
diff changeset
  7840
resetVariablesBeforeNewSearch
4451
71e8b21c63ce comment in: #resetVariablesBeforeNewSearch
Claus Gittinger <cg@exept.de>
parents: 4449
diff changeset
  7841
    "clear the autosearch action, when the first pattern is searched for"
3996
d0b0d69334ed added: #resetVariablesBeforeNewSearch
fm
parents: 3982
diff changeset
  7842
d0b0d69334ed added: #resetVariablesBeforeNewSearch
fm
parents: 3982
diff changeset
  7843
    super resetVariablesBeforeNewSearch.
d0b0d69334ed added: #resetVariablesBeforeNewSearch
fm
parents: 3982
diff changeset
  7844
d0b0d69334ed added: #resetVariablesBeforeNewSearch
fm
parents: 3982
diff changeset
  7845
    "/ new search invalidates remembered string
4048
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
  7846
    lastStringFromReplaceForNextSearch := nil.
4451
71e8b21c63ce comment in: #resetVariablesBeforeNewSearch
Claus Gittinger <cg@exept.de>
parents: 4449
diff changeset
  7847
71e8b21c63ce comment in: #resetVariablesBeforeNewSearch
Claus Gittinger <cg@exept.de>
parents: 4449
diff changeset
  7848
    "Modified (comment): / 07-03-2012 / 23:21:06 / cg"
3996
d0b0d69334ed added: #resetVariablesBeforeNewSearch
fm
parents: 3982
diff changeset
  7849
!
d0b0d69334ed added: #resetVariablesBeforeNewSearch
fm
parents: 3982
diff changeset
  7850
4053
31117d801975 added: #setLastStringToReplace:
fm
parents: 4051
diff changeset
  7851
setLastStringToReplace: aString
31117d801975 added: #setLastStringToReplace:
fm
parents: 4051
diff changeset
  7852
31117d801975 added: #setLastStringToReplace:
fm
parents: 4051
diff changeset
  7853
    "This method will set the information coming from the last replace into the replacementInfo"
31117d801975 added: #setLastStringToReplace:
fm
parents: 4051
diff changeset
  7854
31117d801975 added: #setLastStringToReplace:
fm
parents: 4051
diff changeset
  7855
    |lastReplaceIgnoredCase|
31117d801975 added: #setLastStringToReplace:
fm
parents: 4051
diff changeset
  7856
4064
140eda842f20 added: #hasSearchActionSelection
fm
parents: 4053
diff changeset
  7857
    "/ The searchAction is mantained until a cut/replace or a search with a user selection is done
140eda842f20 added: #hasSearchActionSelection
fm
parents: 4053
diff changeset
  7858
    self clearSearchAction.
140eda842f20 added: #hasSearchActionSelection
fm
parents: 4053
diff changeset
  7859
4053
31117d801975 added: #setLastStringToReplace:
fm
parents: 4051
diff changeset
  7860
    lastReplacementInfo lastStringToReplace: aString.
31117d801975 added: #setLastStringToReplace:
fm
parents: 4051
diff changeset
  7861
    lastStringFromReplaceForNextSearch := aString.
31117d801975 added: #setLastStringToReplace:
fm
parents: 4051
diff changeset
  7862
31117d801975 added: #setLastStringToReplace:
fm
parents: 4051
diff changeset
  7863
    "If the replace came after a search, the next replace will have the ignored case from that search action"
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7864
    lastReplaceIgnoredCase := (typeOfSelection == #search)
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7865
				ifTrue: [lastSearchIgnoredCase]
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7866
				ifFalse: [nil].
4053
31117d801975 added: #setLastStringToReplace:
fm
parents: 4051
diff changeset
  7867
    lastReplacementInfo lastReplaceIgnoredCase: lastReplaceIgnoredCase.
31117d801975 added: #setLastStringToReplace:
fm
parents: 4051
diff changeset
  7868
!
31117d801975 added: #setLastStringToReplace:
fm
parents: 4051
diff changeset
  7869
2225
65ac7cbffc60 added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents: 2213
diff changeset
  7870
suppressEmphasisInSelection
65ac7cbffc60 added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents: 2213
diff changeset
  7871
    "selection is shown without emphasis"
65ac7cbffc60 added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents: 2213
diff changeset
  7872
65ac7cbffc60 added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents: 2213
diff changeset
  7873
    ^ true
65ac7cbffc60 added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents: 2213
diff changeset
  7874
!
65ac7cbffc60 added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents: 2213
diff changeset
  7875
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  7876
textChanged
522
aa9458e4643e indent/undent did not trigger a modify
ca
parents: 503
diff changeset
  7877
    "my text was modified (internally).
aa9458e4643e indent/undent did not trigger a modify
ca
parents: 503
diff changeset
  7878
     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
  7879
     contentsChanged, which is triggered when the size has changed, and
4635
6218b92cce91 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4630
diff changeset
  7880
     is used to notify scrollers, other views etc.).
6218b92cce91 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4630
diff changeset
  7881
5979
faad087b3207 #DOCUMENTATION by stefan
Stefan Vogel <sv@exept.de>
parents: 5977
diff changeset
  7882
     As some authors of this code have been very sloppy in the past
4635
6218b92cce91 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4630
diff changeset
  7883
     (not sending contentsChanged, but textChanged),
6218b92cce91 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4630
diff changeset
  7884
     we do it here despite what is written above, to ensure that scrollers update correctly."
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  7885
641
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  7886
    self contentsChanged.
1015
caf7265128b9 clear modified on accept.
Claus Gittinger <cg@exept.de>
parents: 1013
diff changeset
  7887
    self modified:true.
5774
3a1531b4c933 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 5773
diff changeset
  7888
    dependents notNil ifTrue:[ self changed:#textChanged ].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  7889
    contentsWasSaved := false
641
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  7890
1015
caf7265128b9 clear modified on accept.
Claus Gittinger <cg@exept.de>
parents: 1013
diff changeset
  7891
    "Modified: 14.2.1997 / 16:58:38 / cg"
2207
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  7892
!
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  7893
2617
a9b1af787406 typo on method name
Claus Gittinger <cg@exept.de>
parents: 2606
diff changeset
  7894
textChangedButNoSizeChange
2207
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  7895
    "my text was modified (internally).
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  7896
     Sent whenever text has been edited (not to confuse with
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  7897
     contentsChanged, which is triggered when the size has changed, and
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  7898
     is used to notify scrollers, other views etc.)"
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  7899
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  7900
    self modified:true.
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  7901
    contentsWasSaved := false
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  7902
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  7903
    "Modified: 14.2.1997 / 16:58:38 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  7904
! !
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  7905
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  7906
!EditTextView methodsFor:'queries'!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  7907
5216
8d6eef5d09c3 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5194
diff changeset
  7908
canAccept
8d6eef5d09c3 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5194
diff changeset
  7909
    "true if text can be accepts.
8d6eef5d09c3 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5194
diff changeset
  7910
     Used to disable the menu if there is nothing selector or the text is readonly"
8d6eef5d09c3 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5194
diff changeset
  7911
8d6eef5d09c3 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5194
diff changeset
  7912
    ^ acceptEnabled ~~ false
8d6eef5d09c3 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5194
diff changeset
  7913
!
8d6eef5d09c3 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5194
diff changeset
  7914
8d6eef5d09c3 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5194
diff changeset
  7915
canCut
8d6eef5d09c3 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5194
diff changeset
  7916
    "true if there is a selection possibly to be cut.
8d6eef5d09c3 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5194
diff changeset
  7917
     Used to disable the menu if there is nothing selector or the text is readonly"
8d6eef5d09c3 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5194
diff changeset
  7918
8d6eef5d09c3 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5194
diff changeset
  7919
    self isReadOnly ifTrue:[ ^ false ].
8d6eef5d09c3 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5194
diff changeset
  7920
    ^ self hasSelection
8d6eef5d09c3 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5194
diff changeset
  7921
!
8d6eef5d09c3 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5194
diff changeset
  7922
8d6eef5d09c3 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5194
diff changeset
  7923
canDoAgain
8d6eef5d09c3 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5194
diff changeset
  7924
    "true if there is a possible repeat last edit operation.
8d6eef5d09c3 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5194
diff changeset
  7925
     Used to disable the menu if there is nothing"
8d6eef5d09c3 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5194
diff changeset
  7926
8d6eef5d09c3 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5194
diff changeset
  7927
    self isReadOnly ifTrue:[ ^ false ].
5972
957ca3b2afb0 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5962
diff changeset
  7928
    ^ lastReplacementInfo lastStringToReplace notNil
957ca3b2afb0 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5962
diff changeset
  7929
957ca3b2afb0 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5962
diff changeset
  7930
    "Modified: / 19-11-2016 / 20:19:02 / cg"
5216
8d6eef5d09c3 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5194
diff changeset
  7931
!
8d6eef5d09c3 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5194
diff changeset
  7932
1526
7676f301bb8f added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents: 1515
diff changeset
  7933
currentLine
7676f301bb8f added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents: 1515
diff changeset
  7934
    "the current line (for relative gotos)"
7676f301bb8f added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents: 1515
diff changeset
  7935
7676f301bb8f added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents: 1515
diff changeset
  7936
    ^ cursorLine
7676f301bb8f added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents: 1515
diff changeset
  7937
7676f301bb8f added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents: 1515
diff changeset
  7938
    "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
  7939
!
7676f301bb8f added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents: 1515
diff changeset
  7940
4064
140eda842f20 added: #hasSearchActionSelection
fm
parents: 4053
diff changeset
  7941
hasSearchActionSelection
140eda842f20 added: #hasSearchActionSelection
fm
parents: 4053
diff changeset
  7942
140eda842f20 added: #hasSearchActionSelection
fm
parents: 4053
diff changeset
  7943
    ^ typeOfSelection == #searchAction
140eda842f20 added: #hasSearchActionSelection
fm
parents: 4053
diff changeset
  7944
!
140eda842f20 added: #hasSearchActionSelection
fm
parents: 4053
diff changeset
  7945
1878
d93809bda6c8 added #isKeyboardConsumer
Claus Gittinger <cg@exept.de>
parents: 1850
diff changeset
  7946
isKeyboardConsumer
d93809bda6c8 added #isKeyboardConsumer
Claus Gittinger <cg@exept.de>
parents: 1850
diff changeset
  7947
    "return true, if the receiver is a keyboard consumer;
5283
9c75aed7c274 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5260
diff changeset
  7948
     Return true here if not readOnly, redefined from SimpleView."
1878
d93809bda6c8 added #isKeyboardConsumer
Claus Gittinger <cg@exept.de>
parents: 1850
diff changeset
  7949
3476
41dde91ae706 isKeyboardConsumer: returns false if readOnly
ca
parents: 3474
diff changeset
  7950
    ^ self isReadOnly not
1878
d93809bda6c8 added #isKeyboardConsumer
Claus Gittinger <cg@exept.de>
parents: 1850
diff changeset
  7951
!
d93809bda6c8 added #isKeyboardConsumer
Claus Gittinger <cg@exept.de>
parents: 1850
diff changeset
  7952
997
615a5a19c5bf specClass
ca
parents: 991
diff changeset
  7953
specClass
1390
99674e1d9c85 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
  7954
    "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
  7955
997
615a5a19c5bf specClass
ca
parents: 991
diff changeset
  7956
    self class == EditTextView ifTrue:[^ TextEditorSpec].
1049
24360c8891d6 specClass query
Claus Gittinger <cg@exept.de>
parents: 1037
diff changeset
  7957
    ^ super specClass
24360c8891d6 specClass query
Claus Gittinger <cg@exept.de>
parents: 1037
diff changeset
  7958
1390
99674e1d9c85 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
  7959
    "Modified: / 31.10.1997 / 19:48:19 / cg"
997
615a5a19c5bf specClass
ca
parents: 991
diff changeset
  7960
!
615a5a19c5bf specClass
ca
parents: 991
diff changeset
  7961
324
9eec6d69e155 better Tab key handling
Claus Gittinger <cg@exept.de>
parents: 323
diff changeset
  7962
tabMeansNextField
323
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
  7963
    "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
  7964
313
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  7965
    "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
  7966
1733
c5139b7402f0 use self isReadonly; readOnly may now be a valueHolder.
Claus Gittinger <cg@exept.de>
parents: 1732
diff changeset
  7967
    ^ self isReadOnly or:[tabMeansNextField]
324
9eec6d69e155 better Tab key handling
Claus Gittinger <cg@exept.de>
parents: 323
diff changeset
  7968
9eec6d69e155 better Tab key handling
Claus Gittinger <cg@exept.de>
parents: 323
diff changeset
  7969
    "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
  7970
!
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  7971
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  7972
widthOfContents
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  7973
    "return the width of the contents in pixels
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  7974
     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
  7975
     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
  7976
     line (and possibly see the cursor behind the line)"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  7977
697
0f258f02e8ea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 693
diff changeset
  7978
    |w dev|
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  7979
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  7980
    w := super widthOfContents.
5643
921578f80870 device access
Claus Gittinger <cg@exept.de>
parents: 5593
diff changeset
  7981
    (dev := device ) isNil ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7982
	"/ really don't know ...
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7983
	dev := Screen current
606
682579fa3b62 fixed #widthOfContents if no device is known
Claus Gittinger <cg@exept.de>
parents: 597
diff changeset
  7984
    ].
4889
3ee5b37416a1 class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 4884
diff changeset
  7985
    ^ w + (gc font widthOn:dev)
697
0f258f02e8ea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 693
diff changeset
  7986
0f258f02e8ea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 693
diff changeset
  7987
    "Modified: 28.5.1996 / 19:32:25 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  7988
! !
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  7989
1588
e2e4ceeed3da category change
Claus Gittinger <cg@exept.de>
parents: 1585
diff changeset
  7990
!EditTextView methodsFor:'realization'!
e2e4ceeed3da category change
Claus Gittinger <cg@exept.de>
parents: 1585
diff changeset
  7991
e2e4ceeed3da category change
Claus Gittinger <cg@exept.de>
parents: 1585
diff changeset
  7992
realize
e2e4ceeed3da category change
Claus Gittinger <cg@exept.de>
parents: 1585
diff changeset
  7993
    "make the view visible - scroll to make the cursor visible."
e2e4ceeed3da category change
Claus Gittinger <cg@exept.de>
parents: 1585
diff changeset
  7994
e2e4ceeed3da category change
Claus Gittinger <cg@exept.de>
parents: 1585
diff changeset
  7995
    super realize.
e2e4ceeed3da category change
Claus Gittinger <cg@exept.de>
parents: 1585
diff changeset
  7996
e2e4ceeed3da category change
Claus Gittinger <cg@exept.de>
parents: 1585
diff changeset
  7997
    self makeCursorVisible.
5643
921578f80870 device access
Claus Gittinger <cg@exept.de>
parents: 5593
diff changeset
  7998
    cursorFgColor := cursorFgColor onDevice:device.
921578f80870 device access
Claus Gittinger <cg@exept.de>
parents: 5593
diff changeset
  7999
    cursorBgColor := cursorBgColor onDevice:device.
1588
e2e4ceeed3da category change
Claus Gittinger <cg@exept.de>
parents: 1585
diff changeset
  8000
e2e4ceeed3da category change
Claus Gittinger <cg@exept.de>
parents: 1585
diff changeset
  8001
    "Modified: 20.12.1996 / 14:16:05 / cg"
e2e4ceeed3da category change
Claus Gittinger <cg@exept.de>
parents: 1585
diff changeset
  8002
    "Created: 24.7.1997 / 18:24:12 / cg"
e2e4ceeed3da category change
Claus Gittinger <cg@exept.de>
parents: 1585
diff changeset
  8003
! !
e2e4ceeed3da category change
Claus Gittinger <cg@exept.de>
parents: 1585
diff changeset
  8004
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8005
!EditTextView methodsFor:'redrawing'!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8006
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8007
redrawCursorIfBetweenVisibleLine:startVisLine and:endVisLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8008
    "redraw the cursor, if it sits in a line range"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8009
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8010
    cursorShown ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8011
	cursorVisibleLine notNil ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8012
	    (cursorVisibleLine between:startVisLine and:endVisLine) ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8013
		self drawCursorCharacter
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8014
	    ]
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8015
	]
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8016
    ]
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  8017
!
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  8018
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8019
redrawCursorIfInVisibleLine:visLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8020
    "redraw the cursor, if it sits in visible line"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8021
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8022
    cursorShown ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8023
	(visLine == cursorVisibleLine) ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8024
	    self drawCursorCharacter
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8025
	]
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8026
    ]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8027
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8028
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8029
redrawFromVisibleLine:startVisLine to:endVisLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8030
    "redraw a visible line range"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8031
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8032
    super redrawFromVisibleLine:startVisLine to:endVisLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8033
    self redrawCursorIfBetweenVisibleLine:startVisLine and:endVisLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8034
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8035
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8036
redrawVisibleLine:visLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8037
    "redraw a visible line"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8038
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8039
    super redrawVisibleLine:visLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8040
    self redrawCursorIfInVisibleLine:visLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8041
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8042
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8043
redrawVisibleLine:visLine col:colNr
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8044
    "redraw the single character in visibleline at colNr"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8045
3510
4bd0b20bd05d cursor-only redrawing, with vertical-insertion cursor
Claus Gittinger <cg@exept.de>
parents: 3495
diff changeset
  8046
    super redrawVisibleLine:visLine col:colNr.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8047
    cursorShown ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8048
	(visLine == cursorVisibleLine) ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8049
	    (colNr == cursorCol) ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8050
		self drawCursorCharacter.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8051
		^ self
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8052
	    ]
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8053
	]
3510
4bd0b20bd05d cursor-only redrawing, with vertical-insertion cursor
Claus Gittinger <cg@exept.de>
parents: 3495
diff changeset
  8054
    ].
4bd0b20bd05d cursor-only redrawing, with vertical-insertion cursor
Claus Gittinger <cg@exept.de>
parents: 3495
diff changeset
  8055
4bd0b20bd05d cursor-only redrawing, with vertical-insertion cursor
Claus Gittinger <cg@exept.de>
parents: 3495
diff changeset
  8056
    "Modified: / 05-11-2007 / 17:35:53 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8057
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8058
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8059
redrawVisibleLine:visLine from:startCol
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8060
    "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
  8061
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8062
    super redrawVisibleLine:visLine from:startCol.
4494
dfe81ebdd5d6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
  8063
    cursorShown ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8064
	self redrawCursorIfInVisibleLine:visLine
4494
dfe81ebdd5d6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
  8065
    ]
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8066
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8067
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8068
redrawVisibleLine:visLine from:startCol to:endCol
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8069
    "redraw a visible line from startCol to endCol"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8070
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8071
    super redrawVisibleLine:visLine from:startCol to:endCol.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8072
    self redrawCursorIfInVisibleLine:visLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8073
! !
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8074
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8075
!EditTextView methodsFor:'scrolling'!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8076
2331
218a017dc1f3 additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents: 2323
diff changeset
  8077
additionalMarginForHorizontalScroll
218a017dc1f3 additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents: 2323
diff changeset
  8078
    "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
  8079
     width of the document would allow.
218a017dc1f3 additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents: 2323
diff changeset
  8080
     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
  8081
     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
  8082
     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
  8083
4889
3ee5b37416a1 class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 4884
diff changeset
  8084
    ^ 10 max:gc font width
2331
218a017dc1f3 additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents: 2323
diff changeset
  8085
!
218a017dc1f3 additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents: 2323
diff changeset
  8086
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8087
halfPageDown
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8088
    "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
  8089
     within the real text  "
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8090
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8091
    |prevCursorLine|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8092
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8093
    prevCursorLine := cursorVisibleLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8094
    super halfPageDown.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8095
    self cursorVisibleLine:prevCursorLine col:cursorCol
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8096
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8097
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8098
halfPageUp
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8099
    "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
  8100
     within the real text  "
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8101
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8102
    |prevCursorLine|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8103
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8104
    prevCursorLine := cursorVisibleLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8105
    super halfPageUp.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8106
    self cursorVisibleLine:prevCursorLine col:cursorCol
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8107
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8108
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8109
originChanged:delta
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8110
    "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
  8111
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8112
    super originChanged:delta.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8113
    "
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8114
     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
  8115
    "
2422
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  8116
    self updateCursorVisibleLine.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8117
    prevCursorState ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8118
	self showCursor
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8119
    ]
1577
4e487247ad33 dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents: 1568
diff changeset
  8120
4e487247ad33 dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents: 1568
diff changeset
  8121
    "Modified: / 17.6.1998 / 16:13:24 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8122
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8123
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8124
originWillChange
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8125
    "sent before scrolling - have to hide the cursor"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8126
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8127
    prevCursorState := cursorShown.
1601
57dde4dfee7e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  8128
    "/ cursorShown := false.
1591
d84c117e71cc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1590
diff changeset
  8129
    cursorShown ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8130
	self hideCursor
1591
d84c117e71cc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1590
diff changeset
  8131
    ]
d84c117e71cc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1590
diff changeset
  8132
1601
57dde4dfee7e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  8133
    "Modified: / 6.7.1998 / 13:07:23 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8134
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8135
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8136
pageDown
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8137
    "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
  8138
     within the real text  "
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8139
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8140
    |prevCursorLine|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8141
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8142
    prevCursorLine := cursorVisibleLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8143
    super pageDown.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8144
    self cursorVisibleLine:prevCursorLine col:cursorCol
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8145
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8146
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8147
pageUp
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8148
    "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
  8149
     within the real text  "
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8150
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8151
    |prevCursorLine|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8152
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8153
    prevCursorLine := cursorVisibleLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8154
    super pageUp.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8155
    self cursorVisibleLine:prevCursorLine col:cursorCol
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8156
! !
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8157
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8158
!EditTextView methodsFor:'searching'!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8159
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8160
searchBwd:pattern ifAbsent:aBlock
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8161
    "do a backward search"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8162
2822
08ceab3fc237 search refactored;
Claus Gittinger <cg@exept.de>
parents: 2819
diff changeset
  8163
    self searchBwd:pattern ignoreCase:false ifAbsent:aBlock
1339
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  8164
!
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  8165
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  8166
searchBwd:pattern ignoreCase:ign ifAbsent:aBlock
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  8167
    "do a backward search"
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  8168
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  8169
    cursorLine isNil ifTrue:[^ self].
4464
bbdc850e9d93 search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents: 4458
diff changeset
  8170
    super searchBwd:pattern ignoreCase:ign ifAbsent:aBlock
3580
c9d10df2b8bc StringSearchTool
fm
parents: 3578
diff changeset
  8171
!
c9d10df2b8bc StringSearchTool
fm
parents: 3578
diff changeset
  8172
c9d10df2b8bc StringSearchTool
fm
parents: 3578
diff changeset
  8173
searchBwd:pattern ignoreCase:ign startingAtLine:startLine col:startCol ifAbsent:aBlock
c9d10df2b8bc StringSearchTool
fm
parents: 3578
diff changeset
  8174
    "do a backward search"
c9d10df2b8bc StringSearchTool
fm
parents: 3578
diff changeset
  8175
c9d10df2b8bc StringSearchTool
fm
parents: 3578
diff changeset
  8176
    cursorLine isNil ifTrue:[^ self].
c9d10df2b8bc StringSearchTool
fm
parents: 3578
diff changeset
  8177
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  8178
    self
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8179
	searchBackwardFor:pattern
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8180
	ignoreCase:ign
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8181
	startingAtLine:startLine col:startCol
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8182
	ifFound:[:line :col :endColOrNil |
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8183
	    self cursorMovementAllowed ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8184
		self cursorLine:line col:col.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8185
	    ].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8186
	    self showMatch:pattern isMatch:false atLine:line col:col endCol:endColOrNil.
1339
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  8187
"/            self makeLineVisible:cursorLine
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8188
	    typeOfSelection := #search]
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8189
	ifAbsent:aBlock
1339
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  8190
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  8191
    "Modified: 9.10.1997 / 13:02:13 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8192
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8193
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8194
searchForAndSelectMatchingParenthesis
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8195
    "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
  8196
2554
ec6aca20825f refactored
Claus Gittinger <cg@exept.de>
parents: 2544
diff changeset
  8197
    self searchForAndSelectMatchingParenthesisFromLine:cursorLine col:cursorCol
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8198
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8199
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8200
searchForMatchingParenthesis
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  8201
    "search for a matching parenthesis starting at cursor position.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  8202
     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
  8203
     backwards if its a closing parenthesis.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8204
     Positions the cursor if found, peeps if not"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8205
2822
08ceab3fc237 search refactored;
Claus Gittinger <cg@exept.de>
parents: 2819
diff changeset
  8206
    self cursorMovementAllowed ifFalse:[^ self].
08ceab3fc237 search refactored;
Claus Gittinger <cg@exept.de>
parents: 2819
diff changeset
  8207
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  8208
    self
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8209
	searchForMatchingParenthesisFromLine:cursorLine col:cursorCol
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8210
	ifFound:[:line :col | self cursorLine:line col:col]
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8211
	ifNotFound:[self showNotFound]
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8212
	onError:[self beep]
1339
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  8213
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  8214
    "Modified: 9.10.1997 / 12:56:30 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8215
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8216
3967
64bc48cd8e8b do not take search string from selection
fm
parents: 3963
diff changeset
  8217
searchFwd:pattern ignoreCase:ign match: match startingAtLine:startLine col:startCol ifAbsent:aBlock
1339
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  8218
    "do a forward search"
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  8219
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  8220
    cursorLine isNil ifTrue:[^ self].
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8221
    self
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8222
	searchForwardFor:pattern
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8223
	ignoreCase:ign
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8224
	match: match
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8225
	startingAtLine:startLine col:startCol
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8226
	ifFound:[:line :col :endColOrNil|
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8227
	    self cursorMovementAllowed ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8228
		self cursorLine:line col:col.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8229
	    ].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8230
	    self showMatch:pattern isMatch:match atLine:line col:col endCol:endColOrNil.
1339
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  8231
"/            self makeLineVisible:cursorLine
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8232
	    typeOfSelection := #search
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8233
	]
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8234
	ifAbsent:aBlock
1339
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  8235
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  8236
    "Modified: 9.10.1997 / 12:57:47 / cg"
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  8237
    "Created: 9.10.1997 / 13:01:12 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8238
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8239
3967
64bc48cd8e8b do not take search string from selection
fm
parents: 3963
diff changeset
  8240
searchFwd:pattern ignoreCase:ign startingAtLine:startLine col:startCol ifAbsent:aBlock
64bc48cd8e8b do not take search string from selection
fm
parents: 3963
diff changeset
  8241
    "do a forward search"
64bc48cd8e8b do not take search string from selection
fm
parents: 3963
diff changeset
  8242
64bc48cd8e8b do not take search string from selection
fm
parents: 3963
diff changeset
  8243
    self searchFwd:pattern ignoreCase:ign match: false startingAtLine:startLine col:startCol ifAbsent:aBlock
64bc48cd8e8b do not take search string from selection
fm
parents: 3963
diff changeset
  8244
!
64bc48cd8e8b do not take search string from selection
fm
parents: 3963
diff changeset
  8245
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8246
searchFwd:pattern startingAtLine:startLine col:startCol ifAbsent:aBlock
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8247
    "do a forward search"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8248
2822
08ceab3fc237 search refactored;
Claus Gittinger <cg@exept.de>
parents: 2819
diff changeset
  8249
    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
  8250
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8251
3982
79e6af2d27b1 fixes in searchBar
fm
parents: 3976
diff changeset
  8252
searchPatternForSearchBar
79e6af2d27b1 fixes in searchBar
fm
parents: 3976
diff changeset
  8253
79e6af2d27b1 fixes in searchBar
fm
parents: 3976
diff changeset
  8254
    "Returns the next searchPattern from the user selection or from the autoSearch"
79e6af2d27b1 fixes in searchBar
fm
parents: 3976
diff changeset
  8255
79e6af2d27b1 fixes in searchBar
fm
parents: 3976
diff changeset
  8256
    |searchPattern|
79e6af2d27b1 fixes in searchBar
fm
parents: 3976
diff changeset
  8257
4138
fm
parents: 4136
diff changeset
  8258
    searchPattern := self searchPatternFromUserSelectionOrReplace.
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8259
    searchPattern isNil
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8260
	ifTrue: [searchPattern := lastSearchPattern]
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8261
	ifFalse: [lastSearchPattern := searchPattern].
3982
79e6af2d27b1 fixes in searchBar
fm
parents: 3976
diff changeset
  8262
    ^ searchPattern
79e6af2d27b1 fixes in searchBar
fm
parents: 3976
diff changeset
  8263
!
79e6af2d27b1 fixes in searchBar
fm
parents: 3976
diff changeset
  8264
3578
9d43beca1e85 searchForward with match argument
fm
parents: 3572
diff changeset
  8265
setSearchPatternWithMatchEscapes: match
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8266
    "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
  8267
     cursor to start of pattern"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8268
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8269
    |sel|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8270
559
3ff87e9447c6 keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents: 522
diff changeset
  8271
    "/
3967
64bc48cd8e8b do not take search string from selection
fm
parents: 3963
diff changeset
  8272
    "/ if the last operation was a replace, set pattern to last
559
3ff87e9447c6 keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents: 522
diff changeset
  8273
    "/ original string (for search after again)
4121
9232089c04c2 comment/format in: #setSearchPatternWithMatchEscapes:
fm
parents: 4119
diff changeset
  8274
    "/ for cut or delete actions allow lastReplacement with nil
559
3ff87e9447c6 keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents: 522
diff changeset
  8275
    "/
4249
44daffb1b034 comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents: 4248
diff changeset
  8276
"/    (lastStringFromReplaceForNextSearch notNil
44daffb1b034 comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents: 4248
diff changeset
  8277
"/     and:[typeOfSelection ~~ #search]) ifTrue:[
44daffb1b034 comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents: 4248
diff changeset
  8278
"/        lastStringFromReplaceForNextSearch isString ifTrue:[
44daffb1b034 comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents: 4248
diff changeset
  8279
"/            lastSearchPattern := lastStringFromReplaceForNextSearch.
44daffb1b034 comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents: 4248
diff changeset
  8280
"/        ] ifFalse:[
44daffb1b034 comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents: 4248
diff changeset
  8281
"/            lastSearchPattern := lastStringFromReplaceForNextSearch asStringWithoutFinalCR.
44daffb1b034 comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents: 4248
diff changeset
  8282
"/        ].
44daffb1b034 comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents: 4248
diff changeset
  8283
"/        ^ self
44daffb1b034 comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents: 4248
diff changeset
  8284
"/    ].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8285
559
3ff87e9447c6 keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents: 522
diff changeset
  8286
    "/
3ff87e9447c6 keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents: 522
diff changeset
  8287
    "/ if there is a selection:
3ff87e9447c6 keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents: 522
diff changeset
  8288
    "/    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
  8289
    "/    if there was a previous search, only take the selection if
3967
64bc48cd8e8b do not take search string from selection
fm
parents: 3963
diff changeset
  8290
    "/    it did not result from a paste or from the last search itself.
559
3ff87e9447c6 keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents: 522
diff changeset
  8291
    "/    (to allow search-paste to be repeated)
3ff87e9447c6 keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents: 522
diff changeset
  8292
    "/
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8293
    sel := self selection.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8294
    sel notNil ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8295
	(lastSearchPattern isNil
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8296
	or:[typeOfSelection ~~ #paste and:[typeOfSelection ~~ #search]]
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8297
	) ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8298
	    self cursorLine:selectionStartLine col:selectionStartCol.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8299
	    lastSearchPattern := sel asStringWithoutFinalCR.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8300
	    match ifTrue:[lastSearchPattern := lastSearchPattern withMatchEscapes].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8301
	]
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8302
    ]
559
3ff87e9447c6 keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents: 522
diff changeset
  8303
4249
44daffb1b034 comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents: 4248
diff changeset
  8304
    "Modified: / 07-05-2011 / 17:25:59 / cg"
2756
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
  8305
!
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
  8306
5717
94a8cc3be8ec #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 5710
diff changeset
  8307
showMatch:pattern isMatch:isMatch atLine:line col:col endCol:encColOrNil
94a8cc3be8ec #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 5710
diff changeset
  8308
    super showMatch:pattern isMatch:isMatch atLine:line col:col endCol:encColOrNil.
4484
38f88010834c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4483
diff changeset
  8309
    typeOfSelection := #search.
38f88010834c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4483
diff changeset
  8310
!
38f88010834c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4483
diff changeset
  8311
2756
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
  8312
startPositionForSearchBackward
2822
08ceab3fc237 search refactored;
Claus Gittinger <cg@exept.de>
parents: 2819
diff changeset
  8313
    ^ self startPositionForSearchBackwardBasedOnCursorOrSelection
08ceab3fc237 search refactored;
Claus Gittinger <cg@exept.de>
parents: 2819
diff changeset
  8314
!
08ceab3fc237 search refactored;
Claus Gittinger <cg@exept.de>
parents: 2819
diff changeset
  8315
08ceab3fc237 search refactored;
Claus Gittinger <cg@exept.de>
parents: 2819
diff changeset
  8316
startPositionForSearchBackwardBasedOnCursorOrSelection
2756
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
  8317
    |startLine startCol|
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
  8318
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
  8319
    selectionStartLine notNil ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8320
	startLine := selectionStartLine.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8321
	startCol := selectionStartCol
2756
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
  8322
    ] ifFalse:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8323
	cursorLine isNil ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8324
	    startLine := list size.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8325
	    startCol := self listAt:startLine size.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8326
	] ifFalse:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8327
	    startLine := cursorLine min:list size.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8328
	    startCol := cursorCol
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8329
	]
2756
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
  8330
    ].
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
  8331
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
  8332
    ^ startCol @ cursorLine
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
  8333
!
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
  8334
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
  8335
startPositionForSearchForward
2822
08ceab3fc237 search refactored;
Claus Gittinger <cg@exept.de>
parents: 2819
diff changeset
  8336
    ^ self startPositionForSearchForwardBasedOnCursorOrSelection
08ceab3fc237 search refactored;
Claus Gittinger <cg@exept.de>
parents: 2819
diff changeset
  8337
!
08ceab3fc237 search refactored;
Claus Gittinger <cg@exept.de>
parents: 2819
diff changeset
  8338
08ceab3fc237 search refactored;
Claus Gittinger <cg@exept.de>
parents: 2819
diff changeset
  8339
startPositionForSearchForwardBasedOnCursorOrSelection
2756
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
  8340
    |startCol|
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
  8341
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  8342
    "/ 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
  8343
    "/ 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
  8344
    startCol := cursorCol.
4424
b38e9e3b483b changed: #startPositionForSearchForwardBasedOnCursorOrSelection
Claus Gittinger <cg@exept.de>
parents: 4421
diff changeset
  8345
    self hasSelection ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8346
	^ selectionEndCol @ selectionEndLine.
4424
b38e9e3b483b changed: #startPositionForSearchForwardBasedOnCursorOrSelection
Claus Gittinger <cg@exept.de>
parents: 4421
diff changeset
  8347
    ] ifFalse:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8348
	(cursorLine == 1 and:[cursorCol == 1]) ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8349
	    startCol := 0
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8350
	].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8351
	startCol := startCol min:(self at:cursorLine) size
2756
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
  8352
    ].
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
  8353
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
  8354
    ^ startCol @ cursorLine
4424
b38e9e3b483b changed: #startPositionForSearchForwardBasedOnCursorOrSelection
Claus Gittinger <cg@exept.de>
parents: 4421
diff changeset
  8355
b38e9e3b483b changed: #startPositionForSearchForwardBasedOnCursorOrSelection
Claus Gittinger <cg@exept.de>
parents: 4421
diff changeset
  8356
    "Modified (format): / 24-05-2012 / 13:58:37 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8357
! !
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8358
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8359
!EditTextView methodsFor:'selections'!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8360
3023
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  8361
addToSelectionAfter:aBlock
5145
b87b83495631 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5142
diff changeset
  8362
    <resource: #obsolete>
b87b83495631 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5142
diff changeset
  8363
b87b83495631 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5142
diff changeset
  8364
    "evaluate aBlock while unselected.
b87b83495631 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5142
diff changeset
  8365
     Restore the previous selection afterwards.
b87b83495631 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5142
diff changeset
  8366
     CG: I am not sure, if this is a leftover and is still used at all.
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8367
	 It is therefore temporarily marked as obsolete. Please check
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8368
	 and let me know."
3023
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  8369
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  8370
    |startLine startCol endLine endCol |
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  8371
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  8372
    self hasSelection ifTrue: [
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8373
	startLine := selectionStartLine .
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8374
	startCol := selectionStartCol .
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8375
	endLine := selectionEndLine .
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8376
	endCol := selectionEndCol .
3023
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  8377
    ] ifFalse: [
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8378
	startLine := endLine :=  cursorLine .
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8379
	startCol := endCol := cursorCol .
3023
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  8380
    ].
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  8381
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  8382
    "deselectim a provedu presun kurzoru..."
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  8383
    self unselect .
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  8384
    aBlock value .
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  8385
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  8386
    "funguje dost mizerne, jen na jednom radku..."
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  8387
    (startCol - cursorCol) abs <= (endCol - cursorCol) abs
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8388
	ifTrue: [
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8389
	    startCol := cursorCol.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8390
	] ifFalse: [
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8391
	    endCol := cursorCol - 1.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8392
	].
3023
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  8393
    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
  8394
!
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  8395
1850
82516928e791 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1849
diff changeset
  8396
autoMoveCursorToEndOfSelection
82516928e791 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1849
diff changeset
  8397
    "return true, if the cursor should be automatically moved to the
82516928e791 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1849
diff changeset
  8398
     end of a selection.
3963
c315f087d655 comment in: #autoMoveCursorToEndOfSelection
Claus Gittinger <cg@exept.de>
parents: 3945
diff changeset
  8399
     Redefined to return false in terminalViews, where the cursor should
1850
82516928e791 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1849
diff changeset
  8400
     not be affected by selecting"
82516928e791 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1849
diff changeset
  8401
82516928e791 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1849
diff changeset
  8402
    ^ true
82516928e791 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1849
diff changeset
  8403
!
82516928e791 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1849
diff changeset
  8404
2606
6a3ab90d339f redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents: 2599
diff changeset
  8405
changeTypeOfSelectionTo:newType
6a3ab90d339f redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents: 2599
diff changeset
  8406
    typeOfSelection ~~ newType ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8407
	typeOfSelection := newType.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8408
	selectionStartLine notNil ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8409
	    self
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8410
		redrawFromLine:selectionStartLine col:selectionStartCol
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8411
		toLine:selectionEndLine col:selectionEndCol
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8412
	].
2606
6a3ab90d339f redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents: 2599
diff changeset
  8413
    ].
6a3ab90d339f redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents: 2599
diff changeset
  8414
!
6a3ab90d339f redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents: 2599
diff changeset
  8415
4707
f6ac835a1cf6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4701
diff changeset
  8416
findNextWordAfterSelectionAndAddToSelection
f6ac835a1cf6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4701
diff changeset
  8417
    |selStartCol selStartLine selEndCol selEndLine|
f6ac835a1cf6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4701
diff changeset
  8418
f6ac835a1cf6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4701
diff changeset
  8419
    selectionStartCol isNil ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8420
	self selectWordUnderCursor.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8421
	^ self
4707
f6ac835a1cf6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4701
diff changeset
  8422
    ].
f6ac835a1cf6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4701
diff changeset
  8423
f6ac835a1cf6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4701
diff changeset
  8424
    selStartCol := selectionStartCol.
f6ac835a1cf6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4701
diff changeset
  8425
    selEndCol := selectionEndCol.
f6ac835a1cf6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4701
diff changeset
  8426
    selStartLine := selectionStartLine.
f6ac835a1cf6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4701
diff changeset
  8427
    selEndLine := selectionEndLine.
f6ac835a1cf6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4701
diff changeset
  8428
f6ac835a1cf6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4701
diff changeset
  8429
    self cursorToNextWord.
f6ac835a1cf6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4701
diff changeset
  8430
    self selectWordUnderCursor.
f6ac835a1cf6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4701
diff changeset
  8431
f6ac835a1cf6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4701
diff changeset
  8432
    self selectFromLine:selStartLine col:selStartCol toLine:selectionEndLine col:selectionEndCol.
f6ac835a1cf6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4701
diff changeset
  8433
!
f6ac835a1cf6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4701
diff changeset
  8434
4138
fm
parents: 4136
diff changeset
  8435
searchPatternFromUserSelectionOrReplace
fm
parents: 4136
diff changeset
  8436
fm
parents: 4136
diff changeset
  8437
    |sel searchPattern|
fm
parents: 4136
diff changeset
  8438
fm
parents: 4136
diff changeset
  8439
    "/
fm
parents: 4136
diff changeset
  8440
    "/ if the last operation was a replace, set pattern to last
fm
parents: 4136
diff changeset
  8441
    "/ original string (for search after again)
fm
parents: 4136
diff changeset
  8442
    "/
fm
parents: 4136
diff changeset
  8443
    (lastStringFromReplaceForNextSearch notNil
fm
parents: 4136
diff changeset
  8444
     and:[typeOfSelection ~~ #search]) ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8445
	lastStringFromReplaceForNextSearch isString ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8446
	    searchPattern := lastStringFromReplaceForNextSearch.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8447
	] ifFalse:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8448
	    searchPattern := lastStringFromReplaceForNextSearch asStringWithoutFinalCR.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8449
	].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8450
	^ searchPattern
4138
fm
parents: 4136
diff changeset
  8451
    ].
fm
parents: 4136
diff changeset
  8452
fm
parents: 4136
diff changeset
  8453
    "/
fm
parents: 4136
diff changeset
  8454
    "/ if there is a selection:
fm
parents: 4136
diff changeset
  8455
    "/    if there was no previous search, take it as search pattern.
fm
parents: 4136
diff changeset
  8456
    "/    if there was a previous search, only take the selection if
fm
parents: 4136
diff changeset
  8457
    "/    it did not result from a paste.
fm
parents: 4136
diff changeset
  8458
    "/    (to allow search-paste to be repeated)
fm
parents: 4136
diff changeset
  8459
    "/
fm
parents: 4136
diff changeset
  8460
    sel := self selection.
fm
parents: 4136
diff changeset
  8461
    sel notNil ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8462
	typeOfSelection ~~ #search ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8463
	    typeOfSelection ~~ #paste ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8464
		self cursorLine:selectionStartLine col:selectionStartCol.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8465
		searchPattern := sel asStringWithoutFinalCR.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8466
	    ]
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8467
	].
4138
fm
parents: 4136
diff changeset
  8468
    ].
fm
parents: 4136
diff changeset
  8469
fm
parents: 4136
diff changeset
  8470
    ^ searchPattern
fm
parents: 4136
diff changeset
  8471
!
fm
parents: 4136
diff changeset
  8472
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8473
selectAll
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8474
    "select the whole text.
5593
ad41e448d7a8 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 5581
diff changeset
  8475
     redefined to send super selectFrom... since we don't want the
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8476
     cursor to be moved in this case."
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8477
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8478
    list isNil ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8479
	self unselect
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8480
    ] ifFalse:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8481
	super selectFromLine:1 col:1 toLine:(list size + 1) col:0.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8482
	typeOfSelection := nil
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8483
    ]
1082
ccc3aa4268c1 better #selectAll
Claus Gittinger <cg@exept.de>
parents: 1054
diff changeset
  8484
ccc3aa4268c1 better #selectAll
Claus Gittinger <cg@exept.de>
parents: 1054
diff changeset
  8485
    "Modified: 28.2.1997 / 19:14:54 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8486
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8487
4117
470a3086aaa9 added: #selectAllInitially
sr
parents: 4114
diff changeset
  8488
selectAllInitially
470a3086aaa9 added: #selectAllInitially
sr
parents: 4114
diff changeset
  8489
    "select the whole text. This is called only once during the initialization
470a3086aaa9 added: #selectAllInitially
sr
parents: 4114
diff changeset
  8490
     for editFields which are shown in a table or tree.
470a3086aaa9 added: #selectAllInitially
sr
parents: 4114
diff changeset
  8491
     The selectAll is called via this method to allow for easier redefinition and
470a3086aaa9 added: #selectAllInitially
sr
parents: 4114
diff changeset
  8492
     to distinguish auto-select from user-initiated selects."
470a3086aaa9 added: #selectAllInitially
sr
parents: 4114
diff changeset
  8493
470a3086aaa9 added: #selectAllInitially
sr
parents: 4114
diff changeset
  8494
    self selectAll
470a3086aaa9 added: #selectAllInitially
sr
parents: 4114
diff changeset
  8495
!
470a3086aaa9 added: #selectAllInitially
sr
parents: 4114
diff changeset
  8496
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8497
selectCursorLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8498
    "select cursorline"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8499
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  8500
    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
  8501
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8502
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8503
selectCursorLineFromBeginning
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8504
    "select cursorline up to cursor position"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8505
823
fc61564f7832 escape selects up to previous character
Claus Gittinger <cg@exept.de>
parents: 785
diff changeset
  8506
    cursorCol > 1 ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8507
	self selectFromLine:cursorLine col:1
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8508
		     toLine:cursorLine col:(cursorCol-1)
823
fc61564f7832 escape selects up to previous character
Claus Gittinger <cg@exept.de>
parents: 785
diff changeset
  8509
    ]
fc61564f7832 escape selects up to previous character
Claus Gittinger <cg@exept.de>
parents: 785
diff changeset
  8510
fc61564f7832 escape selects up to previous character
Claus Gittinger <cg@exept.de>
parents: 785
diff changeset
  8511
    "Modified: 16.8.1996 / 19:14:14 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8512
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8513
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8514
selectExpandCursorLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8515
    "expand selection by one line or select cursorline"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8516
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8517
    selectionStartLine isNil ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8518
	self selectCursorLine
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8519
    ] ifFalse:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8520
	self selectFromLine:selectionStartLine col:selectionStartCol
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8521
		     toLine:cursorLine+1 col:0.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8522
	self makeLineVisible:selectionEndLine
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8523
    ]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8524
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8525
4257
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  8526
selectFromBeginOfLine
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  8527
    "select the text from the beginning of the current line to the current cursor position."
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  8528
4430
61c074a935cf fixed: #selectFromBeginOfLine
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4424
diff changeset
  8529
    | newCursorCol ln |
4271
3ce604308987 changed:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4258
diff changeset
  8530
4257
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  8531
    list isNil ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8532
	self unselect
4257
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  8533
    ] ifFalse:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8534
	cursorCol > 1 ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8535
	    ln := list at: cursorLine.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8536
	    newCursorCol := ln notEmptyOrNil ifTrue:[ln indexOfNonSeparator] ifFalse:[1].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8537
	    self selectFromLine:cursorLine col:newCursorCol toLine:cursorLine col:cursorCol-1.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8538
	    cursorCol := newCursorCol.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8539
	    typeOfSelection := nil
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8540
	]
4257
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  8541
    ]
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  8542
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  8543
    "Created: / 28-06-2011 / 22:47:04 / cg"
4430
61c074a935cf fixed: #selectFromBeginOfLine
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4424
diff changeset
  8544
    "Modified: / 18-07-2012 / 17:00:26 / Jan Vrany <jan.vrany@fit.cvut.cz>"
4257
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  8545
!
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  8546
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8547
selectFromBeginning
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8548
    "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
  8549
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8550
    |col|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8551
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8552
    list isNil ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8553
	self unselect
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8554
    ] ifFalse:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8555
	cursorCol == 0 ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8556
	    col := 0
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8557
	] ifFalse:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8558
	    col := cursorCol - 1
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8559
	].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8560
	super selectFromLine:1 col:1 toLine:cursorLine col:col.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8561
	typeOfSelection := nil
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8562
    ]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8563
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8564
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8565
selectFromLine:startLine col:startCol toLine:endLine col:endCol
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8566
    "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
  8567
     for easier editing. Also typeOfSelection is nilled here."
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8568
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8569
    super selectFromLine:startLine col:startCol toLine:endLine col:endCol.
1850
82516928e791 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1849
diff changeset
  8570
    (selectionEndLine notNil and:[self autoMoveCursorToEndOfSelection]) ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8571
	self cursorLine:selectionEndLine col:(selectionEndCol + 1).
1198
1c5390d2d3fb care for failed selection when positioning cursor.
ca
parents: 1177
diff changeset
  8572
    ].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8573
    typeOfSelection := nil
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8574
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8575
4257
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  8576
selectToEndOfLine
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  8577
    "select the text from the current cursor position to the end of the current line"
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  8578
4271
3ce604308987 changed:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4258
diff changeset
  8579
    | newCursorCol line |
3ce604308987 changed:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4258
diff changeset
  8580
4257
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  8581
    list isNil ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8582
	self unselect
4257
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  8583
    ] ifFalse:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8584
	cursorCol >= 1 ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8585
	    line := list at: cursorLine.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8586
	    newCursorCol := line size.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8587
	    [ newCursorCol > 1 and:[(line at:newCursorCol) isSeparator] ]
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8588
		whileTrue:[newCursorCol := newCursorCol - 1].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8589
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8590
	    self selectFromLine:cursorLine col:cursorCol toLine:cursorLine col: newCursorCol.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8591
	    cursorCol := newCursorCol.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8592
	    typeOfSelection := nil
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8593
	]
4257
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  8594
    ]
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  8595
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  8596
    "Created: / 28-06-2011 / 23:07:07 / cg"
4275
16c80f32c06c bug fix in #selectToEndOfLine
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4271
diff changeset
  8597
    "Modified: / 30-06-2011 / 19:51:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
4257
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  8598
!
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  8599
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8600
selectUpToEnd
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8601
    "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
  8602
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8603
    list isNil ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8604
	self unselect
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8605
    ] ifFalse:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8606
	super selectFromLine:cursorLine col:cursorCol toLine:(list size + 1) col:0.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8607
	typeOfSelection := nil
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8608
    ]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8609
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8610
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8611
selectWordUnderCursor
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8612
    "select the word under the cursor"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8613
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8614
    self selectWordAtLine:cursorLine col:cursorCol
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8615
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8616
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8617
unselect
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8618
    "forget and unhilight selection - must take care of cursor here"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8619
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8620
    |wasOn|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8621
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8622
    wasOn := self hideCursor.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8623
    super unselect.
2606
6a3ab90d339f redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents: 2599
diff changeset
  8624
    typeOfSelection := nil.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8625
    wasOn ifTrue:[self showCursor]
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  8626
! !
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  8627
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  8628
!EditTextView methodsFor:'undo & again'!
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  8629
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  8630
addUndo:action
2989
5dcc2912bcb6 undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents: 2984
diff changeset
  8631
    ^ undoSupport addUndo:action.
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  8632
!
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  8633
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  8634
again
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  8635
    "repeat the last action (which was a cut or replace).
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  8636
     If current selection is not last string, search forward to
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  8637
     next occurrence of it before repeating the last operation."
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  8638
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8639
    |s l c sel savedSelectStyle startColForSearch
4051
4fdd00fbdc60 changed:
fm
parents: 4048
diff changeset
  8640
     lastStringToReplace lastReplaceIgnoredCase lastReplaceWasMatch|
4048
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
  8641
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
  8642
    lastStringToReplace := lastReplacementInfo lastStringToReplace.
4010
9c22bd531240 lastStringToReplace to use in again
fm
parents: 3996
diff changeset
  8643
    lastStringToReplace isNil ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8644
	^ false
2579
74d3798f4200 do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents: 2574
diff changeset
  8645
    ].
4048
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
  8646
    lastReplaceIgnoredCase := lastReplacementInfo lastReplaceIgnoredCase.
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
  8647
    lastReplaceWasMatch := lastReplacementInfo lastReplaceWasMatch.
2579
74d3798f4200 do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents: 2574
diff changeset
  8648
3127
29767bf8a215 better info of replace action (compound-undo-action has info, too)
Claus Gittinger <cg@exept.de>
parents: 3115
diff changeset
  8649
    self undoableDo:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8650
	s := lastStringToReplace asString.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8651
	"remove final cr"
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8652
	(s endsWith:Character cr) ifTrue:[s := s copyButLast:1].
3127
29767bf8a215 better info of replace action (compound-undo-action has info, too)
Claus Gittinger <cg@exept.de>
parents: 3115
diff changeset
  8653
    "/        s := s withoutSpaces.        "XXX - replacing text with spaces ..."
4010
9c22bd531240 lastStringToReplace to use in again
fm
parents: 3996
diff changeset
  8654
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8655
	"set lastStringToReplace as the next search string
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8656
	 and set lastReplaceIgnoredCase as the next search ignored case flag"
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8657
	lastStringFromReplaceForNextSearch := s.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8658
	lastSearchIgnoredCase := lastReplaceIgnoredCase.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8659
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8660
	savedSelectStyle := selectStyle.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8661
	selectStyle := nil.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8662
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8663
	sel := self selection.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8664
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8665
	"if we are already there (after a find), ommit search"
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8666
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8667
	(sel notNil and:[sel asString withoutSeparators = s]) ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8668
	    l := selectionStartLine "cursorLine".
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8669
	    c := selectionStartCol "cursorCol".
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8670
	    self deleteSelection.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8671
	    lastReplacementInfo lastReplacement notNil ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8672
		self insertLines:lastReplacementInfo lastReplacement asStringCollection withCR:false.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8673
		self selectFromLine:l col:c toLine:cursorLine col:(cursorCol - 1).
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8674
		typeOfSelection := #paste
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8675
	    ].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8676
	    selectStyle := savedSelectStyle.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8677
	    ^ true
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8678
	].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8679
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8680
	sel isEmptyOrNil ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8681
	    startColForSearch := cursorCol - 1
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8682
	] ifFalse:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8683
	    startColForSearch := selectionEndCol ? (cursorCol - 1)
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8684
	].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8685
	self
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8686
	    searchForwardFor:s
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8687
	    ignoreCase: lastReplaceIgnoredCase
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8688
	    match: lastReplaceWasMatch
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8689
	    startingAtLine:cursorLine col:startColForSearch
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8690
	    ifFound:
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8691
		[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8692
		    :line :col |
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8693
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8694
		    |repl|
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8695
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8696
		    self selectFromLine:line col:col
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8697
				 toLine:line col:(col + s size - 1).
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8698
		    self makeLineVisible:line.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8699
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8700
		    self deleteSelection.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8701
		    lastReplacementInfo lastReplacement notNil ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8702
			lastReplacementInfo lastReplacement isString ifFalse:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8703
			    repl := lastReplacementInfo lastReplacement asString "withoutSpaces"
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8704
			] ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8705
			    repl := lastReplacementInfo lastReplacement "withoutSpaces".
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8706
			].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8707
			self insertLines:repl asStringCollection withCR:false.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8708
			self selectFromLine:line col:col toLine:cursorLine col:(cursorCol - 1).
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8709
			undoSupport actionInfo:'replace'.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8710
		    ].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8711
		    selectStyle := savedSelectStyle.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8712
		    typeOfSelection := #paste.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8713
		    ^ true
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8714
		]
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8715
	    ifAbsent:
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8716
		[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8717
		    self sensor compressKeyPressEventsWithKey:#Again.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8718
		    self showNotFound.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8719
		    selectStyle := savedSelectStyle.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8720
		    ^ false
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8721
		].
3127
29767bf8a215 better info of replace action (compound-undo-action has info, too)
Claus Gittinger <cg@exept.de>
parents: 3115
diff changeset
  8722
    ].
2730
61a2f1981ac6 Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents: 2725
diff changeset
  8723
61a2f1981ac6 Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents: 2725
diff changeset
  8724
    ^ true.
501
13fc7b9ce5cb fixed (?) again-replace
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  8725
840
b0071cea13fd fixed Again when spaces are replaced
Claus Gittinger <cg@exept.de>
parents: 828
diff changeset
  8726
    "Modified: 9.10.1996 / 16:14:11 / cg"
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  8727
!
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  8728
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  8729
hasRedoAction
2989
5dcc2912bcb6 undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents: 2984
diff changeset
  8730
    ^ undoSupport hasRedoAction.
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  8731
!
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  8732
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  8733
hasUndoAction
2989
5dcc2912bcb6 undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents: 2984
diff changeset
  8734
    ^ undoSupport hasUndoAction.
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  8735
!
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  8736
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8737
multipleAgain
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8738
    "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
  8739
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8740
    [self again] whileTrue:[]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8741
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8742
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  8743
nonUndoableDo:aBlock
2989
5dcc2912bcb6 undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents: 2984
diff changeset
  8744
    undoSupport nonUndoableDo:aBlock.
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  8745
!
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  8746
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  8747
redo
3780
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  8748
    "undo the last undo"
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  8749
2989
5dcc2912bcb6 undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents: 2984
diff changeset
  8750
    undoSupport hasRedoAction ifFalse:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8751
	self beep
2989
5dcc2912bcb6 undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents: 2984
diff changeset
  8752
    ] ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8753
	undoSupport redo.
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  8754
    ]
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  8755
!
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  8756
121
claus
parents: 118
diff changeset
  8757
undo
3780
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  8758
    "undo the last edit operation"
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  8759
2989
5dcc2912bcb6 undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents: 2984
diff changeset
  8760
    undoSupport hasUndoAction ifFalse:[
5834
60d6d5a839d3 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5833
diff changeset
  8761
        self beep
2989
5dcc2912bcb6 undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents: 2984
diff changeset
  8762
    ] ifTrue:[
5834
60d6d5a839d3 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5833
diff changeset
  8763
        undoSupport undo.
60d6d5a839d3 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5833
diff changeset
  8764
        self makeSelectionVisible.
60d6d5a839d3 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5833
diff changeset
  8765
        self makeCursorVisible.
121
claus
parents: 118
diff changeset
  8766
    ]
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  8767
!
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  8768
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  8769
undoableDo:aBlock
3495
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  8770
    self undoableDo:aBlock info:nil.
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  8771
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  8772
    "Modified: / 28-07-2007 / 13:20:14 / cg"
3130
c0f39f9f28d6 undoable keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3127
diff changeset
  8773
!
c0f39f9f28d6 undoable keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3127
diff changeset
  8774
c0f39f9f28d6 undoable keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3127
diff changeset
  8775
undoableDo:aBlock info:aString
5689
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  8776
    |selectionRestore|
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  8777
3154
42bf7ebd54c8 refadctored intention revealing code:
Claus Gittinger <cg@exept.de>
parents: 3150
diff changeset
  8778
    self checkModificationsAllowed ifFalse:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8779
	"/ will trigger an error-dialog there (no need for undo-carekeeping)
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8780
	aBlock value.
3154
42bf7ebd54c8 refadctored intention revealing code:
Claus Gittinger <cg@exept.de>
parents: 3150
diff changeset
  8781
    ] ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8782
	undoSupport isInTransaction ifFalse:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8783
	    selectionRestore := RestoreSelectionAndCursor new
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8784
				    cursorLine:cursorLine cursorCol:cursorCol
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8785
				    selectionStartLine:selectionStartLine selectionStartCol:selectionStartCol
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8786
				    selectionEndLine:selectionEndLine selectionEndCol:selectionEndCol
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8787
				    info:nil.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8788
	].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8789
	undoSupport
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8790
	    undoableDo:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8791
		aBlock value.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8792
		selectionRestore notNil ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8793
		    undoSupport transactionNotEmpty ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8794
			undoSupport addUndoFirst:selectionRestore
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8795
		    ].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8796
		].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8797
	    ]
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8798
	    info:aString.
5689
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  8799
    ].
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  8800
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  8801
    "Modified: / 30-04-2016 / 21:08:30 / cg"
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  8802
! !
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  8803
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  8804
!EditTextView::EditAction class methodsFor:'instance creation'!
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  8805
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  8806
line1:arg1 col1:arg2 line2:arg3 col2:arg4
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  8807
    ^ self new line1:arg1 col1:arg2 line2:arg3 col2:arg4
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  8808
!
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  8809
3115
b75128334006 info string in undo
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
  8810
line1:arg1 col1:arg2 line2:arg3 col2:arg4 info:info
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  8811
    ^ (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
  8812
!
b75128334006 info string in undo
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
  8813
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  8814
line:arg1 col:arg2 character:arg3
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  8815
    ^ self new line:arg1 col:arg2 character:arg3
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  8816
!
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  8817
3115
b75128334006 info string in undo
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
  8818
line:arg1 col:arg2 character:arg3 info:info
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  8819
    ^ (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
  8820
!
b75128334006 info string in undo
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
  8821
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  8822
line:arg1 col:arg2 characters:arg3 info:info
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  8823
    ^ (self new line:arg1 col:arg2 characters:arg3) info:info
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  8824
!
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  8825
3156
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  8826
line:arg1 col:arg2 info:arg3
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  8827
    ^ self new line:arg1 col:arg2 info:arg3
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  8828
!
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  8829
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  8830
line:arg1 col:arg2 string:arg3
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  8831
    ^ self new line:arg1 col:arg2 string:arg3
3115
b75128334006 info string in undo
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
  8832
!
b75128334006 info string in undo
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
  8833
b75128334006 info string in undo
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
  8834
line:arg1 col:arg2 string:arg3 info:info
b75128334006 info string in undo
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
  8835
    ^ (self new line:arg1 col:arg2 string:arg3) info:info
3130
c0f39f9f28d6 undoable keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3127
diff changeset
  8836
!
c0f39f9f28d6 undoable keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3127
diff changeset
  8837
c0f39f9f28d6 undoable keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3127
diff changeset
  8838
line:arg1 string:arg3 info:info
c0f39f9f28d6 undoable keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3127
diff changeset
  8839
    ^ (self new line:arg1 string:arg3) info:info
3131
8f21dba07d24 undoable format
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
  8840
!
8f21dba07d24 undoable format
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
  8841
8f21dba07d24 undoable format
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
  8842
text:arg info:info
8f21dba07d24 undoable format
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
  8843
    ^ (self new text:arg) info:info
3115
b75128334006 info string in undo
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
  8844
! !
b75128334006 info string in undo
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
  8845
b75128334006 info string in undo
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
  8846
!EditTextView::EditAction methodsFor:'accessing'!
b75128334006 info string in undo
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
  8847
b75128334006 info string in undo
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
  8848
info
b75128334006 info string in undo
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
  8849
    ^ userFriendlyInfo
b75128334006 info string in undo
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
  8850
!
b75128334006 info string in undo
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
  8851
b75128334006 info string in undo
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
  8852
info:aString
b75128334006 info string in undo
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
  8853
    userFriendlyInfo := aString
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  8854
! !
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  8855
3400
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  8856
!EditTextView::EditAction methodsFor:'combining'!
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  8857
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  8858
canCombineWithPreviousPasteStringAction: aPasteStringAction
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  8859
    ^ false.
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  8860
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  8861
    "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
  8862
! !
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  8863
3156
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  8864
!EditTextView::EditAction methodsFor:'queries'!
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  8865
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  8866
canCombineWithNext:nextAction
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  8867
    ^ false
5710
7757eb8d4d3e #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5689
diff changeset
  8868
!
7757eb8d4d3e #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5689
diff changeset
  8869
7757eb8d4d3e #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5689
diff changeset
  8870
isRestoreSelectionAndCursor
7757eb8d4d3e #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5689
diff changeset
  8871
    ^ false
3156
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  8872
! !
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  8873
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  8874
!EditTextView::DeleteRange methodsFor:'accessing'!
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  8875
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  8876
line1:line1Arg col1:col1Arg line2:line2Arg col2:col2Arg
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  8877
    "set instance variables (automatically generated)"
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  8878
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  8879
    self assert:(line1Arg notNil).
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  8880
    self assert:(col1Arg notNil).
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  8881
    self assert:(line2Arg notNil).
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  8882
    self assert:(col2Arg notNil).
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  8883
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  8884
    line1 := line1Arg.
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  8885
    col1 := col1Arg.
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  8886
    line2 := line2Arg.
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  8887
    col2 := col2Arg.
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  8888
! !
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  8889
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  8890
!EditTextView::DeleteRange methodsFor:'execution'!
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  8891
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  8892
executeIn:editor
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  8893
    editor unselect.
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  8894
    editor
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8895
	deleteFromLine:line1
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8896
	col:col1
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8897
	toLine:line2
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8898
	col:col2.
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  8899
    editor cursorLine:line1 col:col1.
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  8900
! !
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  8901
3156
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  8902
!EditTextView::DeleteCharacters methodsFor:'accessing'!
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  8903
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  8904
col1
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  8905
    ^ col1
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  8906
!
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  8907
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  8908
col2
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  8909
    ^ col2
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  8910
!
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  8911
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  8912
line
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  8913
    ^ line
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  8914
!
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  8915
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  8916
line:lineArg col1:col1Arg col2:col2Arg
3156
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  8917
    "set instance variables (automatically generated)"
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  8918
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  8919
    self assert:(lineArg notNil).
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  8920
    self assert:(col1Arg notNil).
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  8921
    self assert:(col2Arg notNil).
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  8922
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  8923
    line := lineArg.
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  8924
    col1 := col1Arg.
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  8925
    col2 := col2Arg.
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  8926
!
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  8927
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  8928
line:lineArg col:colArg info:infoArg
3156
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  8929
    self assert:(lineArg notNil).
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  8930
    self assert:(colArg notNil).
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  8931
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  8932
    line := lineArg.
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  8933
    col1 := col2 := colArg.
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  8934
    self info:infoArg.
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  8935
! !
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  8936
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  8937
!EditTextView::DeleteCharacters methodsFor:'combining'!
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  8938
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  8939
canCombineWithNext:anotherAction
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  8940
    ^ anotherAction perform:#canCombineWithPreviousDeleteCharactersAction: with:self ifNotUnderstood:false
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  8941
!
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  8942
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  8943
canCombineWithPreviousDeleteCharactersAction:previousDeleteAction
3156
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  8944
    "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
  8945
     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
  8946
     (i.e. single-character typing)"
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  8947
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  8948
    previousDeleteAction line == line ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8949
	previousDeleteAction col2 == (col1-1) ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8950
	    ^ true
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8951
	].
3156
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  8952
    ].
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  8953
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  8954
    ^ false
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  8955
!
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  8956
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  8957
combineWithNext:nextDeleteAction
3156
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  8958
    self assert:(line == nextDeleteAction line).
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  8959
    self assert:(col2 == (nextDeleteAction col1 - 1)).
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  8960
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  8961
    col2 := nextDeleteAction col2.
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  8962
    userFriendlyInfo := 'insert ' , (col2 - col1 + 1) printString
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  8963
! !
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  8964
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  8965
!EditTextView::DeleteCharacters methodsFor:'execution'!
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  8966
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  8967
executeIn:editor
3156
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  8968
    editor unselect.
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  8969
    editor
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8970
	deleteFromLine:line
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8971
	col:col1
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8972
	toLine:line
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8973
	col:col2.
3156
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  8974
    editor cursorLine:line col:col1.
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  8975
! !
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  8976
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  8977
!EditTextView::EditMode class methodsFor:'constants'!
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  8978
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  8979
insertAndSelectMode
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  8980
    ^ InsertAndSelectMode
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  8981
!
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  8982
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  8983
insertMode
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  8984
    ^ InsertMode
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  8985
!
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  8986
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  8987
overwriteMode
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  8988
    ^ OverwriteMode
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  8989
! !
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  8990
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  8991
!EditTextView::EditMode class methodsFor:'queries'!
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  8992
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  8993
isInsertAndSelectMode
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  8994
    ^ false
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  8995
!
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  8996
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  8997
isInsertMode
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  8998
    ^ false
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  8999
!
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9000
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9001
symbolicName
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9002
    self subclassResponsibility
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9003
! !
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9004
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9005
!EditTextView::EditMode::InsertAndSelectMode class methodsFor:'info'!
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9006
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9007
infoPrintString
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9008
    ^ 'IS'
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9009
! !
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9010
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9011
!EditTextView::EditMode::InsertAndSelectMode class methodsFor:'queries'!
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9012
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9013
isInsertAndSelectMode
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9014
    ^ true
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9015
!
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9016
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9017
isInsertMode
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9018
    ^ true
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9019
! !
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9020
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9021
!EditTextView::EditMode::InsertMode class methodsFor:'info'!
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9022
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9023
infoPrintString
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9024
    ^ 'I'
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9025
! !
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9026
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9027
!EditTextView::EditMode::InsertMode class methodsFor:'queries'!
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9028
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9029
isInsertMode
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9030
    ^ true
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9031
! !
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9032
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9033
!EditTextView::EditMode::OverwriteMode class methodsFor:'info'!
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9034
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9035
infoPrintString
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9036
    ^ 'O'
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9037
! !
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9038
4048
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
  9039
!EditTextView::LastReplacementInfo methodsFor:'accessing'!
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
  9040
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
  9041
lastReplaceIgnoredCase
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
  9042
    ^ lastReplaceIgnoredCase ? false
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
  9043
!
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
  9044
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
  9045
lastReplaceIgnoredCase:something
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
  9046
    lastReplaceIgnoredCase := something.
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
  9047
!
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
  9048
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
  9049
lastReplaceWasMatch
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
  9050
    ^ lastReplaceWasMatch ? false
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
  9051
!
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
  9052
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
  9053
lastReplaceWasMatch:something
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
  9054
    lastReplaceWasMatch := something.
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
  9055
!
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
  9056
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
  9057
lastReplacement
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
  9058
    ^ lastReplacement
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
  9059
!
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
  9060
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
  9061
lastReplacement:something
4053
31117d801975 added: #setLastStringToReplace:
fm
parents: 4051
diff changeset
  9062
"/Transcript showCR: 'lastReplacement:', something printString.
4048
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
  9063
    lastReplacement := something.
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
  9064
!
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
  9065
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
  9066
lastStringToReplace
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
  9067
    ^ lastStringToReplace
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
  9068
!
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
  9069
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
  9070
lastStringToReplace:something
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
  9071
    lastStringToReplace := something.
4818
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  9072
!
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  9073
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  9074
previousReplacements
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  9075
    ^ previousReplacements ? #()
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  9076
!
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  9077
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  9078
stillCollectingInput
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  9079
    ^ stillCollectingInput
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  9080
!
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  9081
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  9082
stillCollectingInput:aBoolean
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  9083
    stillCollectingInput := aBoolean.
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  9084
! !
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  9085
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  9086
!EditTextView::LastReplacementInfo methodsFor:'history'!
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  9087
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  9088
rememberReplacement
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  9089
    "remember the previous replacement (called when a new one appears).
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  9090
     Mostly for the benefit of the code completion..."
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  9091
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  9092
    |oldString newString|
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  9093
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  9094
    oldString := lastStringToReplace.
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  9095
    newString := lastReplacement.
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  9096
    (oldString notEmptyOrNil and:[newString notEmptyOrNil]) ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  9097
	previousReplacements isNil ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  9098
	    previousReplacements := OrderedCollection new.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  9099
	].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  9100
	previousReplacements := previousReplacements reject:[:entry | entry key = oldString].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  9101
	previousReplacements addFirst:(oldString -> newString).
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  9102
	previousReplacements size > 20 ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  9103
	    previousReplacements removeLast.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  9104
	]
4818
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  9105
    ].
4048
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
  9106
! !
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
  9107
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9108
!EditTextView::PasteString methodsFor:'accessing'!
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9109
3400
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9110
col
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9111
    ^ col
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9112
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9113
    "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
  9114
!
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9115
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9116
col2
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9117
    ^ col + string size - 1
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9118
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9119
    "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
  9120
!
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9121
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9122
line
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9123
    ^ line
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9124
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9125
    "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
  9126
!
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9127
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  9128
line:lineArg col:colArg string:stringArg
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9129
    self assert:(lineArg notNil).
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9130
    self assert:(colArg notNil).
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9131
    self assert:(stringArg notNil).
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9132
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9133
    line := lineArg.
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9134
    col := colArg.
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9135
    string := stringArg.
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9136
!
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9137
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9138
line:lineArg col:colArg string:stringArg selected:selectedArg
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9139
    self assert:(lineArg notNil).
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9140
    self assert:(colArg notNil).
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9141
    self assert:(stringArg notNil).
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9142
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9143
    line := lineArg.
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9144
    col := colArg.
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9145
    string := stringArg.
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9146
    selected := selectedArg.
3400
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9147
!
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9148
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9149
string
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9150
    ^ string
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9151
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9152
    "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
  9153
! !
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9154
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9155
!EditTextView::PasteString methodsFor:'combining'!
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9156
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9157
canCombineWithNext:anotherAction
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9158
    ^ anotherAction canCombineWithPreviousPasteStringAction:self
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9159
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9160
    "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
  9161
!
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9162
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9163
canCombineWithPreviousPasteStringAction: previousPasteAction
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9164
    "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
  9165
     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
  9166
     (i.e. single-character deletes)"
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9167
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9168
    previousPasteAction line == line ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  9169
	previousPasteAction col == (self col2+1) ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  9170
	    ^ true
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  9171
	].
3400
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9172
    ].
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9173
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9174
    ^ false
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9175
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9176
    "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
  9177
!
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9178
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9179
combineWithNext:nextPasteAction
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9180
    |s1 s2|
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9181
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9182
    self assert:(line == nextPasteAction line).
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9183
    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
  9184
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9185
    s1 := nextPasteAction string.
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9186
    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
  9187
    s2 := string.
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9188
    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
  9189
3683
5891af82a177 middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents: 3650
diff changeset
  9190
    string := s1, s2.
3400
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9191
    col := nextPasteAction col.
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9192
    userFriendlyInfo := 'delete ' , string size printString
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9193
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9194
    "Created: / 25-09-2006 / 12:24:10 / cg"
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9195
! !
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9196
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9197
!EditTextView::PasteString methodsFor:'execution'!
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9198
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  9199
executeIn:editor
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9200
    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
  9201
    editor paste:string.
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9202
    selected ~~ true ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  9203
	editor unselect
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9204
    ].
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9205
! !
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9206
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9207
!EditTextView::ReplaceCharacter methodsFor:'accessing'!
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9208
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9209
col
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9210
    ^ col
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9211
!
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9212
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9213
col1
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9214
    ^ col
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9215
!
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9216
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9217
col2
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9218
    ^ col
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9219
!
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9220
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9221
line
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9222
    ^ line
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9223
!
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9224
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  9225
line:lineArg col:colArg character:characterArg
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9226
    line := lineArg.
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9227
    col := colArg.
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9228
    character := characterArg.
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9229
! !
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9230
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9231
!EditTextView::ReplaceCharacter methodsFor:'execution'!
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9232
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  9233
executeIn:editor
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  9234
    editor
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  9235
	replace:character
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  9236
	atLine:line
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  9237
	col:col.
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9238
    editor cursorLine:line col:col.
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  9239
! !
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  9240
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9241
!EditTextView::ReplaceCharacters methodsFor:'accessing'!
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9242
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9243
characters
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9244
    ^ characters
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9245
!
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9246
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9247
col1
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9248
    ^ col1
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9249
!
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9250
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9251
col2
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9252
    ^ col2
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9253
!
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9254
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9255
line
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9256
    ^ line
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9257
!
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9258
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9259
line:lineArg col:colArg character:characterArg
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9260
    line := lineArg.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9261
    col1 := col2 := colArg.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9262
    characters := characterArg asString.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9263
!
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9264
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9265
line:lineArg col:colArg characters:charactersArg
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9266
    line := lineArg.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9267
    col1 := colArg.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9268
    characters := charactersArg asString.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9269
    col2 := col1 + charactersArg size - 1
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9270
! !
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9271
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9272
!EditTextView::ReplaceCharacters methodsFor:'combining'!
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9273
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9274
canCombineWithNext:anotherAction
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9275
    ^ anotherAction perform:#canCombineWithPreviousReplaceCharactersAction: with:self ifNotUnderstood:false
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9276
!
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9277
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9278
canCombineWithPreviousReplaceCharactersAction:previousReplaceAction
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9279
    "I will combine only if we both are single character deletes,
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9280
     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
  9281
     (i.e. single-character typing)"
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9282
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9283
    previousReplaceAction line == line ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  9284
	previousReplaceAction col2 == (col1-1) ifTrue:[
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  9285
	    ^ true
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  9286
	].
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9287
    ].
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9288
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9289
    ^ false
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9290
!
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9291
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9292
combineWithNext:nextReplaceAction
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9293
    self assert:(line == nextReplaceAction line).
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9294
    self assert:(self col2 == (nextReplaceAction col1 - 1)).
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9295
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9296
    col2 := nextReplaceAction col2.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9297
    userFriendlyInfo := 'replace ' , (col2 - col1 + 1) printString.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9298
    characters := characters , nextReplaceAction characters.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9299
! !
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9300
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9301
!EditTextView::ReplaceCharacters methodsFor:'execution'!
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9302
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9303
executeIn:editor
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9304
    editor
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  9305
	replaceString:characters
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  9306
	atLine:line
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  9307
	col:col1.
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9308
    editor cursorLine:line col:col1.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9309
! !
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9310
3131
8f21dba07d24 undoable format
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
  9311
!EditTextView::ReplaceContents methodsFor:'accessing'!
8f21dba07d24 undoable format
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
  9312
8f21dba07d24 undoable format
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
  9313
text:something
8f21dba07d24 undoable format
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
  9314
    text := something.
8f21dba07d24 undoable format
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
  9315
! !
8f21dba07d24 undoable format
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
  9316
8f21dba07d24 undoable format
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
  9317
!EditTextView::ReplaceContents methodsFor:'execution'!
8f21dba07d24 undoable format
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
  9318
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  9319
executeIn:editor
3131
8f21dba07d24 undoable format
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
  9320
    editor contents:text
8f21dba07d24 undoable format
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
  9321
! !
8f21dba07d24 undoable format
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
  9322
3130
c0f39f9f28d6 undoable keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3127
diff changeset
  9323
!EditTextView::ReplaceLine methodsFor:'accessing'!
c0f39f9f28d6 undoable keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3127
diff changeset
  9324
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  9325
line:lineArg string:stringArg
3130
c0f39f9f28d6 undoable keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3127
diff changeset
  9326
    line := lineArg.
c0f39f9f28d6 undoable keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3127
diff changeset
  9327
    text := stringArg.
c0f39f9f28d6 undoable keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3127
diff changeset
  9328
! !
c0f39f9f28d6 undoable keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3127
diff changeset
  9329
c0f39f9f28d6 undoable keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3127
diff changeset
  9330
!EditTextView::ReplaceLine methodsFor:'execution'!
c0f39f9f28d6 undoable keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3127
diff changeset
  9331
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  9332
executeIn:editor
3130
c0f39f9f28d6 undoable keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3127
diff changeset
  9333
    editor list at:line put:text.
c0f39f9f28d6 undoable keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3127
diff changeset
  9334
    editor invalidateLine:line
c0f39f9f28d6 undoable keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3127
diff changeset
  9335
! !
c0f39f9f28d6 undoable keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3127
diff changeset
  9336
3402
d6545009a22b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3400
diff changeset
  9337
!EditTextView::ReplaceLines methodsFor:'accessing'!
d6545009a22b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3400
diff changeset
  9338
d6545009a22b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3400
diff changeset
  9339
line:lineArg lines:lineCollectionArg
d6545009a22b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3400
diff changeset
  9340
    line := lineArg.
d6545009a22b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3400
diff changeset
  9341
    text := lineCollectionArg.
d6545009a22b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3400
diff changeset
  9342
d6545009a22b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3400
diff changeset
  9343
    "Created: / 09-10-2006 / 10:35:22 / cg"
d6545009a22b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3400
diff changeset
  9344
! !
d6545009a22b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3400
diff changeset
  9345
d6545009a22b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3400
diff changeset
  9346
!EditTextView::ReplaceLines methodsFor:'execution'!
d6545009a22b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3400
diff changeset
  9347
d6545009a22b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3400
diff changeset
  9348
executeIn:editor
d6545009a22b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3400
diff changeset
  9349
    |lnr|
d6545009a22b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3400
diff changeset
  9350
d6545009a22b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3400
diff changeset
  9351
    lnr := line.
d6545009a22b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3400
diff changeset
  9352
    text do:[:eachLine |
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  9353
	editor list at:lnr put:eachLine.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  9354
	editor invalidateLine:lnr.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  9355
	lnr := lnr + 1.
3402
d6545009a22b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3400
diff changeset
  9356
    ].
d6545009a22b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3400
diff changeset
  9357
d6545009a22b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3400
diff changeset
  9358
    "Modified: / 09-10-2006 / 10:39:16 / cg"
d6545009a22b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3400
diff changeset
  9359
! !
d6545009a22b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3400
diff changeset
  9360
5689
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  9361
!EditTextView::RestoreSelectionAndCursor methodsFor:'accessing'!
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  9362
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  9363
cursorLine:cursorLineArg cursorCol:cursorColArg selectionStartLine:selectionStartLineArg selectionStartCol:selectionStartColArg selectionEndLine:selectionEndLineArg selectionEndCol:selectionEndColArg
5689
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  9364
    cursorLine := cursorLineArg.
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  9365
    cursorCol := cursorColArg.
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  9366
    selectionStartLine := selectionStartLineArg.
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  9367
    selectionStartCol := selectionStartColArg.
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  9368
    selectionEndLine := selectionEndLineArg.
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  9369
    selectionEndCol := selectionEndColArg.
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  9370
!
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  9371
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  9372
cursorLine:cursorLineArg cursorCol:cursorColArg
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  9373
	selectionStartLine:selectionStartLineArg selectionStartCol:selectionStartColArg
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  9374
	selectionEndLine:selectionEndLineArg selectionEndCol:selectionEndColArg
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  9375
	info:info
5689
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  9376
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  9377
    cursorLine := cursorLineArg.
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  9378
    cursorCol := cursorColArg.
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  9379
    selectionStartLine := selectionStartLineArg.
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  9380
    selectionStartCol := selectionStartColArg.
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  9381
    selectionEndLine := selectionEndLineArg.
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  9382
    selectionEndCol := selectionEndColArg.
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  9383
    userFriendlyInfo := info.
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  9384
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  9385
    "Created: / 30-04-2016 / 20:21:18 / cg"
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  9386
! !
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  9387
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  9388
!EditTextView::RestoreSelectionAndCursor methodsFor:'execution'!
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  9389
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  9390
executeIn:editor
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  9391
    (selectionStartLine notNil and:[selectionEndLine notNil
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  9392
    and:[selectionStartCol notNil and:[selectionEndCol notNil]]]) ifTrue:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  9393
	editor setCursorLine:cursorLine col:cursorCol.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  9394
	editor selectFromLine:selectionStartLine col:selectionStartCol toLine:selectionEndLine col:selectionEndCol
5689
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  9395
    ] ifFalse:[
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  9396
	editor cursorLine:cursorLine col:cursorCol.
5689
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  9397
    ].
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  9398
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  9399
    "Created: / 30-04-2016 / 20:14:55 / cg"
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  9400
! !
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  9401
5710
7757eb8d4d3e #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5689
diff changeset
  9402
!EditTextView::RestoreSelectionAndCursor methodsFor:'queries'!
7757eb8d4d3e #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5689
diff changeset
  9403
7757eb8d4d3e #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5689
diff changeset
  9404
isRestoreSelectionAndCursor
7757eb8d4d3e #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5689
diff changeset
  9405
    ^ true
7757eb8d4d3e #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5689
diff changeset
  9406
! !
7757eb8d4d3e #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5689
diff changeset
  9407
865
d42c7c99e67d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 840
diff changeset
  9408
!EditTextView class methodsFor:'documentation'!
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  9409
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  9410
version
5361
d39070e004c1 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5357
diff changeset
  9411
    ^ '$Header$'
3945
295e4733f3a5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3915
diff changeset
  9412
!
295e4733f3a5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3915
diff changeset
  9413
295e4733f3a5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3915
diff changeset
  9414
version_CVS
5361
d39070e004c1 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5357
diff changeset
  9415
    ^ '$Header$'
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  9416
! !
4481
76c592c0ae9c class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 4475
diff changeset
  9417