EditTextView.st
author Claus Gittinger <cg@exept.de>
Sat, 13 Jul 2019 14:10:43 +0200
changeset 6627 322e0fc5efc4
parent 6623 682c9f9e6a11
child 6641 fd2baccc909a
permissions -rw-r--r--
#BUGFIX by cg class: EditTextViewCompletionSupport changed: #startCompletionProcess
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
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
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
6154
3e745dfae512 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 6152
diff changeset
    17
	instanceVariableNames:'cursorLine cursorVisibleLine cursorCol cursorShown
3e745dfae512 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 6152
diff changeset
    18
		prevCursorState readOnly modifiedChannel fixedSize exceptionBlock
3e745dfae512 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 6152
diff changeset
    19
		cursorFgColor cursorBgColor cursorNoFocusFgColor cursorType
3e745dfae512 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 6152
diff changeset
    20
		cursorTypeNoFocus typeOfSelection lastAction replacing
3e745dfae512 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 6152
diff changeset
    21
		showMatchingParenthesis hasKeyboardFocus acceptAction lockUpdates
3e745dfae512 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 6152
diff changeset
    22
		tabMeansNextField autoIndent insertMode editMode trimBlankLines
3e745dfae512 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 6152
diff changeset
    23
		wordWrap replacementWordSelectStyle acceptChannel acceptEnabled
3e745dfae512 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 6152
diff changeset
    24
		st80Mode disableIfInvisible cursorMovementWhenUpdating learnMode
3e745dfae512 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 6152
diff changeset
    25
		learnedMacro cursorLineHolder cursorColHolder tabRequiresControl
3e745dfae512 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 6152
diff changeset
    26
		undoSupport lastStringFromReplaceForNextSearch
3e745dfae512 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 6152
diff changeset
    27
		lastReplacementInfo completionSupport codeAspectHolder'
6227
ff84138a7915 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6226
diff changeset
    28
	classVariableNames:'DefaultCursorBackgroundColor DefaultCursorForegroundColor
ff84138a7915 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6226
diff changeset
    29
		DefaultCursorNoFocusForegroundColor DefaultCursorType
6517
7a141e818635 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6514
diff changeset
    30
		DefaultCursorTypeNoFocus LastColumnNumberForSort Macros
7a141e818635 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6514
diff changeset
    31
		CharacterInputViewSingleton'
6154
3e745dfae512 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 6152
diff changeset
    32
	poolDictionaries:''
3e745dfae512 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 6152
diff changeset
    33
	category:'Views-Text'
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    34
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    35
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
    36
Object subclass:#EditAction
6154
3e745dfae512 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 6152
diff changeset
    37
	instanceVariableNames:'userFriendlyInfo'
3e745dfae512 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 6152
diff changeset
    38
	classVariableNames:''
3e745dfae512 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 6152
diff changeset
    39
	poolDictionaries:''
3e745dfae512 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 6152
diff changeset
    40
	privateIn:EditTextView
2952
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
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
    43
EditTextView::EditAction subclass:#DeleteRange
6154
3e745dfae512 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 6152
diff changeset
    44
	instanceVariableNames:'line1 col1 line2 col2'
3e745dfae512 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 6152
diff changeset
    45
	classVariableNames:''
3e745dfae512 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 6152
diff changeset
    46
	poolDictionaries:''
3e745dfae512 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 6152
diff changeset
    47
	privateIn:EditTextView
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
    48
!
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
    49
3156
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
    50
EditTextView::EditAction subclass:#DeleteCharacters
6154
3e745dfae512 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 6152
diff changeset
    51
	instanceVariableNames:'line col1 col2'
3e745dfae512 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 6152
diff changeset
    52
	classVariableNames:''
3e745dfae512 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 6152
diff changeset
    53
	poolDictionaries:''
3e745dfae512 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 6152
diff changeset
    54
	privateIn:EditTextView
3156
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
    55
!
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
    56
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
    57
Object subclass:#EditMode
6154
3e745dfae512 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 6152
diff changeset
    58
	instanceVariableNames:''
3e745dfae512 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 6152
diff changeset
    59
	classVariableNames:''
3e745dfae512 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 6152
diff changeset
    60
	poolDictionaries:''
3e745dfae512 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 6152
diff changeset
    61
	privateIn:EditTextView
3235
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
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
    64
EditTextView::EditMode subclass:#InsertAndSelectMode
6154
3e745dfae512 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 6152
diff changeset
    65
	instanceVariableNames:''
3e745dfae512 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 6152
diff changeset
    66
	classVariableNames:''
3e745dfae512 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 6152
diff changeset
    67
	poolDictionaries:''
3e745dfae512 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 6152
diff changeset
    68
	privateIn:EditTextView::EditMode
3235
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
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
    71
EditTextView::EditMode subclass:#InsertMode
6154
3e745dfae512 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 6152
diff changeset
    72
	instanceVariableNames:''
3e745dfae512 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 6152
diff changeset
    73
	classVariableNames:''
3e745dfae512 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 6152
diff changeset
    74
	poolDictionaries:''
3e745dfae512 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 6152
diff changeset
    75
	privateIn:EditTextView::EditMode
3235
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
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
    78
EditTextView::EditMode subclass:#OverwriteMode
6154
3e745dfae512 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 6152
diff changeset
    79
	instanceVariableNames:''
3e745dfae512 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 6152
diff changeset
    80
	classVariableNames:'InsertMode OverwriteMode InsertAndSelectMode'
3e745dfae512 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 6152
diff changeset
    81
	poolDictionaries:''
3e745dfae512 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 6152
diff changeset
    82
	privateIn:EditTextView::EditMode
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
    83
!
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
    84
3813
8d719ca5812d dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3811
diff changeset
    85
Query subclass:#ExecutingMacroQuery
6154
3e745dfae512 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 6152
diff changeset
    86
	instanceVariableNames:''
3e745dfae512 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 6152
diff changeset
    87
	classVariableNames:''
3e745dfae512 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 6152
diff changeset
    88
	poolDictionaries:''
3e745dfae512 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 6152
diff changeset
    89
	privateIn:EditTextView
3813
8d719ca5812d dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3811
diff changeset
    90
!
8d719ca5812d dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3811
diff changeset
    91
4048
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
    92
Object subclass:#LastReplacementInfo
6154
3e745dfae512 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 6152
diff changeset
    93
	instanceVariableNames:'lastReplacement lastStringToReplace lastReplaceWasMatch
3e745dfae512 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 6152
diff changeset
    94
		lastReplaceIgnoredCase stillCollectingInput previousReplacements'
3e745dfae512 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 6152
diff changeset
    95
	classVariableNames:''
3e745dfae512 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 6152
diff changeset
    96
	poolDictionaries:''
3e745dfae512 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 6152
diff changeset
    97
	privateIn:EditTextView
4048
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
    98
!
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
    99
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
   100
EditTextView::EditAction subclass:#PasteString
6154
3e745dfae512 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 6152
diff changeset
   101
	instanceVariableNames:'line col string selected'
3e745dfae512 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 6152
diff changeset
   102
	classVariableNames:''
3e745dfae512 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 6152
diff changeset
   103
	poolDictionaries:''
3e745dfae512 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 6152
diff changeset
   104
	privateIn:EditTextView
2952
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
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
   107
EditTextView::EditAction subclass:#ReplaceCharacter
6154
3e745dfae512 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 6152
diff changeset
   108
	instanceVariableNames:'line col character'
3e745dfae512 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 6152
diff changeset
   109
	classVariableNames:''
3e745dfae512 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 6152
diff changeset
   110
	poolDictionaries:''
3e745dfae512 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 6152
diff changeset
   111
	privateIn:EditTextView
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
   112
!
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
   113
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
   114
EditTextView::EditAction subclass:#ReplaceCharacters
6154
3e745dfae512 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 6152
diff changeset
   115
	instanceVariableNames:'line col1 col2 characters'
3e745dfae512 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 6152
diff changeset
   116
	classVariableNames:''
3e745dfae512 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 6152
diff changeset
   117
	poolDictionaries:''
3e745dfae512 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 6152
diff changeset
   118
	privateIn:EditTextView
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
   119
!
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
   120
3131
8f21dba07d24 undoable format
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
   121
EditTextView::EditAction subclass:#ReplaceContents
6154
3e745dfae512 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 6152
diff changeset
   122
	instanceVariableNames:'text'
3e745dfae512 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 6152
diff changeset
   123
	classVariableNames:''
3e745dfae512 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 6152
diff changeset
   124
	poolDictionaries:''
3e745dfae512 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 6152
diff changeset
   125
	privateIn:EditTextView
3131
8f21dba07d24 undoable format
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
   126
!
8f21dba07d24 undoable format
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
   127
3130
c0f39f9f28d6 undoable keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3127
diff changeset
   128
EditTextView::EditAction subclass:#ReplaceLine
6154
3e745dfae512 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 6152
diff changeset
   129
	instanceVariableNames:'line text'
3e745dfae512 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 6152
diff changeset
   130
	classVariableNames:''
3e745dfae512 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 6152
diff changeset
   131
	poolDictionaries:''
3e745dfae512 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 6152
diff changeset
   132
	privateIn:EditTextView
3130
c0f39f9f28d6 undoable keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3127
diff changeset
   133
!
c0f39f9f28d6 undoable keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3127
diff changeset
   134
3402
d6545009a22b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3400
diff changeset
   135
EditTextView::EditAction subclass:#ReplaceLines
6154
3e745dfae512 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 6152
diff changeset
   136
	instanceVariableNames:'line text'
3e745dfae512 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 6152
diff changeset
   137
	classVariableNames:''
3e745dfae512 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 6152
diff changeset
   138
	poolDictionaries:''
3e745dfae512 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 6152
diff changeset
   139
	privateIn:EditTextView
3402
d6545009a22b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3400
diff changeset
   140
!
d6545009a22b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3400
diff changeset
   141
5689
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
   142
EditTextView::EditAction subclass:#RestoreSelectionAndCursor
6154
3e745dfae512 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 6152
diff changeset
   143
	instanceVariableNames:'cursorLine cursorCol selectionStartLine selectionStartCol
3e745dfae512 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 6152
diff changeset
   144
		selectionEndLine selectionEndCol'
3e745dfae512 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 6152
diff changeset
   145
	classVariableNames:''
3e745dfae512 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 6152
diff changeset
   146
	poolDictionaries:''
3e745dfae512 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 6152
diff changeset
   147
	privateIn:EditTextView
5689
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
   148
!
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
   149
865
d42c7c99e67d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 840
diff changeset
   150
!EditTextView class methodsFor:'documentation'!
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   151
33
5eeef3ea8ebd added access methods for cursorLine & cursorCol
claus
parents: 25
diff changeset
   152
copyright
5eeef3ea8ebd added access methods for cursorLine & cursorCol
claus
parents: 25
diff changeset
   153
"
5eeef3ea8ebd added access methods for cursorLine & cursorCol
claus
parents: 25
diff changeset
   154
 COPYRIGHT (c) 1989 by Claus Gittinger
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   155
              All Rights Reserved
33
5eeef3ea8ebd added access methods for cursorLine & cursorCol
claus
parents: 25
diff changeset
   156
5eeef3ea8ebd added access methods for cursorLine & cursorCol
claus
parents: 25
diff changeset
   157
 This software is furnished under a license and may be used
5eeef3ea8ebd added access methods for cursorLine & cursorCol
claus
parents: 25
diff changeset
   158
 only in accordance with the terms of that license and with the
5eeef3ea8ebd added access methods for cursorLine & cursorCol
claus
parents: 25
diff changeset
   159
 inclusion of the above copyright notice.   This software may not
5eeef3ea8ebd added access methods for cursorLine & cursorCol
claus
parents: 25
diff changeset
   160
 be provided or otherwise made available to, or used by, any
5eeef3ea8ebd added access methods for cursorLine & cursorCol
claus
parents: 25
diff changeset
   161
 other person.  No title to or ownership of the software is
5eeef3ea8ebd added access methods for cursorLine & cursorCol
claus
parents: 25
diff changeset
   162
 hereby transferred.
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
!
5eeef3ea8ebd added access methods for cursorLine & cursorCol
claus
parents: 25
diff changeset
   165
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   166
documentation
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   167
"
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   168
    a view for editable text - adds editing functionality to TextView
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   169
    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
   170
    acceptAction to be performed for accept
125
claus
parents: 123
diff changeset
   171
claus
parents: 123
diff changeset
   172
    If used with a model, this is informed by sending it a changeMsg with
claus
parents: 123
diff changeset
   173
    the current contents as argument.
297
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   174
    (however, it is possible to define both changeMsg and acceptAction)
125
claus
parents: 123
diff changeset
   175
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
   176
    Please read the historic notice in the ListView class.
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   177
586
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 567
diff changeset
   178
    [Instance variables:]
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   179
5988
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   180
        cursorLine              <Number>        line where cursor sits (1..)
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   181
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   182
        cursorVisibleLine       <Number>        visible line where cursor sits (1..nLinesShown)
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   183
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   184
        cursorCol               <Number>        col where cursor sits (1..)
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   185
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   186
        cursorShown             <Boolean>       true, if cursor is currently shown
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   187
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   188
        readOnly                <Boolean>       true, if text may not be edited
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   189
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   190
        modifiedChannel         <ValueHolder>   holding true, if text has been modified.
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   191
                                                cleared on accept.
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   192
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   193
        acceptChannel           <ValueHolder>   holding true, if text has been accepted.
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   194
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   195
        fixedSize               <Boolean>       true, if no lines may be added/removed
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   196
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   197
        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
   198
                                                if it returns true, the modification will be done anyway.
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   199
                                                if it returns anything else, the modification is not done.
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   200
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   201
        cursorFgColor           <Color>         color used for cursor drawing
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   202
        cursorBgColor           <Color>         color used for cursor drawing
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   203
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   204
        cursorType              <Symbol>        how the cursor is drawn; currently implemented
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   205
                                                are #none, #block (solid-block cursor), #ibeam
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   206
                                                (vertical bar at insertion point)
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   207
                                                and #caret (caret below insertion-point).
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   208
                                                see cursorType: for an up-to-date list.
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   209
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   210
        cursorTypeNoFocus       <Symbol>        like above, if view has no focus
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   211
                                                nil means: hide the cursor.
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   212
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   213
        undoAction              <Block>         block which undoes last cut, paste or replace
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   214
                                                (not yet fully implemented)
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   215
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   216
        typeOfSelection         <Symbol>        #paste, if selection created by paste, nil otherwise
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   217
                                                this affects the next keyPress: if #paste it does not
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   218
                                                replace; otherwise it replaces the selection.
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   219
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   220
        lastCut                 <String>        last cut or replaced string
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   221
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   222
        lastReplacementInfo     <LastReplacementInfo>        holds the information about the last replace action
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   223
                                                             lastStringToReplace is the string to be replaced by lastReplacement
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   224
                                                             lastReplacement is the string to replace lastStringToReplace
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   225
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   226
        lastStringFromReplaceForNextSearch   <String>        string to be taken be the next search action
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   227
                                                             (cleared after a new selection)
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   228
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   229
        replacing               <Boolean>       true if entered characters replace last selection
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   230
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   231
        showMatchingParenthesis <Boolean>       if true, shows matching parenthesis
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   232
                                                when entering one; this is the default.
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   233
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   234
        hasKeyboardFocus        <Boolean>       true if this view has the focus
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   235
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   236
        acceptAction            <Block>         accept action - evaluated passing the contents as
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   237
                                                argument
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   238
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   239
        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
   240
                                                focus to the next field. For editTextViews, this is false
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   241
                                                by default (i.e. tabs can be entered into the text).
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   242
                                                For some subclasses (inputFields), this may be true.
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   243
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   244
        trimBlankLines          <Boolean>       if true, trailing blanks are
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   245
                                                removed when editing.
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   246
                                                Also, empty lines are represented as nil in the lines collection.
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   247
                                                Default is true.
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   248
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   249
        wordWrap                <Boolean>       Currently not used.
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   250
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   251
        lockUpdates             <Boolean>       internal, private
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   252
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   253
        prevCursorState         <Boolean>       temporary, private
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   254
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   255
        cursorMovementWhenUpdating
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   256
                                <Symbol>        defines where the cursor is to be positioned if the
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   257
                                                model changes its value by some outside activity
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   258
                                                (i.e. not by user input into the field).
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   259
                                                Can be one of:
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   260
                                                    #keep / nil     -> stay where it was
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   261
                                                    #endOfText      -> cursor to the end
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   262
                                                    #endOfLine      -> stay in the line, but move to end
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   263
                                                    #beginOfText    -> cursor to the beginning
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   264
                                                    #beginOfLine    -> stay in the line, but move to begin
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   265
                                                The default is #beginOfText
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
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   269
        dropTarget              <DropTarget|nil> drop operation descriptor or nil (drop disabled)
2589
62794ae04446 support drop
ca
parents: 2580
diff changeset
   270
62794ae04446 support drop
ca
parents: 2580
diff changeset
   271
2712
e83d71c9bdec ST80Mode classVariables is now UserPreferences.st80EditMode
Claus Gittinger <cg@exept.de>
parents: 2707
diff changeset
   272
    userPreference values:
5988
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   273
        userPreferences.st80EditMode
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   274
                                <Boolean>       if true, cursor positioning is
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   275
                                                done as in vi or ST80; i.e.
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   276
                                                wysiwyg mode is somewhat relaxed,
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   277
                                                in that the cursor cannot be
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   278
                                                positioned behind a lines end.
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   279
                                                This is not yet completely implemented.
33
5eeef3ea8ebd added access methods for cursorLine & cursorCol
claus
parents: 25
diff changeset
   280
    used globals:
5eeef3ea8ebd added access methods for cursorLine & cursorCol
claus
parents: 25
diff changeset
   281
5988
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   282
        DeleteHistory           <Text>          last 1000 lines of deleted text
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   283
                                                (but only if this variable exists already)
586
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 567
diff changeset
   284
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 567
diff changeset
   285
    [styleSheet parameters:]
121
claus
parents: 118
diff changeset
   286
5988
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   287
        textCursorForegroundColor <Color>          cursor fg color; default: text background
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   288
        textCursorBackgroundColor <Color>          cursor bg color; default: text foreground
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   289
        textCursorNoFocusForegroundColor
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   290
                                  <Color>          cursor fg color if no focus; default: cursor fg color
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   291
        textCursorType            <Symbol>         cursor type; default:  #block
586
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 567
diff changeset
   292
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 567
diff changeset
   293
    [author:]
5988
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   294
        Claus Gittinger
586
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 567
diff changeset
   295
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 567
diff changeset
   296
    [see also:]
5988
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   297
        CodeView Workspace TextView ListView
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   298
        EditField
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   299
"
297
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
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   302
examples
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   303
"
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   304
  non MVC operation:
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   305
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   306
    basic setup:
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   307
                                                                        [exBegin]
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   308
        |top textView|
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   309
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   310
        top := StandardSystemView new.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   311
        top extent:300@200.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   312
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   313
        textView := EditTextView new.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   314
        textView origin:0.0 @ 0.0 corner:1.0 @ 1.0.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   315
        top addSubView:textView.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   316
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   317
        textView contents:('/etc/hosts' asFilename contentsOfEntireFile).
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   318
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   319
        top open.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   320
                                                                        [exEnd]
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   321
297
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   322
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   323
    with vertical scrollbar:
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   324
                                                                        [exBegin]
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   325
        |top scrollView textView|
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   326
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   327
        top := StandardSystemView new.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   328
        top extent:300@200.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   329
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   330
        scrollView := ScrollableView for:EditTextView.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   331
        textView := scrollView scrolledView.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   332
        scrollView origin:0.0 @ 0.0 corner:1.0 @ 1.0.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   333
        top addSubView:scrollView.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   334
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   335
        textView contents:('/etc/hosts' asFilename contentsOfEntireFile).
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   336
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   337
        top open.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   338
                                                                        [exEnd]
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   339
297
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   340
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   341
    with horizontal & vertical scrollbars:
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   342
                                                                        [exBegin]
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   343
        |top scrollView textView|
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   344
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   345
        top := StandardSystemView new.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   346
        top extent:300@200.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   347
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   348
        scrollView := HVScrollableView for:EditTextView.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   349
        textView := scrollView scrolledView.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   350
        scrollView origin:0.0 @ 0.0 corner:1.0 @ 1.0.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   351
        top addSubView:scrollView.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   352
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   353
        textView contents:('/etc/hosts' asFilename contentsOfEntireFile).
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   354
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   355
        top open.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   356
                                                                        [exEnd]
297
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
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   359
    set the action for accept:
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   360
                                                                        [exBegin]
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   361
        |top textView|
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   362
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   363
        top := StandardSystemView new.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   364
        top extent:300@200.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   365
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   366
        textView := EditTextView new.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   367
        textView origin:0.0 @ 0.0 corner:1.0 @ 1.0.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   368
        top addSubView:textView.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   369
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   370
        textView contents:('/etc/hosts' asFilename contentsOfEntireFile).
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   371
        textView acceptAction:[:contents |
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   372
                                Transcript showCR:'will not overwrite the file with:'.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   373
                                Transcript showCR:contents asString
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   374
                              ].
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   375
        top open.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   376
                                                                        [exEnd]
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   377
297
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   378
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   379
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
   380
    non-string (text) items:
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   381
                                                                        [exBegin]
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   382
        |top textView list|
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   383
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   384
        list := '/etc/hosts' asFilename contentsOfEntireFile asStringCollection.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   385
        1 to:list size by:2 do:[:nr |
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   386
            list at:nr put:(Text string:(list at:nr)
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   387
                                 emphasis:(Array with:#bold with:(#color->Color red)))
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   388
        ].
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   389
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   390
        top := StandardSystemView new.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   391
        top extent:300@200.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   392
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   393
        textView := EditTextView new.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   394
        textView origin:0.0 @ 0.0 corner:1.0 @ 1.0.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   395
        top addSubView:textView.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   396
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   397
        textView contents:list.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   398
        top open.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   399
                                                                        [exEnd]
629
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
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
   402
297
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   403
  MVC operation:
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   404
    (the examples model here is a plug simulating a real model;
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   405
     real world applications would not use a plug ..)
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   406
                                                                        [exBegin]
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   407
        |top textView model|
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   408
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   409
        model := Plug new.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   410
        model respondTo:#accepted:
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   411
                   with:[:newContents |
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   412
                                Transcript showCR:'will not overwrite the file with:'.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   413
                                Transcript showCR:newContents asString
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   414
                        ].
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   415
        model respondTo:#getList
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   416
                   with:['/etc/hosts' asFilename contentsOfEntireFile].
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   417
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   418
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   419
        top := StandardSystemView new.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   420
        top extent:300@200.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   421
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   422
        textView := EditTextView new.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   423
        textView origin:0.0 @ 0.0 corner:1.0 @ 1.0.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   424
        top addSubView:textView.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   425
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   426
        textView listMessage:#getList;
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   427
                 model:model;
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   428
                 changeMessage:#accepted:;
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   429
                 aspect:#list.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   430
        top open.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   431
                                                                        [exEnd]
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   432
297
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   433
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   434
    two textViews on the same model:
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   435
                                                                        [exBegin]
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   436
        |top1 textView1 top2 textView2 model currentContents|
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   437
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   438
        model := Plug new.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   439
        model respondTo:#accepted:
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   440
                   with:[:newContents |
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   441
                                Transcript showCR:'accepted:'.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   442
                                Transcript showCR:newContents asString.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   443
                                currentContents := newContents.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   444
                                model changed:#contents
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   445
                        ].
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   446
        model respondTo:#getList
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   447
                   with:[Transcript showCR:'query'.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   448
                         currentContents].
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   449
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   450
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   451
        top1 := StandardSystemView new.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   452
        top1 extent:300@200.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   453
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   454
        textView1 := EditTextView new.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   455
        textView1 origin:0.0 @ 0.0 corner:1.0 @ 1.0.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   456
        top1 addSubView:textView1.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   457
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   458
        textView1 listMessage:#getList;
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   459
                  model:model;
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   460
                  aspect:#contents;
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   461
                  changeMessage:#accepted:.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   462
        top1 open.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   463
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   464
        top2 := StandardSystemView new.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   465
        top2 extent:300@200.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   466
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   467
        textView2 := EditTextView new.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   468
        textView2 origin:0.0 @ 0.0 corner:1.0 @ 1.0.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   469
        top2 addSubView:textView2.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   470
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   471
        textView2 listMessage:#getList;
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   472
                  model:model;
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   473
                  aspect:#contents;
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   474
                  changeMessage:#accepted:.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   475
        top2 open.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   476
                                                                        [exEnd]
297
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   477
"
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   478
! !
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   479
865
d42c7c99e67d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 840
diff changeset
   480
!EditTextView class methodsFor:'defaults'!
59
450ce95a72a4 *** empty log message ***
claus
parents: 46
diff changeset
   481
4801
69a5bff7b5cd Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4786
diff changeset
   482
defaultCompletionSupportClass
69a5bff7b5cd Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4786
diff changeset
   483
    ^ nil
69a5bff7b5cd Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4786
diff changeset
   484
69a5bff7b5cd Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4786
diff changeset
   485
    "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
   486
!
428c8bc44cfb refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents: 4694
diff changeset
   487
1419
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   488
st80Mode
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   489
    "return true, if the st80 editing mode is turned on.
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   490
     This setting affects the behavior of the cursor, when positioned
5909
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
   491
     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
   492
     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
   493
     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
   494
     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
   495
2647
23dca8f032c3 changed st80Mode from classVar to userPreferences value
Claus Gittinger <cg@exept.de>
parents: 2627
diff changeset
   496
    ^ UserPreferences current st80EditMode
1419
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
   "
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   499
    EditTextView st80Mode:true
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   500
    EditTextView st80Mode:false
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
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   503
    "Modified: / 16.1.1998 / 22:54:57 / cg"
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
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   506
st80Mode:aBoolean
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   507
    "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
   508
     beyond the end of a line or the last line.
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
   509
     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
   510
     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
   511
     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
   512
2647
23dca8f032c3 changed st80Mode from classVar to userPreferences value
Claus Gittinger <cg@exept.de>
parents: 2627
diff changeset
   513
    UserPreferences current st80EditMode:aBoolean.
1419
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
   "
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   516
    EditTextView st80Mode:true
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   517
    EditTextView st80Mode:false
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
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   520
    "Modified: / 16.1.1998 / 22:55:19 / cg"
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   521
!
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   522
59
450ce95a72a4 *** empty log message ***
claus
parents: 46
diff changeset
   523
updateStyleCache
440
2beb33cb0146 added style resource directive
Claus Gittinger <cg@exept.de>
parents: 428
diff changeset
   524
    "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
   525
1390
99674e1d9c85 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
   526
    <resource: #style (#'textCursor.foregroundColor' #'textCursor.backgroundColor'
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   527
                       #'textCursor.noFocusForegroundColor'
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   528
                       #'textCursor.type'
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   529
                       #'textCursor.typeNoFocus'
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   530
                       #'editText.st80Mode')>
1355
6725ab9cc6f5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
   531
6725ab9cc6f5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
   532
    DefaultCursorForegroundColor := StyleSheet colorAt:'textCursor.foregroundColor'.
6725ab9cc6f5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
   533
    DefaultCursorBackgroundColor := StyleSheet colorAt:'textCursor.backgroundColor'.
6725ab9cc6f5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
   534
    DefaultCursorNoFocusForegroundColor := StyleSheet colorAt:'textCursor.noFocusForegroundColor'.
6725ab9cc6f5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
   535
    DefaultCursorType := StyleSheet at:'textCursor.type' default:#block.
1534
bcb211e1b41a read noFocus cursorStyle from styleSheet
Claus Gittinger <cg@exept.de>
parents: 1533
diff changeset
   536
    DefaultCursorTypeNoFocus := StyleSheet at:'textCursor.typeNoFocus'.
bcb211e1b41a read noFocus cursorStyle from styleSheet
Claus Gittinger <cg@exept.de>
parents: 1533
diff changeset
   537
1419
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   538
    "
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   539
     self updateStyleCache
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   540
    "
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   541
1534
bcb211e1b41a read noFocus cursorStyle from styleSheet
Claus Gittinger <cg@exept.de>
parents: 1533
diff changeset
   542
    "Modified: / 20.5.1998 / 04:27:41 / cg"
59
450ce95a72a4 *** empty log message ***
claus
parents: 46
diff changeset
   543
! !
450ce95a72a4 *** empty log message ***
claus
parents: 46
diff changeset
   544
3431
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   545
!EditTextView class methodsFor:'specs'!
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   546
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   547
searchReplaceDialogSpec
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   548
    "This resource specification was automatically generated
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   549
     by the UIPainter of ST/X."
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   550
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   551
    "Do not manually edit this!! If it is corrupted,
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   552
     the UIPainter may not be able to read the specification."
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   553
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   554
    "
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   555
     UIPainter new openOnClass:DAPASX::ProjectEditorTextView andSelector:#searchReplaceDialogSpec
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   556
    "
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   557
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   558
    <resource: #canvas>
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   559
3683
5891af82a177 middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents: 3650
diff changeset
   560
    ^
3431
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   561
     #(FullSpec
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   562
        name: searchReplaceDialogSpec
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   563
        window:
3431
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   564
       (WindowSpec
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   565
          label: 'String Search and Replace'
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   566
          name: 'String Search and Replace'
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   567
          min: (Point 283 196)
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   568
          max: (Point 283 196)
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   569
          bounds: (Rectangle 0 0 279 192)
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   570
        )
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   571
        component:
3431
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   572
       (SpecCollection
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   573
          collection: (
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   574
           (LabelSpec
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   575
              label: 'Search Pattern:'
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   576
              name: 'label'
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   577
              layout: (LayoutFrame 1 0.0 3 0 -1 1.0 20 0)
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   578
              level: 0
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   579
              translateLabel: true
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   580
              adjust: left
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   581
            )
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   582
           (ComboBoxSpec
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   583
              name: 'patternComboBox'
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   584
              layout: (LayoutFrame 3 0.0 26 0 -3 1.0 48 0)
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   585
              tabable: true
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   586
              model: searchPattern
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   587
              immediateAccept: false
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   588
              acceptOnLeave: true
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   589
              acceptOnReturn: true
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   590
              acceptOnTab: true
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   591
              acceptOnLostFocus: true
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   592
              acceptOnPointerLeave: false
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   593
              autoSelectInitialText: true
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   594
              comboList: patternList
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   595
            )
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   596
           (ComboBoxSpec
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   597
              name: 'replaceComboBox'
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   598
              layout: (LayoutFrame 3 0.0 76 0 -3 1.0 98 0)
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   599
              tabable: true
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   600
              model: replacePattern
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   601
              immediateAccept: false
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   602
              acceptOnLeave: true
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   603
              acceptOnReturn: true
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   604
              acceptOnTab: true
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   605
              acceptOnLostFocus: true
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   606
              acceptOnPointerLeave: false
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   607
              autoSelectInitialText: true
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   608
              comboList: patternList
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   609
            )
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   610
           (CheckBoxSpec
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   611
              label: 'Ignore Case'
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   612
              name: 'ignoreCaseCheckBox'
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   613
              layout: (LayoutFrame 3 0.0 107 0 -3 1.0 130 0)
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   614
              level: 0
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   615
              tabable: true
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   616
              model: ignoreCase
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   617
              translateLabel: true
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   618
            )
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   619
           (VariableVerticalPanelSpec
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   620
              name: 'VariableVerticalPanel1'
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   621
              layout: (LayoutFrame 0 0 -64 1 0 1 -4 1)
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   622
              component:
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   623
             (SpecCollection
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   624
                collection: (
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   625
                 (HorizontalPanelViewSpec
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   626
                    name: 'HorizontalPanel1'
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   627
                    level: 0
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   628
                    horizontalLayout: fitSpace
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   629
                    verticalLayout: center
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   630
                    horizontalSpace: 3
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   631
                    verticalSpace: 3
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   632
                    ignoreInvisibleComponents: true
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   633
                    reverseOrderIfOKAtLeft: true
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   634
                    component:
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   635
                   (SpecCollection
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   636
                      collection: (
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   637
                       (ActionButtonSpec
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   638
                          label: 'Replace'
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   639
                          name: 'replaceButton'
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   640
                          level: 2
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   641
                          translateLabel: true
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   642
                          tabable: true
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   643
                          model: replaceAction
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   644
                          extent: (Point 134 21)
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   645
                        )
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   646
                       (ActionButtonSpec
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   647
                          label: 'Replace All'
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   648
                          name: 'replaceAllButton'
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   649
                          level: 2
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   650
                          borderWidth: 1
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   651
                          translateLabel: true
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   652
                          tabable: true
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   653
                          model: replaceAllAction
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   654
                          extent: (Point 134 21)
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   655
                        )
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   656
                       )
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   657
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   658
                    )
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   659
                  )
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   660
                 (HorizontalPanelViewSpec
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   661
                    name: 'horizontalPanelView'
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   662
                    level: 0
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   663
                    horizontalLayout: fitSpace
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   664
                    verticalLayout: center
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   665
                    horizontalSpace: 3
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   666
                    verticalSpace: 3
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   667
                    ignoreInvisibleComponents: true
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   668
                    reverseOrderIfOKAtLeft: true
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   669
                    component:
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   670
                   (SpecCollection
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   671
                      collection: (
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   672
                       (ActionButtonSpec
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   673
                          label: 'Cancel'
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   674
                          name: 'cancelButton'
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   675
                          level: 2
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   676
                          translateLabel: true
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   677
                          tabable: true
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   678
                          model: cancel
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   679
                          extent: (Point 88 21)
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   680
                        )
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   681
                       (ActionButtonSpec
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   682
                          label: 'Prev'
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   683
                          name: 'prevButton'
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   684
                          level: 2
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   685
                          translateLabel: true
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   686
                          tabable: true
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   687
                          model: prevAction
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   688
                          extent: (Point 89 21)
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   689
                        )
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   690
                       (ActionButtonSpec
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   691
                          label: 'Next'
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   692
                          name: 'nextButton'
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   693
                          level: 2
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   694
                          borderWidth: 1
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   695
                          translateLabel: true
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   696
                          tabable: true
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   697
                          model: nextAction
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   698
                          isDefault: true
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   699
                          extent: (Point 88 21)
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   700
                        )
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   701
                       )
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   702
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   703
                    )
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   704
                  )
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   705
                 )
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   706
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   707
              )
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   708
              handles: (Any 0.5 1.0)
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   709
            )
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   710
           (LabelSpec
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   711
              label: 'Replace By:'
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   712
              name: 'ReplaceLabel'
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   713
              layout: (LayoutFrame 1 0.0 53 0 -1 1.0 70 0)
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   714
              level: 0
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   715
              translateLabel: true
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   716
              adjust: left
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   717
            )
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   718
           )
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   719
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   720
        )
3431
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   721
      )
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   722
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   723
    "Modified: / 11-10-2006 / 21:05:09 / cg"
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   724
! !
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   725
2744
cb920467a4b4 method category rename
Claus Gittinger <cg@exept.de>
parents: 2730
diff changeset
   726
!EditTextView methodsFor:'Compatibility-ST80'!
1552
d3d4afaf4c68 dummy ST80 compatibility: #autoAccept:
Claus Gittinger <cg@exept.de>
parents: 1548
diff changeset
   727
d3d4afaf4c68 dummy ST80 compatibility: #autoAccept:
Claus Gittinger <cg@exept.de>
parents: 1548
diff changeset
   728
autoAccept:aBoolean
d3d4afaf4c68 dummy ST80 compatibility: #autoAccept:
Claus Gittinger <cg@exept.de>
parents: 1548
diff changeset
   729
    "ignored for now"
d3d4afaf4c68 dummy ST80 compatibility: #autoAccept:
Claus Gittinger <cg@exept.de>
parents: 1548
diff changeset
   730
2019
b6b078ea3bbf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2018
diff changeset
   731
    "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
   732
!
9bf6cf249376 two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents: 1580
diff changeset
   733
9bf6cf249376 two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents: 1580
diff changeset
   734
continuousAccept:aBoolean
9bf6cf249376 two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents: 1580
diff changeset
   735
    "ignored for now"
9bf6cf249376 two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents: 1580
diff changeset
   736
9bf6cf249376 two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents: 1580
diff changeset
   737
    "Created: / 19.6.1998 / 00:03:49 / cg"
9bf6cf249376 two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents: 1580
diff changeset
   738
!
9bf6cf249376 two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents: 1580
diff changeset
   739
1390
99674e1d9c85 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
   740
cutSelection
99674e1d9c85 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
   741
    self cut
99674e1d9c85 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
   742
99674e1d9c85 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
   743
    "Created: / 31.10.1997 / 03:29:50 / cg"
99674e1d9c85 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
   744
!
99674e1d9c85 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
   745
1590
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   746
deselect
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   747
    "remove the selection"
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   748
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   749
    ^ self unselect
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   750
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   751
    "Created: / 19.6.1998 / 02:41:54 / cg"
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   752
!
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   753
2101
8f2fab818f71 category renamining
Claus Gittinger <cg@exept.de>
parents: 2088
diff changeset
   754
enabled:aBoolean
8f2fab818f71 category renamining
Claus Gittinger <cg@exept.de>
parents: 2088
diff changeset
   755
8f2fab818f71 category renamining
Claus Gittinger <cg@exept.de>
parents: 2088
diff changeset
   756
    self readOnly:aBoolean not
8f2fab818f71 category renamining
Claus Gittinger <cg@exept.de>
parents: 2088
diff changeset
   757
8f2fab818f71 category renamining
Claus Gittinger <cg@exept.de>
parents: 2088
diff changeset
   758
    "Created: / 30.3.1999 / 15:10:23 / stefan"
8f2fab818f71 category renamining
Claus Gittinger <cg@exept.de>
parents: 2088
diff changeset
   759
    "Modified: / 30.3.1999 / 15:10:53 / stefan"
8f2fab818f71 category renamining
Claus Gittinger <cg@exept.de>
parents: 2088
diff changeset
   760
!
8f2fab818f71 category renamining
Claus Gittinger <cg@exept.de>
parents: 2088
diff changeset
   761
1732
2d433e114bbc added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 1717
diff changeset
   762
find:pattern
2d433e114bbc added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 1717
diff changeset
   763
    self searchFwd:pattern ifAbsent:nil
2d433e114bbc added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 1717
diff changeset
   764
2d433e114bbc added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 1717
diff changeset
   765
    "Created: / 29.1.1999 / 19:09:42 / cg"
2d433e114bbc added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 1717
diff changeset
   766
    "Modified: / 29.1.1999 / 19:10:12 / cg"
2d433e114bbc added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 1717
diff changeset
   767
!
2d433e114bbc added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 1717
diff changeset
   768
1294
dac755d4acd3 added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   769
insert:aString at:aCharacterPosition
dac755d4acd3 added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   770
    "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
   771
dac755d4acd3 added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   772
    |line col|
dac755d4acd3 added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   773
dac755d4acd3 added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   774
    line := self lineOfCharacterPosition:aCharacterPosition.
dac755d4acd3 added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   775
    col := aCharacterPosition - (self characterPositionOfLine:line col:1) + 1.
1480
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
   776
    col < 1 ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   777
        col := 1
1480
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
   778
    ].
1294
dac755d4acd3 added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   779
    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
   780
dac755d4acd3 added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   781
    "
dac755d4acd3 added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   782
     |top v|
dac755d4acd3 added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   783
dac755d4acd3 added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   784
     top := StandardSystemView new.
dac755d4acd3 added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   785
     top extent:300@300.
dac755d4acd3 added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   786
     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
   787
     top openAndWait.
dac755d4acd3 added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   788
     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
   789
     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
   790
    "
dac755d4acd3 added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   791
1480
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
   792
    "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
   793
!
dac755d4acd3 added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   794
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   795
insertAndSelect:aString at:aCharacterPosition
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   796
    "insert a selected string at aCharacterPosition."
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   797
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   798
    |line col|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   799
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   800
    line := self lineOfCharacterPosition:aCharacterPosition.
2310
861ab02b13b9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2225
diff changeset
   801
    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
   802
    self insertString:aString atLine:line col:col.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   803
    self selectFromLine:line col:col toLine:line col:col + aString size - 1
125
claus
parents: 123
diff changeset
   804
    "
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   805
     |v|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   806
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   807
     v := EditTextView new openAndWait.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   808
     v contents:'1234567890\1234567890\1234567890\' withCRs.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   809
     v insertAndSelect:'<- hello there' at:5.
125
claus
parents: 123
diff changeset
   810
    "
1390
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
99674e1d9c85 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
   813
pasteSelection
99674e1d9c85 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
   814
    self paste
99674e1d9c85 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
   815
99674e1d9c85 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
   816
    "Created: / 31.10.1997 / 03:28:53 / cg"
1590
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
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   819
replaceSelectionWith:aString
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   820
    ^ self replaceSelectionBy:aString
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   821
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   822
    "Created: / 19.6.1998 / 02:42:32 / cg"
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
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   825
selectAt:pos
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   826
    "move the cursor before cursorPosition."
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   827
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   828
    self cursorToCharacterPosition:pos
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   829
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   830
    "Modified: / 19.6.1998 / 02:41:28 / cg"
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   831
    "Created: / 19.6.1998 / 02:43:39 / cg"
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   832
!
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   833
2101
8f2fab818f71 category renamining
Claus Gittinger <cg@exept.de>
parents: 2088
diff changeset
   834
textHasChanged
8f2fab818f71 category renamining
Claus Gittinger <cg@exept.de>
parents: 2088
diff changeset
   835
    ^ self modified
8f2fab818f71 category renamining
Claus Gittinger <cg@exept.de>
parents: 2088
diff changeset
   836
8f2fab818f71 category renamining
Claus Gittinger <cg@exept.de>
parents: 2088
diff changeset
   837
    "Created: / 19.6.1998 / 00:09:43 / cg"
2117
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
b50c6d182e28 added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 2107
diff changeset
   840
textHasChanged:aBoolean
b50c6d182e28 added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 2107
diff changeset
   841
    "ST-80 compatibility: set/clear the modified flag."
b50c6d182e28 added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 2107
diff changeset
   842
b50c6d182e28 added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 2107
diff changeset
   843
    self modified:aBoolean
b50c6d182e28 added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 2107
diff changeset
   844
b50c6d182e28 added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 2107
diff changeset
   845
    "Created: / 5.2.2000 / 17:07:59 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   846
! !
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   847
4585
7b31719bf07a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4580
diff changeset
   848
!EditTextView methodsFor:'accessing'!
7b31719bf07a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4580
diff changeset
   849
4803
87d60a4b098b Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4801
diff changeset
   850
codeAspect
87d60a4b098b Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4801
diff changeset
   851
    | codeAspect app |
87d60a4b098b Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4801
diff changeset
   852
87d60a4b098b Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4801
diff changeset
   853
    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
   854
    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
   855
    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
   856
6314
ac5b9324a82a #DOCUMENTATION by stefan
Stefan Vogel <sv@exept.de>
parents: 6313
diff changeset
   857
    "/ Applications should set it explictly, however, to make it behave like
4803
87d60a4b098b Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4801
diff changeset
   858
    "/ 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
   859
    ^((app := self topView application) notNil and:[app respondsTo: #codeAspect])
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   860
        ifTrue:[app codeAspect]
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   861
        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
   862
87d60a4b098b Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4801
diff changeset
   863
    "Created: / 27-09-2013 / 09:53:40 / Jan Vrany <jan.vrany@fit.cvut.cz>"
6314
ac5b9324a82a #DOCUMENTATION by stefan
Stefan Vogel <sv@exept.de>
parents: 6313
diff changeset
   864
    "Modified (comment): / 27-04-2018 / 16:39:15 / stefan"
4803
87d60a4b098b Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4801
diff changeset
   865
!
87d60a4b098b Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4801
diff changeset
   866
87d60a4b098b Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4801
diff changeset
   867
codeAspect: aSymbol
87d60a4b098b Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4801
diff changeset
   868
    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
   869
87d60a4b098b Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4801
diff changeset
   870
    "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
   871
!
87d60a4b098b Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4801
diff changeset
   872
4801
69a5bff7b5cd Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4786
diff changeset
   873
completionSupport
69a5bff7b5cd Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4786
diff changeset
   874
    ^ completionSupport
69a5bff7b5cd Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4786
diff changeset
   875
!
69a5bff7b5cd Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4786
diff changeset
   876
69a5bff7b5cd Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4786
diff changeset
   877
completionSupport:anEditTextViewCompletionSupport
69a5bff7b5cd Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4786
diff changeset
   878
    completionSupport := anEditTextViewCompletionSupport.
69a5bff7b5cd Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4786
diff changeset
   879
!
69a5bff7b5cd Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4786
diff changeset
   880
69a5bff7b5cd Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4786
diff changeset
   881
completionSupportClass
69a5bff7b5cd Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4786
diff changeset
   882
    ^ self class defaultCompletionSupportClass
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
    "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
   885
!
69a5bff7b5cd Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4786
diff changeset
   886
4609
8b3eb80d04d0 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4595
diff changeset
   887
editedClass
8b3eb80d04d0 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4595
diff changeset
   888
    |cm|
8b3eb80d04d0 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4595
diff changeset
   889
8b3eb80d04d0 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4595
diff changeset
   890
    cm := self editedMethodOrClass.
8b3eb80d04d0 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4595
diff changeset
   891
    cm isBehavior ifTrue:[^ cm].
8b3eb80d04d0 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4595
diff changeset
   892
    cm isMethod ifTrue:[^ cm mclass].
8b3eb80d04d0 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4595
diff changeset
   893
    ^ nil
8b3eb80d04d0 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4595
diff changeset
   894
!
8b3eb80d04d0 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4595
diff changeset
   895
4775
e34752e6214e Pass programming language when asking DWIM to complete code
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4771
diff changeset
   896
editedLanguage
6610
7cb4e0787a81 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6609
diff changeset
   897
    "get the programming language (for comments, indentation etc.).
7cb4e0787a81 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6609
diff changeset
   898
     Here, in the generic editor, we don't know anything about languages"
7cb4e0787a81 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6609
diff changeset
   899
4775
e34752e6214e Pass programming language when asking DWIM to complete code
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4771
diff changeset
   900
    ^ nil
e34752e6214e Pass programming language when asking DWIM to complete code
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4771
diff changeset
   901
e34752e6214e Pass programming language when asking DWIM to complete code
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4771
diff changeset
   902
    "Created: / 18-09-2013 / 14:16:38 / Jan Vrany <jan.vrany@fit.cvut.cz>"
6610
7cb4e0787a81 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6609
diff changeset
   903
    "Modified (comment): / 26-06-2019 / 22:07:54 / Claus Gittinger"
4775
e34752e6214e Pass programming language when asking DWIM to complete code
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4771
diff changeset
   904
!
e34752e6214e Pass programming language when asking DWIM to complete code
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4771
diff changeset
   905
4803
87d60a4b098b Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4801
diff changeset
   906
editedLanguage: aProgrammingLanguage
87d60a4b098b Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4801
diff changeset
   907
    "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
   908
87d60a4b098b Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4801
diff changeset
   909
    "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
   910
!
87d60a4b098b Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4801
diff changeset
   911
4609
8b3eb80d04d0 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4595
diff changeset
   912
editedMethod
8b3eb80d04d0 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4595
diff changeset
   913
    |cm|
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
    cm := self editedMethodOrClass.
8b3eb80d04d0 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4595
diff changeset
   916
    cm isMethod ifTrue:[^ cm].
8b3eb80d04d0 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4595
diff changeset
   917
    cm isBehavior ifTrue:[^ nil].
8b3eb80d04d0 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4595
diff changeset
   918
    ^ nil
8b3eb80d04d0 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4595
diff changeset
   919
!
8b3eb80d04d0 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4595
diff changeset
   920
8b3eb80d04d0 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4595
diff changeset
   921
editedMethodOrClass
8b3eb80d04d0 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4595
diff changeset
   922
    ^ nil
8b3eb80d04d0 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4595
diff changeset
   923
!
8b3eb80d04d0 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4595
diff changeset
   924
4803
87d60a4b098b Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4801
diff changeset
   925
editedMethodOrClass: methodOrClass
87d60a4b098b Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4801
diff changeset
   926
    "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
   927
87d60a4b098b Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4801
diff changeset
   928
    "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
   929
!
87d60a4b098b Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4801
diff changeset
   930
4585
7b31719bf07a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4580
diff changeset
   931
hasSelectionOrTextInCursorLine
7b31719bf07a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4580
diff changeset
   932
    ^ (self selectionOrTextOfCursorLine:false) notNil
7b31719bf07a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4580
diff changeset
   933
!
7b31719bf07a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4580
diff changeset
   934
4589
f6da08d703f5 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4585
diff changeset
   935
selectionOrTextOfCursorLine
f6da08d703f5 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4585
diff changeset
   936
    ^ self selectionOrTextOfCursorLine:true
f6da08d703f5 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4585
diff changeset
   937
!
f6da08d703f5 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4585
diff changeset
   938
4585
7b31719bf07a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4580
diff changeset
   939
selectionOrTextOfCursorLine:doSelect
7b31719bf07a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4580
diff changeset
   940
    |sel lNr line|
7b31719bf07a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4580
diff changeset
   941
7b31719bf07a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4580
diff changeset
   942
    sel := self selectionAsString.
7b31719bf07a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4580
diff changeset
   943
    sel notNil ifTrue:[^ sel].
7b31719bf07a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4580
diff changeset
   944
7b31719bf07a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4580
diff changeset
   945
    lNr := self cursorLine.
7b31719bf07a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4580
diff changeset
   946
    line := self listAt:lNr.
7b31719bf07a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4580
diff changeset
   947
    line notEmptyOrNil ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   948
        doSelect ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   949
            self selectLine:lNr.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   950
        ].
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
   951
        ^ line
4585
7b31719bf07a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4580
diff changeset
   952
    ].
7b31719bf07a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4580
diff changeset
   953
7b31719bf07a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4580
diff changeset
   954
    ^ nil
7b31719bf07a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4580
diff changeset
   955
! !
7b31719bf07a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4580
diff changeset
   956
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   957
!EditTextView methodsFor:'accessing-behavior'!
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
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   960
    "return the action to be performed on accept (or nil)"
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
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
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   965
acceptAction:aBlock
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   966
    "set the action to be performed on accept"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   967
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   968
    acceptAction := aBlock
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   969
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   970
2792
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   971
acceptChannel
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   972
    "return the valueHolder holding true if text was accepted.
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   973
     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
   974
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   975
    ^ acceptChannel
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   976
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   977
    "Modified: / 30.1.1998 / 14:17:11 / cg"
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   978
!
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
acceptChannel:aValueHolder
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   981
    "set the valueHolder holding true if text was accepted.
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   982
     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
   983
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   984
    |prev|
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
    prev := acceptChannel.
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   987
    acceptChannel := aValueHolder.
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   988
    self setupChannel:aValueHolder for:nil withOld:prev
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   989
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   990
    "Created: / 30.1.1998 / 14:51:09 / cg"
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   991
!
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
   992
1108
3d14bb6bceb7 added disableAccept
Claus Gittinger <cg@exept.de>
parents: 1082
diff changeset
   993
acceptEnabled:aBoolean
3d14bb6bceb7 added disableAccept
Claus Gittinger <cg@exept.de>
parents: 1082
diff changeset
   994
    "enable/disable accept. This greys the corresponding item in the menu"
3d14bb6bceb7 added disableAccept
Claus Gittinger <cg@exept.de>
parents: 1082
diff changeset
   995
3d14bb6bceb7 added disableAccept
Claus Gittinger <cg@exept.de>
parents: 1082
diff changeset
   996
    acceptEnabled := aBoolean
3d14bb6bceb7 added disableAccept
Claus Gittinger <cg@exept.de>
parents: 1082
diff changeset
   997
3d14bb6bceb7 added disableAccept
Claus Gittinger <cg@exept.de>
parents: 1082
diff changeset
   998
    "Created: 7.3.1997 / 11:04:34 / cg"
3d14bb6bceb7 added disableAccept
Claus Gittinger <cg@exept.de>
parents: 1082
diff changeset
   999
!
3d14bb6bceb7 added disableAccept
Claus Gittinger <cg@exept.de>
parents: 1082
diff changeset
  1000
2792
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1001
accepted
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1002
    "return true if text was accepted"
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1003
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1004
    ^ acceptChannel value
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1005
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1006
    "Created: 14.2.1997 / 16:43:46 / cg"
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1007
!
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
accepted:aBoolean
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1010
    "set/clear the accepted flag.
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1011
     This may force my current contents to be placed into my model."
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1012
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1013
    acceptChannel value:aBoolean.
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1014
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1015
    "Created: / 14.2.1997 / 16:44:01 / cg"
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1016
    "Modified: / 30.1.1998 / 14:20:15 / cg"
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1017
!
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1018
6609
8f4c3e49944d #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6599
diff changeset
  1019
autoIndent
6614
228cd1c3eac9 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6613
diff changeset
  1020
    ^ autoIndent value
228cd1c3eac9 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6613
diff changeset
  1021
228cd1c3eac9 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6613
diff changeset
  1022
    "Modified: / 26-06-2019 / 23:16:17 / Claus Gittinger"
6609
8f4c3e49944d #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6599
diff changeset
  1023
!
8f4c3e49944d #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6599
diff changeset
  1024
474
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  1025
autoIndent:aBoolean
6614
228cd1c3eac9 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6613
diff changeset
  1026
    autoIndent value: aBoolean
228cd1c3eac9 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6613
diff changeset
  1027
228cd1c3eac9 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6613
diff changeset
  1028
    "Created: / 05-03-1996 / 14:37:50 / cg"
228cd1c3eac9 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6613
diff changeset
  1029
    "Modified: / 26-06-2019 / 23:19:24 / Claus Gittinger"
228cd1c3eac9 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6613
diff changeset
  1030
!
228cd1c3eac9 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6613
diff changeset
  1031
228cd1c3eac9 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6613
diff changeset
  1032
autoIndentHolder
228cd1c3eac9 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6613
diff changeset
  1033
    ^ autoIndent
228cd1c3eac9 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6613
diff changeset
  1034
228cd1c3eac9 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6613
diff changeset
  1035
    "Created: / 26-06-2019 / 23:16:24 / Claus Gittinger"
474
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  1036
!
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  1037
4803
87d60a4b098b Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4801
diff changeset
  1038
codeAspectHolder
87d60a4b098b Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4801
diff changeset
  1039
    ^ codeAspectHolder
87d60a4b098b Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4801
diff changeset
  1040
!
87d60a4b098b Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4801
diff changeset
  1041
87d60a4b098b Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4801
diff changeset
  1042
codeAspectHolder:something
87d60a4b098b Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4801
diff changeset
  1043
    codeAspectHolder := something.
87d60a4b098b Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4801
diff changeset
  1044
!
87d60a4b098b Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4801
diff changeset
  1045
2774
0415ba0f8cb5 cursorMovement getter
penk
parents: 2762
diff changeset
  1046
cursorMovementWhenUpdating
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1047
    "return what is be done with the cursor,
2774
0415ba0f8cb5 cursorMovement getter
penk
parents: 2762
diff changeset
  1048
     when I get a new text (via the model or the #contents/#list)
0415ba0f8cb5 cursorMovement getter
penk
parents: 2762
diff changeset
  1049
     Allowed arguments are:
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  1050
        #keep / nil     -> stay where it was
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  1051
        #endOfText      -> position cursor to the end
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  1052
        #beginOfText    -> position cursor to the beginning
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  1053
        #endOfLine      -> position cursor to the current lines end
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  1054
        #beginOfLine    -> position cursor to the current lines start
2774
0415ba0f8cb5 cursorMovement getter
penk
parents: 2762
diff changeset
  1055
     The default is #beginOfText.
0415ba0f8cb5 cursorMovement getter
penk
parents: 2762
diff changeset
  1056
     This may be useful for fields which get new values assigned from
0415ba0f8cb5 cursorMovement getter
penk
parents: 2762
diff changeset
  1057
     the program (i.e. not from the user)"
0415ba0f8cb5 cursorMovement getter
penk
parents: 2762
diff changeset
  1058
0415ba0f8cb5 cursorMovement getter
penk
parents: 2762
diff changeset
  1059
    ^ cursorMovementWhenUpdating
0415ba0f8cb5 cursorMovement getter
penk
parents: 2762
diff changeset
  1060
0415ba0f8cb5 cursorMovement getter
penk
parents: 2762
diff changeset
  1061
    "Modified: 16.12.1995 / 16:27:55 / cg"
0415ba0f8cb5 cursorMovement getter
penk
parents: 2762
diff changeset
  1062
!
0415ba0f8cb5 cursorMovement getter
penk
parents: 2762
diff changeset
  1063
2133
47a23fdfc83f comment
Claus Gittinger <cg@exept.de>
parents: 2131
diff changeset
  1064
cursorMovementWhenUpdating:aSymbolOrNil
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1065
    "define what should be done with the cursor,
2133
47a23fdfc83f comment
Claus Gittinger <cg@exept.de>
parents: 2131
diff changeset
  1066
     when I get a new text (via the model or the #contents/#list)
47a23fdfc83f comment
Claus Gittinger <cg@exept.de>
parents: 2131
diff changeset
  1067
     Allowed arguments are:
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  1068
        #keep / nil     -> stay where it was
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  1069
        #endOfText      -> position cursor to the end
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  1070
        #beginOfText    -> position cursor to the beginning
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  1071
        #endOfLine      -> position cursor to the current lines end
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  1072
        #beginOfLine    -> position cursor to the current lines start
2133
47a23fdfc83f comment
Claus Gittinger <cg@exept.de>
parents: 2131
diff changeset
  1073
     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
  1074
     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
  1075
     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
  1076
2133
47a23fdfc83f comment
Claus Gittinger <cg@exept.de>
parents: 2131
diff changeset
  1077
    cursorMovementWhenUpdating := aSymbolOrNil
2129
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  1078
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  1079
    "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
  1080
!
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  1081
2035
6924861adf08 added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents: 2029
diff changeset
  1082
disableIfInvisible:aBoolean
6924861adf08 added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents: 2029
diff changeset
  1083
    disableIfInvisible := aBoolean
6924861adf08 added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents: 2029
diff changeset
  1084
!
6924861adf08 added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents: 2029
diff changeset
  1085
2438
6406f4444ee4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2432
diff changeset
  1086
dontReplaceSelectionOnInput
4742
a00cb40ee392 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4738
diff changeset
  1087
    "remember that the current selection was created by a paste operation
a00cb40ee392 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4738
diff changeset
  1088
     (as opposed to an explicit selection by the user).
a00cb40ee392 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4738
diff changeset
  1089
     This selection will not be replaced by followup user input,
a00cb40ee392 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4738
diff changeset
  1090
     so multiple pastes will be possible."
a00cb40ee392 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4738
diff changeset
  1091
2438
6406f4444ee4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2432
diff changeset
  1092
    typeOfSelection := #paste
6406f4444ee4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2432
diff changeset
  1093
!
6406f4444ee4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2432
diff changeset
  1094
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  1095
editModeHolder
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  1096
    ^ editMode.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  1097
!
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  1098
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  1099
editModeInsert
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  1100
    editMode value:EditMode insertMode
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  1101
!
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  1102
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  1103
editModeInsertAndSelect
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  1104
    editMode value:EditMode insertAndSelectMode
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  1105
!
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  1106
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  1107
editModeOverwrite
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  1108
    editMode value:EditMode overwriteMode
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  1109
!
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  1110
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1111
exceptionBlock:aBlock
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1112
    "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
  1113
     readonly text"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1114
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1115
    exceptionBlock := aBlock
323
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
  1116
!
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
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
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  1160
        with:[:m | m isInsertMode]
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
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
6572
9cec05d7dbff #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 6567
diff changeset
  1184
lineEndCRLF:aBoolean
9cec05d7dbff #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 6567
diff changeset
  1185
    "If aBoolean is true, use CRLF (as in windows) for end of line.
9cec05d7dbff #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 6567
diff changeset
  1186
     Otherwise and default use Character cr (which in newline as in unix)."
9cec05d7dbff #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 6567
diff changeset
  1187
9cec05d7dbff #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 6567
diff changeset
  1188
    lineEndCRLF := aBoolean.
9cec05d7dbff #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 6567
diff changeset
  1189
9cec05d7dbff #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 6567
diff changeset
  1190
    "Created: / 16-04-2019 / 10:59:47 / Stefan Vogel"
9cec05d7dbff #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 6567
diff changeset
  1191
!
9cec05d7dbff #FEATURE by stefan
Stefan Vogel <sv@exept.de>
parents: 6567
diff changeset
  1192
2796
481d9e54434c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2795
diff changeset
  1193
modeLabelHolder
481d9e54434c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2795
diff changeset
  1194
    "a valueHolder, which contains 'L' (learnMode), I (insertMode) or empty"
481d9e54434c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2795
diff changeset
  1195
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1196
    ^ BlockValue
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  1197
        with:[:e :l |
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  1198
            self isReadOnly ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  1199
                ''
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  1200
            ] ifFalse:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  1201
                l ifTrue:[ 'L' allBold withColor:#red]
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  1202
                  ifFalse:[ e infoPrintString]]]
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  1203
        argument:(self editModeHolder)
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  1204
        argument:(self learnModeHolder).
3465
a6eb20608b1f BlockValue usage cleanup
Claus Gittinger <cg@exept.de>
parents: 3439
diff changeset
  1205
a6eb20608b1f BlockValue usage cleanup
Claus Gittinger <cg@exept.de>
parents: 3439
diff changeset
  1206
    "Modified: / 08-03-2007 / 22:58:59 / cg"
2796
481d9e54434c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2795
diff changeset
  1207
!
481d9e54434c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2795
diff changeset
  1208
2792
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1209
modified
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1210
    "return true if text was modified"
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1211
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1212
    ^ modifiedChannel value
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
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1215
modified:aBoolean
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1216
    "set/clear the modified flag"
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1217
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1218
    modifiedChannel value:aBoolean
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
    "Modified: 14.2.1997 / 16:44:05 / cg"
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1221
!
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
modifiedChannel
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1224
    "return the valueHolder holding true if text was modified"
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1225
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1226
    ^ modifiedChannel
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1227
!
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
modifiedChannel:aValueHolder
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1230
    "set the valueHolder holding true if text was modified"
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
    |prev|
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1233
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1234
    prev := modifiedChannel.
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1235
    modifiedChannel := aValueHolder.
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1236
    self setupChannel:aValueHolder for:nil withOld:prev
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1237
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1238
    "Created: / 30.1.1998 / 14:51:32 / cg"
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1239
!
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1240
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1241
readOnly
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1242
    "make the text readonly.
4664
f09d5587253f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4661
diff changeset
  1243
     Obsolete because it is obfuscating (looks like a getter)
f09d5587253f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4661
diff changeset
  1244
     - use #readOnly:"
2792
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
    <resource:#obsolete>
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1247
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1248
    self obsoleteMethodWarning:'use #readOnly:'.
3705
a819d7204ee3 changed #readOnly
Stefan Vogel <sv@exept.de>
parents: 3683
diff changeset
  1249
    self readOnly:true.
2792
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1250
4664
f09d5587253f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4661
diff changeset
  1251
    "Modified: / 14-02-1997 / 17:35:56 / cg"
f09d5587253f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4661
diff changeset
  1252
    "Modified (comment): / 02-08-2013 / 16:46:57 / cg"
2792
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
6401
de518dc6caf9 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6400
diff changeset
  1255
readOnly:aBooleanOrValueHolder
2792
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1256
    "make the text readonly (aBoolean == true) or writable (aBoolean == false).
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1257
     The argument may also be a valueHolder."
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1258
6401
de518dc6caf9 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6400
diff changeset
  1259
    readOnly := aBooleanOrValueHolder
de518dc6caf9 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6400
diff changeset
  1260
de518dc6caf9 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6400
diff changeset
  1261
    "Created: / 14-02-1997 / 17:35:39 / cg"
de518dc6caf9 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6400
diff changeset
  1262
    "Modified (format): / 22-08-2018 / 15:35:14 / Claus Gittinger"
2792
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1263
!
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1264
4782
353079ce0c9d class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4781
diff changeset
  1265
reallyModifiedChannel
353079ce0c9d class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4781
diff changeset
  1266
    "return the valueHolder holding true if text was really modified.
353079ce0c9d class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4781
diff changeset
  1267
     For compatibility with views which use the modified flag for syntax highlighting."
353079ce0c9d class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4781
diff changeset
  1268
353079ce0c9d class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4781
diff changeset
  1269
    ^ self modifiedChannel
353079ce0c9d class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4781
diff changeset
  1270
!
353079ce0c9d class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4781
diff changeset
  1271
5909
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  1272
st80EditMode
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  1273
    "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
  1274
     if off, we have the Rand-editor behavior (random access)"
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  1275
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  1276
    ^ st80Mode ? (UserPreferences current st80EditMode)
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  1277
!
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  1278
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  1279
st80EditMode:aBooleanOrNil
4192
0bc8b69bb610 added: #st80Mode:
Claus Gittinger <cg@exept.de>
parents: 4191
diff changeset
  1280
    "set/clear the st80Mode flag.
0bc8b69bb610 added: #st80Mode:
Claus Gittinger <cg@exept.de>
parents: 4191
diff changeset
  1281
     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
  1282
     if off, we have the Rand-editor behavior (random access)
c24842bec834 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5251
diff changeset
  1283
     if nil, the setting follows the current userPref setting."
c24842bec834 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5251
diff changeset
  1284
c24842bec834 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5251
diff changeset
  1285
    st80Mode := aBooleanOrNil
4192
0bc8b69bb610 added: #st80Mode:
Claus Gittinger <cg@exept.de>
parents: 4191
diff changeset
  1286
0bc8b69bb610 added: #st80Mode:
Claus Gittinger <cg@exept.de>
parents: 4191
diff changeset
  1287
    "Created: / 09-11-2010 / 13:55:50 / cg"
0bc8b69bb610 added: #st80Mode:
Claus Gittinger <cg@exept.de>
parents: 4191
diff changeset
  1288
!
0bc8b69bb610 added: #st80Mode:
Claus Gittinger <cg@exept.de>
parents: 4191
diff changeset
  1289
5909
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  1290
st80Mode:aBooleanOrNil
6070
18e8ef85aedf #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 6068
diff changeset
  1291
    <resource: #obsolete>
5909
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  1292
    self obsoleteMethodWarning.
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  1293
    self st80EditMode:aBooleanOrNil
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  1294
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  1295
    "Created: / 09-11-2010 / 13:55:50 / cg"
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  1296
!
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  1297
323
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
  1298
tabMeansNextField:aBoolean
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
  1299
    "set/clear tabbing to the next field.
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
  1300
     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
  1301
     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
  1302
     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
  1303
     input fields."
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
  1304
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
  1305
    tabMeansNextField := aBoolean
2779
5ca530482fdd unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 2774
diff changeset
  1306
!
5ca530482fdd unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 2774
diff changeset
  1307
5ca530482fdd unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 2774
diff changeset
  1308
tabRequiresControl
5ca530482fdd unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 2774
diff changeset
  1309
    "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
  1310
     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
  1311
     to allow for easier text entry"
5ca530482fdd unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 2774
diff changeset
  1312
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1313
    ^ tabRequiresControl
2779
5ca530482fdd unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 2774
diff changeset
  1314
!
5ca530482fdd unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 2774
diff changeset
  1315
5ca530482fdd unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 2774
diff changeset
  1316
tabRequiresControl:aBoolean
5ca530482fdd unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 2774
diff changeset
  1317
    "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
  1318
     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
  1319
     to allow for easier text entry"
5ca530482fdd unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 2774
diff changeset
  1320
5ca530482fdd unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 2774
diff changeset
  1321
    tabRequiresControl := aBoolean
5909
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  1322
!
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
6310
53912415ce0e #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 6309
diff changeset
  1325
    "If true, the blank lines are trimmed to zero size and trailing blank lines are removed;
53912415ce0e #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 6309
diff changeset
  1326
     if false, they are left as is;
5909
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  1327
     if nil, the setting follows the current userPref setting."
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  1328
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  1329
    ^ trimBlankLines ? (UserPreferences current trimBlankLines)
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  1330
!
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  1331
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  1332
trimBlankLines:aBooleanOrNil
6310
53912415ce0e #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 6309
diff changeset
  1333
    "If true, the blank lines are trimmed to zero size and trailing blank lines are removed;
53912415ce0e #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 6309
diff changeset
  1334
     if false, they are left as is;
5909
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  1335
     if nil, the setting follows the current userPref setting."
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  1336
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  1337
    trimBlankLines := aBooleanOrNil.
6329
d828eeb4f784 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6328
diff changeset
  1338
!
d828eeb4f784 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6328
diff changeset
  1339
d828eeb4f784 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6328
diff changeset
  1340
trimLastCR
d828eeb4f784 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6328
diff changeset
  1341
    "If true, the last line is returned without a trailing CR character;
d828eeb4f784 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6328
diff changeset
  1342
     The default is false; this is only used by very specialized editors."
d828eeb4f784 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6328
diff changeset
  1343
d828eeb4f784 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6328
diff changeset
  1344
    ^ (self objectAttributeAt:#trimLastCR) ? false
d828eeb4f784 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6328
diff changeset
  1345
d828eeb4f784 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6328
diff changeset
  1346
    "Created: / 28-05-2018 / 12:05:34 / Claus Gittinger"
d828eeb4f784 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6328
diff changeset
  1347
!
d828eeb4f784 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6328
diff changeset
  1348
d828eeb4f784 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6328
diff changeset
  1349
trimLastCR:aBooleanOrNil
d828eeb4f784 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6328
diff changeset
  1350
    "If true, the last line is returned without a trailing CR character;
d828eeb4f784 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6328
diff changeset
  1351
     The default is false; this is only used by very specialized editors."
d828eeb4f784 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6328
diff changeset
  1352
d828eeb4f784 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6328
diff changeset
  1353
    self objectAttributeAt:#trimLastCR put:aBooleanOrNil.
d828eeb4f784 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6328
diff changeset
  1354
d828eeb4f784 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6328
diff changeset
  1355
    "Created: / 28-05-2018 / 12:05:02 / Claus Gittinger"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1356
! !
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1357
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1358
!EditTextView methodsFor:'accessing-contents'!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1359
1902
302a68c2255e added #at:basicPut: to access a line without change notification.
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
  1360
at:lineNr basicPut:aLine
5413
b21cbb97c038 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5404
diff changeset
  1361
    "change a line without change notification.
b21cbb97c038 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5404
diff changeset
  1362
     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
  1363
302a68c2255e added #at:basicPut: to access a line without change notification.
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
  1364
    (self at:lineNr) = aLine ifFalse:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  1365
        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
  1366
    ].
302a68c2255e added #at:basicPut: to access a line without change notification.
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
  1367
!
302a68c2255e added #at:basicPut: to access a line without change notification.
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
  1368
522
aa9458e4643e indent/undent did not trigger a modify
ca
parents: 503
diff changeset
  1369
at:lineNr put:aLine
5413
b21cbb97c038 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5404
diff changeset
  1370
    "replace a line by something new.
b21cbb97c038 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5404
diff changeset
  1371
     this is not undoably, unless you care for yourself"
b21cbb97c038 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5404
diff changeset
  1372
5393
efb824b89cdf class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5390
diff changeset
  1373
    |oldLine|
efb824b89cdf class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5390
diff changeset
  1374
efb824b89cdf class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5390
diff changeset
  1375
    oldLine := (self at:lineNr) ? ''.
efb824b89cdf class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5390
diff changeset
  1376
    (oldLine sameStringAndEmphasisAs: (aLine? '')) ifFalse:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  1377
        super at:lineNr put:aLine.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  1378
        self textChanged
522
aa9458e4643e indent/undent did not trigger a modify
ca
parents: 503
diff changeset
  1379
    ].
aa9458e4643e indent/undent did not trigger a modify
ca
parents: 503
diff changeset
  1380
!
aa9458e4643e indent/undent did not trigger a modify
ca
parents: 503
diff changeset
  1381
4700
150468a2ea5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4697
diff changeset
  1382
characterAfterCursor
150468a2ea5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4697
diff changeset
  1383
    "return the character one after the cursor - space if beyond line."
150468a2ea5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4697
diff changeset
  1384
150468a2ea5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4697
diff changeset
  1385
    ^ self characterAtLine:cursorLine col:cursorCol+1
150468a2ea5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4697
diff changeset
  1386
!
150468a2ea5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4697
diff changeset
  1387
1577
4e487247ad33 dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents: 1568
diff changeset
  1388
characterBeforeCursor
4700
150468a2ea5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4697
diff changeset
  1389
    "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
  1390
5142
54457633c096 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5134
diff changeset
  1391
    cursorCol <= 1 ifTrue:[^ nil].
1577
4e487247ad33 dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents: 1568
diff changeset
  1392
4e487247ad33 dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents: 1568
diff changeset
  1393
    ^ self characterAtLine:cursorLine col:cursorCol-1
4e487247ad33 dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents: 1568
diff changeset
  1394
4e487247ad33 dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents: 1568
diff changeset
  1395
    "Created: / 17.6.1998 / 15:16:41 / cg"
4e487247ad33 dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents: 1568
diff changeset
  1396
!
4e487247ad33 dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents: 1568
diff changeset
  1397
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1398
characterUnderCursor
2707
810c994db0b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2696
diff changeset
  1399
    "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
  1400
     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
  1401
     of the insertion-bar or caret.
5413
b21cbb97c038 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5404
diff changeset
  1402
     For block cursors, this is the highlighted cursor-character"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1403
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1404
    ^ self characterAtLine:cursorLine col:cursorCol
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1405
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1406
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1407
contents
6330
58a0c92543c4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6329
diff changeset
  1408
    "return the contents as a String or Text (i.e. with emphasis).
58a0c92543c4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6329
diff changeset
  1409
     Cares for trimBlankLines and trimLastCR options."
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1410
6329
d828eeb4f784 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6328
diff changeset
  1411
    |numLines contents|
5988
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
  1412
    
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
  1413
    list isNil ifTrue:[^ ''].    
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
  1414
    self trimBlankLines ifTrue:[
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
  1415
        self removeTrailingBlankLines.
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
  1416
    ] ifFalse:[
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
  1417
        "/ the last line does not count, if the cursor is at
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
  1418
        "/ the begining
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
  1419
        cursorCol == 1 ifTrue:[
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
  1420
            numLines := list size.    
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
  1421
            cursorLine == numLines ifTrue:[
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
  1422
                numLines > 1 ifTrue:[
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
  1423
                    (self listAt:numLines) isEmptyOrNil ifTrue:[
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
  1424
                        list grow:numLines-1.
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
  1425
                    ].    
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
  1426
                ].    
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
  1427
            ].    
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
  1428
        ].    
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
  1429
    ].    
6329
d828eeb4f784 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6328
diff changeset
  1430
    contents := super contents.
d828eeb4f784 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6328
diff changeset
  1431
    (self trimLastCR) ifTrue:[
d828eeb4f784 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6328
diff changeset
  1432
        contents isString ifTrue:[
d828eeb4f784 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6328
diff changeset
  1433
            (contents endsWith:Character cr) ifTrue:[
d828eeb4f784 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6328
diff changeset
  1434
                ^ contents copyButLast
d828eeb4f784 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6328
diff changeset
  1435
            ].    
d828eeb4f784 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6328
diff changeset
  1436
        ].    
d828eeb4f784 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6328
diff changeset
  1437
    ].    
d828eeb4f784 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6328
diff changeset
  1438
    ^ contents
3313
6c2fd7c5a02f CRLF management
fm
parents: 3310
diff changeset
  1439
6c2fd7c5a02f CRLF management
fm
parents: 3310
diff changeset
  1440
    "Modified: / 04-07-2006 / 19:22:32 / fm"
6330
58a0c92543c4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6329
diff changeset
  1441
    "Modified (comment): / 28-05-2018 / 12:28:11 / Claus Gittinger"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1442
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1443
5413
b21cbb97c038 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5404
diff changeset
  1444
contents:aStringOrStringCollectionOrNil
b21cbb97c038 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5404
diff changeset
  1445
    "replace the whole contents by something new.
5414
87ff3f9cbe55 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5413
diff changeset
  1446
     this is not undoably, unless you care for yourself.
87ff3f9cbe55 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5413
diff changeset
  1447
     See replaceContentsWith:newContents for an undoable version of this"
5413
b21cbb97c038 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5404
diff changeset
  1448
b21cbb97c038 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5404
diff changeset
  1449
    self contents:aStringOrStringCollectionOrNil keepUndoHistory:false.
3249
a4beb76b3f59 code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents: 3241
diff changeset
  1450
!
a4beb76b3f59 code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents: 3241
diff changeset
  1451
a4beb76b3f59 code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents: 3241
diff changeset
  1452
contents:something keepUndoHistory:keepUndoHistory
5414
87ff3f9cbe55 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5413
diff changeset
  1453
    "set the contents and optionally clear the undo history.
87ff3f9cbe55 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5413
diff changeset
  1454
     The contents-change is not undoable."
87ff3f9cbe55 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5413
diff changeset
  1455
3249
a4beb76b3f59 code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents: 3241
diff changeset
  1456
    super contents:something.
a4beb76b3f59 code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents: 3241
diff changeset
  1457
    keepUndoHistory ifFalse:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  1458
        undoSupport resetHistories.
3249
a4beb76b3f59 code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents: 3241
diff changeset
  1459
    ].
a4beb76b3f59 code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents: 3241
diff changeset
  1460
!
a4beb76b3f59 code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents: 3241
diff changeset
  1461
2213
6068f2786bd6 added #contentsAsString
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1462
contentsAsString
6563
3cbb78c9dc1f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6548
diff changeset
  1463
    "return the contents as a String (i.e. without emphasis).
3cbb78c9dc1f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6548
diff changeset
  1464
     Trims always (i.e. ignores trimBlankLines and trimLastCR options)"
2213
6068f2786bd6 added #contentsAsString
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1465
6068f2786bd6 added #contentsAsString
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1466
    list isNil ifTrue:[^ ''].
6068f2786bd6 added #contentsAsString
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1467
    self removeTrailingBlankLines.
6412
5ceab4c0d579 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 6401
diff changeset
  1468
    ^ (list collect:[:each | 
5ceab4c0d579 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 6401
diff changeset
  1469
                each isNil 
5ceab4c0d579 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 6401
diff changeset
  1470
                    ifTrue:['']
5ceab4c0d579 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 6401
diff changeset
  1471
                    ifFalse:[each string]
5ceab4c0d579 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 6401
diff changeset
  1472
      ]) asStringWithCRs
5ceab4c0d579 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 6401
diff changeset
  1473
6563
3cbb78c9dc1f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6548
diff changeset
  1474
    "Modified (comment): / 21-03-2019 / 13:09:54 / Claus Gittinger"
2213
6068f2786bd6 added #contentsAsString
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1475
!
6068f2786bd6 added #contentsAsString
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1476
5067
a5298bf273fa class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5063
diff changeset
  1477
contentsAsStringWithTabs
a5298bf273fa class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5063
diff changeset
  1478
    "return the contents as a String (i.e. without emphasis)
a5298bf273fa class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5063
diff changeset
  1479
     and with leading spaces replaced by tab characters
6563
3cbb78c9dc1f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6548
diff changeset
  1480
     (i.e. as would be written to a file).
3cbb78c9dc1f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6548
diff changeset
  1481
     Trims always (i.e. ignores trimBlankLines and trimLastCR options)"
5067
a5298bf273fa class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5063
diff changeset
  1482
a5298bf273fa class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5063
diff changeset
  1483
    list isNil ifTrue:[^ ''].
a5298bf273fa class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5063
diff changeset
  1484
    self removeTrailingBlankLines.
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  1485
    ^ (list collect:[:each |
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  1486
        each isNil
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  1487
            ifTrue:['']
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  1488
            ifFalse:[each string withTabs]
5067
a5298bf273fa class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5063
diff changeset
  1489
       ]) asStringWithCRs
6563
3cbb78c9dc1f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6548
diff changeset
  1490
3cbb78c9dc1f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6548
diff changeset
  1491
    "Modified (format): / 21-03-2019 / 13:10:33 / Claus Gittinger"
5067
a5298bf273fa class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5063
diff changeset
  1492
!
a5298bf273fa class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5063
diff changeset
  1493
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1494
cursorCol
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1495
    "return the cursors col (1..).
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1496
     This is the absolute col; NOT the visible col"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1497
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1498
    ^ cursorCol
125
claus
parents: 123
diff changeset
  1499
!
claus
parents: 123
diff changeset
  1500
2422
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1501
cursorColHolder
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1502
    "return a valueHolder for the cursors column (1..)."
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1503
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1504
    ^ cursorColHolder
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1505
!
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1506
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1507
cursorLine
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1508
    "return the cursors line (1..).
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1509
     This is the absolute line; NOT the visible line"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1510
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1511
    ^ cursorLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1512
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1513
6295
408d5ea999ac #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6289
diff changeset
  1514
cursorLineAndColumnHolder
408d5ea999ac #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6289
diff changeset
  1515
    "return a valueHolder for the cursors line and column as an
408d5ea999ac #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6289
diff changeset
  1516
     array of the form { lineNr . col }
408d5ea999ac #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6289
diff changeset
  1517
     This can be used directly as a model to react on cursor movement"
408d5ea999ac #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6289
diff changeset
  1518
408d5ea999ac #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6289
diff changeset
  1519
    ^ BlockValue
408d5ea999ac #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6289
diff changeset
  1520
        with:[:l :c | (Array with:l with:c) ]
408d5ea999ac #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6289
diff changeset
  1521
        argument:self cursorLineHolder
408d5ea999ac #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6289
diff changeset
  1522
        argument:self cursorColHolder
408d5ea999ac #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6289
diff changeset
  1523
!
408d5ea999ac #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6289
diff changeset
  1524
5400
c8c25c1392f7 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5399
diff changeset
  1525
cursorLineAndColumnLabelHolder
5399
22d3682235f9 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5394
diff changeset
  1526
    "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
  1527
     of the form 'line : col'.
5399
22d3682235f9 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5394
diff changeset
  1528
     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
  1529
22d3682235f9 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5394
diff changeset
  1530
    ^ BlockValue
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  1531
        with:[:l :c | '%1 : %2' bindWith:l with:c]
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  1532
        argument:self cursorLineHolder
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  1533
        argument:self cursorColHolder
5399
22d3682235f9 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5394
diff changeset
  1534
!
22d3682235f9 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5394
diff changeset
  1535
2422
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1536
cursorLineHolder
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1537
    "return a valueHolder for the cursors line (1..).
2422
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1538
     This is the absolute line; NOT the visible line"
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1539
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1540
    ^ cursorLineHolder
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1541
!
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1542
4713
e8c9caf13e05 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4707
diff changeset
  1543
lineStringBeforeCursor
e8c9caf13e05 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4707
diff changeset
  1544
    "return the line's string before the cursor.
e8c9caf13e05 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4707
diff changeset
  1545
     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
  1546
6563
3cbb78c9dc1f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6548
diff changeset
  1547
    |line prevCol|
3cbb78c9dc1f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6548
diff changeset
  1548
3cbb78c9dc1f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6548
diff changeset
  1549
    prevCol := cursorCol-1.
3cbb78c9dc1f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6548
diff changeset
  1550
    line := ((self at:cursorLine) ? '') string.
3cbb78c9dc1f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6548
diff changeset
  1551
    line size < prevCol ifTrue:[
3cbb78c9dc1f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6548
diff changeset
  1552
        ^ line paddedTo:prevCol
3cbb78c9dc1f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6548
diff changeset
  1553
    ].
3cbb78c9dc1f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6548
diff changeset
  1554
    ^ line copyTo:prevCol
3cbb78c9dc1f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6548
diff changeset
  1555
3cbb78c9dc1f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6548
diff changeset
  1556
    "
3cbb78c9dc1f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6548
diff changeset
  1557
     EditTextView new
3cbb78c9dc1f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6548
diff changeset
  1558
        contents:c'line1\nline2\nline3';
3cbb78c9dc1f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6548
diff changeset
  1559
        lineStringBeforeCursor
3cbb78c9dc1f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6548
diff changeset
  1560
3cbb78c9dc1f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6548
diff changeset
  1561
     EditTextView new
3cbb78c9dc1f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6548
diff changeset
  1562
        contents:c'line1\nline2\nline3';
3cbb78c9dc1f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6548
diff changeset
  1563
        cursorLine:2 col:1;
3cbb78c9dc1f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6548
diff changeset
  1564
        lineStringBeforeCursor
3cbb78c9dc1f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6548
diff changeset
  1565
3cbb78c9dc1f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6548
diff changeset
  1566
     EditTextView new
3cbb78c9dc1f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6548
diff changeset
  1567
        contents:c'line1\nline2\nline3';
3cbb78c9dc1f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6548
diff changeset
  1568
        cursorLine:2 col:3;
3cbb78c9dc1f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6548
diff changeset
  1569
        lineStringBeforeCursor
3cbb78c9dc1f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6548
diff changeset
  1570
3cbb78c9dc1f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6548
diff changeset
  1571
     EditTextView new
3cbb78c9dc1f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6548
diff changeset
  1572
        contents:c'line1\nline2\nline3';
3cbb78c9dc1f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6548
diff changeset
  1573
        cursorLine:2 col:20;
3cbb78c9dc1f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6548
diff changeset
  1574
        lineStringBeforeCursor
3cbb78c9dc1f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6548
diff changeset
  1575
    "
3cbb78c9dc1f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6548
diff changeset
  1576
3cbb78c9dc1f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6548
diff changeset
  1577
    "Modified: / 21-03-2019 / 12:55:56 / Claus Gittinger"
3cbb78c9dc1f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6548
diff changeset
  1578
!
3cbb78c9dc1f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6548
diff changeset
  1579
3cbb78c9dc1f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6548
diff changeset
  1580
lineStringFromCursor
3cbb78c9dc1f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6548
diff changeset
  1581
    "return the line's string beginning at the cursor position to the line's end."
3cbb78c9dc1f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6548
diff changeset
  1582
4713
e8c9caf13e05 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4707
diff changeset
  1583
    |line|
e8c9caf13e05 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4707
diff changeset
  1584
e8c9caf13e05 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4707
diff changeset
  1585
    line := ((self at:cursorLine) ? '') string.
6563
3cbb78c9dc1f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6548
diff changeset
  1586
    line size < cursorCol ifTrue:[
3cbb78c9dc1f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6548
diff changeset
  1587
        ^ ''
3cbb78c9dc1f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6548
diff changeset
  1588
    ].
3cbb78c9dc1f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6548
diff changeset
  1589
    ^ line copyFrom:cursorCol
3cbb78c9dc1f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6548
diff changeset
  1590
3cbb78c9dc1f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6548
diff changeset
  1591
    "
3cbb78c9dc1f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6548
diff changeset
  1592
     EditTextView new
3cbb78c9dc1f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6548
diff changeset
  1593
        contents:c'line1\nline2\nline3';
3cbb78c9dc1f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6548
diff changeset
  1594
        lineStringFromCursor
3cbb78c9dc1f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6548
diff changeset
  1595
3cbb78c9dc1f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6548
diff changeset
  1596
     EditTextView new
3cbb78c9dc1f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6548
diff changeset
  1597
        contents:c'line1\nline2\nline3';
3cbb78c9dc1f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6548
diff changeset
  1598
        cursorLine:2 col:1;
3cbb78c9dc1f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6548
diff changeset
  1599
        lineStringFromCursor
3cbb78c9dc1f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6548
diff changeset
  1600
3cbb78c9dc1f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6548
diff changeset
  1601
     EditTextView new
3cbb78c9dc1f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6548
diff changeset
  1602
        contents:c'line1\nline2\nline3';
3cbb78c9dc1f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6548
diff changeset
  1603
        cursorLine:2 col:3;
3cbb78c9dc1f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6548
diff changeset
  1604
        lineStringFromCursor
3cbb78c9dc1f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6548
diff changeset
  1605
    "
3cbb78c9dc1f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6548
diff changeset
  1606
3cbb78c9dc1f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6548
diff changeset
  1607
    "Created: / 21-03-2019 / 12:51:08 / Claus Gittinger"
4713
e8c9caf13e05 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4707
diff changeset
  1608
!
e8c9caf13e05 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4707
diff changeset
  1609
6289
110928952dac #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 6274
diff changeset
  1610
list:newCollectionOfLinesOrNil
5413
b21cbb97c038 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5404
diff changeset
  1611
    "replace the whole contents by something new.
b21cbb97c038 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5404
diff changeset
  1612
     this is not undoably, unless you care for yourself.
6289
110928952dac #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 6274
diff changeset
  1613
     Positions the cursor as defined in cursorMovementWhenUpdating
110928952dac #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 6274
diff changeset
  1614
     (which defaults to: home)"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1615
2129
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  1616
    |prevCursorLine prevCursorCol|
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  1617
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  1618
    prevCursorLine := cursorLine.
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  1619
    prevCursorCol := cursorCol.
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  1620
6289
110928952dac #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 6274
diff changeset
  1621
    super list:newCollectionOfLinesOrNil.
2129
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  1622
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  1623
    (cursorMovementWhenUpdating == #endOfText
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  1624
    or:[cursorMovementWhenUpdating == #end]) ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  1625
        ^ self cursorToEndOfText
2129
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  1626
    ].
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  1627
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  1628
    (cursorMovementWhenUpdating == #endOfLine) ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  1629
        ^ self cursorLine:prevCursorLine col:(self listAt:cursorLine) size + 1.
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1630
    ].
2129
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  1631
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  1632
    (cursorMovementWhenUpdating == #beginOfText
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  1633
    or:[cursorMovementWhenUpdating == #begin]) ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  1634
        ^ self cursorHome
2129
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  1635
    ].
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  1636
    (cursorMovementWhenUpdating == #beginOfLine) ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  1637
        ^ 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
  1638
    ].
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  1639
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  1640
    "/ 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
  1641
    "/ self cursorLine:prevCursorLine col:prevCursorCol.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1642
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1643
1476
ac38c8af8585 setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents: 1449
diff changeset
  1644
setContents:something
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  1645
    "replace the whole contents by something new
5413
b21cbb97c038 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5404
diff changeset
  1646
     AND clear the remembered undo actions"
b21cbb97c038 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5404
diff changeset
  1647
1476
ac38c8af8585 setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents: 1449
diff changeset
  1648
    |selType|
ac38c8af8585 setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents: 1449
diff changeset
  1649
2989
5dcc2912bcb6 undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents: 2984
diff changeset
  1650
    undoSupport resetHistories.
2955
Claus Gittinger <cg@exept.de>
parents: 2954
diff changeset
  1651
1476
ac38c8af8585 setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents: 1449
diff changeset
  1652
    selType := typeOfSelection.
ac38c8af8585 setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents: 1449
diff changeset
  1653
    super setContents:something.
ac38c8af8585 setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents: 1449
diff changeset
  1654
    typeOfSelection := selType.
ac38c8af8585 setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents: 1449
diff changeset
  1655
ac38c8af8585 setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents: 1449
diff changeset
  1656
    "Created: / 31.3.1998 / 23:35:06 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1657
! !
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1658
4609
8b3eb80d04d0 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4595
diff changeset
  1659
!EditTextView methodsFor:'accessing-dimensions'!
8b3eb80d04d0 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4595
diff changeset
  1660
8b3eb80d04d0 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4595
diff changeset
  1661
xOfCursor
4728
af70b9c1d04c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4721
diff changeset
  1662
    |point|
af70b9c1d04c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4721
diff changeset
  1663
af70b9c1d04c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4721
diff changeset
  1664
    cursorVisibleLine isNil ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  1665
        "/ take the end of the selection, if any
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  1666
        (selectionStartLine notNil
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  1667
            and:[ self listLineIsVisible:selectionEndLine ])
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  1668
        ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  1669
            ^ self xOfCol:selectionEndCol inVisibleLine:selectionEndLine.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  1670
        ].
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  1671
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  1672
"/        point := device
4728
af70b9c1d04c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4721
diff changeset
  1673
"/                    translatePoint:(device pointerPosition)
af70b9c1d04c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4721
diff changeset
  1674
"/                    fromView:nil
af70b9c1d04c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4721
diff changeset
  1675
"/                    toView:self.
af70b9c1d04c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4721
diff changeset
  1676
"/        ((self bounds) containsPoint:point) ifTrue:[
af70b9c1d04c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4721
diff changeset
  1677
"/            ^ point x
af70b9c1d04c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4721
diff changeset
  1678
"/        ].
af70b9c1d04c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4721
diff changeset
  1679
"/        ^ 0
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  1680
        ^ nil
4728
af70b9c1d04c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4721
diff changeset
  1681
    ].
4609
8b3eb80d04d0 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4595
diff changeset
  1682
    ^self xOfCol:cursorCol inVisibleLine:cursorVisibleLine.
8b3eb80d04d0 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4595
diff changeset
  1683
8b3eb80d04d0 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4595
diff changeset
  1684
    "Created: / 27-05-2005 / 07:43:41 / janfrog"
8b3eb80d04d0 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4595
diff changeset
  1685
! !
4590
e28172cd6041 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4589
diff changeset
  1686
474
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  1687
!EditTextView methodsFor:'accessing-look'!
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  1688
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  1689
cursorForegroundColor:color1 backgroundColor:color2
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  1690
    "set both cursor foreground and cursor background colors"
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  1691
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  1692
    |wasOn|
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  1693
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  1694
    wasOn := self hideCursor.
5643
921578f80870 device access
Claus Gittinger <cg@exept.de>
parents: 5593
diff changeset
  1695
    cursorFgColor := color1 onDevice:device.
921578f80870 device access
Claus Gittinger <cg@exept.de>
parents: 5593
diff changeset
  1696
    cursorBgColor := color2 onDevice:device.
474
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  1697
    wasOn ifTrue:[self showCursor]
1333
56af09878b96 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1325
diff changeset
  1698
!
56af09878b96 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1325
diff changeset
  1699
1899
c98fc612bab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
  1700
cursorType
c98fc612bab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
  1701
    "return the style of the text cursor.
4721
59fc420ce5b0 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4715
diff changeset
  1702
     Currently, supported are: #none
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  1703
                               #block, #frame, #ibeam, #caret, #solidCaret
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  1704
                               #bigCaret and #bigSolidCaret"
1899
c98fc612bab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
  1705
c98fc612bab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
  1706
    ^ cursorType
c98fc612bab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
  1707
c98fc612bab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
  1708
    "Modified: / 5.5.1999 / 14:52:33 / cg"
c98fc612bab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
  1709
!
c98fc612bab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
  1710
1333
56af09878b96 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1325
diff changeset
  1711
cursorType:aCursorTypeSymbol
56af09878b96 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1325
diff changeset
  1712
    "set the style of the text cursor.
4721
59fc420ce5b0 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4715
diff changeset
  1713
     Currently, supported are: #none
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  1714
                               #block, #frame, #ibeam, #caret, #solidCaret
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  1715
                               #bigCaret and #bigSolidCaret"
1333
56af09878b96 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1325
diff changeset
  1716
1334
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  1717
    cursorType := aCursorTypeSymbol.
1333
56af09878b96 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1325
diff changeset
  1718
56af09878b96 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1325
diff changeset
  1719
    "Created: 21.9.1997 / 13:42:23 / cg"
56af09878b96 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1325
diff changeset
  1720
    "Modified: 21.9.1997 / 13:43:35 / cg"
1334
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  1721
!
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  1722
1899
c98fc612bab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
  1723
cursorTypeNoFocus
c98fc612bab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
  1724
    "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
  1725
     If left unspecified, this is the same as the regular cursorType."
c98fc612bab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
  1726
c98fc612bab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
  1727
    ^ cursorTypeNoFocus
c98fc612bab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
  1728
c98fc612bab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
  1729
    "Created: / 5.5.1999 / 14:52:46 / cg"
c98fc612bab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
  1730
!
c98fc612bab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
  1731
1334
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  1732
cursorTypeNoFocus:aCursorTypeSymbol
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  1733
    "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
  1734
     If left unspecified, this is the same as the regular cursorType."
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  1735
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  1736
    cursorTypeNoFocus := aCursorTypeSymbol
474
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  1737
! !
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  1738
4048
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
  1739
!EditTextView methodsFor:'accessing-replace'!
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
  1740
4746
39a5681e71ca class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4742
diff changeset
  1741
lastReplacementInfo
39a5681e71ca class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4742
diff changeset
  1742
    ^ lastReplacementInfo
39a5681e71ca class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4742
diff changeset
  1743
!
39a5681e71ca class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4742
diff changeset
  1744
4048
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
  1745
lastStringToReplace: aString
4818
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  1746
!
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  1747
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  1748
previousReplacements
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  1749
    "accessor for the code completion"
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  1750
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  1751
    ^ lastReplacementInfo previousReplacements
4048
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
  1752
! !
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
  1753
2119
2aa585fc62a3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2117
diff changeset
  1754
!EditTextView methodsFor:'change & update'!
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1755
125
claus
parents: 123
diff changeset
  1756
accept
claus
parents: 123
diff changeset
  1757
    "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
  1758
     changeMessage.
c055e993c2f7 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5909
diff changeset
  1759
     Historically, ST/X used a callBack (acceptAction);
c055e993c2f7 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5909
diff changeset
  1760
     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
  1761
     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
  1762
     If there is an acceptAction, it is called."
125
claus
parents: 123
diff changeset
  1763
1108
3d14bb6bceb7 added disableAccept
Claus Gittinger <cg@exept.de>
parents: 1082
diff changeset
  1764
    acceptEnabled == false ifTrue:[
6262
5b9bf7c3c828 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 6249
diff changeset
  1765
        self beepInEditor.
5937
c055e993c2f7 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5909
diff changeset
  1766
        ^ self
2035
6924861adf08 added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents: 2029
diff changeset
  1767
    ].
6924861adf08 added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents: 2029
diff changeset
  1768
    (disableIfInvisible == true and:[self reallyRealized not]) ifTrue:[
5937
c055e993c2f7 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5909
diff changeset
  1769
        ^ self
1108
3d14bb6bceb7 added disableAccept
Claus Gittinger <cg@exept.de>
parents: 1082
diff changeset
  1770
    ].
3d14bb6bceb7 added disableAccept
Claus Gittinger <cg@exept.de>
parents: 1082
diff changeset
  1771
125
claus
parents: 123
diff changeset
  1772
    lockUpdates := true.
1013
391290c747b3 added an acceptChannel
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
  1773
391290c747b3 added an acceptChannel
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
  1774
    "/
391290c747b3 added an acceptChannel
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
  1775
    "/ ST-80 way of doing it
391290c747b3 added an acceptChannel
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
  1776
    "/
391290c747b3 added an acceptChannel
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
  1777
    model notNil ifTrue:[
5937
c055e993c2f7 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5909
diff changeset
  1778
        self sendChangeMessage:changeMsg with:self argForChangeMessage.
c055e993c2f7 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5909
diff changeset
  1779
        acceptChannel notNil ifTrue:[
c055e993c2f7 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5909
diff changeset
  1780
            acceptChannel value:true withoutNotifying:self.
c055e993c2f7 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5909
diff changeset
  1781
        ].
2999
40d3a383e8db *** empty log message ***
ca
parents: 2989
diff changeset
  1782
    ].
40d3a383e8db *** empty log message ***
ca
parents: 2989
diff changeset
  1783
757
2cc7e423f0ef only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents: 730
diff changeset
  1784
    "/
2cc7e423f0ef only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents: 730
diff changeset
  1785
    "/ ST/X way of doing things
5937
c055e993c2f7 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5909
diff changeset
  1786
    "/ as a historic leftover,
757
2cc7e423f0ef only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents: 730
diff changeset
  1787
    "/ 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
  1788
    "/ - not with the actual string
2cc7e423f0ef only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents: 730
diff changeset
  1789
    "/
2cc7e423f0ef only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents: 730
diff changeset
  1790
    acceptAction notNil ifTrue:[
5937
c055e993c2f7 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5909
diff changeset
  1791
        acceptAction value:self list
757
2cc7e423f0ef only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents: 730
diff changeset
  1792
    ].
2cc7e423f0ef only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents: 730
diff changeset
  1793
125
claus
parents: 123
diff changeset
  1794
    lockUpdates := false.
757
2cc7e423f0ef only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents: 730
diff changeset
  1795
1437
ab84b08a9f9c allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
  1796
    "Modified: / 30.1.1998 / 14:19:00 / cg"
131
claus
parents: 130
diff changeset
  1797
!
claus
parents: 130
diff changeset
  1798
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1799
argForChangeMessage
597
fb42c94a042e commentary
Claus Gittinger <cg@exept.de>
parents: 594
diff changeset
  1800
    "return the argument to be passed with the change notification.
fb42c94a042e commentary
Claus Gittinger <cg@exept.de>
parents: 594
diff changeset
  1801
     Defined as separate method for easier subclassability."
fb42c94a042e commentary
Claus Gittinger <cg@exept.de>
parents: 594
diff changeset
  1802
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1803
    ^ self contents
597
fb42c94a042e commentary
Claus Gittinger <cg@exept.de>
parents: 594
diff changeset
  1804
fb42c94a042e commentary
Claus Gittinger <cg@exept.de>
parents: 594
diff changeset
  1805
    "Modified: 29.4.1996 / 12:42:14 / cg"
121
claus
parents: 118
diff changeset
  1806
!
claus
parents: 118
diff changeset
  1807
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1808
getListFromModel
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1809
    "get my contents from the model.
597
fb42c94a042e commentary
Claus Gittinger <cg@exept.de>
parents: 594
diff changeset
  1810
     Redefined to ignore updates resulting from my own changes
fb42c94a042e commentary
Claus Gittinger <cg@exept.de>
parents: 594
diff changeset
  1811
     (i.e. if lockUpdates is true)."
121
claus
parents: 118
diff changeset
  1812
claus
parents: 118
diff changeset
  1813
    "
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1814
     ignore updates from my own change
121
claus
parents: 118
diff changeset
  1815
    "
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1816
    lockUpdates ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  1817
        lockUpdates := false.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  1818
        ^ self
121
claus
parents: 118
diff changeset
  1819
    ].
2196
f8c955dd6eb9 validate the cursorLine, when updating from a changed model
Claus Gittinger <cg@exept.de>
parents: 2186
diff changeset
  1820
    super getListFromModel.
3249
a4beb76b3f59 code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents: 3241
diff changeset
  1821
    undoSupport resetHistories.
2196
f8c955dd6eb9 validate the cursorLine, when updating from a changed model
Claus Gittinger <cg@exept.de>
parents: 2186
diff changeset
  1822
f8c955dd6eb9 validate the cursorLine, when updating from a changed model
Claus Gittinger <cg@exept.de>
parents: 2186
diff changeset
  1823
    "/ validate the cursorLine
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1824
    (cursorLine notNil
2310
861ab02b13b9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2225
diff changeset
  1825
     and:[ cursorLine > list size ]) ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  1826
        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
  1827
    ].
1437
ab84b08a9f9c allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
  1828
!
ab84b08a9f9c allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
  1829
ab84b08a9f9c allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
  1830
update:something with:aParameter from:changedObject
1438
bed1564b0640 fixed update for acceptChannel
Claus Gittinger <cg@exept.de>
parents: 1437
diff changeset
  1831
    changedObject == acceptChannel ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  1832
        acceptChannel value == true ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  1833
            self accept.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  1834
        ].
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  1835
        ^ self.
1437
ab84b08a9f9c allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
  1836
    ].
ab84b08a9f9c allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
  1837
    super update:something with:aParameter from:changedObject
ab84b08a9f9c allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
  1838
ab84b08a9f9c allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
  1839
    "Created: / 30.1.1998 / 14:15:56 / cg"
1439
d1b3ca91ed8a fixed update for acceptChannel
Claus Gittinger <cg@exept.de>
parents: 1438
diff changeset
  1840
    "Modified: / 1.2.1998 / 13:15:55 / cg"
121
claus
parents: 118
diff changeset
  1841
! !
claus
parents: 118
diff changeset
  1842
6015
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1843
!EditTextView methodsFor:'commenting'!
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
commentFrom:line1 to:line2 commentStrings:commentStrings
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1846
    "helper function to comment out a block.
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1847
     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
  1848
     in the first col
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1849
     (if no eol comment is available, a bracketing comment is used)."
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1850
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1851
    |eolComment opening closing|
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
    eolComment := commentStrings at:1.
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1854
    eolComment isNil ifTrue:[
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1855
        opening := (commentStrings at:2) at:1.
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1856
        closing := (commentStrings at:2) at:2.
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1857
        (opening isNil or:[closing isNil]) ifTrue:[^ self].
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1858
    ].
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
    line1 to:line2 do:[:lineNr |
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1861
        |l|
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1862
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1863
        l := self listAt:lineNr.
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1864
        l isNil ifTrue:[l := ''].
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1865
        eolComment notNil ifTrue:[
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1866
            l := eolComment , l
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1867
        ] ifFalse:[
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1868
            l := opening , l , closing
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1869
        ].
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1870
        self replaceLine:lineNr with:l.
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1871
        widthOfWidestLine notNil ifTrue:[
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1872
            widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:l).
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1873
        ].
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1874
    ].
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1875
    self textChanged.
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1876
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1877
    "Created: / 09-11-1997 / 01:05:35 / cg"
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1878
    "Modified: / 09-10-2006 / 10:46:44 / cg"
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1879
!
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1880
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1881
commentSelection:commentStrings
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1882
    "convenient function to comment out a block.
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1883
     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
  1884
     in the first col."
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1885
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1886
    |e commentPair opening closing|
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1887
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1888
    (self checkModificationsAllowed) ifFalse:[ ^ self].
6301
c34a59206e44 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 6295
diff changeset
  1889
    commentStrings isEmptyOrNil ifTrue:[ self beepInEditor. ^ self].
6015
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1890
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1891
    self
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1892
        undoableDo:[ 
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1893
            selectionStartLine isNil ifTrue:[
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1894
                self commentFrom:cursorLine to:cursorLine commentStrings:commentStrings
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1895
            ] ifFalse:[
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1896
                (selectionStartCol == 1 and:[selectionEndCol == 0]) ifTrue:[
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1897
                    self commentFrom:selectionStartLine to:selectionEndLine-1 commentStrings:commentStrings
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1898
                ] ifFalse:[
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1899
                    commentPair := commentStrings at:2 ifAbsent:nil.
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1900
                    commentPair isNil ifTrue:[
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1901
                        self beep.
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1902
                    ] ifFalse:[
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1903
                        opening := commentPair at:1.
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1904
                        closing := commentPair at:2.
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1905
                        (opening isNil or:[closing isNil]) ifTrue:[^ self].
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
                        e := selectionEndCol.
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1908
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1909
                        self insertString:closing atLine:selectionEndLine col:e+1.
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1910
                        self insertString:opening atLine:selectionStartLine col:selectionStartCol.
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1911
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1912
                        selectionStartLine == selectionEndLine ifTrue:[e := e + opening size].
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1913
                        self selectFromLine:selectionStartLine col:selectionStartCol
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1914
                                     toLine:selectionEndLine col:e+closing size.
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1915
                    ]
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1916
                ]
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1917
            ].    
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1918
        ]    
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1919
        info:'Comment'.
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1920
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1921
    "Created: / 9.11.1997 / 01:05:40 / cg"
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1922
    "Modified: / 5.4.1998 / 16:52:23 / cg"
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1923
!
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1924
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1925
uncommentFrom:line1 to:line2 commentStrings:commentStrings
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1926
    "helper function to comment out a block.
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1927
     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
  1928
     in the first col.
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1929
     (if no eol comment is available, a bracketing comment is removed)."
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1930
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1931
    |eolComment opening closing rest|
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1932
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1933
    eolComment := commentStrings at:1.
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1934
    eolComment isNil ifTrue:[
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1935
        opening := (commentStrings at:2) at:1.
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1936
        closing := (commentStrings at:2) at:2.
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1937
        (opening isNil or:[closing isNil]) ifTrue:[^ self].
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1938
    ] ifFalse:[
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1939
        rest := eolComment size + 1.
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1940
    ].
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1941
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1942
    line1 to:line2 do:[:lineNr |
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1943
        |l|
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1944
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1945
        l := self listAt:lineNr.
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1946
        l notNil ifTrue:[
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1947
            eolComment notNil ifTrue:[
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1948
                (l startsWith:eolComment) ifTrue:[
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1949
                    l := l copyFrom:rest
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1950
                ] ifFalse:[
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1951
                    (l withoutLeadingSeparators startsWith:eolComment) ifTrue:[
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1952
                        "/ only for single lines?
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1953
                        true "line1 = line2" ifTrue:[
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1954
                            |numSpaces|
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1955
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1956
                            numSpaces := l indexOfNonSeparator - 1.
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1957
                            l := l copyFrom:numSpaces+1+rest.
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1958
                            l := (String new:numSpaces),l
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1959
                        ].    
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1960
                    ].    
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1961
                ]
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1962
            ] ifFalse:[
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1963
                ((l startsWith:opening) and:[l endsWith:closing]) ifTrue:[
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1964
                    l := l copyFrom:opening size + 1.
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1965
                    l := l copyButLast:closing size.
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1966
                ].    
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1967
            ].
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1968
            self replaceLine:lineNr with:l.
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1969
        ]
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1970
    ].
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1971
    
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1972
    widthOfWidestLine := nil. "/ i.e. unknown
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1973
    self textChanged.
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1974
!
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1975
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1976
uncommentSelection:commentStrings
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1977
    "convenient function to comment out a block.
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1978
     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
  1979
     in the first col."
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1980
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1981
    |e commentPair opening closing sz1 sz2 l1 l2 c1 c2|
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1982
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1983
    (self checkModificationsAllowed) ifFalse:[ ^ self].
6262
5b9bf7c3c828 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 6249
diff changeset
  1984
    commentStrings isNil ifTrue:[ self beepInEditor. ^ self].
6015
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1985
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1986
    self
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1987
        undoableDo:[
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1988
            selectionStartLine isNil ifTrue:[
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1989
                self uncommentFrom:cursorLine to:cursorLine commentStrings:commentStrings
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1990
            ] ifFalse:[
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1991
                (selectionStartCol == 1 and:[selectionEndCol == 0]) ifTrue:[
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1992
                    self uncommentFrom:selectionStartLine to:selectionEndLine-1 commentStrings:commentStrings
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1993
                ] ifFalse:[
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1994
                    commentPair := commentStrings at:2.
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1995
                    opening := commentPair at:1.
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1996
                    closing := commentPair at:2.
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1997
                    (opening isNil or:[closing isNil]) ifTrue:[^ self].
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1998
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1999
                    sz1 := opening size.
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  2000
                    sz2 := closing size.
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  2001
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  2002
                    ((self
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  2003
                        stringAtLine:selectionStartLine
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  2004
                        from:selectionStartCol
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  2005
                        to:selectionStartCol+sz1 - 1) = opening
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  2006
                    and:[(self
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  2007
                        stringAtLine:selectionEndLine
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  2008
                        from:selectionEndCol - sz2 + 1
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  2009
                        to:selectionEndCol) = closing ]) ifTrue:[
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  2010
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  2011
                        l2 := selectionEndLine.   c2 := selectionEndCol.
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  2012
                        l1 := selectionStartLine. c1 := selectionStartCol.
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  2013
                        self deleteCharsAtLine:l2 fromCol:c2-sz2+1 toCol:c2.
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  2014
                        self deleteCharsAtLine:l1 fromCol:c1 toCol:c1+sz1-1.
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  2015
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  2016
                        e := c2 - sz2.
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  2017
                        l1 == l2 ifTrue:[e := e - sz1].
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  2018
                        self selectFromLine:l1 col:c1 toLine:l2 col:e.
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  2019
                    ]
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  2020
                ]
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  2021
            ].
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  2022
        ]   
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  2023
        info:'Uncomment'.
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  2024
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  2025
    "Modified: / 7.1.1997 / 20:13:32 / cg"
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  2026
    "Created: / 9.11.1997 / 01:05:46 / cg"
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  2027
! !
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  2028
121
claus
parents: 118
diff changeset
  2029
!EditTextView methodsFor:'cursor handling'!
claus
parents: 118
diff changeset
  2030
4820
8640fa6f128f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4818
diff changeset
  2031
basicCursorReturn
8640fa6f128f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4818
diff changeset
  2032
    "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
  2033
8640fa6f128f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4818
diff changeset
  2034
    |wasOn|
8640fa6f128f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4818
diff changeset
  2035
8640fa6f128f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4818
diff changeset
  2036
    self checkForExistingLine:(cursorLine + 1).
8640fa6f128f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4818
diff changeset
  2037
    cursorVisibleLine notNil ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  2038
        nFullLinesShown notNil ifTrue:[
6339
1db7973c8ab2 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6330
diff changeset
  2039
            (cursorVisibleLine >= nFullLinesShown) ifTrue:[self scrollDownLines:1]
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  2040
        ]
4820
8640fa6f128f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4818
diff changeset
  2041
    ].
8640fa6f128f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4818
diff changeset
  2042
8640fa6f128f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4818
diff changeset
  2043
    wasOn := self hideCursor.
8640fa6f128f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4818
diff changeset
  2044
    self setValidatedCursorLine:(cursorLine + 1) col:1.
8640fa6f128f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4818
diff changeset
  2045
    self makeCursorVisibleAndShowCursor:wasOn.
8640fa6f128f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4818
diff changeset
  2046
6339
1db7973c8ab2 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6330
diff changeset
  2047
    "Modified: / 22-05-1996 / 18:27:34 / cg"
1db7973c8ab2 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6330
diff changeset
  2048
    "Modified: / 13-06-2018 / 22:14:31 / Claus Gittinger"
4820
8640fa6f128f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4818
diff changeset
  2049
!
8640fa6f128f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4818
diff changeset
  2050
2406
aeabb4ccf07c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2404
diff changeset
  2051
characterPositionOfCursor
aeabb4ccf07c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2404
diff changeset
  2052
    ^ self characterPositionOfLine:cursorLine col:cursorCol
aeabb4ccf07c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2404
diff changeset
  2053
!
aeabb4ccf07c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2404
diff changeset
  2054
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2055
cursorBacktab
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2056
    "move cursor to prev tabstop"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2057
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2058
    self cursorCol:(self prevTabBefore:cursorCol).
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
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2061
cursorCol:newCol
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2062
    "move cursor to some column in the current line"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2063
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2064
    |wasOn|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2065
2822
08ceab3fc237 search refactored;
Claus Gittinger <cg@exept.de>
parents: 2819
diff changeset
  2066
    (cursorCol == newCol) ifTrue:[^ self].
08ceab3fc237 search refactored;
Claus Gittinger <cg@exept.de>
parents: 2819
diff changeset
  2067
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2068
    wasOn := self hideCursor.
2422
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2069
    self setValidatedCursorCol:newCol.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2070
    self makeCursorVisibleAndShowCursor:wasOn.
672
065750d02339 added cursorCol-validation
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  2071
065750d02339 added cursorCol-validation
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  2072
    "Modified: 22.5.1996 / 14:25:53 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2073
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2074
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2075
cursorDown
632
5af2c22002e4 dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
  2076
    "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
  2077
     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
  2078
5af2c22002e4 dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
  2079
    |wasOn|
5af2c22002e4 dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
  2080
5af2c22002e4 dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
  2081
    self cursorDown:1.
5af2c22002e4 dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
  2082
2707
810c994db0b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2696
diff changeset
  2083
    "/ cursor beyond text ?
632
5af2c22002e4 dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
  2084
    cursorLine > list size ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  2085
        wasOn := self hideCursor.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  2086
        self setValidatedCursorLine:(list size + 1) col:cursorCol.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  2087
        self makeCursorVisibleAndShowCursor:wasOn.
6262
5b9bf7c3c828 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 6249
diff changeset
  2088
        self beepInEditor.
632
5af2c22002e4 dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
  2089
    ].
5af2c22002e4 dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
  2090
1561
db5f27354172 make cursor correctly visible if in partial last line.
Claus Gittinger <cg@exept.de>
parents: 1560
diff changeset
  2091
    "Modified: / 10.6.1998 / 17:00:23 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2092
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2093
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2094
cursorDown:n
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2095
    "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
  2096
5857
006deb952a1e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5856
diff changeset
  2097
    |inLastLine wasOn nv nL cursorColBefore|
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2098
4595
2f1e71ea50ac class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4592
diff changeset
  2099
    (nL := cursorLine) isNil ifTrue:[
5857
006deb952a1e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5856
diff changeset
  2100
        nL := firstLineShown
006deb952a1e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5856
diff changeset
  2101
    ].
006deb952a1e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5856
diff changeset
  2102
006deb952a1e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5856
diff changeset
  2103
    inLastLine := (nL == list size).
5890
5dc30fda9ebf #OTHER by mawalch
mawalch
parents: 5887
diff changeset
  2104
5857
006deb952a1e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5856
diff changeset
  2105
    inLastLine ifTrue:[
5858
f281506fb025 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5857
diff changeset
  2106
        |generateTextAfterEndHook|
5857
006deb952a1e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5856
diff changeset
  2107
006deb952a1e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5856
diff changeset
  2108
        cursorColBefore := cursorCol.
5858
f281506fb025 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5857
diff changeset
  2109
        (generateTextAfterEndHook := self getAttribute:#generateTextAfterEndHook) notNil ifTrue:[
5860
acc60507b977 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5859
diff changeset
  2110
            wasOn := self hideCursor.
acc60507b977 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5859
diff changeset
  2111
            nL := generateTextAfterEndHook value:(nL + n).
acc60507b977 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5859
diff changeset
  2112
            self setValidatedCursorLine:nL col:cursorColBefore.
acc60507b977 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5859
diff changeset
  2113
            self makeCursorVisibleAndShowCursor:wasOn.
acc60507b977 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5859
diff changeset
  2114
            ^ self.
5890
5dc30fda9ebf #OTHER by mawalch
mawalch
parents: 5887
diff changeset
  2115
        ].
4595
2f1e71ea50ac class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4592
diff changeset
  2116
    ].
2f1e71ea50ac class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4592
diff changeset
  2117
2f1e71ea50ac class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4592
diff changeset
  2118
    self st80EditMode ifTrue:[
5857
006deb952a1e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5856
diff changeset
  2119
        nL == list size ifTrue:[
006deb952a1e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5856
diff changeset
  2120
            wasOn := self hideCursor.
006deb952a1e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5856
diff changeset
  2121
            self setValidatedCursorLine:nL col:(self listAt:nL) size + 1.
006deb952a1e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5856
diff changeset
  2122
            self makeCursorVisibleAndShowCursor:wasOn.
6262
5b9bf7c3c828 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 6249
diff changeset
  2123
            self beepInEditor.
5857
006deb952a1e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5856
diff changeset
  2124
            ^ self.
006deb952a1e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5856
diff changeset
  2125
        ]
4595
2f1e71ea50ac class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4592
diff changeset
  2126
    ].
2f1e71ea50ac class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4592
diff changeset
  2127
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2128
    cursorVisibleLine notNil ifTrue:[
5857
006deb952a1e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5856
diff changeset
  2129
        wasOn := self hideCursor.
006deb952a1e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5856
diff changeset
  2130
        nv := cursorVisibleLine + n - 1.
006deb952a1e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5856
diff changeset
  2131
        (nv >= nFullLinesShown) ifTrue:[
6339
1db7973c8ab2 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6330
diff changeset
  2132
            self scrollDownLines:(nv - nFullLinesShown + 1)
5857
006deb952a1e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5856
diff changeset
  2133
        ].
006deb952a1e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5856
diff changeset
  2134
        self setValidatedCursorLine:(cursorLine + n) col:(cursorColBefore ? cursorCol).
006deb952a1e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5856
diff changeset
  2135
        self makeCursorVisibleAndShowCursor:wasOn.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2136
    ] ifFalse:[
5857
006deb952a1e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5856
diff changeset
  2137
        self setValidatedCursorLine:(nL + n) col:(cursorColBefore ? cursorCol).
006deb952a1e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5856
diff changeset
  2138
        self makeCursorVisible.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2139
    ].
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2140
6339
1db7973c8ab2 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6330
diff changeset
  2141
    "Modified: / 10-06-1998 / 16:59:17 / cg"
1db7973c8ab2 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6330
diff changeset
  2142
    "Modified: / 13-06-2018 / 22:08:21 / Claus Gittinger"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2143
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2144
121
claus
parents: 118
diff changeset
  2145
cursorHome
597
fb42c94a042e commentary
Claus Gittinger <cg@exept.de>
parents: 594
diff changeset
  2146
    "scroll to top AND move cursor to first line of text."
121
claus
parents: 118
diff changeset
  2147
674
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  2148
    self cursorLine:1 col:1
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  2149
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  2150
"/    |wasOn|
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  2151
"/
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  2152
"/    wasOn := self hideCursor.
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  2153
"/    self scrollToTop.
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  2154
"/    cursorLine := cursorVisibleLine := 1.
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  2155
"/    cursorCol := self validateCursorCol:1 inLine:cursorLine.
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  2156
"/    self makeCursorVisibleAndShowCursor:wasOn.
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  2157
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  2158
    "Modified: 22.5.1996 / 18:26:42 / cg"
121
claus
parents: 118
diff changeset
  2159
!
claus
parents: 118
diff changeset
  2160
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2161
cursorLeft
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2162
    "move cursor to left"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2163
6207
7a5c2914e422 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6203
diff changeset
  2164
    |wasOn|
7a5c2914e422 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6203
diff changeset
  2165
1300
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  2166
    (cursorCol ~~ 1) ifTrue:[
6207
7a5c2914e422 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6203
diff changeset
  2167
        wasOn := self hideCursor.
7a5c2914e422 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6203
diff changeset
  2168
        self setValidatedCursorCol:(cursorCol - 1).
7a5c2914e422 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6203
diff changeset
  2169
        self makeCursorVisibleAndShowCursor:wasOn.
7a5c2914e422 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6203
diff changeset
  2170
        "/ self cursorCol:(cursorCol - 1)
1300
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  2171
    ] ifFalse:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  2172
        cursorLine ~~ 1 ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  2173
            self st80EditMode ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  2174
                self cursorUp.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  2175
                self cursorToEndOfLine.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  2176
           ]
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  2177
        ]
1300
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  2178
    ]
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  2179
1426
de76570ba19e crsrLeft/crsrRight does not wrap to prev/next line in st80 mode
Claus Gittinger <cg@exept.de>
parents: 1419
diff changeset
  2180
    "Modified: / 23.1.1998 / 12:37:13 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2181
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2182
4126
Claus Gittinger <cg@exept.de>
parents: 4121
diff changeset
  2183
cursorLeft:n
Claus Gittinger <cg@exept.de>
parents: 4121
diff changeset
  2184
    "move cursor to left"
Claus Gittinger <cg@exept.de>
parents: 4121
diff changeset
  2185
Claus Gittinger <cg@exept.de>
parents: 4121
diff changeset
  2186
    n timesRepeat:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  2187
        self cursorLeft
4126
Claus Gittinger <cg@exept.de>
parents: 4121
diff changeset
  2188
    ].
Claus Gittinger <cg@exept.de>
parents: 4121
diff changeset
  2189
!
Claus Gittinger <cg@exept.de>
parents: 4121
diff changeset
  2190
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2191
cursorLine:line col:col
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2192
    "this positions onto physical - not visible - line"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2193
5056
9984a425a389 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5050
diff changeset
  2194
    self cursorLine:line col:col makeVisible:true
9984a425a389 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5050
diff changeset
  2195
!
9984a425a389 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5050
diff changeset
  2196
9984a425a389 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5050
diff changeset
  2197
cursorLine:line col:col makeVisible:makeVisibleBoolean
9984a425a389 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5050
diff changeset
  2198
    "this positions onto physical - not visible - line"
9984a425a389 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5050
diff changeset
  2199
676
b65b82a1ffcb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
  2200
    |wasOn newCol|
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2201
2822
08ceab3fc237 search refactored;
Claus Gittinger <cg@exept.de>
parents: 2819
diff changeset
  2202
    ((line == cursorLine) and:[col == cursorCol]) ifTrue:[^ self].
08ceab3fc237 search refactored;
Claus Gittinger <cg@exept.de>
parents: 2819
diff changeset
  2203
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2204
    wasOn := self hideCursor.
2422
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2205
    self setValidatedCursorLine:line.
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2206
6563
3cbb78c9dc1f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6548
diff changeset
  2207
    newCol := (col max:1).
2647
23dca8f032c3 changed st80Mode from classVar to userPreferences value
Claus Gittinger <cg@exept.de>
parents: 2627
diff changeset
  2208
    self st80EditMode ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  2209
        (cursorLine == list size
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  2210
        and:[cursorLine ~~ line]) ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  2211
            newCol := (self listAt:(list size)) size + 1.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  2212
        ]
1419
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
  2213
    ].
2422
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2214
    self setValidatedCursorCol:newCol.
5056
9984a425a389 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5050
diff changeset
  2215
    makeVisibleBoolean ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  2216
        self makeCursorVisibleAndShowCursor:wasOn.
5056
9984a425a389 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5050
diff changeset
  2217
    ] ifFalse:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  2218
        wasOn ifTrue:[self showCursor]
5056
9984a425a389 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5050
diff changeset
  2219
    ].
672
065750d02339 added cursorCol-validation
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  2220
6563
3cbb78c9dc1f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6548
diff changeset
  2221
    "Modified: / 20-06-1998 / 18:19:06 / cg"
3cbb78c9dc1f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6548
diff changeset
  2222
    "Modified: / 21-03-2019 / 12:53:27 / Claus Gittinger"
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
1580
d30e562bea15 allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
  2225
cursorMovementAllowed
d30e562bea15 allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
  2226
    "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
  2227
     (via button-click, or cursor-key with selection).
d30e562bea15 allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
  2228
     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
  2229
     in special subclasses (such as a terminal view), where
d30e562bea15 allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
  2230
     this is not wanted"
d30e562bea15 allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
  2231
d30e562bea15 allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
  2232
    ^ true
d30e562bea15 allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
  2233
d30e562bea15 allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
  2234
    "Created: / 18.6.1998 / 14:11:16 / cg"
d30e562bea15 allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
  2235
!
d30e562bea15 allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
  2236
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2237
cursorReturn
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2238
    "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
  2239
4820
8640fa6f128f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4818
diff changeset
  2240
    self basicCursorReturn
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2241
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2242
5529
0b33c7ac879d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 5525
diff changeset
  2243
cursorReturn:withPossibleAutoIndent
0b33c7ac879d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 5525
diff changeset
  2244
    "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
  2245
0b33c7ac879d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 5525
diff changeset
  2246
    self basicCursorReturn
0b33c7ac879d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 5525
diff changeset
  2247
!
0b33c7ac879d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 5525
diff changeset
  2248
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2249
cursorRight
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2250
    "move cursor to right"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2251
1300
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  2252
    |l|
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  2253
3023
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  2254
    self st80EditMode ifTrue:[
6210
e699fa83a3b2 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6207
diff changeset
  2255
        self isInputField ifFalse:[
e699fa83a3b2 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6207
diff changeset
  2256
            l := (self listAt:cursorLine).
e699fa83a3b2 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6207
diff changeset
  2257
            cursorCol >= (l size + 1) ifTrue:[
e699fa83a3b2 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6207
diff changeset
  2258
                cursorLine <= list size ifTrue:[
e699fa83a3b2 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6207
diff changeset
  2259
                    self cursorReturn:false. "/ no autoindent
e699fa83a3b2 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6207
diff changeset
  2260
                ].
e699fa83a3b2 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6207
diff changeset
  2261
                ^ self
e699fa83a3b2 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6207
diff changeset
  2262
            ]
e699fa83a3b2 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6207
diff changeset
  2263
        ].
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2264
    ].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2265
    self cursorCol:(cursorCol + 1)
1300
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  2266
6210
e699fa83a3b2 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6207
diff changeset
  2267
    "Modified: / 27-09-2017 / 15:38:26 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2268
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2269
4126
Claus Gittinger <cg@exept.de>
parents: 4121
diff changeset
  2270
cursorRight:n
Claus Gittinger <cg@exept.de>
parents: 4121
diff changeset
  2271
    "move cursor to right"
Claus Gittinger <cg@exept.de>
parents: 4121
diff changeset
  2272
Claus Gittinger <cg@exept.de>
parents: 4121
diff changeset
  2273
    n timesRepeat:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  2274
        self cursorRight
4126
Claus Gittinger <cg@exept.de>
parents: 4121
diff changeset
  2275
    ].
Claus Gittinger <cg@exept.de>
parents: 4121
diff changeset
  2276
!
Claus Gittinger <cg@exept.de>
parents: 4121
diff changeset
  2277
1833
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  2278
cursorShown:aBoolean
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  2279
    "change cursor visibility
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  2280
     return true if cursor was visible before."
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  2281
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  2282
    |oldState|
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  2283
4494
dfe81ebdd5d6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
  2284
    aBoolean == cursorShown ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  2285
        ^ cursorShown
4494
dfe81ebdd5d6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
  2286
    ].
1833
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  2287
    oldState := cursorShown.
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  2288
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  2289
    aBoolean ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  2290
        self drawCursor.
1833
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  2291
    ] ifFalse:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  2292
        (cursorShown and:[shown]) ifTrue: [
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  2293
            self undrawCursor.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  2294
        ].
1833
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  2295
    ].
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  2296
    cursorShown := aBoolean.
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  2297
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  2298
    ^ oldState
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  2299
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  2300
    "Modified: / 30.3.1999 / 15:32:43 / stefan"
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  2301
    "Created: / 30.3.1999 / 15:59:30 / stefan"
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  2302
!
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  2303
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2304
cursorTab
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2305
    "move cursor to next tabstop"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2306
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2307
    self cursorCol:(self nextTabAfter:cursorCol).
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2308
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2309
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2310
cursorToBeginOfLine
3020
68a2dfad4e5e CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents: 2999
diff changeset
  2311
    "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
  2312
68a2dfad4e5e CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents: 2999
diff changeset
  2313
    |textStart l|
68a2dfad4e5e CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents: 2999
diff changeset
  2314
68a2dfad4e5e CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents: 2999
diff changeset
  2315
    l := self listAt:cursorLine.
68a2dfad4e5e CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents: 2999
diff changeset
  2316
    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
  2317
    cursorCol > textStart ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  2318
        self cursorCol:textStart
3020
68a2dfad4e5e CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents: 2999
diff changeset
  2319
    ] ifFalse:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  2320
        self cursorCol:1
3020
68a2dfad4e5e CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents: 2999
diff changeset
  2321
    ]
68a2dfad4e5e CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents: 2999
diff changeset
  2322
68a2dfad4e5e CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents: 2999
diff changeset
  2323
    "Created: / 8.8.2004 / 18:51:21 / janfrog"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2324
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2325
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2326
cursorToBottom
2129
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  2327
    "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
  2328
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2329
    |wasOn newTop|
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
    wasOn := self hideCursor.
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
    newTop := list size - nFullLinesShown.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2334
    (newTop < 1) ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  2335
        newTop := 1
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2336
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2337
    self scrollToLine:newTop.
2422
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2338
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2339
    self setValidatedCursorLine:(list size) col:1.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2340
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2341
    self makeCursorVisibleAndShowCursor:wasOn.
672
065750d02339 added cursorCol-validation
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  2342
674
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  2343
    "Modified: 22.5.1996 / 18:27:45 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2344
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2345
1415
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2346
cursorToCharacterPosition:pos
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2347
    "compute line/col from character position (1..)
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2348
     and move the cursor onto that char"
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2349
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2350
    |line col|
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2351
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2352
    line := self lineOfCharacterPosition:pos.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2353
    col := pos - (self characterPositionOfLine:line col:1) + 1.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2354
    self cursorLine:line col:col
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2355
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2356
    "Created: / 15.1.1998 / 21:55:33 / cg"
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2357
!
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2358
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2359
cursorToEnd
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2360
    "move cursor down below last line of text"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2361
2422
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2362
    |wasOn newTop lineNr line|
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2363
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2364
    lineNr := list size.
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2365
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2366
    cursorLine >= lineNr ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  2367
        line := self listAt:cursorLine.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  2368
        (line isEmptyOrNil) ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  2369
            ^ self
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  2370
        ]
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2371
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2372
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2373
    wasOn := self hideCursor.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2374
2422
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2375
    lineNr := lineNr + 1.
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2376
    newTop :=  lineNr - nFullLinesShown.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2377
    (newTop < 1) ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  2378
        newTop := 1
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2379
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2380
    self scrollToLine:newTop.
2422
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2381
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2382
    self setValidatedCursorLine:lineNr col:1.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2383
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2384
    self makeCursorVisibleAndShowCursor:wasOn.
672
065750d02339 added cursorCol-validation
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  2385
674
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  2386
    "Modified: 22.5.1996 / 18:27:53 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2387
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2388
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2389
cursorToEndOfLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2390
    "move cursor to end of current line"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2391
1300
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  2392
    |line|
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  2393
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  2394
    line := (self listAt:cursorLine).
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  2395
    self cursorCol:(line size + 1)
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  2396
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  2397
    "Modified: 13.8.1997 / 15:34:02 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2398
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2399
2129
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  2400
cursorToEndOfText
4288
f68354357ecc changed: #cursorToEndOfText
Claus Gittinger <cg@exept.de>
parents: 4287
diff changeset
  2401
    "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
  2402
f68354357ecc changed: #cursorToEndOfText
Claus Gittinger <cg@exept.de>
parents: 4287
diff changeset
  2403
    |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
  2404
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  2405
    wasOn := self hideCursor.
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  2406
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  2407
    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
  2408
    (newTop < 1) ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  2409
        newTop := 1
2129
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  2410
    ].
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  2411
    self scrollToLine:newTop.
2422
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2412
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2413
    self setValidatedCursorLine:list size.
4288
f68354357ecc changed: #cursorToEndOfText
Claus Gittinger <cg@exept.de>
parents: 4287
diff changeset
  2414
    lastLineLength := (self listAt:cursorLine) size.
f68354357ecc changed: #cursorToEndOfText
Claus Gittinger <cg@exept.de>
parents: 4287
diff changeset
  2415
    pos := (lastLineLength==0) ifTrue:[0] ifFalse:[lastLineLength+1].
f68354357ecc changed: #cursorToEndOfText
Claus Gittinger <cg@exept.de>
parents: 4287
diff changeset
  2416
    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
  2417
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  2418
    self makeCursorVisibleAndShowCursor:wasOn.
4288
f68354357ecc changed: #cursorToEndOfText
Claus Gittinger <cg@exept.de>
parents: 4287
diff changeset
  2419
4289
d74f746d4c0d comment/format in: #cursorToEndOfText
Claus Gittinger <cg@exept.de>
parents: 4288
diff changeset
  2420
    "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
  2421
!
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  2422
3310
83368f9014a1 word check
Claus Gittinger <cg@exept.de>
parents: 3303
diff changeset
  2423
cursorToEndOfWord
83368f9014a1 word check
Claus Gittinger <cg@exept.de>
parents: 3303
diff changeset
  2424
    "move the cursor to the end of the word"
83368f9014a1 word check
Claus Gittinger <cg@exept.de>
parents: 3303
diff changeset
  2425
83368f9014a1 word check
Claus Gittinger <cg@exept.de>
parents: 3303
diff changeset
  2426
    (cursorLine > list size) ifTrue:[^ self].
83368f9014a1 word check
Claus Gittinger <cg@exept.de>
parents: 3303
diff changeset
  2427
83368f9014a1 word check
Claus Gittinger <cg@exept.de>
parents: 3303
diff changeset
  2428
    self wordAtLine:cursorLine col:cursorCol do:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  2429
        :beginLine :beginCol :endLine :endCol :style |
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  2430
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  2431
        self cursorLine:endLine col:endCol+1
3310
83368f9014a1 word check
Claus Gittinger <cg@exept.de>
parents: 3303
diff changeset
  2432
    ]
83368f9014a1 word check
Claus Gittinger <cg@exept.de>
parents: 3303
diff changeset
  2433
83368f9014a1 word check
Claus Gittinger <cg@exept.de>
parents: 3303
diff changeset
  2434
    "Created: / 28-06-2006 / 19:16:30 / cg"
83368f9014a1 word check
Claus Gittinger <cg@exept.de>
parents: 3303
diff changeset
  2435
!
83368f9014a1 word check
Claus Gittinger <cg@exept.de>
parents: 3303
diff changeset
  2436
131
claus
parents: 130
diff changeset
  2437
cursorToFirstVisibleLine
claus
parents: 130
diff changeset
  2438
    "place cursor into the first visible line; do not scroll."
claus
parents: 130
diff changeset
  2439
claus
parents: 130
diff changeset
  2440
    self cursorLine:(self visibleLineToAbsoluteLine:1) col:1
claus
parents: 130
diff changeset
  2441
!
claus
parents: 130
diff changeset
  2442
claus
parents: 130
diff changeset
  2443
cursorToLastVisibleLine
claus
parents: 130
diff changeset
  2444
    "place cursor into the first visible line; do not scroll."
claus
parents: 130
diff changeset
  2445
claus
parents: 130
diff changeset
  2446
    self cursorLine:(self visibleLineToAbsoluteLine:nFullLinesShown) col:1
claus
parents: 130
diff changeset
  2447
!
claus
parents: 130
diff changeset
  2448
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2449
cursorToNextWord
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2450
    "move the cursor to the beginning of the next word"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2451
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2452
    |col line searching|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2453
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2454
    (cursorLine > list size) ifTrue:[^ self].
2422
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2455
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2456
    self
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  2457
        wordAtLine:cursorLine col:cursorCol
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  2458
        do:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  2459
            :beginLine :beginCol :endLine :endCol :style |
6154
3e745dfae512 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 6152
diff changeset
  2460
            |lineSize|
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  2461
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  2462
            line := endLine.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  2463
            col := endCol + 1.
6154
3e745dfae512 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 6152
diff changeset
  2464
            lineSize := (self listAt:line) size.
3e745dfae512 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 6152
diff changeset
  2465
            (endCol ~= lineSize or:[lineSize == 0]) ifTrue:[
3e745dfae512 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 6152
diff changeset
  2466
                searching := true.
3e745dfae512 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 6152
diff changeset
  2467
                [searching and:[(self characterAtLine:line col:col) isSeparator]] whileTrue:[
3e745dfae512 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 6152
diff changeset
  2468
                    self wordAtLine:line col:col do:[
3e745dfae512 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 6152
diff changeset
  2469
                        :beginLine :beginCol :endLine :endCol :style |
3e745dfae512 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 6152
diff changeset
  2470
3e745dfae512 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 6152
diff changeset
  2471
                        (line > list size) ifTrue:[
3e745dfae512 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 6152
diff changeset
  2472
                            "break out"
3e745dfae512 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 6152
diff changeset
  2473
                            searching := false
3e745dfae512 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 6152
diff changeset
  2474
                        ] ifFalse:[
3e745dfae512 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 6152
diff changeset
  2475
                            line := endLine.
3e745dfae512 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 6152
diff changeset
  2476
                            col := endCol + 1.
3e745dfae512 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 6152
diff changeset
  2477
                        ]
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  2478
                    ]
6154
3e745dfae512 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 6152
diff changeset
  2479
                ].
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  2480
            ].
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  2481
            self cursorLine:line col:col
4707
f6ac835a1cf6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4701
diff changeset
  2482
    ]
6154
3e745dfae512 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 6152
diff changeset
  2483
3e745dfae512 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 6152
diff changeset
  2484
    "Modified: / 11-05-2017 / 17:50:47 / stefan"
121
claus
parents: 118
diff changeset
  2485
!
claus
parents: 118
diff changeset
  2486
499
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
  2487
cursorToPreviousWord
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
  2488
    "move the cursor to the beginning of this or the previous word"
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
  2489
6154
3e745dfae512 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 6152
diff changeset
  2490
    |col line searching|
499
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
  2491
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
  2492
    self wordAtLine:cursorLine col:cursorCol do:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  2493
        :beginLine :beginCol :endLine :endCol :style |
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  2494
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  2495
        line := beginLine.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  2496
        col := beginCol.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  2497
        style == #wordLeft ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  2498
            col := col + 1
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  2499
        ].
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  2500
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  2501
        (cursorLine == line
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  2502
        and:[cursorCol == col]) ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  2503
            searching := true.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  2504
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  2505
            col > 1 ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  2506
                col := col - 1.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  2507
            ].
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  2508
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  2509
            [searching] whileTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  2510
                (col == 1) ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  2511
                    line == 1 ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  2512
                        searching := false
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  2513
                    ] ifFalse:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  2514
                        line := line - 1.
6154
3e745dfae512 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 6152
diff changeset
  2515
                        col := (list at:line) size + 1.
3e745dfae512 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 6152
diff changeset
  2516
                        col ~~ 1 ifTrue:[
3e745dfae512 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 6152
diff changeset
  2517
                            "at end of word in previous line"
3e745dfae512 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 6152
diff changeset
  2518
                            searching := false.
3e745dfae512 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 6152
diff changeset
  2519
                        ].
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  2520
                    ]
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  2521
                ] ifFalse:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  2522
                    (self characterAtLine:line col:col) isSeparator ifFalse:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  2523
                        self wordAtLine:line col:col do:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  2524
                            :beginLine :beginCol :endLine :endCol :style |
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  2525
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  2526
                            line := beginLine.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  2527
                            col := beginCol.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  2528
                            style == #wordLeft ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  2529
                                col := col + 1
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  2530
                            ].
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  2531
                            searching := false.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  2532
                        ]
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  2533
                    ] ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  2534
                        col := col - 1
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  2535
                    ]
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  2536
                ]
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  2537
            ]
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  2538
        ].
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  2539
        self cursorLine:line col:col
499
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
  2540
    ]
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
  2541
6154
3e745dfae512 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 6152
diff changeset
  2542
    "Created: / 08-03-1996 / 21:52:48 / cg"
3e745dfae512 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 6152
diff changeset
  2543
    "Modified (format): / 11-05-2017 / 17:45:11 / stefan"
499
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
  2544
!
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
  2545
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2546
cursorToTop
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2547
    "move cursor to absolute home"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2548
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2549
    self cursorLine:1 col:1
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2550
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2551
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2552
cursorUp
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2553
    "move cursor up; scroll if at start of visible text"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2554
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2555
    self cursorUp:1
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2556
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2557
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2558
cursorUp:n
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2559
    "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
  2560
5856
a4d4442497d6 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5850
diff changeset
  2561
    |wasOn nv nl cursorColBefore|
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2562
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2563
    cursorLine isNil ifTrue:[
5850
988655795073 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5834
diff changeset
  2564
        self setCursorLine:(firstLineShown + nFullLinesShown - 1).
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2565
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2566
    nl := cursorLine - n.
5850
988655795073 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5834
diff changeset
  2567
    nl < 1 ifTrue:[
5858
f281506fb025 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5857
diff changeset
  2568
        |generateTextBeforeStartHook|
5890
5dc30fda9ebf #OTHER by mawalch
mawalch
parents: 5887
diff changeset
  2569
5856
a4d4442497d6 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5850
diff changeset
  2570
        cursorColBefore := cursorCol.
5858
f281506fb025 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5857
diff changeset
  2571
        (generateTextBeforeStartHook := self getAttribute:#generateTextBeforeStartHook) notNil ifTrue:[
f281506fb025 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5857
diff changeset
  2572
            nl := generateTextBeforeStartHook value:nl
5890
5dc30fda9ebf #OTHER by mawalch
mawalch
parents: 5887
diff changeset
  2573
        ].
5850
988655795073 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5834
diff changeset
  2574
        nl := nl max:1
988655795073 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5834
diff changeset
  2575
    ].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2576
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2577
    (nl ~~ cursorLine) ifTrue: [
5850
988655795073 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5834
diff changeset
  2578
        wasOn := self hideCursor.
988655795073 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5834
diff changeset
  2579
        cursorVisibleLine notNil ifTrue:[
988655795073 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5834
diff changeset
  2580
            nv := cursorVisibleLine - n.
988655795073 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5834
diff changeset
  2581
            nv < 1 ifTrue:[
6339
1db7973c8ab2 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6330
diff changeset
  2582
                self scrollUpLines:(nv negated + 1)
5850
988655795073 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5834
diff changeset
  2583
            ].
988655795073 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5834
diff changeset
  2584
        ].
5856
a4d4442497d6 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5850
diff changeset
  2585
        self setValidatedCursorLine:nl col:(cursorColBefore ? cursorCol).
3725
410e861ca010 also makeCursorVisible after cursorUp:
Claus Gittinger <cg@exept.de>
parents: 3707
diff changeset
  2586
"/        wasOn ifTrue:[self showCursor].
5850
988655795073 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5834
diff changeset
  2587
        self makeCursorVisibleAndShowCursor:wasOn.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2588
    ]
672
065750d02339 added cursorCol-validation
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  2589
6339
1db7973c8ab2 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6330
diff changeset
  2590
    "Modified: / 22-05-1996 / 18:28:11 / cg"
1db7973c8ab2 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6330
diff changeset
  2591
    "Modified: / 13-06-2018 / 22:45:32 / Claus Gittinger"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2592
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2593
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2594
cursorVisibleLine:visibleLineNr col:colNr
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2595
    "put cursor to visibleline/col"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2596
2422
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2597
    |wasOn newCol listLine|
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2598
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2599
    wasOn := self hideCursor.
2422
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2600
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2601
    listLine := self visibleLineToAbsoluteLine:visibleLineNr.
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2602
    self setValidatedCursorLine:listLine.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2603
    cursorVisibleLine := visibleLineNr.
2422
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2604
676
b65b82a1ffcb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
  2605
    newCol := colNr.
b65b82a1ffcb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
  2606
    (newCol < 1) ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  2607
        newCol := 1
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2608
    ].
2422
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2609
    self setValidatedCursorCol:newCol.
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2610
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2611
    self makeCursorVisibleAndShowCursor:wasOn.
672
065750d02339 added cursorCol-validation
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  2612
1597
5fdcfcedb91c fixed cursor positioning after replaceStringAtCursor.
Claus Gittinger <cg@exept.de>
parents: 1596
diff changeset
  2613
    "Modified: / 20.6.1998 / 18:40:28 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2614
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2615
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2616
cursorX:x y:y
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2617
    "put cursor to position next to x/y coordinate in view"
121
claus
parents: 118
diff changeset
  2618
claus
parents: 118
diff changeset
  2619
    |line col|
claus
parents: 118
diff changeset
  2620
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2621
    line := self visibleLineOfY:y.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2622
    col := self colOfX:x inVisibleLine:line.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2623
    self cursorVisibleLine:line col:col.
121
claus
parents: 118
diff changeset
  2624
!
claus
parents: 118
diff changeset
  2625
claus
parents: 118
diff changeset
  2626
drawCursor
claus
parents: 118
diff changeset
  2627
    "draw the cursor if shown and cursor is visible.
claus
parents: 118
diff changeset
  2628
     (but not, if there is a selection - to avoid confusion)"
claus
parents: 118
diff changeset
  2629
claus
parents: 118
diff changeset
  2630
    shown ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  2631
        cursorVisibleLine notNil ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  2632
            self hasSelection ifFalse:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  2633
                self drawCursorCharacter
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  2634
            ]
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  2635
        ]
121
claus
parents: 118
diff changeset
  2636
    ]
claus
parents: 118
diff changeset
  2637
!
claus
parents: 118
diff changeset
  2638
claus
parents: 118
diff changeset
  2639
drawCursor:cursorType with:fgColor and:bgColor
claus
parents: 118
diff changeset
  2640
    "draw a cursor; the argument cursorType specifies what type
125
claus
parents: 123
diff changeset
  2641
     of cursor should be drawn.
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  2642
     Currently, supported are: #none,
6031
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2643
                               #block, #frame, #ibeam, #caret, #solidCaret
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2644
                               #bigCaret and #bigSolidCaret"
2085
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  2645
2570
590956e81610 Remove unused method vars.
Stefan Vogel <sv@exept.de>
parents: 2569
diff changeset
  2646
    |x y w char y2 x1 x2 oldPaint oldClip|
121
claus
parents: 118
diff changeset
  2647
claus
parents: 118
diff changeset
  2648
    self hasSelection ifTrue:[
6031
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2649
        "
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2650
         hide cursor, if there is a selection
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2651
        "
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2652
        ^ super redrawVisibleLine:cursorVisibleLine col:cursorCol.
121
claus
parents: 118
diff changeset
  2653
    ].
claus
parents: 118
diff changeset
  2654
1334
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  2655
    cursorType == #none ifTrue:[
6031
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2656
        ^ self
1334
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  2657
    ].
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  2658
121
claus
parents: 118
diff changeset
  2659
    cursorType == #block ifTrue:[
6031
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2660
        super drawVisibleLine:cursorVisibleLine col:cursorCol with:fgColor and:bgColor.
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2661
        ^ self
121
claus
parents: 118
diff changeset
  2662
    ].
2429
eed79a96e43b eliminated accesses to leftOffset
Claus Gittinger <cg@exept.de>
parents: 2427
diff changeset
  2663
    x := (self xOfCol:cursorCol inVisibleLine:cursorVisibleLine) - viewOrigin x.
121
claus
parents: 118
diff changeset
  2664
    y := self yOfVisibleLine:cursorVisibleLine.
claus
parents: 118
diff changeset
  2665
1449
2a54bdfff203 eliminated direct refs to paint instvar
Claus Gittinger <cg@exept.de>
parents: 1446
diff changeset
  2666
    oldPaint := self paint. "/ do not clobber GC
121
claus
parents: 118
diff changeset
  2667
    cursorType == #frame ifTrue:[
6031
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2668
        super redrawVisibleLine:cursorVisibleLine col:cursorCol.
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2669
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2670
        char := self characterUnderCursor asString.
6068
01e28002daf7 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6050
diff changeset
  2671
        gc paint:bgColor.
01e28002daf7 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6050
diff changeset
  2672
        gc displayRectangleX:x y:y width:(gc font widthOf:char) height:fontHeight-2.
133
claus
parents: 132
diff changeset
  2673
    ] ifFalse:[
6031
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2674
        self paint:bgColor.
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2675
        cursorType == #ibeam ifTrue:[
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2676
            x1 := x - 1.
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2677
            y2 := y + fontHeight - lineSpacing - 1.
6068
01e28002daf7 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6050
diff changeset
  2678
            gc displayLineFromX:x1 y:y toX:x1 y:y2.
01e28002daf7 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6050
diff changeset
  2679
            gc displayLineFromX:x y:y toX:x y:y2.
6031
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2680
            ^ self
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2681
        ].
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2682
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2683
        cursorType == #Ibeam ifTrue:[
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2684
            x1 := x - 1.
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2685
            y := y + 1.
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2686
            y2 := y + fontHeight - lineSpacing - 1.
6068
01e28002daf7 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6050
diff changeset
  2687
            gc displayLineFromX:x1 y:y toX:x1 y:y2.
01e28002daf7 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6050
diff changeset
  2688
            gc displayLineFromX:x y:y toX:x y:y2.
01e28002daf7 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6050
diff changeset
  2689
            gc displayLineFromX:x1-2 y:y toX:x+2 y:y.
01e28002daf7 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6050
diff changeset
  2690
            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
  2691
            ^ self
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2692
        ].
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2693
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2694
        y := y + fontHeight - 3.
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2695
        ((cursorType == #bigCaret) or:[cursorType == #bigSolidCaret]) ifTrue:[
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2696
            w := (fontWidth * 2 // 3) max:4.
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2697
            y2 := y + w + (w//2).
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2698
        ] ifFalse:[
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2699
            w := (fontWidth // 2) max:4.
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2700
            y2 := y + w.
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2701
        ].
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2702
        x1 := x - w.
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2703
        x2 := x + w.
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2704
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2705
        oldClip := self clippingBoundsOrNil.
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2706
        self clippingBounds:(margin@margin extent:(width-margin) @ (height-margin)).
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2707
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2708
        cursorType == #caret ifTrue:[
6068
01e28002daf7 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6050
diff changeset
  2709
            gc lineWidth:2.
01e28002daf7 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6050
diff changeset
  2710
            gc displayLineFromX:x1 y:y2 toX:x y:y.
01e28002daf7 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6050
diff changeset
  2711
            gc displayLineFromX:x y:y toX:x2 y:y2.
6031
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2712
        ] ifFalse:[
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2713
            "anything else: solidCaret"
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2714
6068
01e28002daf7 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6050
diff changeset
  2715
            gc fillPolygon:(Array with:(x1 @ y2)
01e28002daf7 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6050
diff changeset
  2716
                                  with:(x @ y)
01e28002daf7 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6050
diff changeset
  2717
                                  with:(x2 @ y2))
6031
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2718
        ].
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2719
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2720
        self clippingBounds:oldClip
121
claus
parents: 118
diff changeset
  2721
    ].
6068
01e28002daf7 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6050
diff changeset
  2722
    gc paint:oldPaint.
662
4bcdf0cce3a7 dont let caret cursor become too small (with small fonts)
Claus Gittinger <cg@exept.de>
parents: 655
diff changeset
  2723
2088
b2beb67b1a98 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2085
diff changeset
  2724
    "Modified: / 15.12.1999 / 22:24:17 / cg"
121
claus
parents: 118
diff changeset
  2725
!
claus
parents: 118
diff changeset
  2726
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2727
drawCursorCharacter
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2728
    "draw the cursor.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2729
     (i.e. the cursor if no selection)
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2730
     - helper for many cursor methods"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2731
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2732
    (hasKeyboardFocus
3296
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
  2733
     and:[self enabled
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
  2734
     and:[self isReadOnly not]]) ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  2735
        self drawFocusCursor
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2736
    ] ifFalse:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  2737
        self drawNoFocusCursor
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2738
    ]
1817
1a9e22f755c8 show non-focus cursor when disabled or readOnly
Claus Gittinger <cg@exept.de>
parents: 1816
diff changeset
  2739
1a9e22f755c8 show non-focus cursor when disabled or readOnly
Claus Gittinger <cg@exept.de>
parents: 1816
diff changeset
  2740
    "Modified: / 23.3.1999 / 13:52:48 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2741
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2742
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2743
drawFocusCursor
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2744
    "draw the cursor when the focus is in the view."
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2745
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2746
    self hasSelection ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  2747
        ^ super redrawVisibleLine:cursorVisibleLine col:(cursorCol max:1).
1334
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  2748
    ].
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  2749
    cursorType == #none ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  2750
        ^ self undrawCursor
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2751
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2752
    self drawCursor:cursorType with:cursorFgColor and:cursorBgColor.
1334
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  2753
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  2754
    "Modified: 22.9.1997 / 00:16:38 / cg"
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
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2757
drawNoFocusCursor
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2758
    "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
  2759
1334
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  2760
    |cType|
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  2761
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2762
    self hasSelection ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  2763
        ^ super redrawVisibleLine:cursorVisibleLine col:cursorCol.
121
claus
parents: 118
diff changeset
  2764
    ].
1022
4362861fe15e allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents: 1018
diff changeset
  2765
1334
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  2766
    cType := cursorTypeNoFocus ? cursorType.
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  2767
    cType == #none ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  2768
        ^ self undrawCursor
1334
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  2769
    ].
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  2770
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  2771
    cType == #block ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  2772
        ^ self drawCursor:#frame with:cursorNoFocusFgColor and:cursorBgColor
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2773
    ].
1022
4362861fe15e allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents: 1018
diff changeset
  2774
1334
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  2775
    ^ self drawCursor:cType with:cursorNoFocusFgColor and:cursorNoFocusFgColor.
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  2776
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  2777
    "Modified: 22.9.1997 / 00:16:13 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2778
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2779
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2780
gotoLine:aLineNumber
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2781
    "position cursor onto line, aLineNumber.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2782
     Make certain that this line is visible"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2783
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2784
    self makeLineVisible:aLineNumber.
2951
eb820ef25acf unselect before gotoLine
Claus Gittinger <cg@exept.de>
parents: 2950
diff changeset
  2785
    self unselect.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2786
    self cursorLine:aLineNumber col:1
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2787
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2788
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2789
hideCursor
1833
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  2790
    "make cursor invisible if currently invisible"
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  2791
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  2792
    ^ self cursorShown:false
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  2793
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  2794
    "Modified: / 30.3.1999 / 16:02:28 / stefan"
121
claus
parents: 118
diff changeset
  2795
!
claus
parents: 118
diff changeset
  2796
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2797
makeCursorVisible
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2798
    "scroll text to make cursorline visible
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2799
     (i.e. to have cursorLine in visible area)"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2800
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2801
    |line col|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2802
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2803
    cursorLine notNil ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  2804
        line := cursorLine.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  2805
        col := cursorCol.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  2806
        "
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  2807
         if there is a selection, its better to
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  2808
         have its start being visible, instead of the end
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  2809
        "
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  2810
        (selectionStartLine notNil
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  2811
        and:[selectionEndLine notNil]) ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  2812
            expandingTop ~~ false ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  2813
                line := selectionStartLine.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  2814
                col := selectionStartCol.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  2815
            ] ifFalse:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  2816
                line := selectionEndLine.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  2817
                col := selectionEndCol
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  2818
            ]
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  2819
        ].
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  2820
        self makeLineVisible:line.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  2821
        self makeColVisible:col inLine:line
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2822
    ]
479
fae6d1251888 fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 477
diff changeset
  2823
fae6d1251888 fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 477
diff changeset
  2824
    "Modified: 6.3.1996 / 13:46:46 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2825
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2826
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2827
makeCursorVisibleAndShowCursor:flag
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2828
    "scroll to make cursorLine visible;
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2829
     if flag is true, draw the cursor"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2830
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2831
    self makeCursorVisible.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2832
    flag ifTrue:[self showCursor]
121
claus
parents: 118
diff changeset
  2833
!
claus
parents: 118
diff changeset
  2834
2422
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2835
setCursorCol:colNr
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2836
    "strictly private: set the cursorCol"
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2837
2815
d71f43d7de3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2796
diff changeset
  2838
    cursorCol := (colNr max:1).
2422
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2839
    cursorColHolder value:cursorCol.
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2840
!
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2841
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2842
setCursorLine:lineNr
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2843
    "strictly private: set the cursorLine"
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2844
3303
add21df4dcb1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3296
diff changeset
  2845
    "/ self assert:(lineNr notNil).
add21df4dcb1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3296
diff changeset
  2846
add21df4dcb1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3296
diff changeset
  2847
    cursorLine := (lineNr ? 1).
2422
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2848
    cursorLineHolder value:cursorLine.
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2849
    self updateCursorVisibleLine.
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2850
!
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2851
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2852
setCursorLine:lineNr col:colNr
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2853
    "strictly private: set the cursorLine, col and update the visibleLine"
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2854
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2855
    self setCursorLine:lineNr.
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2856
    self setCursorCol:colNr.
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2857
!
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2858
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2859
setValidatedCursorCol:colNr
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2860
    "strictly private: set the cursorCol"
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2861
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2862
    self setCursorCol:(self validateCursorCol:colNr inLine:cursorLine).
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2863
!
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2864
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2865
setValidatedCursorLine:lineNr
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2866
    "strictly private: set the cursorLine and update the visibleLine"
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
    self setCursorLine:(self validateCursorLine:lineNr).
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
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2871
setValidatedCursorLine:lineNr col:colNr
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2872
    "strictly private: set the cursorLine, col and update the visibleLine"
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2873
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2874
    self setValidatedCursorLine:lineNr.
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2875
    self setValidatedCursorCol:colNr.
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2876
!
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2877
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2878
showCursor
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2879
    "make cursor visible if currently invisible"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2880
1833
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  2881
    ^ self cursorShown:true
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  2882
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  2883
    "Modified: / 30.3.1999 / 16:02:34 / stefan"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2884
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2885
5761
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  2886
singleQuoteSelection
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  2887
    "place single quotes around the selected text"
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  2888
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  2889
    |line1 col1 line2 col2|
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  2890
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  2891
    line1 := self selectionStartLine.
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  2892
    col1 := self selectionStartCol.
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  2893
    line2 := self selectionEndLine.
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  2894
    col2 := self selectionEndCol.
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  2895
    (line1 notNil
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  2896
        and:[ col1 notNil
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  2897
        and:[ line2 notNil
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  2898
        and:[ col2 notNil ]]])
5761
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  2899
    ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  2900
        self insertString:Character quote asString atLine:line2 col:col2+1.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  2901
        self insertString:Character quote asString atLine:line1 col:col1.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  2902
        self selectFromLine:line1 col:col1 toLine:line2 col:col2+2.
5761
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  2903
    ] ifFalse:[
6262
5b9bf7c3c828 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 6249
diff changeset
  2904
        self beepInEditor.
5761
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  2905
    ]
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  2906
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  2907
    "Created: / 06-06-2016 / 11:03:36 / cg"
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  2908
!
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  2909
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2910
undrawCursor
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2911
    "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
  2912
2085
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  2913
    |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
  2914
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2915
    cursorVisibleLine notNil ifTrue:[
6031
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2916
        prevCol := cursorCol - 1.
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2917
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2918
        "/ if there is any italic stuff in the cursor line,
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2919
        "/ redraw it completely (because characters overlap).
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2920
        cursorCol > 1 ifTrue:[
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2921
            (line := self listAt:cursorLine) notNil ifTrue:[
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2922
                line hasChangeOfEmphasis ifTrue:[
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2923
                    line size >= (cursorCol-1) ifTrue:[
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2924
                        e1 := Text extractEmphasis:#italic from:(line emphasisAt:cursorCol-1).
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2925
                        line size >= (cursorCol) ifTrue:[
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2926
                            e2 := Text extractEmphasis:#italic from:(line emphasisAt:cursorCol).
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2927
                            line size >= (cursorCol+1) ifTrue:[
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2928
                                e3 := Text extractEmphasis:#italic from:(line emphasisAt:cursorCol+1)
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2929
                            ].
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2930
                        ].
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2931
                    ].
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2932
                    (e1 notNil or:[e2 notNil or:[e3 notNil]]) ifTrue:[
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2933
                        ^ super redrawVisibleLine:cursorVisibleLine
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2934
                    ]
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2935
                ]
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2936
            ]
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2937
        ].
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2938
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2939
        ((cursorType == #caret)
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2940
         or:[cursorType == #solidCaret
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2941
         or:[cursorType == #bigSolidCaret
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2942
         or:[cursorType == #bigCaret
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2943
         or:[cursorType == #Ibeam]]]]) ifTrue:[
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2944
            "caret-cursor touches 4 characters"
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2945
            ((cursorCol > 1) and:[fontIsFixedWidth]) ifTrue:[
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2946
                super redrawVisibleLine:cursorVisibleLine-1 from:prevCol to:cursorCol.
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2947
                super redrawVisibleLine:cursorVisibleLine from:prevCol to:cursorCol.
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2948
                super redrawVisibleLine:cursorVisibleLine+1 from:prevCol to:cursorCol.
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2949
            ] ifFalse:[
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2950
                "care for left margin"
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2951
                super redrawVisibleLine:cursorVisibleLine; redrawVisibleLine:cursorVisibleLine+1.
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2952
            ].
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2953
            ^ self
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2954
        ].
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2955
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2956
        cursorType == #ibeam ifTrue:[
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2957
            "ibeam-cursor touches 2 characters"
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2958
            cursorCol > 1 ifTrue:[
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2959
                super redrawVisibleLine:cursorVisibleLine from:prevCol to:cursorCol.
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2960
            ] ifFalse:[
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2961
                "care for left margin"
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2962
                super redrawVisibleLine:cursorVisibleLine.
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2963
            ].
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2964
            ^ self
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2965
        ].
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2966
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2967
        "block cursor is simple - just one character under cursor"
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2968
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2969
        "/ however, if italic characters are involved, we must care
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2970
        "/ for the chars before/after the cursor.
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2971
        "/ We redraw the part of the previous character which got
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2972
        "/ detroyed by the block cursor.
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2973
        "/ (must change the clip, to avoid destroying the prev-prev character)
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2974
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2975
        line := self visibleAt:cursorVisibleLine.
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2976
        (line notNil and:[line isText]) ifTrue:[
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2977
            cursorCol > 1 ifTrue:[
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2978
                oldClip := self clippingBoundsOrNil.
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2979
                x := (self xOfCol:cursorCol inVisibleLine:cursorVisibleLine) - viewOrigin x.
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2980
                y := self yOfVisibleLine:cursorVisibleLine.
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2981
                self clippingBounds:(x@y extent:((gc font width * 2) @ fontHeight)).
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2982
                super redrawVisibleLine:cursorVisibleLine from:cursorCol-1 to:cursorCol.
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2983
                self clippingBounds:oldClip.
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2984
                ^ self.
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2985
            ].
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2986
        ].
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  2987
        super redrawVisibleLine:cursorVisibleLine col:cursorCol
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2988
    ]
728
3ef81000ee8c new cursorTypes: #bigCaret and #bigSolidCaret
Claus Gittinger <cg@exept.de>
parents: 698
diff changeset
  2989
2088
b2beb67b1a98 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2085
diff changeset
  2990
    "Modified: / 15.12.1999 / 22:25:59 / cg"
121
claus
parents: 118
diff changeset
  2991
!
claus
parents: 118
diff changeset
  2992
2422
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2993
updateCursorVisibleLine
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2994
    "strictly private: set the visibleLine from the cursorLine.
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2995
     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
  2996
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2997
    cursorVisibleLine := self listLineToVisibleLine:cursorLine.
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2998
!
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2999
672
065750d02339 added cursorCol-validation
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  3000
validateCursorCol:col inLine:line
674
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  3001
    "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
  3002
     Here, no limits are enforced (and col is returned),
5593
ad41e448d7a8 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 5581
diff changeset
  3003
     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
  3004
     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
  3005
1300
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  3006
    |l max|
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  3007
1419
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
  3008
    "/ in ST80 mode,
2707
810c994db0b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2696
diff changeset
  3009
    "/ the cursor may not be positioned beyond the
810c994db0b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2696
diff changeset
  3010
    "/ 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
  3011
3023
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  3012
    self st80EditMode ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3013
        l := (self listAt:line).
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3014
        max := l size + 1.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3015
        col > max ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3016
            ^ max
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3017
        ]
1300
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  3018
    ].
672
065750d02339 added cursorCol-validation
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  3019
    ^ col
065750d02339 added cursorCol-validation
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  3020
1419
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
  3021
    "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
  3022
    "Modified: / 20.6.1998 / 18:19:24 / cg"
674
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  3023
!
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  3024
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  3025
validateCursorLine:line
6171
94945eb87a71 #DOCUMENTATION by mawalch
mawalch
parents: 6163
diff changeset
  3026
    "check if 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
  3027
     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
  3028
     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
  3029
     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
  3030
     skip reserved regions"
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  3031
1419
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
  3032
    "/
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
  3033
    "/ in st80Mode, the cursor may not be positioned
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3034
    "/ beyond the last line
6091
b45ae447ed43 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 6070
diff changeset
  3035
    "/ (but it must be possible to place it on one line below the last one
5367
7696ee76ebe8 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5361
diff changeset
  3036
    "/ - otherwise deleteSelection and some others fail to delete from previousToLastLine)
1419
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
  3037
    "/
3023
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  3038
    self st80EditMode ifTrue:[
6091
b45ae447ed43 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 6070
diff changeset
  3039
        ^ (line min:(list size + 1)) max:1
1419
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
  3040
    ].
674
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  3041
    ^ line
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  3042
6091
b45ae447ed43 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 6070
diff changeset
  3043
    "Created: / 22-05-1996 / 18:22:23 / cg"
b45ae447ed43 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 6070
diff changeset
  3044
    "Modified: / 20-06-1998 / 18:19:26 / cg"
b45ae447ed43 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 6070
diff changeset
  3045
    "Modified (comment): / 11-02-2017 / 09:12:37 / cg"
6171
94945eb87a71 #DOCUMENTATION by mawalch
mawalch
parents: 6163
diff changeset
  3046
    "Modified (comment): / 19-06-2017 / 16:25:27 / mawalch"
672
065750d02339 added cursorCol-validation
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  3047
!
065750d02339 added cursorCol-validation
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  3048
121
claus
parents: 118
diff changeset
  3049
withCursorOffDo:aBlock
claus
parents: 118
diff changeset
  3050
    "evaluate aBlock with cursor off; turn it on afterwards."
claus
parents: 118
diff changeset
  3051
claus
parents: 118
diff changeset
  3052
    (shown not or:[cursorShown not]) ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3053
        ^ aBlock value
121
claus
parents: 118
diff changeset
  3054
    ].
claus
parents: 118
diff changeset
  3055
    self hideCursor.
2522
d80496af7eaf #valueNowOrOnUnwindDo: -> #ensure:
Claus Gittinger <cg@exept.de>
parents: 2506
diff changeset
  3056
    aBlock ensure:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3057
        self showCursor
121
claus
parents: 118
diff changeset
  3058
    ]
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3059
! !
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3060
2589
62794ae04446 support drop
ca
parents: 2580
diff changeset
  3061
!EditTextView methodsFor:'drag & drop'!
62794ae04446 support drop
ca
parents: 2580
diff changeset
  3062
62794ae04446 support drop
ca
parents: 2580
diff changeset
  3063
allowDrop:aBoolean
3236
aeb1fe5a6ead drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3235
diff changeset
  3064
    "enable/disable drop support"
aeb1fe5a6ead drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3235
diff changeset
  3065
2589
62794ae04446 support drop
ca
parents: 2580
diff changeset
  3066
    aBoolean ifFalse:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3067
        dropTarget := nil.
2589
62794ae04446 support drop
ca
parents: 2580
diff changeset
  3068
    ] ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3069
        dropTarget isNil ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3070
            dropTarget := DropTarget
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3071
                                receiver:self
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3072
                                argument:nil
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3073
                                dropSelector:#'drop:'
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3074
                                canDropSelector:#'canDrop:'
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3075
        ]
3236
aeb1fe5a6ead drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3235
diff changeset
  3076
    ].
aeb1fe5a6ead drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3235
diff changeset
  3077
!
aeb1fe5a6ead drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3235
diff changeset
  3078
3412
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  3079
canDrop:aDropContext
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  3080
    "public from d&d.
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  3081
     I accept textObjects and fileObjects only."
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  3082
4089
c6567fb50316 comment/format in: #canDrop:
Claus Gittinger <cg@exept.de>
parents: 4064
diff changeset
  3083
    "/ 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
  3084
    aDropContext sourceWidget == self ifTrue:[^ false].
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  3085
    ^ self canDropObjects:aDropContext dropObjects
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  3086
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  3087
    "Modified: / 13-10-2006 / 17:41:09 / cg"
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  3088
!
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  3089
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  3090
canDropObjects:aCollectionOfDropObjects
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  3091
    "public from d&d.
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  3092
     I accept textObjects and fileObjects only."
2589
62794ae04446 support drop
ca
parents: 2580
diff changeset
  3093
62794ae04446 support drop
ca
parents: 2580
diff changeset
  3094
    self checkModificationsAllowed ifFalse:[^ false].
62794ae04446 support drop
ca
parents: 2580
diff changeset
  3095
3412
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  3096
    aCollectionOfDropObjects isEmpty ifTrue:[ ^ false ].
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  3097
    ^ aCollectionOfDropObjects conform:[:obj| (obj isTextObject or:[obj isFileObject])]
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  3098
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  3099
    "Created: / 13-10-2006 / 15:56:57 / cg"
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  3100
    "Modified: / 13-10-2006 / 17:41:14 / cg"
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  3101
!
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  3102
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  3103
drop:aDropContext
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  3104
    "public from d&d.
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  3105
     drop objects (new API)"
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  3106
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  3107
    self dropObjects:(aDropContext dropObjects)
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  3108
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  3109
    "Modified: / 13-10-2006 / 17:41:19 / cg"
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  3110
!
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  3111
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  3112
dropFileObject:aDropObject
2589
62794ae04446 support drop
ca
parents: 2580
diff changeset
  3113
    "drop objects
3236
aeb1fe5a6ead drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3235
diff changeset
  3114
     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
  3115
4136
fcce27dfc253 changed: #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  3116
    |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
  3117
e4be6bf71a98 Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents: 3890
diff changeset
  3118
    pasteWhat := #name.
3412
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  3119
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  3120
    fn := aDropObject asFilename.
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  3121
    (fn exists and:[fn isRegularFile]) ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3122
        enforcedDropMode := UserPreferences current enforcedDropModeForFiles.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3123
        (enforcedDropMode notNil
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3124
        and:[enforcedDropMode ~~ #name or:[fn fileSize <= (1024*1024)]]) ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3125
            pasteWhat := enforcedDropMode.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3126
        ] ifFalse:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3127
            sensor := self sensor.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3128
            (sensor shiftDown or:[sensor ctrlDown]) ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3129
                pasteWhat := #name.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3130
            ] ifFalse:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3131
                (sensor metaDown) ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3132
                    pasteWhat := #contents.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3133
                ] ifFalse:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3134
                    dontAskAgainHolder := false asValue.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3135
                    answer := Dialog
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3136
                        confirmWithCancel:(resources
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3137
                                            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.'
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3138
                                            with:fn name allBold)
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3139
                        labels:#( 'Cancel' 'Name' 'Contents' )
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3140
                        values:#( nil #name #contents )
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3141
                        default:#contents
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3142
                        check:(resources string:'Do not ask again; instead, always paste the contents of small files.') on:dontAskAgainHolder
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3143
                        title:(resources string:'Drop What').
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3144
                    answer isNil ifTrue:[ ^ self ].
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3145
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3146
                    dontAskAgainHolder value ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3147
                        UserPreferences current enforcedDropModeForFiles:#contents
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3148
                    ].
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3149
                    pasteWhat := answer.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3150
                ]
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3151
            ]
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3152
        ].
3886
b50c9304f1d1 better alien file drop
Claus Gittinger <cg@exept.de>
parents: 3880
diff changeset
  3153
    ].
b50c9304f1d1 better alien file drop
Claus Gittinger <cg@exept.de>
parents: 3880
diff changeset
  3154
3907
e4be6bf71a98 Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents: 3890
diff changeset
  3155
    pasteWhat == #name ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3156
        text := fn pathName
3886
b50c9304f1d1 better alien file drop
Claus Gittinger <cg@exept.de>
parents: 3880
diff changeset
  3157
    ] ifFalse:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3158
        self withWaitCursorDo:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3159
            text := fn contentsAsString
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3160
        ].
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3161
        (app := self application) notNil ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3162
            app droppedFile:fn in:self
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3163
        ].
5787
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
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3166
    self
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3167
        undoablePaste:text
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3168
        info:'Drop File'.
3412
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  3169
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  3170
    "Created: / 13-10-2006 / 17:38:31 / cg"
3495
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  3171
    "Modified: / 28-07-2007 / 13:27:09 / cg"
3412
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  3172
!
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  3173
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  3174
dropObject:aDropObject
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  3175
    "drop objects
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  3176
     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
  3177
3415
35ffbeec46d9 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3412
diff changeset
  3178
    |text|
35ffbeec46d9 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3412
diff changeset
  3179
3412
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  3180
    (aDropObject isFileObject) ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3181
        self dropFileObject:aDropObject
3412
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  3182
    ] ifFalse:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3183
        aDropObject isTextObject ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3184
            text := aDropObject theObject.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3185
            text isStringCollection ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3186
                text := text asStringWithoutFinalCR
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3187
            ].
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3188
        ] ifFalse:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3189
            text := aDropObject theObject asString
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3190
        ].
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3191
        self
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3192
            undoablePaste:text
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3193
            info:'Drop'.
3412
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  3194
    ].
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  3195
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  3196
    "Created: / 13-10-2006 / 17:37:05 / cg"
3495
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  3197
    "Modified: / 28-07-2007 / 13:26:53 / cg"
3412
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  3198
!
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  3199
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  3200
dropObjects:aCollectionOfDropObjects
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  3201
    "public from d&d.
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  3202
     drop objects (old API)"
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  3203
3868
664a888e9c6a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3855
diff changeset
  3204
    aCollectionOfDropObjects do:[:el |
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3205
        self dropObject:el
3412
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  3206
    ].
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  3207
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  3208
    "Created: / 13-10-2006 / 15:59:40 / cg"
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  3209
    "Modified: / 13-10-2006 / 17:41:23 / cg"
2589
62794ae04446 support drop
ca
parents: 2580
diff changeset
  3210
! !
62794ae04446 support drop
ca
parents: 2580
diff changeset
  3211
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3212
!EditTextView methodsFor:'editing'!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3213
5761
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3214
applyConverterToSelection:converter
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3215
    "apply a converter to the selected text"
4286
83ef1d9faf6d added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents: 4285
diff changeset
  3216
83ef1d9faf6d added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents: 4285
diff changeset
  3217
    |line1 line2|
83ef1d9faf6d added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents: 4285
diff changeset
  3218
6226
b7628412aff5 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6210
diff changeset
  3219
    (self checkModificationsAllowedFlashIfNot:true) ifFalse:[^ self].
b7628412aff5 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6210
diff changeset
  3220
    
4286
83ef1d9faf6d added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents: 4285
diff changeset
  3221
    line1 := self selectionStartLine.
83ef1d9faf6d added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents: 4285
diff changeset
  3222
    line2 := self selectionEndLine.
83ef1d9faf6d added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents: 4285
diff changeset
  3223
    line1 isNil ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3224
        line1 := self perform:#cursorLine ifNotUnderstood:nil.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3225
        line1 notNil ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3226
            line2 := line1
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3227
        ]
4286
83ef1d9faf6d added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents: 4285
diff changeset
  3228
    ].
83ef1d9faf6d added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents: 4285
diff changeset
  3229
    line1 notNil ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3230
        line1 to:line2 do:[:lineNr |
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3231
            |line col1 col2 newLine|
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3232
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3233
            line := (self listAt:lineNr) copy.
6548
59a6fdf4dd26 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6543
diff changeset
  3234
            line size ~~ 0 ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3235
                lineNr == line1 ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3236
                    col1 := selectionStartCol.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3237
                ] ifFalse:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3238
                    col1 := 1.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3239
                ].
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3240
                lineNr == line2 ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3241
                    col2 := selectionEndCol.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3242
                ] ifFalse:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3243
                    col2 := (self listAt:lineNr) size.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3244
                ].
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3245
                newLine := converter value:line value:lineNr value:col1 value:col2.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3246
                self withoutRedrawAt:lineNr put:newLine.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3247
                self invalidateLine:lineNr.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3248
            ].
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3249
        ].
5761
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3250
    ]
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
    "Created: / 06-06-2016 / 10:53:17 / cg"
6226
b7628412aff5 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6210
diff changeset
  3253
    "Modified: / 11-11-2017 / 12:55:25 / cg"
6548
59a6fdf4dd26 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6543
diff changeset
  3254
    "Modified: / 01-03-2019 / 14:54:42 / Claus Gittinger"
5761
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3255
!
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3256
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3257
convertSelectionToLowercase
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3258
    "to-lower selected text"
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3259
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3260
    self applyConverterToSelection:[:line :lnr :col1 :col2 |
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3261
        col1 to:col2 do:[:col |
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3262
            |ch|
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3263
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3264
            ch := line at:col.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3265
            line at:col put:ch asLowercase.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3266
        ].
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3267
        line.
5761
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3268
    ].
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3269
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3270
    "Created: / 06-06-2016 / 10:50:28 / cg"
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3271
!
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3272
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3273
convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3274
    "toLower/toUppercaseFirst/toUpper selected text"
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3275
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3276
    self applyConverterToSelection:[:line :lineNr :col1 :col2 |
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3277
        |isAllLower isLowerFirst isAllUpper isUpperFirst
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3278
         makeLowercase makeUppercase makeUppercaseFirst makeLowercaseFirst|
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3279
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3280
        isAllLower := isAllUpper := isUpperFirst := isLowerFirst := true.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3281
        col1 to:col2 do:[:col |
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3282
            |ch|
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3283
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3284
            ch := line at:col.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3285
            ch isUppercase ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3286
                isAllLower := false.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3287
                col == col1 ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3288
                    isLowerFirst := false.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3289
                ].
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3290
            ] ifFalse:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3291
                ch isLowercase ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3292
                    isAllUpper := false.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3293
                    col == col1 ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3294
                        isUpperFirst := false.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3295
                    ].
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3296
                ]
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3297
            ].
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3298
        ].
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3299
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3300
        makeLowercase := makeUppercase := makeUppercaseFirst := makeLowercaseFirst := false.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3301
        isLowerFirst ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3302
            makeUppercaseFirst := true.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3303
        ] ifFalse:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3304
            "/ must remember where we come from - otherwise, we end up
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3305
            "/ in upperFirst - lowerFirst cycle.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3306
            "/ think about a good place to store this state
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3307
            false "(isUpperFirst and:[isAllUpper not])" ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3308
                makeLowercaseFirst := true.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3309
             ] ifFalse:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3310
                isAllUpper ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3311
                    makeLowercase := true.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3312
                ] ifFalse:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3313
                    makeUppercase := true.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3314
                ]
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3315
            ]
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3316
        ].
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3317
        makeUppercaseFirst ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3318
            line at:col1 put:(line at:col1) asUppercase.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3319
        ] ifFalse:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3320
            makeLowercaseFirst ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3321
                line at:col1 put:(line at:col1) asLowercase.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3322
            ] ifFalse:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3323
                col1 to:col2 do:[:col |
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3324
                    |ch|
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3325
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3326
                    ch := line at:col.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3327
                    ch := makeLowercase
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3328
                            ifTrue:[ ch asLowercase ]
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3329
                            ifFalse:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3330
                                makeUppercase
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3331
                                    ifTrue:[ ch asUppercase ]
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3332
                                    ifFalse:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3333
                                        col == col1
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3334
                                            ifTrue:[ ch asUppercase ]
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3335
                                            ifFalse:[ ch asLowercase ]
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3336
                                    ]
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3337
                            ].
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3338
                    line at:col put:ch.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3339
                ].
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3340
            ].
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3341
        ].
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3342
        line
4286
83ef1d9faf6d added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents: 4285
diff changeset
  3343
    ]
83ef1d9faf6d added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents: 4285
diff changeset
  3344
83ef1d9faf6d added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents: 4285
diff changeset
  3345
    "Created: / 14-07-2011 / 11:40:26 / cg"
5761
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3346
    "Modified: / 06-06-2016 / 10:57:15 / cg"
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3347
!
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3348
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3349
convertSelectionToUppercase
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3350
    "to-upper selected text"
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3351
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3352
    self applyConverterToSelection:[:line :lnr :col1 :col2 |
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3353
        col1 to:col2 do:[:col |
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3354
            |ch|
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3355
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3356
            ch := line at:col.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3357
            line at:col put:ch asUppercase.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3358
        ].
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3359
        line.
5761
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3360
    ].
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3361
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3362
    "Created: / 06-06-2016 / 11:09:04 / cg"
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3363
!
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3364
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3365
convertSelectionToUppercaseFirst
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3366
    "to-upperFirst selected text"
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3367
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3368
    self applyConverterToSelection:[:line :lnr :col1 :col2 |
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3369
        |state|
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3370
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3371
        state := #first.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3372
        col1 to:col2 do:[:col |
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3373
            |ch|
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3374
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3375
            ch := line at:col.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3376
            ch isSeparator ifFalse:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3377
                state == #first ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3378
                    line at:col put:ch asUppercase.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3379
                    state := #skipRest
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3380
                ]
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3381
            ] ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3382
                state := #first
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3383
            ]
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3384
        ].
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3385
        line.
5761
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3386
    ].
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3387
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3388
    "Created: / 06-06-2016 / 10:50:52 / cg"
4286
83ef1d9faf6d added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents: 4285
diff changeset
  3389
!
83ef1d9faf6d added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents: 4285
diff changeset
  3390
313
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  3391
copyAndDeleteSelection
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  3392
    "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
  3393
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  3394
    selectionStartLine notNil ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3395
        self setClipboardText:(self selection).
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3396
        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
  3397
    ].
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  3398
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  3399
    "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
  3400
!
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  3401
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3402
deleteCharAtCursor
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3403
    "delete single character under cursor; does not merge lines"
121
claus
parents: 118
diff changeset
  3404
claus
parents: 118
diff changeset
  3405
    |wasOn|
claus
parents: 118
diff changeset
  3406
claus
parents: 118
diff changeset
  3407
    wasOn := self hideCursor.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3408
    self deleteCharAtLine:cursorLine col:cursorCol.
121
claus
parents: 118
diff changeset
  3409
    wasOn ifTrue:[self showCursor]
claus
parents: 118
diff changeset
  3410
!
claus
parents: 118
diff changeset
  3411
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3412
deleteCharAtLine:lineNr col:colNr
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3413
    "delete a single character at colNr in line lineNr"
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3414
3023
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  3415
    self st80EditMode ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3416
        (self listAt:cursorLine) size + 1 = colNr ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3417
            | wasOn |
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3418
            wasOn := self hideCursor.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3419
            self
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3420
                cursorReturn;
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3421
                cursorCol:1;
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3422
                deleteCharBeforeCursor.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3423
            wasOn ifTrue:[ self showCursor].
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3424
            ^ self.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3425
        ].
3023
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  3426
    ].
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  3427
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3428
    self deleteCharsAtLine:lineNr fromCol:colNr toCol:colNr
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3429
!
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3430
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3431
deleteCharBeforeCursor
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3432
    "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
  3433
4592
60fc44d286f2 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4590
diff changeset
  3434
    |soCol wasOn lineNrAboveCursor ln originalLine prevTab|
121
claus
parents: 118
diff changeset
  3435
6050
4fb30794fc81 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6031
diff changeset
  3436
    list isEmptyOrNil ifTrue:[^ self]. "/ there is nothing to delete.
4fb30794fc81 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6031
diff changeset
  3437
    
121
claus
parents: 118
diff changeset
  3438
    wasOn := self hideCursor.
6614
228cd1c3eac9 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6613
diff changeset
  3439
    (self autoIndent and:[ (tabPositions includes:cursorCol)]) ifTrue:[
6050
4fb30794fc81 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6031
diff changeset
  3440
        prevTab := (self prevTabBefore:cursorCol) max:1.
4fb30794fc81 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6031
diff changeset
  3441
        ln := originalLine := (list at:cursorLine ifAbsent:'') ? ''.
4fb30794fc81 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6031
diff changeset
  3442
        ln size < prevTab ifTrue:[
6567
bb0ac8be28cc #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6564
diff changeset
  3443
            ln := ln , (String new:prevTab).
6050
4fb30794fc81 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6031
diff changeset
  3444
        ].
4fb30794fc81 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6031
diff changeset
  3445
        (ln copyTo:prevTab) isBlank ifTrue:[
4fb30794fc81 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6031
diff changeset
  3446
            (ln copyFrom:prevTab+1) isBlank ifTrue:[
4fb30794fc81 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6031
diff changeset
  3447
                cursorCol > prevTab ifTrue:[
4fb30794fc81 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6031
diff changeset
  3448
                    self st80EditMode ifTrue:[
4fb30794fc81 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6031
diff changeset
  3449
                        "/ ensure that there is no conflict here: st80EditMode will
4fb30794fc81 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6031
diff changeset
  3450
                        "/ not allow a cursor position beyond the end of line,
4fb30794fc81 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6031
diff changeset
  3451
                        "/ 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
  3452
                        originalLine size < prevTab ifTrue:[
4fb30794fc81 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6031
diff changeset
  3453
                            self checkForExistingLine:cursorLine.
4fb30794fc81 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6031
diff changeset
  3454
                            self basicListAt:cursorLine put:ln
4fb30794fc81 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6031
diff changeset
  3455
                        ]
4fb30794fc81 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6031
diff changeset
  3456
                    ].
4fb30794fc81 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6031
diff changeset
  3457
                    self cursorLine:cursorLine col:prevTab.
4fb30794fc81 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6031
diff changeset
  3458
                    wasOn ifTrue:[ self showCursor ].
4fb30794fc81 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6031
diff changeset
  3459
                    ^  self
4fb30794fc81 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6031
diff changeset
  3460
                ].
4fb30794fc81 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6031
diff changeset
  3461
            ] ifFalse:[
4fb30794fc81 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6031
diff changeset
  3462
                self deleteFromLine:cursorLine col:prevTab toLine:cursorLine col:cursorCol-1.
4fb30794fc81 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6031
diff changeset
  3463
                self cursorLine:cursorLine col:prevTab.
4fb30794fc81 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6031
diff changeset
  3464
                wasOn ifTrue:[ self showCursor ].
4fb30794fc81 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6031
diff changeset
  3465
                ^  self.
4fb30794fc81 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6031
diff changeset
  3466
            ]
4fb30794fc81 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6031
diff changeset
  3467
        ].
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3468
    ].
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3469
6614
228cd1c3eac9 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6613
diff changeset
  3470
"/        (self autoIndent 
2491
f3e207ae5156 auto indent fix
Claus Gittinger <cg@exept.de>
parents: 2461
diff changeset
  3471
"/    and:[cursorCol  ~~ 1
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3472
"/    and:[cursorLine <= (list size)]])
2491
f3e207ae5156 auto indent fix
Claus Gittinger <cg@exept.de>
parents: 2461
diff changeset
  3473
"/     ifTrue:[
f3e207ae5156 auto indent fix
Claus Gittinger <cg@exept.de>
parents: 2461
diff changeset
  3474
"/        soCol := (self leftIndentForLine:cursorLine) + 1.
f3e207ae5156 auto indent fix
Claus Gittinger <cg@exept.de>
parents: 2461
diff changeset
  3475
"/
f3e207ae5156 auto indent fix
Claus Gittinger <cg@exept.de>
parents: 2461
diff changeset
  3476
"/        (cursorCol == soCol and:[soCol > 1]) ifTrue:[
f3e207ae5156 auto indent fix
Claus Gittinger <cg@exept.de>
parents: 2461
diff changeset
  3477
"/            ln := list at:cursorLine.
f3e207ae5156 auto indent fix
Claus Gittinger <cg@exept.de>
parents: 2461
diff changeset
  3478
"/            (ln notNil and:[(ln indexOfNonSeparatorStartingAt:1) < soCol]) ifTrue:[
f3e207ae5156 auto indent fix
Claus Gittinger <cg@exept.de>
parents: 2461
diff changeset
  3479
"/                soCol := 1
f3e207ae5156 auto indent fix
Claus Gittinger <cg@exept.de>
parents: 2461
diff changeset
  3480
"/            ]
f3e207ae5156 auto indent fix
Claus Gittinger <cg@exept.de>
parents: 2461
diff changeset
  3481
"/        ]
f3e207ae5156 auto indent fix
Claus Gittinger <cg@exept.de>
parents: 2461
diff changeset
  3482
"/    ] ifFalse:[
6050
4fb30794fc81 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6031
diff changeset
  3483
        soCol := 1.
2491
f3e207ae5156 auto indent fix
Claus Gittinger <cg@exept.de>
parents: 2461
diff changeset
  3484
"/    ].
f3e207ae5156 auto indent fix
Claus Gittinger <cg@exept.de>
parents: 2461
diff changeset
  3485
1419
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
  3486
    (cursorCol ~~ soCol and:[cursorCol ~~ 1]) ifTrue:[
6050
4fb30794fc81 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6031
diff changeset
  3487
        "
4fb30794fc81 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6031
diff changeset
  3488
         somewhere in the middle of a line
4fb30794fc81 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6031
diff changeset
  3489
        "
4fb30794fc81 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6031
diff changeset
  3490
        self cursorLeft.
4fb30794fc81 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6031
diff changeset
  3491
        self deleteCharAtLine:cursorLine col:cursorCol.
1419
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
  3492
    ] ifFalse:[
6050
4fb30794fc81 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6031
diff changeset
  3493
        "
4fb30794fc81 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6031
diff changeset
  3494
         at begin of line - merge with previous line;
4fb30794fc81 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6031
diff changeset
  3495
         except for the very first line.
4fb30794fc81 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6031
diff changeset
  3496
        "
4fb30794fc81 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6031
diff changeset
  3497
        (cursorLine == 1) ifFalse:[
4fb30794fc81 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6031
diff changeset
  3498
            lineNrAboveCursor := self validateCursorLine:(cursorLine - 1).
4fb30794fc81 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6031
diff changeset
  3499
            lineNrAboveCursor < cursorLine ifTrue:[
4fb30794fc81 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6031
diff changeset
  3500
                (lineNrAboveCursor > 0 and:[lineNrAboveCursor > list size]) ifTrue:[
4fb30794fc81 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6031
diff changeset
  3501
                    "/ we are beyond the end of the text.
4fb30794fc81 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6031
diff changeset
  3502
                    "/ move the cursor to the previous line.
4fb30794fc81 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6031
diff changeset
  3503
                    self cursorLine:lineNrAboveCursor col:1.
4fb30794fc81 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6031
diff changeset
  3504
                ] ifFalse:[
4fb30794fc81 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6031
diff changeset
  3505
                    self mergeLine:lineNrAboveCursor removeBlanks:false.
4fb30794fc81 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6031
diff changeset
  3506
                ]
4fb30794fc81 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6031
diff changeset
  3507
            ]
4fb30794fc81 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6031
diff changeset
  3508
        ]
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3509
    ].
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3510
    wasOn ifTrue:[ self showCursor ]
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3511
6567
bb0ac8be28cc #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6564
diff changeset
  3512
    "Modified: / 16-01-1998 / 22:33:04 / cg"
6614
228cd1c3eac9 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6613
diff changeset
  3513
    "Modified: / 26-06-2019 / 23:19:59 / Claus Gittinger"
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3514
!
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3515
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3516
deleteCharsAtLine:lineNr fromCol:colNr
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3517
    "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
  3518
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3519
    |line|
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
    (line := self listAt:lineNr) notNil ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3522
        self deleteCharsAtLine:lineNr fromCol:colNr toCol:(line size)
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3523
    ]
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3524
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3525
!
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3526
4458
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  3527
deleteCharsAtLine:lineNr fromCol:startCol toCol:endCol
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  3528
    "delete characters from startCol to endCol in line lineNr"
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  3529
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  3530
    |deleted|
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  3531
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  3532
    deleted := self textFromLine:lineNr col:startCol toLine:lineNr col:endCol.
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  3533
    self basicDeleteCharsAtLine:lineNr fromCol:startCol toCol:endCol.
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  3534
    self addUndo:(PasteString line:lineNr col:startCol string:deleted info:'delete').
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  3535
!
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  3536
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3537
deleteCharsAtLine:lineNr toCol:colNr
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3538
    "delete characters from start up to colNr in line lineNr"
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3539
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3540
    self deleteCharsAtLine:lineNr fromCol:1 toCol:colNr
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3541
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3542
121
claus
parents: 118
diff changeset
  3543
!
claus
parents: 118
diff changeset
  3544
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3545
deleteCursorLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3546
    "delete the line where the cursor sits"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3547
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3548
    self deleteLine:cursorLine
121
claus
parents: 118
diff changeset
  3549
!
claus
parents: 118
diff changeset
  3550
2385
357e8a1cb2b2 added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents: 2373
diff changeset
  3551
deleteFromCharacterPosition:charPos1 to:charPos2
357e8a1cb2b2 added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents: 2373
diff changeset
  3552
    "delete a substring at a character position"
357e8a1cb2b2 added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents: 2373
diff changeset
  3553
357e8a1cb2b2 added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents: 2373
diff changeset
  3554
    |line1 col1 line2 col2|
357e8a1cb2b2 added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents: 2373
diff changeset
  3555
357e8a1cb2b2 added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents: 2373
diff changeset
  3556
    line1 := self lineOfCharacterPosition:charPos1.
357e8a1cb2b2 added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents: 2373
diff changeset
  3557
    col1 := charPos1 - (self characterPositionOfLine:line1 col:1) + 1.
2725
eccf283b2efb deleteFromCharacterPos - fixed
Claus Gittinger <cg@exept.de>
parents: 2724
diff changeset
  3558
    col1 == 0 ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3559
        line1 := line1 - 1.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3560
        col1 := (self listAt:line1) size + 1.
2725
eccf283b2efb deleteFromCharacterPos - fixed
Claus Gittinger <cg@exept.de>
parents: 2724
diff changeset
  3561
    ].
2385
357e8a1cb2b2 added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents: 2373
diff changeset
  3562
357e8a1cb2b2 added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents: 2373
diff changeset
  3563
    line2 := self lineOfCharacterPosition:charPos2.
357e8a1cb2b2 added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents: 2373
diff changeset
  3564
    col2 := charPos2 - (self characterPositionOfLine:line2 col:1) + 1.
357e8a1cb2b2 added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents: 2373
diff changeset
  3565
357e8a1cb2b2 added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents: 2373
diff changeset
  3566
    self deleteFromLine:line1 col:col1 toLine:line2 col:col2.
357e8a1cb2b2 added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents: 2373
diff changeset
  3567
!
357e8a1cb2b2 added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents: 2373
diff changeset
  3568
2954
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3569
deleteFromLine:startLine col:startCol toLine:endLine col:endCol
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3570
    "delete all text from startLine/startCol to endLine/endCol -
6163
a43ebb055c61 #DOCUMENTATION by mawalch
mawalch
parents: 6156
diff changeset
  3571
     joining lines if necessary"
2954
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3572
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3573
    |line newLine lineSize nMore|
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3574
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3575
    self checkModificationsAllowed ifFalse:[ ^ self].
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3576
    list isNil ifTrue:[^ self].
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3577
    startLine > list size ifTrue:[ ^ self]. "/ deleted space below text
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3578
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3579
    (startLine == endLine) ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3580
        "/ delete chars within a line
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3581
        self deleteCharsAtLine:startLine fromCol:startCol toCol:endCol.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3582
        ^ self
2954
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3583
    ].
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3584
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3585
    ((startCol == 1) and:[endCol == 0]) ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3586
        "/ delete full lines only
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3587
        endLine > startLine ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3588
            self deleteFromLine:startLine toLine:(endLine - 1)
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3589
        ].
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3590
        ^ self
2954
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3591
    ].
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3592
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3593
    "/ delete right rest of 1st line
4786
70fd2d143e7c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4782
diff changeset
  3594
    self deleteCharsAtLine:startLine fromCol:(startCol max:1).
2954
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3595
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3596
    "/ delete the inner lines ...
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3597
    endLine > (startLine + 1) ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3598
        self deleteFromLine:(startLine + 1) toLine:(endLine - 1)
2954
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3599
    ].
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3600
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3601
    (endCol ~~ 0) ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3602
        "/ delete the left rest of the last line
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3603
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3604
        self deleteCharsAtLine:(startLine + 1) toCol:endCol.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3605
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3606
        "/ must add blanks, if startCol lies beyond end of startLine
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3607
        startLine <= list size ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3608
            line := list at:startLine.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3609
            lineSize := line size.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3610
            (startCol > lineSize) ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3611
                newLine := line.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3612
                line isNil ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3613
                    newLine := String new:(startCol - 1)
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3614
                ] ifFalse:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3615
                    nMore := startCol - 1 - lineSize.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3616
                    nMore > 0 ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3617
                        newLine := line , (line species new:nMore)
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3618
                    ]
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3619
                ].
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3620
                newLine ~~ line ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3621
                    self basicListAt:startLine put:newLine.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3622
                ].
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3623
                "/ TODO: remember old maxwidth of linerange,
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3624
                "/ only clear widthOfWidestLine, if this max
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3625
                "/ length was (one of) the longest.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3626
                "/ avoids slow delete with huge texts.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3627
                widthOfWidestLine := nil. "/ i.e. unknown
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3628
                self textChanged.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3629
            ]
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3630
        ]
2954
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3631
    ].
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3632
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3633
    "/ 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
  3634
    self mergeLine:startLine removeBlanks:false
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3635
4225
a0a83ed7368c changed: #deleteFromLine:col:toLine:col:
az
parents: 4213
diff changeset
  3636
    "Modified: / 10-11-1998 / 23:52:59 / cg"
a0a83ed7368c changed: #deleteFromLine:col:toLine:col:
az
parents: 4213
diff changeset
  3637
    "Modified: / 18-03-2011 / 18:25:01 / az"
6163
a43ebb055c61 #DOCUMENTATION by mawalch
mawalch
parents: 6156
diff changeset
  3638
    "Modified (comment): / 30-05-2017 / 17:34:03 / mawalch"
2954
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3639
!
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3640
4458
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  3641
deleteFromLine:startLineNr toLine:endLineNr
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  3642
    "delete some lines"
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  3643
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  3644
    |deleted|
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  3645
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  3646
    deleted := self textFromLine:startLineNr col:1 toLine:endLineNr+1 col:0.
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  3647
    self basicDeleteFromLine:startLineNr toLine:endLineNr.
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  3648
    self addUndo:(PasteString line:startLineNr col:1 string:deleted info:'delete').
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  3649
!
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  3650
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3651
deleteLine:lineNr
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3652
    "delete line"
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3653
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3654
    self deleteFromLine:lineNr toLine:lineNr
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3655
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3656
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3657
!
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3658
4458
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  3659
deleteLineWithoutRedraw:lineNr
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  3660
    "delete line - no redraw;
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  3661
     return true, if something was really deleted"
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  3662
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  3663
    |deleted ret|
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  3664
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  3665
    deleted := self textFromLine:lineNr col:1 toLine:lineNr+1 col:0.
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  3666
    ret := self basicDeleteLineWithoutRedraw:lineNr.
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  3667
    self addUndo:(PasteString line:lineNr col:1 string:deleted info:'delete').
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  3668
    ^ ret.
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  3669
!
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  3670
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3671
deleteLinesWithoutRedrawFrom:startLine to:endLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3672
    "delete lines - no redraw;
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3673
     return true, if something was really deleted"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3674
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3675
    |lastLine|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3676
4771
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  3677
    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
  3678
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3679
    (list isNil or:[startLine > list size]) ifTrue:[^ false].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3680
    (endLine > list size) ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3681
        lastLine := list size
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3682
    ] ifFalse:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3683
        lastLine := endLine
4771
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  3684
    ].
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  3685
    self basicListRemoveFromIndex:startLine toIndex:lastLine.
1717
83203096a851 dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  3686
    "/ TODO: remember old maxwidth of linerange,
83203096a851 dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  3687
    "/ only clear widthOfWidestLine, if this max
83203096a851 dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  3688
    "/ length was (one of) the longest.
83203096a851 dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  3689
    "/ avoids slow delete with huge texts.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3690
    widthOfWidestLine := nil. "/ i.e. unknown
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3691
    self textChanged.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3692
    ^ true
1717
83203096a851 dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  3693
83203096a851 dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  3694
    "Modified: / 10.11.1998 / 23:55:29 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3695
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3696
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3697
deleteSelection
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3698
    "delete the selection"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3699
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3700
    |wasOn startLine startCol endLine endCol|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3701
331
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
  3702
    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
  3703
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3704
    selectionStartLine notNil ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3705
        wasOn := self hideCursor.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3706
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3707
        startLine := selectionStartLine.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3708
        startCol := selectionStartCol.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3709
        endLine := selectionEndLine.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3710
        endCol := selectionEndCol.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3711
        self unselectWithoutRedraw.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3712
        self deleteFromLine:startLine col:startCol toLine:endLine col:endCol.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3713
        self setCursorLine:startLine col:startCol.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3714
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3715
        self makeCursorVisibleAndShowCursor:wasOn
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3716
    ]
121
claus
parents: 118
diff changeset
  3717
!
claus
parents: 118
diff changeset
  3718
2157
ba22c3cc278b added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
  3719
deleteWordBeforeCursor
ba22c3cc278b added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
  3720
    "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
  3721
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3722
    |wasOn beginCol beginLine endCol endLine|
2157
ba22c3cc278b added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
  3723
3799
f6cbe8d860d5 code formatting
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3724
    self checkModificationsAllowed ifFalse:[ ^ self].
5361
d39070e004c1 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5357
diff changeset
  3725
    cursorCol <= 1 ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3726
        self deleteCharBeforeCursor.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3727
        ^ self
5361
d39070e004c1 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5357
diff changeset
  3728
    ].
3799
f6cbe8d860d5 code formatting
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3729
2157
ba22c3cc278b added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
  3730
    wasOn := self hideCursor.
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  3731
    self
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3732
        undoableDo:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3733
            endCol := cursorCol-1.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3734
            endLine := cursorLine.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3735
            self cursorToPreviousWord.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3736
            beginCol := cursorCol.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3737
            beginLine := cursorLine.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3738
            self deleteFromLine:beginLine col:beginCol toLine:endLine col:endCol.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3739
            self cursorLine:cursorLine col:beginCol.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3740
        ]
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3741
        info:'Delete Word'.
2157
ba22c3cc278b added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
  3742
    wasOn ifTrue:[ self showCursor ].
ba22c3cc278b added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
  3743
ba22c3cc278b added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
  3744
    "Modified: / 22.2.2000 / 23:59:04 / cg"
ba22c3cc278b added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
  3745
!
ba22c3cc278b added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
  3746
5761
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3747
indentSelectionBy1
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3748
    "indent selected line-range
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3749
     by 1 space (i.e. to the right)"
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3750
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3751
    self indentBy:1
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3752
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3753
    "Created: / 06-06-2016 / 10:58:19 / cg"
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3754
!
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3755
4458
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  3756
insert:aCharacter atLine:lineNr col:colNr
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  3757
    "insert a single character at lineNr/colNr;
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  3758
     set emphasis to character at current position"
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  3759
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  3760
    self basicInsert:aCharacter atLine:lineNr col:colNr.
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  3761
    aCharacter ~~ Character cr ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3762
        self addUndo:(DeleteCharacters line:lineNr col:colNr info:'insert').
4458
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  3763
    ]
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  3764
!
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  3765
121
claus
parents: 118
diff changeset
  3766
insertCharAtCursor:aCharacter
1566
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  3767
    "insert a single character at cursor-position - advance cursor."
121
claus
parents: 118
diff changeset
  3768
claus
parents: 118
diff changeset
  3769
    |wasOn|
claus
parents: 118
diff changeset
  3770
claus
parents: 118
diff changeset
  3771
    wasOn := self hideCursor.
1566
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  3772
    aCharacter == Character tab ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3773
        "/ needs special care to advance cursor correctly
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3774
        self insertTabAtCursor
121
claus
parents: 118
diff changeset
  3775
    ] ifFalse:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3776
        self insert:aCharacter atLine:cursorLine col:cursorCol.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3777
        aCharacter == (Character cr) ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3778
            self basicCursorReturn
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3779
        ] ifFalse:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3780
            self cursorRight.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3781
        ].
121
claus
parents: 118
diff changeset
  3782
    ].
claus
parents: 118
diff changeset
  3783
    self makeCursorVisibleAndShowCursor:wasOn.
1566
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  3784
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  3785
    "Modified: / 12.6.1998 / 21:50:20 / cg"
121
claus
parents: 118
diff changeset
  3786
!
claus
parents: 118
diff changeset
  3787
641
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  3788
insertLine:aString before:lineNr
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  3789
    "insert the line aString before line lineNr"
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  3790
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  3791
    ^ self insertLines:(Array with:aString) from:1 to:1  before:lineNr.
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  3792
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  3793
    "Modified: 14.5.1996 / 13:42:54 / cg"
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  3794
!
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  3795
155
claus
parents: 133
diff changeset
  3796
insertLines:aStringCollection before:lineNr
claus
parents: 133
diff changeset
  3797
    "insert a bunch before line lineNr"
claus
parents: 133
diff changeset
  3798
claus
parents: 133
diff changeset
  3799
    self insertLines:aStringCollection from:1 to:aStringCollection size before:lineNr
claus
parents: 133
diff changeset
  3800
claus
parents: 133
diff changeset
  3801
    "Modified: 6.9.1995 / 20:51:03 / claus"
claus
parents: 133
diff changeset
  3802
!
claus
parents: 133
diff changeset
  3803
4771
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  3804
insertLines:someText from:start to:end before:lineNr
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  3805
    "insert a bunch of lines before line lineNr.
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  3806
     The cursor position is left unchanged."
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  3807
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  3808
    |text indent visLine w nLines "{ Class: SmallInteger }"
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  3809
     srcY "{ Class: SmallInteger }"
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  3810
     dstY "{ Class: SmallInteger }" |
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  3811
5357
d942c4152f03 class: EditTextView
ca
parents: 5331
diff changeset
  3812
    "wrong when pasting multiple lines"
d942c4152f03 class: EditTextView
ca
parents: 5331
diff changeset
  3813
    false "autoIndent" ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3814
        indent := self leftIndentForLine:lineNr.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3815
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3816
        text := someText
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3817
            collect:[:ln||line|
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3818
                ln notNil ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3819
                    line := ln withoutLeadingSeparators.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3820
                    (line isEmpty or:[indent == 0]) ifFalse:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3821
                        line := (String new:indent), line
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3822
                    ].
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3823
                    line
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3824
                ] ifFalse:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3825
                    nil
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3826
                ]
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3827
            ].
4771
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  3828
    ] ifFalse:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3829
        text := someText
4771
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  3830
    ].
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  3831
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  3832
    visLine := self listLineToVisibleLine:lineNr.
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  3833
    (shown not or:[visLine isNil]) ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3834
        self withoutRedrawInsertLines:text
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3835
             from:start to:end
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3836
             before:lineNr.
4771
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  3837
    ] ifFalse:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3838
        nLines := end - start + 1.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3839
        ((visLine + nLines) >= nLinesShown) ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3840
            self withoutRedrawInsertLines:text
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3841
                 from:start to:end
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3842
                 before:lineNr.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3843
            self redrawFromVisibleLine:visLine to:nLinesShown
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3844
        ] ifFalse:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3845
            w := self widthForScrollBetween:(lineNr + nLines)
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3846
                                        and:(firstLineShown + nLines + nLinesShown).
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3847
            srcY := topMargin + ((visLine - 1) * fontHeight).
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3848
            dstY := srcY + (nLines * fontHeight).
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3849
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3850
            "/
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3851
            "/ scroll ...
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3852
            "/
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3853
            "
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3854
             stupid: must catchExpose before inserting new
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3855
             stuff - since catchExpose may perform redraws
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3856
            "
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3857
            self catchExpose.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3858
            self withoutRedrawInsertLines:text
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3859
                 from:start to:end
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3860
                 before:lineNr.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3861
            self
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3862
                copyFrom:self
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3863
                x:textStartLeft y:srcY
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3864
                toX:textStartLeft y:dstY
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3865
                width:w
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3866
                height:(height - dstY)
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3867
                async:true.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3868
            self redrawFromVisibleLine:visLine to:(visLine + nLines - 1).
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3869
            self waitForExpose
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3870
        ].
4771
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  3871
    ].
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  3872
    widthOfWidestLine notNil ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3873
        text do:[:line |
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3874
            widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:line).
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3875
        ]
4771
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  3876
    ].
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  3877
    self textChanged.
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  3878
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  3879
    "Modified: 29.1.1997 / 13:02:39 / cg"
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  3880
!
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  3881
654
d621e63baaa5 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 641
diff changeset
  3882
insertLines:lines withCR:withCr
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3883
    "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
  3884
     Cursor is moved behind insertion.
641
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  3885
     If withCr is true, append cr after last line"
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  3886
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  3887
    |start end nLines wasOn|
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  3888
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  3889
    lines notNil ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3890
        nLines := lines size.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3891
        (nLines == 1) ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3892
            self insertStringAtCursor:(lines at:1).
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3893
            withCr ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3894
                self insertCharAtCursor:(Character cr)
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3895
            ]
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3896
        ] ifFalse:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3897
            (cursorCol ~~ 1) ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3898
                self insertStringAtCursor:(lines at:1).
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3899
                self insertCharAtCursor:(Character cr).
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3900
                start := 2
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3901
            ] ifFalse:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3902
                start := 1
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3903
            ].
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3904
            withCr ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3905
                end := nLines
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3906
            ] ifFalse:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3907
                end := nLines - 1
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3908
            ].
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3909
            (start <= nLines) ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3910
                (end >= start) ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3911
                    wasOn := self hideCursor.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3912
                    self insertLines:lines from:start to:end before:cursorLine.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3913
                    self setCursorLine:(cursorLine + (end - start + 1)).
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3914
                    wasOn ifTrue:[self showCursor].
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3915
                ]
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3916
            ].
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3917
            withCr ifFalse:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3918
                "last line without cr"
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3919
                self insertStringAtCursor:(lines at:nLines)
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3920
            ]
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3921
        ]
641
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  3922
    ]
654
d621e63baaa5 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 641
diff changeset
  3923
1566
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  3924
    "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
  3925
    "Modified: / 12.6.1998 / 21:51:16 / cg"
654
d621e63baaa5 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 641
diff changeset
  3926
!
d621e63baaa5 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 641
diff changeset
  3927
d621e63baaa5 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 641
diff changeset
  3928
insertLines:lines withCr:withCr
d621e63baaa5 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 641
diff changeset
  3929
    "insert a bunch of lines at cursor position. Cursor
d621e63baaa5 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 641
diff changeset
  3930
     is moved behind insertion.
d621e63baaa5 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 641
diff changeset
  3931
     If withCr is true, append cr after last line"
d621e63baaa5 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 641
diff changeset
  3932
2363
1982139b2c0b Use <resource:#obsolete>
Stefan Vogel <sv@exept.de>
parents: 2357
diff changeset
  3933
    <resource:#obsolete>
1982139b2c0b Use <resource:#obsolete>
Stefan Vogel <sv@exept.de>
parents: 2357
diff changeset
  3934
1292
ca4c9a957a32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1290
diff changeset
  3935
    self obsoleteMethodWarning:'use #insertLines:withCR:'.
ca4c9a957a32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1290
diff changeset
  3936
    self insertLines:lines withCR:withCr.
ca4c9a957a32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1290
diff changeset
  3937
ca4c9a957a32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1290
diff changeset
  3938
    "Modified: 31.7.1997 / 23:07:22 / cg"
641
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  3939
!
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  3940
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3941
insertSelectedStringAtCursor:aString
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3942
    "insert the argument, aString at cursor position and select it"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3943
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3944
    |startLine startCol|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3945
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3946
    startLine := cursorLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3947
    startCol := cursorCol.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3948
    self insertStringAtCursor:aString.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3949
    self selectFromLine:startLine col:startCol
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3950
                 toLine:cursorLine col:(cursorCol - 1).
3514
98e103cad51d insertSelectedStringAtCursor: - make selection visible afterwards;
Michael Beyl <mb@exept.de>
parents: 3510
diff changeset
  3951
    self makeSelectionVisible.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3952
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3953
1935
b59ff4681762 added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
  3954
insertString:aString atCharacterPosition:charPos
b59ff4681762 added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
  3955
    "insert the argument, aString at a character position"
b59ff4681762 added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
  3956
b59ff4681762 added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
  3957
    |line col|
b59ff4681762 added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
  3958
b59ff4681762 added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
  3959
    line := self lineOfCharacterPosition:charPos.
b59ff4681762 added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
  3960
    col := charPos - (self characterPositionOfLine:line col:1) + 1.
5060
669de456849b class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5057
diff changeset
  3961
    col == 0 ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3962
        line > 1 ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3963
            line := line - 1.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3964
            col := (self listAt:line) size + 1.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3965
        ] ifFalse:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3966
            col := 1.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3967
        ]
5060
669de456849b class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5057
diff changeset
  3968
    ].
1935
b59ff4681762 added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
  3969
    self insertString:aString atLine:line col:col
b59ff4681762 added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
  3970
!
b59ff4681762 added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
  3971
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3972
insertString:aString atLine:lineNr col:colNr
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3973
    "insert the string, aString at line/col;
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3974
     handle cr's correctly"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3975
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3976
    |start           "{ Class: SmallInteger }"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3977
     stop            "{ Class: SmallInteger }"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3978
     end             "{ Class: SmallInteger }"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3979
     subString c
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3980
     l               "{ Class: SmallInteger }" |
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3981
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3982
    aString isNil ifTrue:[^ self].
1560
43d0f7c2143f use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents: 1559
diff changeset
  3983
    (aString includes:(Character cr)) ifFalse:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3984
        ^ self insertStringWithoutCRs:aString atLine:lineNr col:colNr
121
claus
parents: 118
diff changeset
  3985
    ].
1560
43d0f7c2143f use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents: 1559
diff changeset
  3986
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3987
    l := lineNr.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3988
    c := colNr.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3989
    start := 1.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3990
    end := aString size.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3991
    [start <= end] whileTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3992
        stop := aString indexOf:(Character cr) startingAt:start.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3993
        stop == 0 ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3994
            stop := end + 1
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3995
        ].
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3996
        subString := aString copyFrom:start to:(stop - 1).
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3997
        self insertStringWithoutCRs:subString atLine:l col:c.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3998
        (stop <= end) ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  3999
            c := c + subString size.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4000
            self insert:(Character cr) atLine:l col:c.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4001
            l := l + 1.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4002
            c := 1
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4003
        ].
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4004
        start := stop + 1
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4005
    ]
1480
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  4006
1560
43d0f7c2143f use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents: 1559
diff changeset
  4007
    "Modified: / 10.6.1998 / 19:03:59 / cg"
121
claus
parents: 118
diff changeset
  4008
!
claus
parents: 118
diff changeset
  4009
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4010
insertStringAtCursor:aString
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4011
    "insert the argument, aString at cursor position
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4012
     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
  4013
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4014
    aString isNil ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4015
        "new:"
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4016
        self insertCharAtCursor:(Character cr).
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4017
        ^ self
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  4018
    ].
1560
43d0f7c2143f use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents: 1559
diff changeset
  4019
    (aString includes:(Character cr)) ifFalse:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4020
        ^ self insertStringWithoutCRsAtCursor:aString
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  4021
    ].
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  4022
654
d621e63baaa5 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 641
diff changeset
  4023
    self insertLines:aString asStringCollection withCR:false.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4024
1560
43d0f7c2143f use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents: 1559
diff changeset
  4025
    "Modified: / 10.6.1998 / 19:03:21 / cg"
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  4026
!
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  4027
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4028
insertStringWithoutCRs:aString atLine:lineNr col:colNr
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4029
    "insert aString (which has no crs) at lineNr/colNr"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4030
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4031
    self withoutRedrawInsertStringWithoutCRs:aString atLine:lineNr col:colNr.
4190
d79217c1317d changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4189
diff changeset
  4032
    shown ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4033
        gc font hasOverlappingCharacters ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4034
            self invalidateLine:lineNr.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4035
        ] ifFalse:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4036
            self redrawLine:lineNr from:colNr
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4037
        ]
4190
d79217c1317d changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4189
diff changeset
  4038
    ]
d79217c1317d changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4189
diff changeset
  4039
4191
8ac20ced2fbf changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4190
diff changeset
  4040
    "Modified: / 09-11-2010 / 13:43:03 / cg"
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  4041
!
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  4042
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4043
insertStringWithoutCRsAtCursor:aString
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4044
    "insert a string (which has no crs) at cursor position
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4045
     - advance cursor"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4046
2422
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  4047
    |wasOn oldLen newLen deltaLen|
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  4048
6548
59a6fdf4dd26 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6543
diff changeset
  4049
    aString size ~~ 0 ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4050
        wasOn := self hideCursor.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4051
        (aString includes:Character tab) ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4052
            self checkForExistingLine:cursorLine.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4053
            oldLen := (list at:cursorLine) size.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4054
            self insertString:aString atLine:cursorLine col:cursorCol.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4055
            newLen := (list at:cursorLine) size.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4056
            deltaLen := newLen - oldLen.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4057
        ] ifFalse:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4058
            self insertString:aString atLine:(cursorLine ? 1) col:cursorCol.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4059
            deltaLen := aString size.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4060
        ].
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4061
        self setCursorCol:(cursorCol + deltaLen).
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4062
        wasOn ifTrue:[self showCursor]
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4063
    ]
1563
b4eb49efdfcd fixed cursor positioning if inserting a string with tabs.
Claus Gittinger <cg@exept.de>
parents: 1561
diff changeset
  4064
6548
59a6fdf4dd26 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6543
diff changeset
  4065
    "Modified: / 10-06-1998 / 20:43:52 / cg"
59a6fdf4dd26 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6543
diff changeset
  4066
    "Modified: / 01-03-2019 / 14:54:49 / Claus Gittinger"
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
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4069
insertTabAtCursor
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4070
    "insert spaces to next tab"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4071
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4072
    |wasOn nextTab|
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  4073
121
claus
parents: 118
diff changeset
  4074
    wasOn := self hideCursor.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4075
    nextTab := self nextTabAfter:cursorCol.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4076
    self insertStringAtCursor:(String new:(nextTab - cursorCol)).
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4077
    self makeCursorVisibleAndShowCursor:wasOn.
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  4078
!
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  4079
3542
30ed44ed0178 +joinLines (CTRL-j);
Claus Gittinger <cg@exept.de>
parents: 3517
diff changeset
  4080
joinLines
3890
4c5c54cf856b +wrapLines
Claus Gittinger <cg@exept.de>
parents: 3886
diff changeset
  4081
    "join lines (remove line-break)"
4c5c54cf856b +wrapLines
Claus Gittinger <cg@exept.de>
parents: 3886
diff changeset
  4082
3583
fd5a924c8681 menu enablement
Claus Gittinger <cg@exept.de>
parents: 3580
diff changeset
  4083
    self checkModificationsAllowed ifFalse:[ ^ self].
fd5a924c8681 menu enablement
Claus Gittinger <cg@exept.de>
parents: 3580
diff changeset
  4084
3683
5891af82a177 middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents: 3650
diff changeset
  4085
    self
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4086
        undoableDo:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4087
            |line col lineLen|
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4088
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4089
            line := cursorLine.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4090
            col := cursorCol.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4091
            lineLen := (list at:line) size.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4092
            col > lineLen ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4093
                self insertString:(String new:col-lineLen) atLine:line col:col+1.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4094
            ] ifFalse:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4095
                self deleteCharsAtLine:line fromCol:col toCol:lineLen.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4096
            ].
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4097
            self mergeLine:line removeBlanks:true.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4098
            self cursorLine:line col:col.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4099
        ]
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4100
        info:'Join'
3542
30ed44ed0178 +joinLines (CTRL-j);
Claus Gittinger <cg@exept.de>
parents: 3517
diff changeset
  4101
!
30ed44ed0178 +joinLines (CTRL-j);
Claus Gittinger <cg@exept.de>
parents: 3517
diff changeset
  4102
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4103
mergeLine:lineNr
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4104
    "merge line lineNr with line lineNr+1"
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4105
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4106
    self mergeLine:lineNr removeBlanks:true
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4107
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4108
    "Modified: 9.9.1997 / 09:28:03 / cg"
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4109
!
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4110
4458
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4111
mergeLine:lineNr removeBlanks:removeBlanks
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4112
    "merge line lineNr with line lineNr+1"
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4113
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4114
    |len|
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4115
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4116
    self checkModificationsAllowed ifFalse:[ ^ self].
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4117
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4118
    len := (self listAt:lineNr) size.
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4119
    self nonUndoableDo:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4120
        self basicMergeLine:lineNr removeBlanks:removeBlanks.
4458
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4121
    ].
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4122
    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
  4123
!
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4124
5761
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  4125
parenthizeSelection
6198
8c4bc6c92871 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 6184
diff changeset
  4126
    "place parentheses around the selected text.
5761
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  4127
     if already parenthized, de-parenthize it"
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  4128
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  4129
    self parenthizeSelectionWith:$( and:$)
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  4130
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  4131
    "Created: / 06-06-2016 / 10:59:05 / cg"
6198
8c4bc6c92871 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 6184
diff changeset
  4132
    "Modified (comment): / 30-08-2017 / 20:17:46 / cg"
5761
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  4133
!
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  4134
2506
5568d67dbddd Ctrl-8 / Ctrl-9,
Claus Gittinger <cg@exept.de>
parents: 2505
diff changeset
  4135
parenthizeSelectionWith:openingCharacter and:closingCharacter
5761
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  4136
    "if already parenthized, de-parenthize it"
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  4137
5560
511e59f19726 #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 5529
diff changeset
  4138
    |newSelectionEnd startLine endLine startCol endCol|
2505
9204d5313979 Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents: 2491
diff changeset
  4139
9204d5313979 Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents: 2491
diff changeset
  4140
    self hasSelection ifFalse:[^ self].
5560
511e59f19726 #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 5529
diff changeset
  4141
    startLine := selectionStartLine.
511e59f19726 #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 5529
diff changeset
  4142
    endLine := selectionEndLine.
511e59f19726 #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 5529
diff changeset
  4143
    startCol := selectionStartCol.
511e59f19726 #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 5529
diff changeset
  4144
    endCol := selectionEndCol.
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4145
5560
511e59f19726 #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 5529
diff changeset
  4146
    newSelectionEnd := endCol.
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4147
5560
511e59f19726 #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 5529
diff changeset
  4148
    (self characterAtLine:startLine col:startCol) == openingCharacter ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4149
        (self characterAtLine:endLine col:endCol) == closingCharacter ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4150
            self deleteCharAtLine:endLine col:endCol.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4151
            newSelectionEnd := newSelectionEnd-1.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4152
        ].
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4153
        self deleteCharAtLine:startLine col:startCol.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4154
        startLine == endLine ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4155
            newSelectionEnd := newSelectionEnd-1.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4156
        ]
2505
9204d5313979 Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents: 2491
diff changeset
  4157
    ] ifFalse:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4158
        self insert:closingCharacter atLine:endLine col:endCol+1.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4159
        newSelectionEnd := newSelectionEnd+1.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4160
        self insert:openingCharacter atLine:startLine col:startCol.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4161
        startLine == endLine ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4162
            newSelectionEnd := newSelectionEnd+1.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4163
        ]
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  4164
    ].
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  4165
    self
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4166
        selectFromLine:startLine col:startCol
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4167
        toLine:endLine col:newSelectionEnd.
5761
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  4168
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  4169
    "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
  4170
!
9204d5313979 Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents: 2491
diff changeset
  4171
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4172
removeTrailingBlankLines
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4173
    "remove all blank lines at end of text"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4174
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4175
    |lastLine "{ Class: SmallInteger }"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4176
     line finished|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4177
5114
679cca16c072 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5112
diff changeset
  4178
    NoModificationError handle:[:ex |
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4179
        ^ self
5114
679cca16c072 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5112
diff changeset
  4180
    ] do:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4181
        lastLine := list size.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4182
        finished := false.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4183
        [finished] whileFalse:[
6469
8d931d8edf6c #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6452
diff changeset
  4184
            ((lastLine <= 1) or:[lastLine = cursorLine]) ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4185
                finished := true
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4186
            ] ifFalse:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4187
                line := list at:lastLine.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4188
                line notNil ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4189
                    line isBlank ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4190
                        self basicListAt:lastLine put:nil.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4191
                        line := nil
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4192
                    ]
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4193
                ].
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4194
                line notNil ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4195
                    finished := true
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4196
                ] ifFalse:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4197
                    lastLine := lastLine - 1
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4198
                ]
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4199
            ]
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4200
        ].
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4201
        (lastLine ~~ list size) ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4202
            list grow:lastLine.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4203
            "/ self textChanged
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4204
        ]
118
claus
parents: 105
diff changeset
  4205
    ].
6469
8d931d8edf6c #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6452
diff changeset
  4206
8d931d8edf6c #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6452
diff changeset
  4207
    "Modified: / 26-10-2018 / 18:22:26 / Claus Gittinger"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4208
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4209
4458
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4210
replace:aCharacter atLine:lineNr col:colNr
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4211
    "replace a single character at lineNr/colNr"
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4212
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4213
    |originalChar|
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4214
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4215
    originalChar := self characterAtLine:lineNr col:colNr.
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4216
    self basicReplace:aCharacter atLine:lineNr col:colNr.
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4217
    self addUndo:(ReplaceCharacters line:lineNr col:colNr character:originalChar info:'replace').
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4218
!
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4219
4713
e8c9caf13e05 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4707
diff changeset
  4220
replace:patternArg by:replacePatternArg all:all ignoreCase:ignoreCase
3430
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  4221
    |pattern replacePattern|
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  4222
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  4223
    pattern := patternArg string.
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  4224
    replacePattern := replacePatternArg string.
4630
b043ca9e5060 class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 4623
diff changeset
  4225
    (pattern notEmpty and:[ replacePattern notEmpty ]) ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4226
        self rememberSearchPattern:pattern.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4227
        self rememberSearchPattern:replacePattern.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4228
        LastSearchIgnoredCase := ignoreCase.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4229
        self
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4230
            undoableDo:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4231
                all ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4232
                    self
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4233
                        replaceString:pattern
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4234
                        to:replacePattern
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4235
                        ignoreCase:ignoreCase
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4236
                ] ifFalse:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4237
                    (self selectionAsString notNil
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4238
                        and:[ self selectionAsString sameAs:pattern caseSensitive:ignoreCase not ])
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4239
                            ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4240
                                self replaceSelectionBy:replacePattern.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4241
                                self
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4242
                                    search:pattern
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4243
                                    ignoreCase:ignoreCase
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4244
                                    forward:(lastSearchDirection = #forward).
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4245
                            ].
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4246
                ]
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4247
            ]
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4248
            info:'Replace'
3430
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  4249
    ]
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  4250
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  4251
    "Created: / 11-07-2006 / 11:19:57 / fm"
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  4252
!
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  4253
477
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  4254
replaceCharAtCursor:aCharacter
5413
b21cbb97c038 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5404
diff changeset
  4255
    "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
  4256
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  4257
    |wasOn|
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  4258
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  4259
    wasOn := self hideCursor.
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  4260
    aCharacter == (Character cr) ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4261
        self cursorReturn
477
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  4262
    ] ifFalse:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4263
        self replace:aCharacter atLine:cursorLine col:cursorCol.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4264
        self cursorRight.
477
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  4265
    ].
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  4266
    self makeCursorVisibleAndShowCursor:wasOn.
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  4267
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  4268
    "Created: 6.3.1996 / 12:27:42 / cg"
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  4269
!
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  4270
4458
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4271
replaceContentsWith:newContents
5413
b21cbb97c038 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5404
diff changeset
  4272
    "undoably replace everything"
4458
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4273
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4274
    |originalContents|
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
    originalContents := self contents.
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4277
    self contents:newContents keepUndoHistory:true.
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4278
    self addUndo:(ReplaceContents text:originalContents info:'replace').
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
2427
43cc7ea39bac more editing stuff (xxx-characterPosition)
Claus Gittinger <cg@exept.de>
parents: 2422
diff changeset
  4281
replaceFromCharacterPosition:charPos1 to:charPos2 with:newString
5413
b21cbb97c038 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5404
diff changeset
  4282
    "undoably replace a substring at a character position"
2427
43cc7ea39bac more editing stuff (xxx-characterPosition)
Claus Gittinger <cg@exept.de>
parents: 2422
diff changeset
  4283
5216
8d6eef5d09c3 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5194
diff changeset
  4284
    "/ 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
  4285
    self insertString:newString atCharacterPosition:charPos1.
43cc7ea39bac more editing stuff (xxx-characterPosition)
Claus Gittinger <cg@exept.de>
parents: 2422
diff changeset
  4286
    self deleteFromCharacterPosition:charPos1+newString size to:charPos2+newString size.
43cc7ea39bac more editing stuff (xxx-characterPosition)
Claus Gittinger <cg@exept.de>
parents: 2422
diff changeset
  4287
!
43cc7ea39bac more editing stuff (xxx-characterPosition)
Claus Gittinger <cg@exept.de>
parents: 2422
diff changeset
  4288
4458
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4289
replaceLine:lineNr with:newText
5413
b21cbb97c038 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5404
diff changeset
  4290
    "undoably replace a line at lineNr"
4458
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4291
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4292
    |originalLine|
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4293
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4294
    originalLine := self listAt:lineNr.
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4295
    originalLine isNil ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4296
        self checkForExistingLine:lineNr
4458
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4297
    ].
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4298
    self list at:lineNr put:newText.
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4299
    self addUndo:(ReplaceLine line:lineNr string:originalLine info:'replace').
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4300
    self invalidateLine:lineNr.
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4301
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4302
    "Modified: / 12-04-2007 / 09:31:33 / cg"
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4303
!
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4304
1564
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  4305
replaceLines:lines withCR:withCr
5413
b21cbb97c038 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5404
diff changeset
  4306
    "undoably a bunch of lines at cursor position. Cursor
1564
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  4307
     is moved behind replacement.
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  4308
     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
  4309
     after the last line"
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  4310
1809
111f603c0a1c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1807
diff changeset
  4311
    |line col nLines wasOn|
1564
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  4312
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  4313
    lines notNil ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4314
        wasOn := self hideCursor.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4315
        nLines := lines size.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4316
        line := cursorLine.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4317
        col := cursorCol.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4318
        lines keysAndValuesDo:[:i :l |
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4319
            self replaceString:(l ? '') atLine:line col:col.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4320
            (i ~~ nLines or:[withCr]) ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4321
                line := line + 1.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4322
                col := 1.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4323
            ] ifFalse:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4324
                col := col + (l size).
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4325
            ]
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4326
        ].
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4327
        self cursorLine:line col:col.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4328
        self makeCursorVisibleAndShowCursor:wasOn.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4329
        "/ wasOn ifTrue:[self showCursor].
1564
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  4330
    ]
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  4331
4661
c029273f7660 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4649
diff changeset
  4332
    "Created: / 18-05-1996 / 15:32:06 / cg"
c029273f7660 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4649
diff changeset
  4333
    "Modified: / 25-07-2013 / 17:00:53 / cg"
1564
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  4334
!
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  4335
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4336
replaceSelectionBy:something
5413
b21cbb97c038 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5404
diff changeset
  4337
    "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
  4338
     leave cursor after insertion"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4339
4666
81e48e442abe class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4664
diff changeset
  4340
    self replaceSelectionBy:something keepCursor:false select:false
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  4341
!
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  4342
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  4343
replaceSelectionBy:something keepCursor:keep
5413
b21cbb97c038 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5404
diff changeset
  4344
    "undoably delete the selection (if any) and insert something, a character or string;
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  4345
     leave cursor after insertion or leave it, depending on keep"
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  4346
4666
81e48e442abe class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4664
diff changeset
  4347
    self replaceSelectionBy:something keepCursor:keep select:false
81e48e442abe class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4664
diff changeset
  4348
81e48e442abe class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4664
diff changeset
  4349
    "Modified: 9.10.1996 / 16:14:35 / cg"
81e48e442abe class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4664
diff changeset
  4350
!
81e48e442abe class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4664
diff changeset
  4351
81e48e442abe class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4664
diff changeset
  4352
replaceSelectionBy:something keepCursor:keep select:selectNewText
5413
b21cbb97c038 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5404
diff changeset
  4353
    "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
  4354
     leave cursor after insertion or leave it, depending on keep.
81e48e442abe class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4664
diff changeset
  4355
     If selectNewText is true, select the new text; otherwise deselect"
81e48e442abe class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4664
diff changeset
  4356
81e48e442abe class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4664
diff changeset
  4357
    |sel l c selStartLine selStartCol|
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  4358
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  4359
    l := cursorLine.
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  4360
    c := cursorCol.
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  4361
4818
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  4362
    sel := self selectionAsString.
4666
81e48e442abe class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4664
diff changeset
  4363
    sel isNil ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4364
        selStartLine := l.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4365
        selStartCol := c.
4666
81e48e442abe class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4664
diff changeset
  4366
    ] ifFalse:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4367
        selStartLine := selectionStartLine.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4368
        selStartCol := selectionStartCol.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4369
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4370
        self setLastStringToReplace: sel.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4371
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4372
        self deleteSelection.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4373
        replacing := true.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4374
        lastReplacementInfo rememberReplacement.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4375
        lastReplacementInfo lastReplacement: ''.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4376
        lastReplacementInfo stillCollectingInput:true.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4377
        undoSupport actionInfo:'replace'.
3161
982c2e416728 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3160
diff changeset
  4378
    ].
982c2e416728 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3160
diff changeset
  4379
982c2e416728 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3160
diff changeset
  4380
    something isCharacter ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4381
        lastReplacementInfo lastReplacement notNil ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4382
            lastReplacementInfo stillCollectingInput ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4383
                lastReplacementInfo lastReplacement: (lastReplacementInfo lastReplacement copyWith:something).
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4384
            ].
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4385
        ].
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4386
        self isInInsertMode ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4387
            self insertCharAtCursor:something
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4388
        ] ifFalse:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4389
            self replaceCharAtCursor:something
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4390
        ]
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  4391
    ] ifFalse:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4392
        something isString ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4393
            lastReplacementInfo lastReplacement: something.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4394
            self isInInsertMode ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4395
                self insertStringAtCursor:something
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4396
            ] ifFalse:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4397
                self replaceStringAtCursor:something
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4398
            ]
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4399
        ] ifFalse:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4400
            Transcript showCR:'EditTextView: non String-or-Character in replace'.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4401
        ].
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  4402
    ].
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  4403
    keep ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4404
        self cursorLine:l col:c
4666
81e48e442abe class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4664
diff changeset
  4405
    ].
81e48e442abe class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4664
diff changeset
  4406
    selectNewText ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4407
        self selectFromLine:selStartLine col:selStartCol toLine:cursorLine col:cursorCol-1
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  4408
    ]
477
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  4409
840
b0071cea13fd fixed Again when spaces are replaced
Claus Gittinger <cg@exept.de>
parents: 828
diff changeset
  4410
    "Modified: 9.10.1996 / 16:14:35 / cg"
1564
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  4411
!
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  4412
4458
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4413
replaceString:aString atLine:lineNr col:colNr
5413
b21cbb97c038 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5404
diff changeset
  4414
    "undoably replace multiple characters starting at lineNr/colNr.
4458
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4415
     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
  4416
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4417
    |originalString|
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4418
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4419
    self checkModificationsAllowed ifFalse:[ ^ self].
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4420
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4421
    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
  4422
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4423
    self basicReplaceString:aString atLine:lineNr col:colNr.
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4424
    self addUndo:(ReplaceCharacters line:lineNr col:colNr characters:originalString info:'replace').
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4425
!
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4426
4713
e8c9caf13e05 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4707
diff changeset
  4427
replaceString:aString to:aNewString ignoreCase:ignoreCase
3549
569d0e4ab5a3 join at cursorposition
Claus Gittinger <cg@exept.de>
parents: 3542
diff changeset
  4428
    |continue count|
569d0e4ab5a3 join at cursorposition
Claus Gittinger <cg@exept.de>
parents: 3542
diff changeset
  4429
569d0e4ab5a3 join at cursorposition
Claus Gittinger <cg@exept.de>
parents: 3542
diff changeset
  4430
    self cursorToTop.
569d0e4ab5a3 join at cursorposition
Claus Gittinger <cg@exept.de>
parents: 3542
diff changeset
  4431
    self selectFromBeginning.
569d0e4ab5a3 join at cursorposition
Claus Gittinger <cg@exept.de>
parents: 3542
diff changeset
  4432
    count := 0.
569d0e4ab5a3 join at cursorposition
Claus Gittinger <cg@exept.de>
parents: 3542
diff changeset
  4433
    continue := true.
569d0e4ab5a3 join at cursorposition
Claus Gittinger <cg@exept.de>
parents: 3542
diff changeset
  4434
    [ continue ] whileTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4435
        (self selectionAsString notNil
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4436
        and:[ self selectionAsString sameAs:aString caseSensitive:ignoreCase not ])
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4437
            ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4438
                self replaceSelectionBy:aNewString.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4439
                count := count + 1.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4440
            ].
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4441
        self
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4442
            searchFwd:aString
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4443
            ignoreCase:ignoreCase
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4444
            ifAbsent:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4445
                Dialog information:('%1 has been replaced by %2 %3 times'
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4446
                                    bindWith:aString with:aNewString with:count).
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4447
                continue := false.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4448
            ].
3549
569d0e4ab5a3 join at cursorposition
Claus Gittinger <cg@exept.de>
parents: 3542
diff changeset
  4449
    ].
3430
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  4450
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  4451
    "Created: / 10-07-2006 / 16:42:48 / fm"
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  4452
!
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  4453
1564
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  4454
replaceStringAtCursor:aString
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  4455
    "replace multiple characters at cursor-position - advance cursor"
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  4456
1566
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  4457
    |wasOn i1 i2|
1564
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  4458
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  4459
    wasOn := self hideCursor.
1566
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  4460
    (aString includes:Character tab) ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4461
        "/ need special care for TAB (to move cursor correctly)
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4462
        i1 := 1.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4463
        [i1 ~~ 0] whileTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4464
            i2 := aString indexOf:Character tab startingAt:i1.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4465
            i2 ~~ 0 ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4466
                i1 ~~ i2 ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4467
                    self replaceString:(aString copyFrom:i1 to:i2-1) atLine:cursorLine col:cursorCol.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4468
                    self cursorCol:(cursorCol + (i2 - i1)).
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4469
                ].
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4470
                self replaceTABAtCursor.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4471
                i2 := i2 + 1.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4472
            ] ifFalse:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4473
                self replaceString:(aString copyFrom:i1) atLine:cursorLine col:cursorCol.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4474
                self cursorCol:(cursorCol + (aString size - i1 + 1)).
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4475
            ].
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4476
            i1 := i2.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4477
        ]
1566
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  4478
    ] ifFalse:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4479
        self replaceString:aString atLine:cursorLine col:cursorCol.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4480
        self setValidatedCursorCol:(cursorCol + aString size).
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4481
        "/ self cursorCol:(cursorCol + aString size).
5325
b3d62a76761c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5283
diff changeset
  4482
    ].
b3d62a76761c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5283
diff changeset
  4483
    wasOn ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4484
        self sensor pushUserEvent:#makeCursorVisibleAndShowCursor: for:self withArguments:{ wasOn }
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4485
        "/ self makeCursorVisibleAndShowCursor:wasOn.
5325
b3d62a76761c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5283
diff changeset
  4486
    ].
1564
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  4487
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  4488
    "Created: / 9.6.1998 / 20:33:20 / cg"
1597
5fdcfcedb91c fixed cursor positioning after replaceStringAtCursor.
Claus Gittinger <cg@exept.de>
parents: 1596
diff changeset
  4489
    "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
  4490
!
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  4491
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  4492
replaceTABAtCursor
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  4493
    "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
  4494
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  4495
    |wasOn nextTab|
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  4496
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  4497
    wasOn := self hideCursor.
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  4498
    nextTab := self nextTabAfter:cursorCol.
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  4499
    self replaceStringAtCursor:(String new:(nextTab - cursorCol)).
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  4500
    self makeCursorVisibleAndShowCursor:wasOn.
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  4501
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  4502
    "Created: / 12.6.1998 / 21:53:23 / cg"
3890
4c5c54cf856b +wrapLines
Claus Gittinger <cg@exept.de>
parents: 3886
diff changeset
  4503
!
4c5c54cf856b +wrapLines
Claus Gittinger <cg@exept.de>
parents: 3886
diff changeset
  4504
4256
1e4bdc48136c added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents: 4253
diff changeset
  4505
selectWordBeforeCursor
1e4bdc48136c added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents: 4253
diff changeset
  4506
    "select the word to the left of cursor"
1e4bdc48136c added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents: 4253
diff changeset
  4507
1e4bdc48136c added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents: 4253
diff changeset
  4508
    |savCursorLine savCursorCol  beginCol beginLine endCol endLine|
1e4bdc48136c added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents: 4253
diff changeset
  4509
1e4bdc48136c added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents: 4253
diff changeset
  4510
    savCursorLine := cursorLine.
1e4bdc48136c added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents: 4253
diff changeset
  4511
    savCursorCol := cursorCol.
1e4bdc48136c added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents: 4253
diff changeset
  4512
1e4bdc48136c added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents: 4253
diff changeset
  4513
    endCol := cursorCol-1.
1e4bdc48136c added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents: 4253
diff changeset
  4514
    endLine := cursorLine.
1e4bdc48136c added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents: 4253
diff changeset
  4515
    self cursorToPreviousWord.
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  4516
    beginCol := cursorCol.
4256
1e4bdc48136c added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents: 4253
diff changeset
  4517
    beginLine := cursorLine.
1e4bdc48136c added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents: 4253
diff changeset
  4518
    self cursorLine:savCursorLine col:savCursorCol.
1e4bdc48136c added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents: 4253
diff changeset
  4519
    self selectFromLine:beginLine col:beginCol toLine:endLine col:endCol.
1e4bdc48136c added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents: 4253
diff changeset
  4520
1e4bdc48136c added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents: 4253
diff changeset
  4521
    "Created: / 14-06-2011 / 14:46:35 / cg"
1e4bdc48136c added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents: 4253
diff changeset
  4522
!
1e4bdc48136c added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents: 4253
diff changeset
  4523
4458
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4524
splitLine:lineNr before:colNr
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4525
    "split the line linNr before colNr; the right part (from colNr)
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4526
     is cut off and inserted after lineNr; the view is redrawn"
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4527
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4528
    self basicSplitLine:lineNr before:colNr.
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4529
    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
  4530
!
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4531
5761
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  4532
toggleTabSetting
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  4533
    "toggle between 4-col
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  4534
     and 8-col tabs"
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  4535
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  4536
    (tabPositions == self class tab4Positions)
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4537
         ifTrue:[self setTab8]
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4538
         ifFalse:[self setTab4]
5761
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  4539
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  4540
    "Created: / 06-06-2016 / 11:02:07 / cg"
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  4541
!
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  4542
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  4543
undentSelectionBy1
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  4544
    "undent selected line-range
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  4545
     by 1 space (i.e. to the left)"
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  4546
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  4547
    self undentBy:1
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  4548
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  4549
    "Created: / 06-06-2016 / 10:49:51 / cg"
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  4550
!
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  4551
5146
3169904851a4 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5145
diff changeset
  4552
withAutoIndent:aBoolean do:aBlock
3169904851a4 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5145
diff changeset
  4553
    |sav|
3169904851a4 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5145
diff changeset
  4554
6614
228cd1c3eac9 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6613
diff changeset
  4555
    sav := self autoIndent.
228cd1c3eac9 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6613
diff changeset
  4556
    self autoIndent:aBoolean.
228cd1c3eac9 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6613
diff changeset
  4557
    aBlock ensure:[ self autoIndent:sav ].
228cd1c3eac9 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6613
diff changeset
  4558
228cd1c3eac9 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6613
diff changeset
  4559
    "Modified: / 26-06-2019 / 23:18:17 / Claus Gittinger"
5146
3169904851a4 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5145
diff changeset
  4560
!
3169904851a4 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5145
diff changeset
  4561
4458
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4562
withoutRedrawAt:lineNr put:aString
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4563
    "replace a line at lineNr"
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4564
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4565
    |originalLine|
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4566
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4567
    originalLine := self listAt:lineNr.
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4568
    self addUndo:(ReplaceLine line:lineNr string:originalLine info:'replace').
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4569
    super withoutRedrawAt:lineNr put:aString.
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4570
!
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4571
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4572
withoutRedrawInsertLine:aString before:lineNr
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4573
    "insert the argument, aString before line lineNr; the string
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4574
     becomes line lineNr; everything else is moved down; the view
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4575
     is not redrawn"
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4576
4771
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  4577
    self basicWithoutRedrawInsertLines:{ aString } from:1 to:1 before:lineNr.
4458
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4578
    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
  4579
!
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4580
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4581
withoutRedrawInsertLines:lines from:start to:end before:lineNr
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4582
    "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
  4583
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4584
    self basicWithoutRedrawInsertLines:lines from:start to:end before:lineNr.
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4585
    self isReadOnly ifFalse:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4586
        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
  4587
    ].
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4588
!
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4589
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4590
withoutRedrawInsertStringWithoutCRs:aString atLine:lineNr col:colNr
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4591
    "insert aString (which has no crs) at lineNr/colNr"
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4592
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4593
    self basicWithoutRedrawInsertStringWithoutCRs:aString atLine:lineNr col:colNr.
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4594
    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
  4595
!
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4596
3890
4c5c54cf856b +wrapLines
Claus Gittinger <cg@exept.de>
parents: 3886
diff changeset
  4597
wrapLines
4c5c54cf856b +wrapLines
Claus Gittinger <cg@exept.de>
parents: 3886
diff changeset
  4598
    "wrap lines (insert line-break)"
4c5c54cf856b +wrapLines
Claus Gittinger <cg@exept.de>
parents: 3886
diff changeset
  4599
4c5c54cf856b +wrapLines
Claus Gittinger <cg@exept.de>
parents: 3886
diff changeset
  4600
    |lineLength answerString string|
4c5c54cf856b +wrapLines
Claus Gittinger <cg@exept.de>
parents: 3886
diff changeset
  4601
4c5c54cf856b +wrapLines
Claus Gittinger <cg@exept.de>
parents: 3886
diff changeset
  4602
    self checkModificationsAllowed ifFalse:[ ^ self].
4c5c54cf856b +wrapLines
Claus Gittinger <cg@exept.de>
parents: 3886
diff changeset
  4603
4c5c54cf856b +wrapLines
Claus Gittinger <cg@exept.de>
parents: 3886
diff changeset
  4604
    self hasSelection ifFalse:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4605
        self selectLine:cursorLine.
3890
4c5c54cf856b +wrapLines
Claus Gittinger <cg@exept.de>
parents: 3886
diff changeset
  4606
    ].
4c5c54cf856b +wrapLines
Claus Gittinger <cg@exept.de>
parents: 3886
diff changeset
  4607
    string := self selectionAsString.
4c5c54cf856b +wrapLines
Claus Gittinger <cg@exept.de>
parents: 3886
diff changeset
  4608
    string isEmptyOrNil ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4609
        Dialog information:(resources string:'Nothing selected.').
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4610
        ^ self.
3890
4c5c54cf856b +wrapLines
Claus Gittinger <cg@exept.de>
parents: 3886
diff changeset
  4611
    ].
4c5c54cf856b +wrapLines
Claus Gittinger <cg@exept.de>
parents: 3886
diff changeset
  4612
4c5c54cf856b +wrapLines
Claus Gittinger <cg@exept.de>
parents: 3886
diff changeset
  4613
    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
  4614
    lineLength := Number readFrom:answerString onError:nil.
4388
558b4dbf5648 changed:
Claus Gittinger <cg@exept.de>
parents: 4373
diff changeset
  4615
    lineLength isNil ifTrue:[^ self].
3890
4c5c54cf856b +wrapLines
Claus Gittinger <cg@exept.de>
parents: 3886
diff changeset
  4616
    lineLength < 1 ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4617
        lineLength := 1.
3890
4c5c54cf856b +wrapLines
Claus Gittinger <cg@exept.de>
parents: 3886
diff changeset
  4618
    ].
4c5c54cf856b +wrapLines
Claus Gittinger <cg@exept.de>
parents: 3886
diff changeset
  4619
4c5c54cf856b +wrapLines
Claus Gittinger <cg@exept.de>
parents: 3886
diff changeset
  4620
    self
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4621
        undoableDo:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4622
            |inStream line col lineLen lastGoodCol lastStartCol word|
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4623
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4624
            line := selectionStartLine.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4625
            col := selectionStartCol.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4626
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4627
            self cutSelection.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4628
            self cursorLine:line col:col.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4629
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4630
            lastGoodCol := col.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4631
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4632
            inStream := string readStream.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4633
            [ inStream atEnd ] whileFalse:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4634
                [inStream atEnd not and:[inStream peek isSeparator]] whileTrue:[ inStream next ].
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4635
                word := CharacterWriteStream new.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4636
                [inStream atEnd not and:[inStream peek isSeparator not]] whileTrue:[ word nextPut:inStream next ].
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4637
                (col + 1 + word size > lineLength) ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4638
                    self insertCharAtCursor:(Character cr).
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4639
                    col := 1.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4640
                ] ifFalse:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4641
                    col ~~ 1 ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4642
                        self insertStringAtCursor:' '.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4643
                        col := col + 1.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4644
                    ]
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4645
               ].
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4646
               self insertStringAtCursor:word contents.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4647
               col := col + word size.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4648
            ].
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4649
        ]
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4650
        info:'Wrap'
4388
558b4dbf5648 changed:
Claus Gittinger <cg@exept.de>
parents: 4373
diff changeset
  4651
558b4dbf5648 changed:
Claus Gittinger <cg@exept.de>
parents: 4373
diff changeset
  4652
    "Modified: / 01-03-2012 / 19:56:22 / cg"
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4653
! !
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4654
2752
5650a9ab5935 method category rename
Claus Gittinger <cg@exept.de>
parents: 2744
diff changeset
  4655
!EditTextView methodsFor:'editing-basic'!
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4656
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4657
basicDeleteCharsAtLine:lineNr fromCol:startCol toCol:endCol
3549
569d0e4ab5a3 join at cursorposition
Claus Gittinger <cg@exept.de>
parents: 3542
diff changeset
  4658
    "delete characters from startCol to endCol in line lineNr"
569d0e4ab5a3 join at cursorposition
Claus Gittinger <cg@exept.de>
parents: 3542
diff changeset
  4659
6232
787d471436e3 #DOCUMENTATION by mawalch
mawalch
parents: 6230
diff changeset
  4660
    |line lineSize newLine start stop
6207
7a5c2914e422 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6203
diff changeset
  4661
     prevWidth newWidth newCol|
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4662
4673
575d2d398823 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4666
diff changeset
  4663
    self unselect.
575d2d398823 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4666
diff changeset
  4664
575d2d398823 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4666
diff changeset
  4665
    cursorLine == lineNr ifTrue:[
5909
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4666
        cursorCol >= startCol ifTrue:[
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4667
            cursorCol >= endCol ifTrue:[
6207
7a5c2914e422 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6203
diff changeset
  4668
                newCol := startCol.
5909
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4669
            ] ifFalse:[
6207
7a5c2914e422 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6203
diff changeset
  4670
                newCol := cursorCol - (endCol - startCol + 1).
5909
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4671
                "/ self assert:(cursorCol >= 0).
6207
7a5c2914e422 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6203
diff changeset
  4672
                newCol := newCol max:1.
7a5c2914e422 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6203
diff changeset
  4673
            ].
7a5c2914e422 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6203
diff changeset
  4674
            self setCursorCol:newCol.
5909
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4675
        ].
4673
575d2d398823 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4666
diff changeset
  4676
    ].
575d2d398823 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4666
diff changeset
  4677
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4678
    line := self listAt:lineNr.
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  4679
4673
575d2d398823 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4666
diff changeset
  4680
    (self checkModificationsAllowed and:[line notNil]) ifFalse:[^ self].
575d2d398823 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4666
diff changeset
  4681
575d2d398823 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4666
diff changeset
  4682
    lineSize := line size.
575d2d398823 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4666
diff changeset
  4683
575d2d398823 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4666
diff changeset
  4684
    startCol == 0 ifFalse:[ start := startCol ] ifTrue:[ start := 1 ].
575d2d398823 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4666
diff changeset
  4685
    endCol > lineSize ifFalse:[ stop  := endCol ] ifTrue:[ stop  := lineSize ].
575d2d398823 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4666
diff changeset
  4686
575d2d398823 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4666
diff changeset
  4687
    stop >= start ifTrue:[
5909
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4688
        start ~~ 1 ifTrue:[ newLine := line copyFrom:1 to:(start-1) ]
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4689
                  ifFalse:[ newLine := '' ].
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4690
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4691
        stop == lineSize ifFalse:[
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4692
            line bitsPerCharacter > newLine bitsPerCharacter ifTrue:[
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4693
                newLine := line string species fromString:newLine.
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4694
            ].
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4695
            newLine := newLine, (line copyFrom:(stop + 1) to:lineSize)
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4696
        ].
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4697
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4698
        (self trimBlankLines and:[newLine isBlank]) ifTrue:[
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4699
            newLine := nil
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4700
        ].
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4701
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4702
        prevWidth := self widthOfLine:lineNr.
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4703
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4704
        self basicListAt:lineNr put:newLine.
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4705
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4706
        (prevWidth = widthOfWidestLine) ifTrue:[
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4707
            "/ remember old width of this line,
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4708
            "/ only clear widthOfWidestLine, if this lines
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4709
            "/ length was (one of) the longest.
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4710
            "/ avoids slow delete with huge texts.
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4711
            widthOfWidestLine := nil.   "i.e. unknown"
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4712
6232
787d471436e3 #DOCUMENTATION by mawalch
mawalch
parents: 6230
diff changeset
  4713
            "/ scroll left if required
5909
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4714
            viewOrigin x > 0 ifTrue:[
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4715
                newWidth := self widthOfLine:lineNr.
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4716
                newWidth < (viewOrigin x + width) ifTrue:[
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4717
                    self scrollHorizontalTo:(newWidth
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4718
                                             - width
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4719
                                             + margin + margin
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4720
                                             + (gc font widthOf:'  '))
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4721
                ]
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4722
            ].
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4723
            self textChanged.
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4724
        ] ifFalse:[
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4725
            self textChanged "/ textChangedButNoSizeChange
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4726
        ].
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4727
        gc font hasOverlappingCharacters ifTrue:[
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4728
            self invalidateLine:lineNr.
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4729
        ] ifFalse:[
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4730
            self redrawLine:lineNr from:start.
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4731
        ].
4673
575d2d398823 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4666
diff changeset
  4732
    ].
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  4733
4191
8ac20ced2fbf changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4190
diff changeset
  4734
    "Modified: / 09-11-2010 / 13:42:45 / cg"
6232
787d471436e3 #DOCUMENTATION by mawalch
mawalch
parents: 6230
diff changeset
  4735
    "Modified (format): / 20-11-2017 / 20:17:55 / mawalch"
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4736
!
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4737
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4738
basicDeleteFromLine:startLineNr toLine:endLineNr
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4739
    "delete some lines"
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4740
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4741
    |wasOn nLines|
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4742
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4743
    self checkModificationsAllowed ifFalse:[ ^ self].
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4744
    list isNil ifTrue:[^ self].
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4745
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4746
    wasOn := self hideCursor.
1717
83203096a851 dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  4747
83203096a851 dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  4748
    "/ isnt this the same as:
83203096a851 dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  4749
    "/ self deleteLinesWithoutRedrawFrom:startLineNr to:endLineNr.
4226
a09775d899a6 changed: #basicDeleteFromLine:toLine:
az
parents: 4225
diff changeset
  4750
    startLineNr <= list size ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4751
        self basicListRemoveFromIndex:startLineNr toIndex:(endLineNr min:list size).
4226
a09775d899a6 changed: #basicDeleteFromLine:toLine:
az
parents: 4225
diff changeset
  4752
    ].
1717
83203096a851 dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  4753
    "/ TODO: remember old maxwidth of linerange,
83203096a851 dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  4754
    "/ only clear widthOfWidestLine, if this max
83203096a851 dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  4755
    "/ length was (one of) the longest.
83203096a851 dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  4756
    "/ avoids slow delete with huge texts.
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4757
    widthOfWidestLine := nil. "/ i.e. unknown
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4758
    self textChanged.
1717
83203096a851 dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  4759
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4760
    self redrawFromLine:startLineNr.
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4761
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4762
    nLines := list size.
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4763
    (firstLineShown >= nLines) ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  4764
        self makeLineVisible:nLines
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4765
    ].
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4766
    wasOn ifTrue:[self showCursor].
1717
83203096a851 dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  4767
4226
a09775d899a6 changed: #basicDeleteFromLine:toLine:
az
parents: 4225
diff changeset
  4768
    "Modified: / 10-11-1998 / 23:55:05 / cg"
a09775d899a6 changed: #basicDeleteFromLine:toLine:
az
parents: 4225
diff changeset
  4769
    "Modified: / 18-03-2011 / 18:26:23 / az"
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4770
!
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4771
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4772
basicDeleteLineWithoutRedraw:lineNr
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4773
    "delete line - no redraw;
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4774
     return true, if something was really deleted"
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4775
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4776
    self checkModificationsAllowed ifFalse:[ ^ false].
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4777
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4778
    (list isNil or:[lineNr > list size]) ifTrue:[^ false].
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4779
    list removeIndex:lineNr.
1717
83203096a851 dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  4780
    "/ TODO: remember old maxwidth of linerange,
83203096a851 dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  4781
    "/ only clear widthOfWidestLine, if this max
83203096a851 dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  4782
    "/ length was (one of) the longest.
83203096a851 dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  4783
    "/ avoids slow delete with huge texts.
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4784
    widthOfWidestLine := nil. "/ i.e. unknown
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4785
    self textChanged.
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4786
    ^ true
1717
83203096a851 dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  4787
83203096a851 dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  4788
    "Modified: / 10.11.1998 / 23:53:24 / cg"
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4789
!
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4790
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4791
basicInsert:aCharacter atLine:lineNr col:colNr
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  4792
    "insert a single character at lineNr/colNr;
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  4793
     set emphasis to character at current position"
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  4794
1929
8e70fb7c9701 fixed handling of italic text when inserting
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  4795
    |line lineSize newLine drawCharacterOnly attribute oldClip x y|
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4796
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4797
    self checkModificationsAllowed ifFalse:[ ^ self].
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4798
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4799
    aCharacter == (Character cr) ifTrue:[
5909
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4800
        self splitLine:lineNr before:colNr.
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4801
        ^ self
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4802
    ].
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  4803
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4804
    drawCharacterOnly := false.
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4805
    self checkForExistingLine:lineNr.
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4806
    line := list at:lineNr.
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4807
    lineSize := line size.
671
f3fe0d8c604d added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents: 666
diff changeset
  4808
3023
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  4809
    self st80EditMode ifFalse:[
5909
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4810
        (self trimBlankLines
6469
8d931d8edf6c #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6452
diff changeset
  4811
        and:[colNr > (lineSize + 1)
5909
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4812
        and:[aCharacter == Character space]]) ifTrue:[
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4813
            ^ self
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4814
        ]
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4815
    ].
671
f3fe0d8c604d added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents: 666
diff changeset
  4816
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4817
    (lineSize == 0) ifTrue:[
5909
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4818
        newLine := aCharacter asString species new:colNr.
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4819
        drawCharacterOnly := true
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4820
    ] ifFalse: [
5909
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4821
        (colNr > lineSize) ifTrue: [
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4822
            colNr == (lineSize +1) ifTrue:[
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4823
                attribute := line emphasisAt:lineSize
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4824
            ].
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4825
            newLine := line species new:colNr.
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4826
            newLine replaceFrom:1 to:lineSize with:line startingAt:1.
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4827
            drawCharacterOnly := true
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4828
        ] ifFalse: [
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4829
            attribute := line emphasisAt:colNr.
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4830
            newLine   := line species new:(lineSize + 1).
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4831
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4832
            newLine replaceFrom:1 to:(colNr - 1) with:line startingAt:1.
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4833
            newLine replaceFrom:(colNr + 1) to:(lineSize + 1) with:line startingAt:colNr
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4834
        ]
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4835
    ].
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  4836
2869
48d830f0aea5 insertCharacter: care for wide chars
Claus Gittinger <cg@exept.de>
parents: 2866
diff changeset
  4837
    aCharacter asString bitsPerCharacter > newLine bitsPerCharacter ifTrue:[
5909
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4838
        newLine := aCharacter asString species fromString:newLine.
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4839
        line isText ifTrue:[
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4840
            newLine := newLine asText
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4841
        ]
2869
48d830f0aea5 insertCharacter: care for wide chars
Claus Gittinger <cg@exept.de>
parents: 2866
diff changeset
  4842
    ].
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4843
    newLine at:colNr put:aCharacter.
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  4844
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  4845
    attribute notNil ifTrue:[
5909
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4846
        newLine emphasisAt:colNr put:attribute.
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  4847
    ].
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  4848
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4849
    aCharacter == (Character tab) ifTrue:[
5909
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4850
        newLine := self withTabsExpanded:newLine.
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4851
        drawCharacterOnly := false
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4852
    ].
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  4853
4771
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  4854
    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
  4855
    widthOfWidestLine notNil ifTrue:[
5909
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4856
        widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:newLine).
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4857
    ].
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4858
    self textChanged.
6399
b3bc4be4a579 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6390
diff changeset
  4859
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4860
    shown ifTrue:[
5909
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4861
        "/ care for italic text - in this case, we must also
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4862
        "/ redraw the character before the insertion in order
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4863
        "/ to fix the slanted piece of the character.
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4864
        "/ (but we must clip, to avoid destoying the character before)
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4865
        (newLine notNil and:[newLine isText]) ifTrue:[
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4866
            colNr > 1 ifTrue:[
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4867
                cursorVisibleLine notNil ifTrue:[
6031
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  4868
                    oldClip := self clippingBoundsOrNil.
5909
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4869
                    x := (self xOfCol:colNr-1 inVisibleLine:cursorVisibleLine) - viewOrigin x.
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4870
                    y := self yOfVisibleLine:cursorVisibleLine.
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4871
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4872
                    gc font hasOverlappingCharacters ifTrue:[
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4873
                        self invalidateLine:lineNr.
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4874
                    ] ifFalse:[
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4875
                        drawCharacterOnly ifTrue:[
6031
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  4876
                            self clippingBounds:(x@y extent:((gc font width * 2) @ fontHeight)).
5909
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4877
                            self redrawLine:lineNr from:colNr-1 to:colNr
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4878
                        ] ifFalse:[
6031
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  4879
                            self clippingBounds:(x@y extent:((width - x) @ fontHeight)).
5909
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4880
                            self redrawLine:lineNr from:colNr-1
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4881
                        ].
6031
01fbf7320331 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6015
diff changeset
  4882
                        self clippingBounds:oldClip.
5909
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4883
                    ].
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4884
                ].
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4885
                ^ self.
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4886
            ].
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4887
        ].
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4888
        gc font hasOverlappingCharacters ifTrue:[
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4889
            self invalidateLine:lineNr.
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4890
        ] ifFalse:[
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4891
            drawCharacterOnly ifTrue:[
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4892
                self redrawLine:lineNr col:colNr
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4893
            ] ifFalse:[
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4894
                self redrawLine:lineNr from:colNr
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4895
            ]
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4896
        ]
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4897
    ]
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4898
4191
8ac20ced2fbf changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4190
diff changeset
  4899
    "Modified: / 09-11-2010 / 13:43:18 / cg"
6469
8d931d8edf6c #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6452
diff changeset
  4900
    "Modified: / 26-10-2018 / 18:18:17 / Claus Gittinger"
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4901
!
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4902
4771
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  4903
basicListAt:lineNr put:newLine
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  4904
    "redefinable for special subclasses (with virtual list)"
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  4905
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  4906
    list at:lineNr put:newLine.
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  4907
!
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  4908
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  4909
basicListRemoveFromIndex:startLineNr toIndex:endLineNr
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  4910
    "redefinable for special subclasses (with virtual list)"
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  4911
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  4912
    list removeFromIndex:startLineNr toIndex:(endLineNr min:list size).
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  4913
!
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  4914
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4915
basicMergeLine:lineNr removeBlanks:removeBlanks
1319
2739903e7a80 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  4916
    "merge line lineNr with line lineNr+1"
2739903e7a80 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  4917
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  4918
    |leftPart rightPart bothParts nextLineNr i|
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  4919
2356
6416beb0f23a backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents: 2350
diff changeset
  4920
    (list notNil and:[(list size) >= lineNr]) ifFalse:[
5909
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4921
        "/ empty list or beyond end of text
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4922
        ^ self
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  4923
    ].
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  4924
    leftPart := self listAt:lineNr.
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  4925
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  4926
    leftPart isNil ifTrue:[
5909
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4927
        leftPart := ''.
6614
228cd1c3eac9 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6613
diff changeset
  4928
        self autoIndent ifTrue:[
6147
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  4929
            "/ cg: only do this, if the second line has no indent
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  4930
            (i := self leftIndentOfLine:(lineNr+1)) == 0 ifTrue:[
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  4931
                leftPart := String new:(self leftIndentForLine:lineNr)
5909
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4932
            ]
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4933
        ]
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  4934
    ].
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  4935
    self cursorLine:lineNr col:((leftPart size) + 1).
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  4936
    nextLineNr := self validateCursorLine:(lineNr + 1).
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  4937
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  4938
    nextLineNr > (list size) ifFalse:[
5909
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4939
        (rightPart := self listAt:nextLineNr) isNil ifTrue:[
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4940
            rightPart := ''
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4941
        ] ifFalse:[
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4942
            removeBlanks ifTrue:[
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4943
                rightPart := rightPart withoutLeadingSeparators.
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4944
            ]
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4945
        ].
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4946
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4947
        bothParts := leftPart , rightPart.
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4948
        (self trimBlankLines and:[bothParts isBlank]) ifTrue:[bothParts := nil].
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4949
        self basicListAt:lineNr put:bothParts.
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4950
        self redrawLine:lineNr.
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4951
        self deleteLine:nextLineNr
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4952
    ]
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4953
6147
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  4954
    "Created: / 09-09-1997 / 09:27:38 / cg"
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  4955
    "Modified: / 25-04-2017 / 12:41:20 / cg"
6614
228cd1c3eac9 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6613
diff changeset
  4956
    "Modified: / 26-06-2019 / 23:19:41 / Claus Gittinger"
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4957
!
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4958
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4959
basicReplace:aCharacter atLine:lineNr col:colNr
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4960
    "replace a single character at lineNr/colNr"
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4961
5045
6197bf1337fe class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4988
diff changeset
  4962
    |line lineSize newLineSpecies newLine drawCharacterOnly|
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4963
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4964
    self checkModificationsAllowed ifFalse:[ ^ self].
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4965
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4966
    aCharacter == (Character cr) ifTrue:[
5909
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4967
        ^ self
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4968
    ].
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4969
1558
abf35cc39757 minimize redraw in overwrite-replace;
Claus Gittinger <cg@exept.de>
parents: 1557
diff changeset
  4970
    drawCharacterOnly := true.
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4971
    self checkForExistingLine:lineNr.
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4972
    line := list at:lineNr.
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4973
    lineSize := line size.
671
f3fe0d8c604d added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents: 666
diff changeset
  4974
5909
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4975
    (self trimBlankLines
6469
8d931d8edf6c #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6452
diff changeset
  4976
    and:[colNr > (lineSize + 1)
671
f3fe0d8c604d added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents: 666
diff changeset
  4977
    and:[aCharacter == Character space]]) ifTrue:[
5909
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4978
        ^ self
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4979
    ].
671
f3fe0d8c604d added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents: 666
diff changeset
  4980
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4981
    (lineSize == 0) ifTrue:[
5909
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4982
        newLine := aCharacter asString species new:colNr.
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4983
    ] ifFalse: [
5909
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4984
        (aCharacter bitsPerCharacter > line bitsPerCharacter) ifTrue:[
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4985
            newLineSpecies := aCharacter stringSpecies
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4986
        ] ifFalse:[
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4987
            newLineSpecies := line species
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4988
        ].
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4989
        newLine := newLineSpecies new:(colNr max:lineSize).
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4990
        newLine replaceFrom:1 to:lineSize with:line startingAt:1.
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4991
    ].
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4992
    newLine at:colNr put:aCharacter.
1558
abf35cc39757 minimize redraw in overwrite-replace;
Claus Gittinger <cg@exept.de>
parents: 1557
diff changeset
  4993
    aCharacter == (Character tab) ifTrue:[
5909
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4994
        newLine := self withTabsExpanded:newLine.
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4995
        drawCharacterOnly := false
1558
abf35cc39757 minimize redraw in overwrite-replace;
Claus Gittinger <cg@exept.de>
parents: 1557
diff changeset
  4996
    ].
4771
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  4997
    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
  4998
    widthOfWidestLine notNil ifTrue:[
5909
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4999
        widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:newLine).
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  5000
    ].
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  5001
    self textChanged.
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  5002
    shown ifTrue:[
5909
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  5003
        gc font hasOverlappingCharacters ifTrue:[
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  5004
            self invalidateLine:lineNr.
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  5005
        ] ifFalse:[
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  5006
            drawCharacterOnly ifTrue:[
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  5007
                self redrawLine:lineNr col:colNr
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  5008
            ] ifFalse:[
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  5009
                self redrawLine:lineNr from:colNr
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  5010
            ]
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  5011
        ]
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  5012
    ]
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  5013
4190
d79217c1317d changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4189
diff changeset
  5014
    "Created: / 06-03-1996 / 12:29:20 / cg"
4191
8ac20ced2fbf changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4190
diff changeset
  5015
    "Modified: / 09-11-2010 / 13:42:54 / cg"
6469
8d931d8edf6c #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6452
diff changeset
  5016
    "Modified: / 26-10-2018 / 18:21:21 / Claus Gittinger"
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  5017
!
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  5018
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  5019
basicReplaceString:aString atLine:lineNr col:colNr
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  5020
    "replace multiple characters starting at lineNr/colNr.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  5021
     This is not prepared to encounter special chars (except TAB)
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  5022
     in the string."
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  5023
5045
6197bf1337fe class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4988
diff changeset
  5024
    |line lineSize newLine newLineSpecies endCol|
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  5025
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  5026
    self checkModificationsAllowed ifFalse:[ ^ self].
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  5027
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  5028
    self checkForExistingLine:lineNr.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  5029
    line := list at:lineNr.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  5030
    lineSize := line size.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  5031
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  5032
    endCol := colNr + aString size - 1.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  5033
    (lineSize == 0) ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  5034
        newLine := aString species new:endCol.
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  5035
    ] ifFalse: [
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  5036
        (aString bitsPerCharacter > line bitsPerCharacter) ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  5037
            newLineSpecies := aString stringSpecies
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  5038
        ] ifFalse:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  5039
            newLineSpecies := line species
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  5040
        ].
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  5041
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  5042
        newLine := newLineSpecies new:(endCol max:lineSize).
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  5043
        newLine replaceFrom:1 to:lineSize with:line startingAt:1.
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  5044
    ].
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  5045
    newLine replaceFrom:colNr with:aString.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  5046
    (aString includes:(Character tab)) ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  5047
        newLine := self withTabsExpanded:newLine.
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  5048
    ].
4771
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  5049
    self basicListAt:lineNr put:(newLine ifNil:[newLine] ifNotNil:[newLine asSingleByteStringIfPossible]).
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  5050
    widthOfWidestLine notNil ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  5051
        widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:newLine).
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  5052
    ].
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  5053
    self textChanged.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  5054
    shown ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  5055
        gc font hasOverlappingCharacters ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  5056
            self invalidateLine:lineNr.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  5057
        ] ifFalse:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  5058
            self redrawLine:lineNr from:colNr
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  5059
        ]
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  5060
    ]
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  5061
4190
d79217c1317d changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4189
diff changeset
  5062
    "Created: / 11-06-1998 / 10:38:32 / cg"
4191
8ac20ced2fbf changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4190
diff changeset
  5063
    "Modified: / 09-11-2010 / 13:42:56 / cg"
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  5064
!
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  5065
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5066
basicSplitLine:lineNr before:colNr
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5067
    "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
  5068
     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
  5069
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  5070
    |line lineSize leftRest rightRest visLine w h mustWait
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5071
     srcY    "{ Class: SmallInteger }" |
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5072
3027
0dd9657b8033 *** empty log message ***
ca
parents: 3024
diff changeset
  5073
    list isNil ifTrue:[ ^ self ].
0dd9657b8033 *** empty log message ***
ca
parents: 3024
diff changeset
  5074
    lineNr > (list size) ifTrue:[ ^ self ].
0dd9657b8033 *** empty log message ***
ca
parents: 3024
diff changeset
  5075
0dd9657b8033 *** empty log message ***
ca
parents: 3024
diff changeset
  5076
    (colNr == 1) ifTrue:[
5909
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  5077
        self nonUndoableDo:[
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  5078
            self insertLine:nil before:lineNr.
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  5079
        ].
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  5080
        ^ self
3027
0dd9657b8033 *** empty log message ***
ca
parents: 3024
diff changeset
  5081
    ].
0dd9657b8033 *** empty log message ***
ca
parents: 3024
diff changeset
  5082
0dd9657b8033 *** empty log message ***
ca
parents: 3024
diff changeset
  5083
    line := list at:lineNr.
4199
cd7069b3bc33 comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents: 4192
diff changeset
  5084
    line notNil ifTrue:[
5909
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  5085
        lineSize := line size.
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  5086
        (colNr <= lineSize) ifTrue:[
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  5087
            rightRest := line copyFrom:colNr to:lineSize.
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  5088
            (colNr > 1) ifTrue:[
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  5089
                leftRest := line copyTo:(colNr - 1)
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  5090
            ]
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  5091
        ] ifFalse:[
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  5092
            leftRest := line
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  5093
        ]
3027
0dd9657b8033 *** empty log message ***
ca
parents: 3024
diff changeset
  5094
    ].
6400
d2e345ce8778 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6399
diff changeset
  5095
    "/ -- debug: self windowGroup sensor hasDamage ifTrue:[self halt].
d2e345ce8778 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6399
diff changeset
  5096
3027
0dd9657b8033 *** empty log message ***
ca
parents: 3024
diff changeset
  5097
    leftRest notNil ifTrue:[
6400
d2e345ce8778 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6399
diff changeset
  5098
        (self trimBlankLines and:[leftRest isBlank]) ifTrue:[leftRest := nil].
d2e345ce8778 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6399
diff changeset
  5099
    ].
d2e345ce8778 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6399
diff changeset
  5100
    leftRest = (self listAt:lineNr) ifFalse:[
d2e345ce8778 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6399
diff changeset
  5101
        self basicListAt:lineNr put:leftRest.
d2e345ce8778 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6399
diff changeset
  5102
    ].
d2e345ce8778 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6399
diff changeset
  5103
    "/ -- debug: (self windowGroup sensor hasDamageFor:self) ifTrue:[self halt].
d2e345ce8778 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6399
diff changeset
  5104
d2e345ce8778 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6399
diff changeset
  5105
    "/ -- debug: TraceDamage := self.
d2e345ce8778 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6399
diff changeset
  5106
3027
0dd9657b8033 *** empty log message ***
ca
parents: 3024
diff changeset
  5107
    self nonUndoableDo:[
5909
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  5108
        self withoutRedrawInsertLine:rightRest before:(lineNr + 1).
3027
0dd9657b8033 *** empty log message ***
ca
parents: 3024
diff changeset
  5109
    ].
6400
d2e345ce8778 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6399
diff changeset
  5110
d2e345ce8778 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6399
diff changeset
  5111
    "/ Delay waitForSeconds:1.
d2e345ce8778 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6399
diff changeset
  5112
    "/ (self windowGroup sensor hasDamageFor:self) ifTrue:[self halt].
d2e345ce8778 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6399
diff changeset
  5113
    "/ TraceDamage := nil.
d2e345ce8778 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6399
diff changeset
  5114
3027
0dd9657b8033 *** empty log message ***
ca
parents: 3024
diff changeset
  5115
    visLine := self listLineToVisibleLine:(lineNr).
0dd9657b8033 *** empty log message ***
ca
parents: 3024
diff changeset
  5116
    visLine notNil ifTrue:[
5909
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  5117
        w := self widthForScrollBetween:lineNr
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  5118
                                    and:(firstLineShown + nLinesShown).
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  5119
        srcY := topMargin + (visLine * fontHeight).
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  5120
        h := ((nLinesShown - visLine - 1) * fontHeight).
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  5121
        (mustWait := (w > 0 and:[h > 0])) ifTrue:[
6306
da16573a2e64 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  5122
            mustWait := self catchExpose.
5909
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  5123
            self
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  5124
                copyFrom:self
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  5125
                x:textStartLeft y:srcY
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  5126
                toX:textStartLeft y:(srcY + fontHeight)
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  5127
                width:w
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  5128
                height:((nLinesShown - visLine - 1) * fontHeight)
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  5129
                async:true.
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  5130
        ].
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  5131
        self redrawLine:lineNr.
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  5132
        self redrawLine:(lineNr + 1).
6400
d2e345ce8778 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6399
diff changeset
  5133
        mustWait ifTrue:[self waitForExpose].
3027
0dd9657b8033 *** empty log message ***
ca
parents: 3024
diff changeset
  5134
    ].
0dd9657b8033 *** empty log message ***
ca
parents: 3024
diff changeset
  5135
    widthOfWidestLine := nil. "/ unknown
0dd9657b8033 *** empty log message ***
ca
parents: 3024
diff changeset
  5136
    self textChanged.
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5137
4199
cd7069b3bc33 comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents: 4192
diff changeset
  5138
    "Modified: / 06-12-2010 / 13:12:55 / cg"
6306
da16573a2e64 #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  5139
    "Modified: / 19-04-2018 / 12:21:52 / stefan"
6400
d2e345ce8778 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6399
diff changeset
  5140
    "Modified: / 22-08-2018 / 12:56:24 / Claus Gittinger"
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5141
!
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5142
2954
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  5143
basicWithoutRedrawInsertLines:lines from:start to:end before:lineNr
4328
ea91d179b5f0 changed:
Claus Gittinger <cg@exept.de>
parents: 4289
diff changeset
  5144
    "insert a bunch of lines before line lineNr; the view is not redrawn.
ea91d179b5f0 changed:
Claus Gittinger <cg@exept.de>
parents: 4289
diff changeset
  5145
     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
  5146
     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
  5147
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  5148
    |newLine newLines nLines|
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  5149
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  5150
    nLines := end - start + 1.
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  5151
    newLines := Array new:(lines size).
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  5152
    start to:end do:[:index |
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  5153
        newLine := lines at:index.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  5154
        newLine notNil ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  5155
            newLine isString ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  5156
                newLine isBlank ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  5157
                    newLine := nil
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  5158
                ] ifFalse:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  5159
                    (newLine includes:(Character tab)) ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  5160
                        newLine := self withTabs:(ListView tab8Positions) expand:newLine
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  5161
                    ]
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  5162
                ]
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  5163
            ]
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  5164
        ].
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  5165
        newLines at:index put:newLine
2954
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  5166
    ].
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  5167
    list isNil ifTrue: [
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  5168
        list := StringCollection new:(lineNr + nLines + 1)
2954
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  5169
    ] ifFalse: [
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  5170
        list grow:((list size + nLines) max:(lineNr + nLines - 1))
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  5171
    ].
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  5172
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  5173
    "I have changed 'replaceFrom:to:with:startingAt:' to correctly handle
2954
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  5174
     overlapping copy - if it didn't, we had to use:"
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  5175
"
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  5176
    index := list size.
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  5177
    [index > lineNr] whileTrue: [
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  5178
        pIndex := index - 1.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  5179
        list at:index put:(list at:pIndex).
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  5180
        index := pIndex
2954
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  5181
    ].
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  5182
"
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  5183
    list replaceFrom:(lineNr + nLines) to:(list size) with:list startingAt:lineNr.
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  5184
    list replaceFrom:lineNr to:(lineNr + nLines - 1) with:newLines startingAt:start.
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  5185
    self contentsChanged
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  5186
4328
ea91d179b5f0 changed:
Claus Gittinger <cg@exept.de>
parents: 4289
diff changeset
  5187
    "Modified: / 07-10-2011 / 15:55:18 / cg"
2954
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  5188
!
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  5189
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  5190
basicWithoutRedrawInsertStringWithoutCRs:aString atLine:lineNr col:colNr
4328
ea91d179b5f0 changed:
Claus Gittinger <cg@exept.de>
parents: 4289
diff changeset
  5191
    "insert aString (which has no crs) at lineNr/colNr.
ea91d179b5f0 changed:
Claus Gittinger <cg@exept.de>
parents: 4289
diff changeset
  5192
     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
  5193
     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
  5194
4360
fe77e479d95a comment/format in:
Claus Gittinger <cg@exept.de>
parents: 4328
diff changeset
  5195
    |isText strLen line lineSize newLine stringType sz lineCharWidth stringCharWidth|
2954
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  5196
4623
22047f737cb0 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4609
diff changeset
  5197
    (aString isNil) ifTrue:[ ^ self].
2954
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  5198
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  5199
    strLen := aString size.
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  5200
    self checkForExistingLine:lineNr.
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  5201
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  5202
    stringType := aString string species.
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  5203
    isText     := aString isText.
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  5204
    line       := list at:lineNr.
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  5205
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  5206
    line notNil ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  5207
        lineSize := line size.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  5208
        line isString ifFalse:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  5209
            stringType := line species
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  5210
        ] ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  5211
            lineCharWidth := line bitsPerCharacter.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  5212
            stringCharWidth := aString bitsPerCharacter.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  5213
            lineCharWidth > stringCharWidth ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  5214
                stringType := line string species
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  5215
            ] ifFalse:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  5216
                stringCharWidth > lineCharWidth ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  5217
                    stringType := aString string species
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  5218
                ]
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  5219
            ].
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  5220
            line isText ifTrue:[ isText := true ]
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  5221
        ].
2954
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  5222
    ] ifFalse:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  5223
        lineSize := 0
2954
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  5224
    ].
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  5225
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  5226
    ((colNr == 1) and:[lineSize == 0]) ifTrue: [
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  5227
        newLine := aString
2954
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  5228
    ] ifFalse:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  5229
        (lineSize == 0 or:[colNr > lineSize]) ifTrue: [
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  5230
            sz := colNr + strLen - 1
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  5231
        ] ifFalse:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  5232
            sz := lineSize + strLen
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  5233
        ].
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  5234
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  5235
        newLine := stringType new:sz.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  5236
        isText ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  5237
            newLine := Text string:newLine
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  5238
        ].
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  5239
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  5240
        (lineSize ~~ 0) ifTrue: [
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  5241
            (colNr > lineSize) ifTrue: [
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  5242
                newLine replaceFrom:1 to:lineSize with:line startingAt:1
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  5243
            ] ifFalse: [
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  5244
                newLine replaceFrom:1 to:(colNr - 1) with:line startingAt:1.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  5245
                newLine replaceFrom:(colNr + strLen) to:(lineSize + strLen) with:line startingAt:colNr
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  5246
            ]
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  5247
        ].
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  5248
        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
  5249
    ].
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  5250
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  5251
    (aString includes:(Character tab)) ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  5252
        newLine := self withTabs:(ListView tab8Positions) expand:newLine
2954
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  5253
    ].
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  5254
4771
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  5255
    self basicListAt:lineNr put:(newLine ifNil:[newLine] ifNotNil:[newLine asSingleByteStringIfPossible]).
2954
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  5256
    widthOfWidestLine notNil ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  5257
        widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:newLine).
2954
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  5258
    ].
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  5259
    self textChanged.
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  5260
4360
fe77e479d95a comment/format in:
Claus Gittinger <cg@exept.de>
parents: 4328
diff changeset
  5261
    "Modified: / 25-01-2012 / 00:37:29 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5262
! !
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5263
2752
5650a9ab5935 method category rename
Claus Gittinger <cg@exept.de>
parents: 2744
diff changeset
  5264
!EditTextView methodsFor:'event handling'!
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5265
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5266
buttonPress:button x:x y:y
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5267
    "hide the cursor when button is activated"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5268
5216
8d6eef5d09c3 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5194
diff changeset
  5269
    hasKeyboardFocus := true.   "/ cg: why is this needed?
2589
62794ae04446 support drop
ca
parents: 2580
diff changeset
  5270
    dragIsActive := false.
62794ae04446 support drop
ca
parents: 2580
diff changeset
  5271
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5272
    completionSupport notNil ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  5273
        "/ also give that guy a chance to close its popup view
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  5274
        completionSupport buttonPress:button x:x y:y
4696
428c8bc44cfb refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents: 4694
diff changeset
  5275
    ].
4609
8b3eb80d04d0 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4595
diff changeset
  5276
1817
1a9e22f755c8 show non-focus cursor when disabled or readOnly
Claus Gittinger <cg@exept.de>
parents: 1816
diff changeset
  5277
    cursorShown ifTrue: [
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  5278
        self drawCursor
5787
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
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5281
    "On X11, be nice and paste PRIMARY when middle click.
4420
8f0164295ef8 changed:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4414
diff changeset
  5282
     Note, that middle button on X11 is translated to button
8f0164295ef8 changed:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4414
diff changeset
  5283
     128 in Smalltalk/X - see XWorkstation class>>initializeConstants"
5643
921578f80870 device access
Claus Gittinger <cg@exept.de>
parents: 5593
diff changeset
  5284
    (button == #paste and:[device platformName == #X11]) ifTrue:[
6313
6bf4e512ddb9 #UI_ENHANCEMENT by stefan
Stefan Vogel <sv@exept.de>
parents: 6310
diff changeset
  5285
        "change the cursor position..."
6bf4e512ddb9 #UI_ENHANCEMENT by stefan
Stefan Vogel <sv@exept.de>
parents: 6310
diff changeset
  5286
        super buttonPress:1 x:x y:y.
6bf4e512ddb9 #UI_ENHANCEMENT by stefan
Stefan Vogel <sv@exept.de>
parents: 6310
diff changeset
  5287
        self buttonRelease:1 x:x y:y.
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  5288
        self undoableDo:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  5289
            self paste: (self getClipboardText:#selection).
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  5290
        ].
6313
6bf4e512ddb9 #UI_ENHANCEMENT by stefan
Stefan Vogel <sv@exept.de>
parents: 6310
diff changeset
  5291
        ^ self.
4420
8f0164295ef8 changed:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4414
diff changeset
  5292
    ].
8f0164295ef8 changed:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4414
diff changeset
  5293
3915
737e276852c8 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3907
diff changeset
  5294
    (button == 1) ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  5295
        self hideCursor
3915
737e276852c8 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3907
diff changeset
  5296
    ].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5297
    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
  5298
4420
8f0164295ef8 changed:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4414
diff changeset
  5299
    "Modified: / 23-03-1999 / 13:51:40 / cg"
8f0164295ef8 changed:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4414
diff changeset
  5300
    "Modified (comment): / 17-04-2012 / 21:02:25 / Jan Vrany <jan.vrany@fit.cvut.cz>"
6313
6bf4e512ddb9 #UI_ENHANCEMENT by stefan
Stefan Vogel <sv@exept.de>
parents: 6310
diff changeset
  5301
    "Modified (format): / 27-04-2018 / 13:35:09 / stefan"
121
claus
parents: 118
diff changeset
  5302
!
claus
parents: 118
diff changeset
  5303
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5304
buttonRelease:button x:x y:y
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5305
    "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
  5306
3789
a9b4805e0754 when clicking on a character, position the cursor on the next
Claus Gittinger <cg@exept.de>
parents: 3788
diff changeset
  5307
    |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
  5308
3915
737e276852c8 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3907
diff changeset
  5309
    (button == 1) ifTrue:[
5882
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5310
        typeOfSelection := nil.
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5311
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5312
        dragIsActive ifTrue:[
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5313
            self unselect
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5314
        ].
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5315
        selectionStartLine isNil ifTrue:[
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5316
            clickCol notNil ifTrue:[
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5317
                self cursorMovementAllowed ifTrue:[
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5318
                    newCursorCol := clickCol.
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5319
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5320
                    cursorType ~~ #block ifTrue:[
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5321
                        clickPos notNil ifTrue:[
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5322
                            "/ we do something special, if the text-cursor's type is not a block-cursor
6096
27f0da22dc30 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 6091
diff changeset
  5323
                            "/ (i.e. if it's an ibeam).
5882
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5324
                            "/ adjust clickCol if the user clicked in the right third of a character.
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5325
                            x1 := self xOfCol:clickCol inVisibleLine:clickLine.
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5326
                            x2 := self xOfCol:clickCol+1 inVisibleLine:clickLine.
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5327
                            x2_3 := x1 + ((x2-x1) * (2/3)).
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5328
                            (clickPos x >= x2_3) ifTrue:[ newCursorCol := clickCol+1 ].
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5329
                        ].
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5330
                    ].
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5331
                    "/ the following fixes the ugly select behavior when double clicking on
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5332
                    "/ a partially visible last line (where the first click used to
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5333
                    "/ scroll the text so that the second click was handled on another
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5334
                    "/ line. An alternative (possibly better) solution would be to
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5335
                    "/ remember the last click position and adjust in the double click
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5336
                    "/ event handling (i.e. subtract the number of scrolled lines in between)
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5337
                    "/ Time will show, if this hack works.
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5338
                    clickLine >= (self lastLineShown -1 ) ifTrue:[
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5339
                        self cursorLine:clickLine col:newCursorCol makeVisible:false.
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5340
                        Processor
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5341
                            addTimedBlock:[self sensor pushUserEvent:#makeCursorVisible for:self]
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5342
                            after:0.3 seconds.
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5343
                    ] ifFalse:[
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5344
                        self cursorLine:clickLine col:newCursorCol.
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5345
                    ].
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5346
                ].
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5347
                true "self hadSelectionBeforeClick not" ifTrue:[
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5348
                    list notEmptyOrNil ifTrue:[
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5349
                        UserPreferences current selectAllWhenClickingBeyondEnd ifTrue:[
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5350
                            (clickLine >= list size) ifTrue:[
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5351
                                (clickLine > (self list size + 2)
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5352
                                or:[ clickCol > (list last size + 5) ]) ifTrue:[
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5353
                                    self selectAll
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5354
                                ].
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5355
                            ].
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5356
                        ]
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5357
                    ]
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5358
                ]
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5359
            ]
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5360
        ] ifFalse:[
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5361
            lastStringFromReplaceForNextSearch := nil.  "new selection invalidates remembered string"
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5362
        ].
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5363
        self showCursor
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5364
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5365
    super buttonRelease:button x:x y:y
1580
d30e562bea15 allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
  5366
4396
7820ce5cac3d changed: #buttonRelease:x:y:
Claus Gittinger <cg@exept.de>
parents: 4394
diff changeset
  5367
    "Modified: / 07-03-2012 / 18:48:37 / cg"
6096
27f0da22dc30 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 6091
diff changeset
  5368
    "Modified (format): / 13-02-2017 / 20:10:18 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5369
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5370
2580
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  5371
cursorKeyPress:key shifted:shifted
4492
088b5fba29d0 changed: #keyPress:x:y:view:
Claus Gittinger <cg@exept.de>
parents: 4484
diff changeset
  5372
    <resource: #keyboard (#CursorRight #CursorDown #CursorUp #CursorDown)>
088b5fba29d0 changed: #keyPress:x:y:view:
Claus Gittinger <cg@exept.de>
parents: 4484
diff changeset
  5373
2730
61a2f1981ac6 Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents: 2725
diff changeset
  5374
    |n|
61a2f1981ac6 Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents: 2725
diff changeset
  5375
2606
6a3ab90d339f redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents: 2599
diff changeset
  5376
    self changeTypeOfSelectionTo:nil.
2580
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  5377
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  5378
    (key == #CursorRight) ifTrue:[
6137
ede94cb05df9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6134
diff changeset
  5379
        (shifted and:[selectionStartLine isNil]) ifTrue:[
ede94cb05df9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6134
diff changeset
  5380
            selectionStartLine := selectionEndLine := clickStartLine := cursorLine.
ede94cb05df9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6134
diff changeset
  5381
            selectionStartCol := selectionEndCol := clickStartCol := cursorCol.
ede94cb05df9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6134
diff changeset
  5382
            expandingTop := false.
ede94cb05df9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6134
diff changeset
  5383
            self validateNewSelection.
ede94cb05df9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6134
diff changeset
  5384
            self setPrimarySelection.
ede94cb05df9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6134
diff changeset
  5385
            self selectionChanged.
ede94cb05df9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6134
diff changeset
  5386
            self redrawLine:selectionStartLine.
ede94cb05df9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6134
diff changeset
  5387
            ^ self.
ede94cb05df9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6134
diff changeset
  5388
        ].
ede94cb05df9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6134
diff changeset
  5389
ede94cb05df9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6134
diff changeset
  5390
        selectionStartLine notNil ifTrue:[
ede94cb05df9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6134
diff changeset
  5391
            self cursorMovementAllowed ifTrue:[
ede94cb05df9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6134
diff changeset
  5392
                "/
ede94cb05df9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6134
diff changeset
  5393
                "/ treat the whole selection as cursor
ede94cb05df9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6134
diff changeset
  5394
                "/
ede94cb05df9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6134
diff changeset
  5395
                self setCursorLine:(selectionEndLine ? selectionStartLine).
ede94cb05df9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6134
diff changeset
  5396
                selectionEndCol == 0 ifTrue:[
ede94cb05df9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6134
diff changeset
  5397
                    selectionEndCol := 1.
ede94cb05df9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6134
diff changeset
  5398
                ].
ede94cb05df9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6134
diff changeset
  5399
                self setCursorCol:selectionEndCol.
ede94cb05df9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6134
diff changeset
  5400
                shifted ifTrue:[
ede94cb05df9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6134
diff changeset
  5401
                    self expandSelectionRight.
ede94cb05df9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6134
diff changeset
  5402
                    ^ self
ede94cb05df9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6134
diff changeset
  5403
                ].
ede94cb05df9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6134
diff changeset
  5404
                self unselect; makeCursorVisible.
ede94cb05df9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6134
diff changeset
  5405
                "/ cursorCol == 1 ifTrue:[^ self].
ede94cb05df9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6134
diff changeset
  5406
            ].
ede94cb05df9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6134
diff changeset
  5407
        ].
ede94cb05df9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6134
diff changeset
  5408
        self cursorRight.
ede94cb05df9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6134
diff changeset
  5409
        ^ self
2580
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  5410
    ].
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  5411
    (key == #CursorDown) ifTrue:[
6137
ede94cb05df9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6134
diff changeset
  5412
        (shifted and:[selectionStartLine isNil]) ifTrue:[
ede94cb05df9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6134
diff changeset
  5413
            selectionStartLine := clickStartLine := cursorLine. selectionEndLine := cursorLine + 1.
ede94cb05df9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6134
diff changeset
  5414
            selectionStartCol := clickStartCol := selectionEndCol := cursorCol.
ede94cb05df9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6134
diff changeset
  5415
            selectionEndCol == 1 ifTrue:[
ede94cb05df9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6134
diff changeset
  5416
                selectionEndCol := 0.
ede94cb05df9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6134
diff changeset
  5417
            ].
ede94cb05df9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6134
diff changeset
  5418
            self validateNewSelection.
ede94cb05df9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6134
diff changeset
  5419
            self selectionChanged.
ede94cb05df9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6134
diff changeset
  5420
            self redrawLine:selectionStartLine.
ede94cb05df9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6134
diff changeset
  5421
            expandingTop := false.
ede94cb05df9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6134
diff changeset
  5422
            self redrawLine:selectionEndLine.
ede94cb05df9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6134
diff changeset
  5423
            ^ self
ede94cb05df9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6134
diff changeset
  5424
        ].
ede94cb05df9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6134
diff changeset
  5425
ede94cb05df9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6134
diff changeset
  5426
        selectionStartLine notNil ifTrue:[
ede94cb05df9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6134
diff changeset
  5427
            self cursorMovementAllowed ifTrue:[
ede94cb05df9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6134
diff changeset
  5428
                "/
ede94cb05df9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6134
diff changeset
  5429
                "/ treat the whole selection as cursor
ede94cb05df9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6134
diff changeset
  5430
                "/
ede94cb05df9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6134
diff changeset
  5431
                self setCursorLine:(selectionEndLine ? selectionStartLine).
ede94cb05df9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6134
diff changeset
  5432
                self setCursorCol:selectionStartCol.
ede94cb05df9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6134
diff changeset
  5433
                (cursorCol == 0 or:[selectionEndCol == 0]) ifTrue:[
ede94cb05df9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6134
diff changeset
  5434
                    self setCursorCol:1.
ede94cb05df9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6134
diff changeset
  5435
                    self setCursorLine:(cursorLine - 1).
ede94cb05df9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6134
diff changeset
  5436
                ].
ede94cb05df9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6134
diff changeset
  5437
                self makeCursorVisible.
ede94cb05df9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6134
diff changeset
  5438
ede94cb05df9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6134
diff changeset
  5439
                shifted ifTrue:[
ede94cb05df9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6134
diff changeset
  5440
                    clickLine := cursorLine.
ede94cb05df9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6134
diff changeset
  5441
                    clickCol := cursorCol.
ede94cb05df9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6134
diff changeset
  5442
                    self expandSelectionDown.
ede94cb05df9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6134
diff changeset
  5443
                    ^ self
ede94cb05df9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6134
diff changeset
  5444
                ].
ede94cb05df9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6134
diff changeset
  5445
                self unselect.
ede94cb05df9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6134
diff changeset
  5446
            ].
ede94cb05df9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6134
diff changeset
  5447
        ].
ede94cb05df9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6134
diff changeset
  5448
ede94cb05df9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6134
diff changeset
  5449
        n := 1 + (self sensor compressKeyPressEventsWithKey:#CursorDown).
ede94cb05df9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6134
diff changeset
  5450
        self cursorDown:n.
ede94cb05df9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6134
diff changeset
  5451
        "/
ede94cb05df9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6134
diff changeset
  5452
        "/ flush keyboard to avoid runaway cursor
ede94cb05df9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6134
diff changeset
  5453
        "/
ede94cb05df9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6134
diff changeset
  5454
        self sensor flushKeyboardFor:self.
ede94cb05df9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6134
diff changeset
  5455
        ^ self
2580
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  5456
    ].
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  5457
    (key == #CursorLeft or:[key == #CursorUp]) ifTrue:[
6137
ede94cb05df9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6134
diff changeset
  5458
        (shifted and:[selectionStartLine isNil]) ifTrue:[
ede94cb05df9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6134
diff changeset
  5459
            expandingTop := true.
ede94cb05df9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6134
diff changeset
  5460
            key == #CursorLeft ifTrue:[
ede94cb05df9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6134
diff changeset
  5461
                cursorCol > 1 ifTrue:[
ede94cb05df9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6134
diff changeset
  5462
                    selectionStartLine := selectionEndLine := clickStartLine := cursorLine.
ede94cb05df9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6134
diff changeset
  5463
                    selectionEndCol := clickStartCol := cursorCol-1.
ede94cb05df9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6134
diff changeset
  5464
                    selectionStartCol := cursorCol-1.
ede94cb05df9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6134
diff changeset
  5465
                    self validateNewSelection.
ede94cb05df9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6134
diff changeset
  5466
                    self selectionChanged.
ede94cb05df9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6134
diff changeset
  5467
                    self redrawLine:selectionStartLine.
ede94cb05df9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6134
diff changeset
  5468
                    ^ self
ede94cb05df9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6134
diff changeset
  5469
                ]
ede94cb05df9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6134
diff changeset
  5470
            ] ifFalse:[
ede94cb05df9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6134
diff changeset
  5471
                cursorLine > 1 ifTrue:[
ede94cb05df9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6134
diff changeset
  5472
                    selectionEndLine := clickStartLine := cursorLine.
ede94cb05df9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6134
diff changeset
  5473
                    selectionEndCol := selectionStartCol := clickStartCol := cursorCol.
ede94cb05df9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6134
diff changeset
  5474
                    selectionStartLine := cursorLine - 1.
ede94cb05df9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6134
diff changeset
  5475
                    selectionEndCol == 1 ifTrue:[
ede94cb05df9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6134
diff changeset
  5476
                        selectionEndCol := 0.
ede94cb05df9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6134
diff changeset
  5477
                    ].
ede94cb05df9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6134
diff changeset
  5478
                    self validateNewSelection.
ede94cb05df9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6134
diff changeset
  5479
                    self selectionChanged.
ede94cb05df9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6134
diff changeset
  5480
                    self redrawFromLine:selectionStartLine to:cursorLine.
ede94cb05df9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6134
diff changeset
  5481
                    ^ self
ede94cb05df9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6134
diff changeset
  5482
                ]
ede94cb05df9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6134
diff changeset
  5483
            ]
ede94cb05df9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6134
diff changeset
  5484
        ].
ede94cb05df9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6134
diff changeset
  5485
ede94cb05df9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6134
diff changeset
  5486
        selectionStartLine notNil ifTrue:[
ede94cb05df9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6134
diff changeset
  5487
            self cursorMovementAllowed ifTrue:[
ede94cb05df9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6134
diff changeset
  5488
                "/
ede94cb05df9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6134
diff changeset
  5489
                "/ treat the whole selection as cursor
ede94cb05df9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6134
diff changeset
  5490
                "/
ede94cb05df9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6134
diff changeset
  5491
                self setCursorLine:selectionStartLine.
ede94cb05df9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6134
diff changeset
  5492
                self setCursorCol:selectionStartCol.
ede94cb05df9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6134
diff changeset
  5493
                (key == #CursorLeft) ifTrue:[
ede94cb05df9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6134
diff changeset
  5494
                    self setCursorCol:(cursorCol+1).  "/ compensate for followup crsr-left
ede94cb05df9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6134
diff changeset
  5495
                ].
ede94cb05df9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6134
diff changeset
  5496
                self makeCursorVisible.
ede94cb05df9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6134
diff changeset
  5497
ede94cb05df9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6134
diff changeset
  5498
                shifted ifTrue:[
ede94cb05df9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6134
diff changeset
  5499
                    (key == #CursorUp) ifTrue:[
ede94cb05df9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6134
diff changeset
  5500
                        clickLine := cursorLine.
ede94cb05df9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6134
diff changeset
  5501
                        self expandSelectionUp.
ede94cb05df9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6134
diff changeset
  5502
                    ] ifFalse:[
ede94cb05df9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6134
diff changeset
  5503
                        self expandSelectionLeft.
ede94cb05df9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6134
diff changeset
  5504
                    ].
ede94cb05df9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6134
diff changeset
  5505
                    ^ self
ede94cb05df9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6134
diff changeset
  5506
                ].
ede94cb05df9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6134
diff changeset
  5507
                self unselect.
ede94cb05df9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6134
diff changeset
  5508
            ].
ede94cb05df9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6134
diff changeset
  5509
        ].
ede94cb05df9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6134
diff changeset
  5510
        (key == #CursorLeft) ifTrue:[
ede94cb05df9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6134
diff changeset
  5511
            self cursorLeft. ^self
ede94cb05df9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6134
diff changeset
  5512
        ].
ede94cb05df9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6134
diff changeset
  5513
        (key == #CursorUp)        ifTrue:[
ede94cb05df9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6134
diff changeset
  5514
            n := 1 + (self sensor compressKeyPressEventsWithKey:#CursorUp).
ede94cb05df9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6134
diff changeset
  5515
            self cursorUp:n.
ede94cb05df9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6134
diff changeset
  5516
            "/
ede94cb05df9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6134
diff changeset
  5517
            "/ flush keyboard to avoid runaway cursor
ede94cb05df9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6134
diff changeset
  5518
            "/
ede94cb05df9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6134
diff changeset
  5519
            self sensor flushKeyboardFor:self.
ede94cb05df9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6134
diff changeset
  5520
            ^ self
ede94cb05df9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6134
diff changeset
  5521
        ].
2580
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  5522
    ].
4420
8f0164295ef8 changed:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4414
diff changeset
  5523
8f0164295ef8 changed:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4414
diff changeset
  5524
    "Modified: / 17-04-2012 / 21:01:15 / Jan Vrany <jan.vrany@fit.cvut.cz>"
6137
ede94cb05df9 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6134
diff changeset
  5525
    "Modified: / 19-03-2017 / 10:08:54 / cg"
2580
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  5526
!
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  5527
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5528
doKeyPress:key x:x y:y
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5529
    "handle keyboard input"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5530
4521
0b6740e2d1a7 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4494
diff changeset
  5531
    <resource: #keyboard (#Paste #Insert #PasteFromHistory #Cut #Again #AgainForAll
6147
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5532
                          #Replace #Undo #Redo #Accept
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5533
                          #Delete #BasicDelete #BackSpace #BasicBackspace
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5534
                          #DeleteSpaces #Join
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5535
                          #SearchMatchingParent #SelectMatchingParents
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5536
                          #SelectWord #ExpandSelectionByWord
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5537
                          #SelectToEnd #SelectFromBeginning
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5538
                          #SelectLine #ExpandSelectionByLine
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5539
                          #BeginOfLine #EndOfLine #NextWord #PreviousWord
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5540
                          #CursorRight #CursorDown #CursorLeft #CursorUp
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5541
                          #Return #Tab #BackTab #NonInsertingTab #Escape
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5542
                          #GotoLine #BeginOfText #EndOfText
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5543
                          #InsertLine #DeleteLine
6354
3fcb3ef259c1 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6339
diff changeset
  5544
                          #SelectLineFromBeginning #SelectToLineEnd
6147
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5545
                          #LearnKeyboardMacro #ExecuteKeyboardMacro #ToggleInsertMode
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5546
                          #OpenSpecialCharacterWindow #InsertUUID
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5547
                          #'F*' #'f*')>
2017
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  5548
6610
7cb4e0787a81 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6609
diff changeset
  5549
    |fKeyMacros shiftPressed ctrlPressed event macroName
5119
1ba5fb52a0e3 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5114
diff changeset
  5550
     immediateCompletion currentUserPrefs rawKey|
4818
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  5551
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  5552
    currentUserPrefs := UserPreferences current.
2184
fb634dc3e606 learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents: 2157
diff changeset
  5553
4701
fc3e667bcc01 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4700
diff changeset
  5554
    "/ experimental
4818
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  5555
    immediateCompletion := currentUserPrefs immediateCodeCompletion.
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5556
    (immediateCompletion
4818
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  5557
    or:[currentUserPrefs codeCompletionOnControlKey
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  5558
    or:[currentUserPrefs codeCompletionOnTabKey]]) ifTrue:[
6147
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5559
        completionSupport isNil ifTrue:[
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5560
            self initializeCompletionSupport.
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5561
        ].
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5562
    ].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  5563
4801
69a5bff7b5cd Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4786
diff changeset
  5564
    "/ JV: why setting it to nil here?
69a5bff7b5cd Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4786
diff changeset
  5565
"/    ifFalse:[
69a5bff7b5cd Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4786
diff changeset
  5566
"/        completionService := nil
69a5bff7b5cd Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4786
diff changeset
  5567
"/    ].
69a5bff7b5cd Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4786
diff changeset
  5568
    completionSupport notNil ifTrue:[
6147
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5569
        completionSupport stopCompletionProcess.
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5570
        (completionSupport handleKeyPress:key x:x y:y) ifTrue:["eaten" ^ self].
4696
428c8bc44cfb refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents: 4694
diff changeset
  5571
    ].
428c8bc44cfb refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents: 4694
diff changeset
  5572
4818
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  5573
    key isSymbol ifTrue:[
6147
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5574
        (device modifierKeys includes:key) ifFalse:[
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5575
            lastReplacementInfo stillCollectingInput:false.
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5576
        ]
4818
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  5577
    ].
3793
5a6074a257c1 learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents: 3790
diff changeset
  5578
    (key == #LearnKeyboardMacro) ifTrue:[
6147
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5579
        lastReplacementInfo stillCollectingInput:false.
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5580
        self toggleLearnMode.
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5581
        ^ self
3793
5a6074a257c1 learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents: 3790
diff changeset
  5582
    ].
5a6074a257c1 learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents: 3790
diff changeset
  5583
    (key == #ExecuteKeyboardMacro) ifTrue:[
6147
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5584
        lastReplacementInfo stillCollectingInput:false.
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5585
        self executeLearnedKeyboardMacro.
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5586
        ^ self.
3793
5a6074a257c1 learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents: 3790
diff changeset
  5587
    ].
3799
f6cbe8d860d5 code formatting
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  5588
    (key == #Undo) ifTrue:[self undo. ^self].
f6cbe8d860d5 code formatting
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  5589
    (key == #Redo) ifTrue:[self redo. ^self].
f6cbe8d860d5 code formatting
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  5590
3793
5a6074a257c1 learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents: 3790
diff changeset
  5591
    self learnMode ifTrue:[
6390
55eb1d87a43f #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 6374
diff changeset
  5592
        event := WindowGroup lastEvent.
6147
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5593
        learnedMacro add:event.
3793
5a6074a257c1 learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents: 3790
diff changeset
  5594
    ].
5a6074a257c1 learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents: 3790
diff changeset
  5595
4238
5f7125996b44 changed:
Stefan Vogel <sv@exept.de>
parents: 4237
diff changeset
  5596
    (self executekeyboardMacroNamed:key) ifTrue:[
6147
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5597
        "the macro named key exists"
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5598
        ^ self
2416
56acdd9e31b5 lifted mkeyboardMacro handling from Workspace to EditTextView
Claus Gittinger <cg@exept.de>
parents: 2406
diff changeset
  5599
    ].
56acdd9e31b5 lifted mkeyboardMacro handling from Workspace to EditTextView
Claus Gittinger <cg@exept.de>
parents: 2406
diff changeset
  5600
4482
0530a2d95b4b class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 4481
diff changeset
  5601
    key isSymbol ifFalse:[
6147
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5602
        "the usual case: key is a character, but maybe a string also (in X11)"
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5603
        self handleNonCommandKey:key.
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5604
        ^ self
4482
0530a2d95b4b class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 4481
diff changeset
  5605
    ].
0530a2d95b4b class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 4481
diff changeset
  5606
0530a2d95b4b class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 4481
diff changeset
  5607
    event isNil ifTrue:[
6390
55eb1d87a43f #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 6374
diff changeset
  5608
        event := WindowGroup lastEvent.
4482
0530a2d95b4b class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 4481
diff changeset
  5609
    ].
0530a2d95b4b class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 4481
diff changeset
  5610
    shiftPressed := event hasShift.
0530a2d95b4b class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 4481
diff changeset
  5611
    ctrlPressed := event hasCtrl and:[(event rawKey asString startsWith:'Ctrl') not].
5119
1ba5fb52a0e3 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5114
diff changeset
  5612
    rawKey := event rawKey.
4482
0530a2d95b4b class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 4481
diff changeset
  5613
5133
9d9d9845258f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5119
diff changeset
  5614
    key == #InsertUUID ifTrue:[
6147
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5615
        self insertUUID.
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5616
        ^ self.
5133
9d9d9845258f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5119
diff changeset
  5617
    ].
9d9d9845258f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5119
diff changeset
  5618
4253
adea55ecdb57 changed: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents: 4249
diff changeset
  5619
    (key == #DeleteWordBeforeCursor) ifTrue:[
6147
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5620
        self deleteWordBeforeCursor.
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5621
        ^ self.
4253
adea55ecdb57 changed: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents: 4249
diff changeset
  5622
    ].
adea55ecdb57 changed: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents: 4249
diff changeset
  5623
5119
1ba5fb52a0e3 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5114
diff changeset
  5624
    (rawKey == #BackSpace or:[key == #BasicBackspace]) ifTrue:[
6147
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5625
        selectionStartLine notNil ifTrue:[
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5626
            ((key == #BasicBackspace)
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5627
            or:[ currentUserPrefs deleteSetsClipboardText not ])
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5628
            ifTrue:[
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5629
                self deleteSelection.
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5630
            ] ifFalse: [
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5631
                self copyAndDeleteSelection.
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5632
            ].
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5633
        ] ifFalse:[
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5634
            self makeCursorVisible.
4609
8b3eb80d04d0 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4595
diff changeset
  5635
"/          (shiftPressed and:[ ctrlPressed ]) ifTrue:[
8b3eb80d04d0 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4595
diff changeset
  5636
"/            self deleteWordBeforeCursor.
8b3eb80d04d0 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4595
diff changeset
  5637
"/          ] ifFalse:[
6147
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5638
            self deleteCharBeforeCursor.
6399
b3bc4be4a579 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6390
diff changeset
  5639
b3bc4be4a579 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6390
diff changeset
  5640
            self maybeShowMatchingParenthesisFor:(self characterBeforeCursor).
b3bc4be4a579 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6390
diff changeset
  5641
4609
8b3eb80d04d0 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4595
diff changeset
  5642
"/          ].
6147
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5643
        ].
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5644
        true "immediateCompletion" ifTrue:[
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5645
            completionSupport notNil ifTrue:[
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5646
                completionSupport postKeyPress:key
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5647
            ].
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5648
        ].
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5649
        ^ self
2205
230cf9cef6c3 searchPatter, if from selection (escape meta characters)
Claus Gittinger <cg@exept.de>
parents: 2196
diff changeset
  5650
    ].
2184
fb634dc3e606 learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents: 2157
diff changeset
  5651
3782
79ae5dad28d4 Ctrl-Insert to toggle insert mode.
Claus Gittinger <cg@exept.de>
parents: 3781
diff changeset
  5652
    (key == #ToggleAutoIndent) ifTrue:[
6614
228cd1c3eac9 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6613
diff changeset
  5653
        self autoIndent:(self autoIndent not).
6147
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5654
        ^ self.
3782
79ae5dad28d4 Ctrl-Insert to toggle insert mode.
Claus Gittinger <cg@exept.de>
parents: 3781
diff changeset
  5655
    ].
79ae5dad28d4 Ctrl-Insert to toggle insert mode.
Claus Gittinger <cg@exept.de>
parents: 3781
diff changeset
  5656
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  5657
    key == #ToggleInsertMode ifTrue:[
6147
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5658
        self insertMode:(editMode value == EditMode insertMode) not.
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5659
        ^ self.
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  5660
    ].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5661
4162
9c80c8f4ba45 changed:
Claus Gittinger <cg@exept.de>
parents: 4143
diff changeset
  5662
    key == #OpenSpecialCharacterWindow ifTrue:[
6147
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5663
        CharacterSetView notNil ifTrue:[
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5664
            self specialCharacters.
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5665
            ^ self.
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5666
        ]
4162
9c80c8f4ba45 changed:
Claus Gittinger <cg@exept.de>
parents: 4143
diff changeset
  5667
    ].
9c80c8f4ba45 changed:
Claus Gittinger <cg@exept.de>
parents: 4143
diff changeset
  5668
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5669
    replacing := false.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5670
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5671
    "
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5672
     Fn      pastes a key-sequence (but only if not overlayed with
6147
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5673
             another function in the keyboard map)
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5674
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5675
     see TextView>>:x:y
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5676
    "
1177
9d23e1241404 avoid match: if possible (to not clobber the previous matchString)
Claus Gittinger <cg@exept.de>
parents: 1108
diff changeset
  5677
    (key at:1) asLowercase == $f ifTrue:[
6147
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5678
        (('[fF][0-9]' match:key)
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5679
        or:['[fF][0-9][0-9]' match:key]) ifTrue:[
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5680
            shiftPressed ifFalse:[
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5681
                fKeyMacros := currentUserPrefs functionKeySequences.
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5682
                fKeyMacros notNil ifTrue:[
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5683
                    (fKeyMacros includesKey:key) ifTrue:[
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5684
                        self pasteOrReplace:(fKeyMacros at:key) asStringCollection.
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5685
                        ^ self
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5686
                    ]
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5687
                ]
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5688
            ]
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5689
        ].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5690
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5691
2506
5568d67dbddd Ctrl-8 / Ctrl-9,
Claus Gittinger <cg@exept.de>
parents: 2505
diff changeset
  5692
    (key == #'Ctrl8' or:[key == #'Ctrl9']) ifTrue:[
6147
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5693
        self parenthizeSelectionWith:$( and:$).
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5694
        ^ self.
2506
5568d67dbddd Ctrl-8 / Ctrl-9,
Claus Gittinger <cg@exept.de>
parents: 2505
diff changeset
  5695
    ].
5568d67dbddd Ctrl-8 / Ctrl-9,
Claus Gittinger <cg@exept.de>
parents: 2505
diff changeset
  5696
    (key == #'Ctrl2') ifTrue:[
6147
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5697
        self parenthizeSelectionWith:$" and:$".
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5698
        ^ self.
2506
5568d67dbddd Ctrl-8 / Ctrl-9,
Claus Gittinger <cg@exept.de>
parents: 2505
diff changeset
  5699
    ].
5568d67dbddd Ctrl-8 / Ctrl-9,
Claus Gittinger <cg@exept.de>
parents: 2505
diff changeset
  5700
    (key == #'Ctrl#') ifTrue:[
6147
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5701
        self parenthizeSelectionWith:$' and:$'.
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5702
        ^ self.
2505
9204d5313979 Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents: 2491
diff changeset
  5703
    ].
4286
83ef1d9faf6d added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents: 4285
diff changeset
  5704
    (key == #'ConvertSelectionToLowercaseOrUppercaseOrUppercaseFirst') ifTrue:[
6147
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5705
        self convertSelectionToLowercaseOrUppercaseOrUppercaseFirst.
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5706
        ^ self.
4286
83ef1d9faf6d added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents: 4285
diff changeset
  5707
    ].
2505
9204d5313979 Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents: 2491
diff changeset
  5708
274
6df4bb990f04 handle accept where acceptAction is define (this was a historic leftover)
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
  5709
    (key == #Accept)  ifTrue:[^ self accept].
5387
b94d35da3ad6 class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 5371
diff changeset
  5710
    (key == #PasteFromHistory) ifTrue:[self pasteOrReplaceFromHistory. ^self].
b94d35da3ad6 class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 5371
diff changeset
  5711
    (key == #Paste or:[key == #Insert]) ifTrue:[self pasteOrReplaceByKeyPress. ^self].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5712
    (key == #Cut) ifTrue:[self cut. ^self].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5713
    (key == #Again) ifTrue:[self again. ^self].
3781
36268d8303d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3780
diff changeset
  5714
    (key == #AgainForAll) ifTrue:[self multipleAgain. ^self].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5715
3542
30ed44ed0178 +joinLines (CTRL-j);
Claus Gittinger <cg@exept.de>
parents: 3517
diff changeset
  5716
    (key == #Join) ifTrue:[self joinLines. ^self].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5717
    (key == #Replace) ifTrue:[self replace. ^self].
4707
f6ac835a1cf6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4701
diff changeset
  5718
    (key == #ExpandSelectionByWord) ifTrue:[
6147
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5719
        self makeCursorVisible.
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5720
        self findNextWordAfterSelectionAndAddToSelection.
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5721
        ^ self
4707
f6ac835a1cf6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4701
diff changeset
  5722
    ].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5723
    (key == #SelectWord) ifTrue:[
6147
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5724
        self makeCursorVisible.
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5725
        self selectWordUnderCursor.
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5726
        ^ self
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5727
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5728
2505
9204d5313979 Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents: 2491
diff changeset
  5729
    (key == #SearchMatchingParent) ifTrue:[self searchForMatchingParenthesis. ^ self].
9204d5313979 Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents: 2491
diff changeset
  5730
    (key == #SelectMatchingParents) ifTrue:[self searchForAndSelectMatchingParenthesis. ^ self].
9204d5313979 Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents: 2491
diff changeset
  5731
    (key == #SelectToEnd) ifTrue:[self selectUpToEnd. ^ self].
9204d5313979 Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents: 2491
diff changeset
  5732
    (key == #SelectFromBeginning) ifTrue:[self selectFromBeginning. ^ self].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5733
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5734
" disabled - nobody liked it ...
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5735
  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
  5736
1304
173d00c195f9 flush pending keyboard events in cursor-up/down
Claus Gittinger <cg@exept.de>
parents: 1300
diff changeset
  5737
    (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
  5738
    (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
  5739
    (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
  5740
    (key == #Ctrlp) ifTrue:[self unselect. self cursorUp. ^ self].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5741
"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5742
1675
b1cba2341f95 EndOfLine / BeginOfLine unselect first.
Claus Gittinger <cg@exept.de>
parents: 1601
diff changeset
  5743
    (key == #BeginOfLine) ifTrue:[
6147
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5744
        "/ cg: this is complete rubbish - you have to define a mapping from
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5745
        "/ some shifted key to selectFromBeginOfLine
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5746
        "/ (otherwise, no shifted key could ever be mapped to BegnOfLine)
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5747
        "/ see code below.
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5748
        false "shiftPressed" ifTrue: [
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5749
            "/ "Original St/X code - now use Ctrl modifier"
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5750
            "/ self unselect.
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5751
            "/ self cursorHome.
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5752
            "Jan's modification"
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5753
            "/ self addToSelectionAfter:[ self cursorToBeginOfLine ].
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5754
            "/ Jan's modification modified by his own request ;-))
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5755
            self selectFromBeginOfLine.
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5756
        ] ifFalse: [
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5757
            self unselect.
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5758
            ctrlPressed ifTrue:[
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5759
                self cursorHome.
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5760
            ] ifFalse:[
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5761
                self cursorToBeginOfLine.
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5762
            ]
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5763
        ].
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5764
        ^ self
1675
b1cba2341f95 EndOfLine / BeginOfLine unselect first.
Claus Gittinger <cg@exept.de>
parents: 1601
diff changeset
  5765
    ].
5226
9194ed3bb118 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5216
diff changeset
  5766
    (key == #BSelectFromeginOfLine) ifTrue:[
6147
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5767
        self selectFromBeginOfLine.
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5768
        ^ self
5226
9194ed3bb118 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5216
diff changeset
  5769
    ].
9194ed3bb118 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5216
diff changeset
  5770
1675
b1cba2341f95 EndOfLine / BeginOfLine unselect first.
Claus Gittinger <cg@exept.de>
parents: 1601
diff changeset
  5771
    (key == #EndOfLine) ifTrue:[
6147
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5772
        "/ cg: this is complete rubbish - you have to define a mapping from
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5773
        "/ some shifted key to selectFromBeginOfLine
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5774
        "/ (otherwise, no shifted key could ever be mapped to BegnOfLine)
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5775
        "/ see code below.
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5776
        false "shiftPressed" ifTrue:[
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5777
            "/ "Original St/X code - now use Ctrl modifier"
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5778
            "/ self unselect.
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5779
            "/ self cursorToBottom
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5780
            " Jan's modification"
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5781
            "/ self addToSelectionAfter:[ self cursorToEndOfLine ] .
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5782
            "/ Jan's modification modified by his own request ;-))
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5783
            self selectToEndOfLine.
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5784
        ] ifFalse:[
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5785
            self unselect.
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5786
            ctrlPressed ifTrue:[
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5787
                self cursorToBottom
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5788
            ] ifFalse:[
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5789
                self cursorToEndOfLine.
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5790
            ]
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5791
        ].
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5792
        ^ self
1675
b1cba2341f95 EndOfLine / BeginOfLine unselect first.
Claus Gittinger <cg@exept.de>
parents: 1601
diff changeset
  5793
    ].
5226
9194ed3bb118 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5216
diff changeset
  5794
9194ed3bb118 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5216
diff changeset
  5795
    (key == #SelectToEndOfLine) ifTrue:[
6147
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5796
        self selectToEndOfLine.
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5797
        ^ self
5226
9194ed3bb118 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5216
diff changeset
  5798
    ].
9194ed3bb118 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5216
diff changeset
  5799
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5800
    (key == #NextWord) ifTrue:[self cursorToNextWord. ^self].
3310
83368f9014a1 word check
Claus Gittinger <cg@exept.de>
parents: 3303
diff changeset
  5801
    (key == #EndOfWord) ifTrue:[self cursorToEndOfWord. ^self].
499
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
  5802
    (key == #PreviousWord) ifTrue:[self cursorToPreviousWord. ^self].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5803
    (key == #GotoLine) ifTrue:[self gotoLine. ^self].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5804
5119
1ba5fb52a0e3 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5114
diff changeset
  5805
    (rawKey == #CursorRight
1ba5fb52a0e3 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5114
diff changeset
  5806
    or:[rawKey == #CursorDown
1ba5fb52a0e3 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5114
diff changeset
  5807
    or:[rawKey == #CursorLeft
1ba5fb52a0e3 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5114
diff changeset
  5808
    or:[rawKey == #CursorUp]]]) ifTrue:[
6147
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5809
        self cursorKeyPress:rawKey shifted:shiftPressed.
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5810
        ^ self.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5811
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5812
5119
1ba5fb52a0e3 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5114
diff changeset
  5813
    (key == #ShiftReturn or:[key == #NonInsertingReturn]) ifTrue:[
6147
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5814
        self unselect. self cursorReturn.
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5815
        ^ self
3257
628e1e05814d shift-Tab fix.
Claus Gittinger <cg@exept.de>
parents: 3252
diff changeset
  5816
    ].
628e1e05814d shift-Tab fix.
Claus Gittinger <cg@exept.de>
parents: 3252
diff changeset
  5817
628e1e05814d shift-Tab fix.
Claus Gittinger <cg@exept.de>
parents: 3252
diff changeset
  5818
    (key == #Return) ifTrue:[
6147
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5819
        shiftPressed ifTrue:[
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5820
            self unselect. self cursorReturn.
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5821
            ^ self
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5822
        ].
6610
7cb4e0787a81 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6609
diff changeset
  5823
        self handleReturnPressed.
6147
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5824
        ^ self
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5825
    ].
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
  5826
2819
a7a41dfb9df7 BackTab / NonInsertingTab modifiers now defined in keyboard.rc
ca
parents: 2817
diff changeset
  5827
    (key == #NonInsertingTab) ifTrue:[
6150
fd1642c99acb #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6147
diff changeset
  5828
        ((rawKey == #ShiftTab)
fd1642c99acb #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6147
diff changeset
  5829
          and:[self hasSelection
fd1642c99acb #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6147
diff changeset
  5830
          and:[selectStyle == #line]]
fd1642c99acb #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6147
diff changeset
  5831
        ) ifTrue:[
fd1642c99acb #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6147
diff changeset
  5832
            self executekeyboardMacroNamed:#UndentBy4.
fd1642c99acb #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6147
diff changeset
  5833
            ^ self.
fd1642c99acb #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6147
diff changeset
  5834
        ].
6147
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5835
        self unselect. self cursorTab.
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5836
        ^ self
2819
a7a41dfb9df7 BackTab / NonInsertingTab modifiers now defined in keyboard.rc
ca
parents: 2817
diff changeset
  5837
    ].
3422
a0c68e8bd56e tab with line selection means: indent/undent
Claus Gittinger <cg@exept.de>
parents: 3416
diff changeset
  5838
    ((key == #BackTab) or:[(key == #Tab)]) ifTrue:[
6147
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5839
        self tabMeansNextField ifTrue:[^ super keyPress:key x:x y:y].
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5840
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5841
        self hasSelection ifTrue:[
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5842
            selectStyle == #line ifTrue:[
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5843
                ((key == #Tab) and:[shiftPressed not]) ifTrue:[
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5844
                    macroName := #IndentBy4.
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5845
                ] ifFalse:[
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5846
                    macroName := #UndentBy4.
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5847
                ].
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5848
                macroName notNil ifTrue:[
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5849
                    self executekeyboardMacroNamed:macroName.
6150
fd1642c99acb #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6147
diff changeset
  5850
                    ^ self.
6147
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5851
                ].
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5852
            ]
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5853
        ].
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5854
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5855
        self unselect.
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5856
        (key == #Tab) ifTrue:[
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5857
            (shiftPressed or:[self isInInsertMode not]) ifTrue:[
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5858
                self cursorTab.
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5859
                ^ self
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5860
            ].
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5861
            self insertTabAtCursor.
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5862
            ^ self
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5863
        ].
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5864
        self cursorBacktab.
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5865
        ^ self
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5866
    ].
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
  5867
2883
6cdb4a5a7b5e shift-delete - delete whiteSpace
Claus Gittinger <cg@exept.de>
parents: 2880
diff changeset
  5868
    "/ key == #DeleteSpaces ifTrue:[
5119
1ba5fb52a0e3 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5114
diff changeset
  5869
    (rawKey == #Delete) ifTrue:[
6147
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5870
        shiftPressed ifTrue:[
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5871
            [(cursorCol <= (self listAt:cursorLine) size)
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5872
             and:[self characterUnderCursor isSeparator]] whileTrue:[
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5873
             self makeCursorVisible.
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5874
                self deleteCharAtCursor.
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5875
            ].
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5876
            ^ self
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5877
        ]
2883
6cdb4a5a7b5e shift-delete - delete whiteSpace
Claus Gittinger <cg@exept.de>
parents: 2880
diff changeset
  5878
    ].
6cdb4a5a7b5e shift-delete - delete whiteSpace
Claus Gittinger <cg@exept.de>
parents: 2880
diff changeset
  5879
5119
1ba5fb52a0e3 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5114
diff changeset
  5880
    (rawKey == #Delete
870
c606f29db5d7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 865
diff changeset
  5881
     or:[key == #BasicDelete]) ifTrue:[
6147
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5882
        selectionStartLine notNil ifTrue:[
4130
87d51f65430e changed: #doKeyPress:x:y:
fm
parents: 4129
diff changeset
  5883
"/          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
  5884
"/          To remove text repetetively, use Cut instead.
87d51f65430e changed: #doKeyPress:x:y:
fm
parents: 4129
diff changeset
  5885
"/            self setLastStringToReplace: self selection asStringWithoutFinalCR.
87d51f65430e changed: #doKeyPress:x:y:
fm
parents: 4129
diff changeset
  5886
"/            lastReplacementInfo lastReplacement: nil.
6147
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5887
            ((key == #BasicDelete)
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5888
            or:[currentUserPrefs deleteSetsClipboardText not]) ifTrue:[
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5889
                self deleteSelection.
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5890
            ] ifFalse:[
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5891
                self copyAndDeleteSelection.
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5892
            ].
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5893
            ^ self
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5894
        ].
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5895
        self makeCursorVisible.
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5896
        self deleteCharAtCursor.
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5897
        ^ self
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5898
    ].
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
  5899
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5900
    (key == #BeginOfText) ifTrue:[     "i.e. HOME"
6147
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5901
        self unselect.
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5902
        cursorVisibleLine == 1 ifTrue:[
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5903
            self cursorHome.
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5904
        ] ifFalse:[
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5905
            self cursorToFirstVisibleLine
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5906
        ].
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5907
        ^ self
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5908
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5909
    (key == #EndOfText) ifTrue:[       "i.e. END"
6147
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5910
        self unselect.
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5911
        cursorVisibleLine == nFullLinesShown ifTrue:[
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5912
            self cursorToBottom.
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5913
        ] ifFalse:[
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5914
            self cursorToLastVisibleLine
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5915
        ].
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5916
        ^ self
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5917
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5918
    ((key == #Escape)
3257
628e1e05814d shift-Tab fix.
Claus Gittinger <cg@exept.de>
parents: 3252
diff changeset
  5919
    or:[key == #SelectLineFromBeginning]) ifTrue:[
6147
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5920
        self makeCursorVisible.
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5921
        self unselect. self selectCursorLineFromBeginning.
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5922
        ^ self
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5923
    ].
6354
3fcb3ef259c1 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6339
diff changeset
  5924
    (key == #SelectToLineEnd) ifTrue:[
3fcb3ef259c1 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6339
diff changeset
  5925
        self makeCursorVisible.
3fcb3ef259c1 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6339
diff changeset
  5926
        self unselect. self selectCursorLineToEnd.
3fcb3ef259c1 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6339
diff changeset
  5927
        ^ self
3fcb3ef259c1 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6339
diff changeset
  5928
    ].
3257
628e1e05814d shift-Tab fix.
Claus Gittinger <cg@exept.de>
parents: 3252
diff changeset
  5929
    (key == #SelectLine) ifTrue:[
6147
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5930
        self makeCursorVisible.
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5931
        self unselect. self selectCursorLine.
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5932
        ^ self
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5933
    ].
3257
628e1e05814d shift-Tab fix.
Claus Gittinger <cg@exept.de>
parents: 3252
diff changeset
  5934
    (key == #ExpandSelectionByLine) ifTrue:[
6147
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5935
        "/ self makeCursorVisible.
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5936
        self selectExpandCursorLine.
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5937
        ^ self
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5938
    ].
3257
628e1e05814d shift-Tab fix.
Claus Gittinger <cg@exept.de>
parents: 3252
diff changeset
  5939
    (key == #DeleteLine) ifTrue:[
6147
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5940
        self makeCursorVisible.
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5941
        self unselect. self deleteCursorLine.
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5942
        ^ self
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5943
    ].
3257
628e1e05814d shift-Tab fix.
Claus Gittinger <cg@exept.de>
parents: 3252
diff changeset
  5944
    (key == #InsertLine) ifTrue:[
6147
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5945
        self makeCursorVisible.
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5946
        self unselect. self insertLine:nil before:cursorLine.
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  5947
        ^ self
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5948
    ].
3781
36268d8303d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3780
diff changeset
  5949
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5950
    super keyPress:key x:x y:y
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5951
3310
83368f9014a1 word check
Claus Gittinger <cg@exept.de>
parents: 3303
diff changeset
  5952
    "Modified: / 06-02-1998 / 11:59:59 / stefan"
4801
69a5bff7b5cd Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4786
diff changeset
  5953
    "Modified: / 26-09-2013 / 17:52:04 / Jan Vrany <jan.vrany@fit.cvut.cz>"
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  5954
    "Modified: / 28-04-2017 / 09:25:22 / cg"
6614
228cd1c3eac9 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6613
diff changeset
  5955
    "Modified: / 26-06-2019 / 23:17:08 / Claus Gittinger"
121
claus
parents: 118
diff changeset
  5956
!
claus
parents: 118
diff changeset
  5957
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5958
executeKeyboardMacro:cmdMacro
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5959
    Error handle:[:ex |
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  5960
        self warn:'Error in keyboard macro: ' , ex description.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  5961
        ex return.
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5962
    ] do:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  5963
        AbortOperationRequest handle:[:ex |
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  5964
            self warn:'Keyboard macro aborted'.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  5965
            ex return.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  5966
        ] do:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  5967
            Parser
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  5968
                evaluate:cmdMacro asString
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  5969
                receiver:self
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  5970
                notifying:nil
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  5971
                compile:false.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  5972
        ].
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5973
    ].
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5974
!
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5975
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5976
handleNonCommandKey:keyArg
4700
150468a2ea5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4697
diff changeset
  5977
    |selStartLineBefore selStartColBefore selEndLineBefore selEndColBefore key|
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5978
6226
b7628412aff5 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6210
diff changeset
  5979
    (self checkModificationsAllowedFlashIfNot:true) ifFalse:[^ self].
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5980
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5981
    key := keyArg.
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5982
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5983
    typeOfSelection == #paste ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  5984
        "pasted selection will NOT be replaced by keystroke"
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  5985
        self unselect
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5986
    ].
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5987
4700
150468a2ea5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4697
diff changeset
  5988
    selStartLineBefore := selectionStartLine.
150468a2ea5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4697
diff changeset
  5989
    selStartColBefore := self selectionStartCol.
150468a2ea5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4697
diff changeset
  5990
    selEndLineBefore := selectionEndLine.
150468a2ea5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4697
diff changeset
  5991
    selEndColBefore := self selectionEndCol.
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5992
6270
4a9ebb5a33ec #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6262
diff changeset
  5993
    gc characterEncoding ~~ #'iso10646-1' ifTrue:[
4a9ebb5a33ec #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6262
diff changeset
  5994
        key := CharacterEncoder encodeString:key asString from:#'iso10646-1' into:gc characterEncoding.
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5995
    ].
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5996
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5997
    "replace selection by what is typed in -
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  5998
     if word was selected with a space, keep it.
4700
150468a2ea5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4697
diff changeset
  5999
     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
  6000
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  6001
    editMode value isInsertAndSelectMode ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  6002
        selectionStartLine := selectionStartCol := selectionEndLine := selectionEndCol := nil.
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  6003
    ].
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  6004
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  6005
    (selectStyle == #wordLeft) ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  6006
        self replaceSelectionBy:(' ' , key asString)
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  6007
    ] ifFalse:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  6008
        (selectStyle == #wordRight) ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  6009
            self replaceSelectionBy:(key asString , ' ').
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  6010
            self cursorLeft
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  6011
        ] ifFalse:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  6012
            self replaceSelectionBy:key
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  6013
        ]
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6014
    ].
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  6015
    selectStyle := nil.
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  6016
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  6017
    editMode value isInsertAndSelectMode ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  6018
        selectionStartLine := selStartLineBefore.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  6019
        selectionStartCol := selStartColBefore.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  6020
        selectionEndLine := selEndLineBefore.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  6021
        selectionEndCol := selEndColBefore.
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  6022
    ].
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  6023
6399
b3bc4be4a579 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6390
diff changeset
  6024
    self maybeShowMatchingParenthesisFor:key.
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  6025
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  6026
"/    true "autoExpandWhileTyping" ifTrue:[
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  6027
"/        self wordAtLine:cursorLine col:cursorCol-1 do:[
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  6028
"/            :beginLine :beginCol :endLine :endCol :style |
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  6029
"/
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  6030
"/            self selectFromLine:beginLine col:beginCol toLine:endLine col:endCol.
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  6031
"/            self selection.
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  6032
"/            typeOfSelection := #paste.
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6033
"/        ].
3683
5891af82a177 middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents: 3650
diff changeset
  6034
"/    ].
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  6035
    editMode value isInsertAndSelectMode ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  6036
        selectionStartLine isNil ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  6037
            self selectFromLine:cursorLine col:cursorCol-1 toLine:cursorLine col:cursorCol-1.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  6038
        ] ifFalse:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  6039
            self selectFromLine:selectionStartLine col:selectionStartCol toLine:cursorLine col:cursorCol-1.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  6040
        ].
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  6041
    ].
4801
69a5bff7b5cd Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4786
diff changeset
  6042
    completionSupport notNil ifTrue:[ completionSupport postKeyPress:keyArg ].
4360
fe77e479d95a comment/format in:
Claus Gittinger <cg@exept.de>
parents: 4328
diff changeset
  6043
6226
b7628412aff5 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6210
diff changeset
  6044
    "Modified: / 11-11-2017 / 12:54:01 / cg"
6270
4a9ebb5a33ec #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 6262
diff changeset
  6045
    "Modified: / 19-01-2018 / 12:23:41 / stefan"
6399
b3bc4be4a579 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6390
diff changeset
  6046
    "Modified: / 22-08-2018 / 08:34:25 / Claus Gittinger"
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  6047
!
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  6048
6610
7cb4e0787a81 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6609
diff changeset
  6049
handleReturnPressed
7cb4e0787a81 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6609
diff changeset
  6050
    "return key pressed - handle autoIndent"
7cb4e0787a81 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6609
diff changeset
  6051
    
6623
682c9f9e6a11 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6620
diff changeset
  6052
    |i leftPart rightPart startIndent oldIndent newIndent language 
6610
7cb4e0787a81 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6609
diff changeset
  6053
     bracketStrings endsWithOpeningBracket startsWithClosingBracket|
7cb4e0787a81 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6609
diff changeset
  6054
    
7cb4e0787a81 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6609
diff changeset
  6055
    self isReadOnly ifTrue:[
7cb4e0787a81 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6609
diff changeset
  6056
        self unselect; makeCursorVisible.
7cb4e0787a81 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6609
diff changeset
  6057
        self cursorReturn.
7cb4e0787a81 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6609
diff changeset
  6058
        ^ self.
7cb4e0787a81 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6609
diff changeset
  6059
    ].
7cb4e0787a81 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6609
diff changeset
  6060
    self isInInsertMode ifFalse:[
7cb4e0787a81 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6609
diff changeset
  6061
        self cursorReturn:true.
6614
228cd1c3eac9 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6613
diff changeset
  6062
        self autoIndent ifTrue:[
6610
7cb4e0787a81 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6609
diff changeset
  6063
            i := self leftIndentForLine:(cursorLine + 1).
7cb4e0787a81 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6609
diff changeset
  6064
            (self listAt:cursorLine) isEmptyOrNil ifTrue:[
7cb4e0787a81 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6609
diff changeset
  6065
                self cursorCol:(i+1 max:1)
7cb4e0787a81 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6609
diff changeset
  6066
            ]
7cb4e0787a81 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6609
diff changeset
  6067
        ].
7cb4e0787a81 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6609
diff changeset
  6068
        ^ self.
7cb4e0787a81 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6609
diff changeset
  6069
    ].
7cb4e0787a81 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6609
diff changeset
  6070
7cb4e0787a81 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6609
diff changeset
  6071
    "/ old version just unselected ...
7cb4e0787a81 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6609
diff changeset
  6072
    "/ self unselect; makeCursorVisible.
7cb4e0787a81 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6609
diff changeset
  6073
7cb4e0787a81 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6609
diff changeset
  6074
    "/ new version deletes ...
7cb4e0787a81 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6609
diff changeset
  6075
    typeOfSelection == #paste ifTrue:[
7cb4e0787a81 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6609
diff changeset
  6076
        self unselect; makeCursorVisible.
7cb4e0787a81 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6609
diff changeset
  6077
    ] ifFalse:[
7cb4e0787a81 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6609
diff changeset
  6078
        self copyAndDeleteSelection.
7cb4e0787a81 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6609
diff changeset
  6079
    ].
7cb4e0787a81 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6609
diff changeset
  6080
6623
682c9f9e6a11 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6620
diff changeset
  6081
    startIndent := self leftIndentOfLine:cursorLine.
682c9f9e6a11 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6620
diff changeset
  6082
6610
7cb4e0787a81 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6609
diff changeset
  6083
    "/ split the line
7cb4e0787a81 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6609
diff changeset
  6084
    leftPart := ((self listAt:cursorLine to:cursorCol-1) ? '') string.
7cb4e0787a81 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6609
diff changeset
  6085
    rightPart := ((self listAt:cursorLine from:cursorCol) ? '') string.
7cb4e0787a81 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6609
diff changeset
  6086
    self insertCharAtCursor:(Character cr).
6620
d1af1ea90691 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6614
diff changeset
  6087
    self autoIndent ifFalse:[^ self].
6610
7cb4e0787a81 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6609
diff changeset
  6088
7cb4e0787a81 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6609
diff changeset
  6089
    endsWithOpeningBracket := startsWithClosingBracket := [:line | false].
7cb4e0787a81 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6609
diff changeset
  6090
    (language := self editedLanguage) notNil ifTrue:[
7cb4e0787a81 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6609
diff changeset
  6091
        bracketStrings := language bracketStrings ? #().
7cb4e0787a81 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6609
diff changeset
  6092
        endsWithOpeningBracket := 
7cb4e0787a81 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6609
diff changeset
  6093
            [:line |
7cb4e0787a81 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6609
diff changeset
  6094
                bracketStrings contains:[:pair | line endsWith:(pair first)].
7cb4e0787a81 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6609
diff changeset
  6095
            ].
7cb4e0787a81 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6609
diff changeset
  6096
        startsWithClosingBracket := 
7cb4e0787a81 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6609
diff changeset
  6097
            [:line |
7cb4e0787a81 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6609
diff changeset
  6098
                bracketStrings contains:[:pair | line startsWith:(pair second)].
7cb4e0787a81 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6609
diff changeset
  6099
            ].
7cb4e0787a81 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6609
diff changeset
  6100
    ]. 
7cb4e0787a81 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6609
diff changeset
  6101
    
6620
d1af1ea90691 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6614
diff changeset
  6102
    (rightPart isEmpty and:[cursorCol ~~ 1]) ifTrue:[
d1af1ea90691 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6614
diff changeset
  6103
        "/ nothing to do.
d1af1ea90691 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6614
diff changeset
  6104
    ] ifFalse:[
d1af1ea90691 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6614
diff changeset
  6105
        i := self leftIndentForLine:cursorLine. 
d1af1ea90691 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6614
diff changeset
  6106
d1af1ea90691 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6614
diff changeset
  6107
        leftPart := leftPart withoutSeparators.
d1af1ea90691 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6614
diff changeset
  6108
        rightPart := rightPart withoutSeparators.
d1af1ea90691 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6614
diff changeset
  6109
        oldIndent := self leftIndentOfLine:cursorLine.
d1af1ea90691 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6614
diff changeset
  6110
d1af1ea90691 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6614
diff changeset
  6111
        rightPart isEmptyOrNil ifTrue:[
d1af1ea90691 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6614
diff changeset
  6112
            (endsWithOpeningBracket value:leftPart) ifTrue:[
d1af1ea90691 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6614
diff changeset
  6113
                newIndent := i.  "/ leftIndentForLine already adjusted the value if ending in an opening bracket
6610
7cb4e0787a81 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6609
diff changeset
  6114
            ] ifFalse:[
6620
d1af1ea90691 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6614
diff changeset
  6115
                (false "(left endsWith:']')" or:[(startsWithClosingBracket value:rightPart)]) ifTrue:[
d1af1ea90691 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6614
diff changeset
  6116
                    newIndent := (self prevTabBefore:i)-1.
6610
7cb4e0787a81 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6609
diff changeset
  6117
                ] ifFalse:[
6620
d1af1ea90691 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6614
diff changeset
  6118
                    newIndent := i.  "/ leftIndentForLine returns the previous line's indent
d1af1ea90691 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6614
diff changeset
  6119
                ]
d1af1ea90691 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6614
diff changeset
  6120
            ].
d1af1ea90691 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6614
diff changeset
  6121
        ] ifFalse:[
d1af1ea90691 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6614
diff changeset
  6122
            (endsWithOpeningBracket value:leftPart) ifTrue:[
d1af1ea90691 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6614
diff changeset
  6123
                newIndent := i.
6623
682c9f9e6a11 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6620
diff changeset
  6124
                (startsWithClosingBracket value:rightPart) ifTrue:[
682c9f9e6a11 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6620
diff changeset
  6125
                    "/ entered return inside [] - insert another empty line
682c9f9e6a11 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6620
diff changeset
  6126
                    self insertCharAtCursor:(Character cr).
682c9f9e6a11 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6620
diff changeset
  6127
                    self indentFromLine:cursorLine toLine:cursorLine by:startIndent.
682c9f9e6a11 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6620
diff changeset
  6128
                    self cursorUp.
682c9f9e6a11 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6620
diff changeset
  6129
                ]
6620
d1af1ea90691 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6614
diff changeset
  6130
            ] ifFalse:[
d1af1ea90691 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6614
diff changeset
  6131
                (startsWithClosingBracket value:rightPart) ifTrue:[
d1af1ea90691 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6614
diff changeset
  6132
                    leftPart notEmptyOrNil ifTrue:[
d1af1ea90691 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6614
diff changeset
  6133
                        newIndent := (self prevTabBefore:i)-1.
6610
7cb4e0787a81 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6609
diff changeset
  6134
                    ]    
6620
d1af1ea90691 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6614
diff changeset
  6135
                ] ifFalse:[
d1af1ea90691 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6614
diff changeset
  6136
                    newIndent := i
6610
7cb4e0787a81 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6609
diff changeset
  6137
                ]    
6620
d1af1ea90691 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6614
diff changeset
  6138
            ]    
d1af1ea90691 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6614
diff changeset
  6139
        ].        
d1af1ea90691 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6614
diff changeset
  6140
    ].
d1af1ea90691 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6614
diff changeset
  6141
    newIndent notNil ifTrue:[
d1af1ea90691 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6614
diff changeset
  6142
        self indentFromLine:cursorLine toLine:cursorLine by:(newIndent-oldIndent).
d1af1ea90691 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6614
diff changeset
  6143
        self st80EditMode ifTrue:[
d1af1ea90691 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6614
diff changeset
  6144
            (self listAt:cursorLine) size < newIndent ifTrue:[
d1af1ea90691 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6614
diff changeset
  6145
                self insertStringAtCursor:(String new:((newIndent-oldIndent) max:0)).
6612
dd61bcd8d7da #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6610
diff changeset
  6146
            ].
6620
d1af1ea90691 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6614
diff changeset
  6147
        ].
d1af1ea90691 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6614
diff changeset
  6148
        self cursorCol:(newIndent+1 max:1)
6610
7cb4e0787a81 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6609
diff changeset
  6149
    ].
7cb4e0787a81 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6609
diff changeset
  6150
7cb4e0787a81 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6609
diff changeset
  6151
    "Created: / 26-06-2019 / 21:57:50 / Claus Gittinger"
6620
d1af1ea90691 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6614
diff changeset
  6152
    "Modified: / 29-06-2019 / 17:38:45 / Claus Gittinger"
6610
7cb4e0787a81 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6609
diff changeset
  6153
!
7cb4e0787a81 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6609
diff changeset
  6154
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  6155
keyPress:key x:x y:y
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  6156
    "handle keyboard input"
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  6157
4771
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  6158
    |wasOn|
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  6159
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  6160
    wasOn := cursorShown.
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  6161
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6162
    NoModificationError
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  6163
        handle:[:ex |
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  6164
            self flashReadOnly.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  6165
            (cursorShown not and:[wasOn]) ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  6166
                self makeCursorVisibleAndShowCursor:wasOn.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  6167
            ].
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  6168
        ]
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  6169
        do:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  6170
            self undoableDo:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  6171
                self doKeyPress:key x:x y:y
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  6172
            ].
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  6173
        ].
5689
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  6174
4242
93363c9c43cd changed: #keyPress:x:y:
Claus Gittinger <cg@exept.de>
parents: 4238
diff changeset
  6175
    self repairDamage
93363c9c43cd changed: #keyPress:x:y:
Claus Gittinger <cg@exept.de>
parents: 4238
diff changeset
  6176
93363c9c43cd changed: #keyPress:x:y:
Claus Gittinger <cg@exept.de>
parents: 4238
diff changeset
  6177
    "Modified: / 18-04-2011 / 21:35:27 / cg"
5689
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  6178
    "Modified (format): / 30-04-2016 / 20:45:52 / cg"
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  6179
!
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  6180
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6181
mapped
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6182
    "view was made visible"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6183
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6184
    super mapped.
2422
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  6185
    self updateCursorVisibleLine.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6186
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6187
6399
b3bc4be4a579 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6390
diff changeset
  6188
maybeShowMatchingParenthesisFor:characterBeforeCursor
b3bc4be4a579 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6390
diff changeset
  6189
    showMatchingParenthesis ifTrue:[
b3bc4be4a579 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6390
diff changeset
  6190
        "emacs style parenthesis shower"
b3bc4be4a579 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6390
diff changeset
  6191
        "claus: only do it for closing parenthesis - otherwise its too anoying."
b3bc4be4a579 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6390
diff changeset
  6192
        ("'()[]{}'" ')]}' includes:characterBeforeCursor) ifTrue:[
b3bc4be4a579 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6390
diff changeset
  6193
            (ExecutingMacroQuery query ? false) ifFalse:[
b3bc4be4a579 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6390
diff changeset
  6194
                self
b3bc4be4a579 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6390
diff changeset
  6195
                    searchForMatchingParenthesisFromLine:cursorLine col:(cursorCol - 1)
b3bc4be4a579 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6390
diff changeset
  6196
                    ifFound:[:line :col | self showMatchingParenthesisAtLine:line col:col ]
b3bc4be4a579 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6390
diff changeset
  6197
                    ifNotFound:[self showNotFound]
b3bc4be4a579 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6390
diff changeset
  6198
                    onError:[self beepInEditor]
b3bc4be4a579 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6390
diff changeset
  6199
            ].
b3bc4be4a579 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6390
diff changeset
  6200
        ]
b3bc4be4a579 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6390
diff changeset
  6201
    ].
b3bc4be4a579 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6390
diff changeset
  6202
b3bc4be4a579 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6390
diff changeset
  6203
    "Created: / 22-08-2018 / 08:34:04 / Claus Gittinger"
b3bc4be4a579 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6390
diff changeset
  6204
!
b3bc4be4a579 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6390
diff changeset
  6205
3268
d30df22739ca move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents: 3257
diff changeset
  6206
requestAutoAccept
5068
3ad3eb432172 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5067
diff changeset
  6207
    "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
  6208
     This forces my value to be accepted into my model.
3ad3eb432172 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5067
diff changeset
  6209
     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
  6210
d30df22739ca move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents: 3257
diff changeset
  6211
    acceptEnabled == false ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  6212
        "/ nope -
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  6213
        ^ false
3268
d30df22739ca move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents: 3257
diff changeset
  6214
    ].
5404
50b74416cbd4 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5400
diff changeset
  6215
    "/ cg: only do this if modified.
50b74416cbd4 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5400
diff changeset
  6216
    "/ otherwise, users would have to make sure that the contents is
50b74416cbd4 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5400
diff changeset
  6217
    "/ always correct (which they don't). If you change this back,
50b74416cbd4 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5400
diff changeset
  6218
    "/ please check the expecco file-save or file-reimport dialog,
50b74416cbd4 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5400
diff changeset
  6219
    "/ which has a problem with that behavior.
50b74416cbd4 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5400
diff changeset
  6220
    self modified ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  6221
        self accept.
5404
50b74416cbd4 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5400
diff changeset
  6222
    ].
3268
d30df22739ca move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents: 3257
diff changeset
  6223
    ^ true.
d30df22739ca move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents: 3257
diff changeset
  6224
!
d30df22739ca move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents: 3257
diff changeset
  6225
6399
b3bc4be4a579 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6390
diff changeset
  6226
showMatchingParenthesisAtLine:line col:col
b3bc4be4a579 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6390
diff changeset
  6227
     self withCursor:Cursor eye do:[
b3bc4be4a579 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6390
diff changeset
  6228
         |savLine savCol sensor|
b3bc4be4a579 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6390
diff changeset
  6229
         
b3bc4be4a579 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6390
diff changeset
  6230
         savLine := cursorLine.
b3bc4be4a579 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6390
diff changeset
  6231
         savCol := cursorCol.
b3bc4be4a579 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6390
diff changeset
  6232
         self cursorLine:line col:col.
b3bc4be4a579 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6390
diff changeset
  6233
         self flush.
b3bc4be4a579 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6390
diff changeset
  6234
b3bc4be4a579 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6390
diff changeset
  6235
         "/ want to wait 240ms, but not if another keyPress
b3bc4be4a579 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6390
diff changeset
  6236
         "/ arrives in the meantime ...
b3bc4be4a579 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6390
diff changeset
  6237
b3bc4be4a579 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6390
diff changeset
  6238
         sensor := self sensor.
b3bc4be4a579 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6390
diff changeset
  6239
         6 timesRepeat:[
b3bc4be4a579 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6390
diff changeset
  6240
             (sensor hasKeyPressEventFor:self) ifFalse:[
b3bc4be4a579 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6390
diff changeset
  6241
                 Processor activeProcess millisecondDelay:40.
b3bc4be4a579 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6390
diff changeset
  6242
             ]
b3bc4be4a579 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6390
diff changeset
  6243
         ].
b3bc4be4a579 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6390
diff changeset
  6244
         self cursorLine:savLine col:savCol
b3bc4be4a579 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6390
diff changeset
  6245
     ]
b3bc4be4a579 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6390
diff changeset
  6246
b3bc4be4a579 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6390
diff changeset
  6247
    "Created: / 22-08-2018 / 08:22:13 / Claus Gittinger"
b3bc4be4a579 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6390
diff changeset
  6248
!
b3bc4be4a579 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6390
diff changeset
  6249
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6250
sizeChanged:how
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6251
    "make certain, cursor is visible after the sizechange"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6252
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6253
    |cv|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6254
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6255
    cv := cursorVisibleLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6256
    super sizeChanged:how.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6257
    cv notNil ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  6258
        self makeLineVisible:cursorLine
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6259
    ]
4967
5af7718d4f2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4966
diff changeset
  6260
!
5af7718d4f2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4966
diff changeset
  6261
5af7718d4f2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4966
diff changeset
  6262
unmapped
5af7718d4f2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4966
diff changeset
  6263
    super unmapped.
5af7718d4f2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4966
diff changeset
  6264
5af7718d4f2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4966
diff changeset
  6265
    completionSupport notNil ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  6266
        completionSupport release.
4967
5af7718d4f2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4966
diff changeset
  6267
    ].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6268
! !
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6269
1807
30526cb1acfc category and comment
Claus Gittinger <cg@exept.de>
parents: 1804
diff changeset
  6270
!EditTextView methodsFor:'focus handling'!
30526cb1acfc category and comment
Claus Gittinger <cg@exept.de>
parents: 1804
diff changeset
  6271
4818
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  6272
focusOut
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  6273
    super focusOut.
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  6274
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  6275
    completionSupport notNil ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  6276
        completionSupport release.
4818
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  6277
    ].
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  6278
!
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  6279
1807
30526cb1acfc category and comment
Claus Gittinger <cg@exept.de>
parents: 1804
diff changeset
  6280
hasKeyboardFocus:aBoolean
30526cb1acfc category and comment
Claus Gittinger <cg@exept.de>
parents: 1804
diff changeset
  6281
    "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
  6282
     (otherwise, I would not know about this)"
30526cb1acfc category and comment
Claus Gittinger <cg@exept.de>
parents: 1804
diff changeset
  6283
30526cb1acfc category and comment
Claus Gittinger <cg@exept.de>
parents: 1804
diff changeset
  6284
    hasKeyboardFocus := aBoolean.
4609
8b3eb80d04d0 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4595
diff changeset
  6285
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6286
    (cursorShown
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6287
    and:[self enabled
3296
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
  6288
    and:[self isReadOnly not]]) ifTrue:[
5890
5dc30fda9ebf #OTHER by mawalch
mawalch
parents: 5887
diff changeset
  6289
        self drawCursor
4609
8b3eb80d04d0 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4595
diff changeset
  6290
    ].
8b3eb80d04d0 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4595
diff changeset
  6291
8b3eb80d04d0 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4595
diff changeset
  6292
    hasKeyboardFocus ifFalse:[
5890
5dc30fda9ebf #OTHER by mawalch
mawalch
parents: 5887
diff changeset
  6293
        completionSupport notNil ifTrue:[
5dc30fda9ebf #OTHER by mawalch
mawalch
parents: 5887
diff changeset
  6294
            "/ this is a hack for Windows:
5dc30fda9ebf #OTHER by mawalch
mawalch
parents: 5887
diff changeset
  6295
            "/ on windows, an activate:false event is first sent to my textView,
5dc30fda9ebf #OTHER by mawalch
mawalch
parents: 5887
diff changeset
  6296
            "/ then an activate is sent to the completion popup.
5dc30fda9ebf #OTHER by mawalch
mawalch
parents: 5887
diff changeset
  6297
            "/ this is done BEFORE the buttonPress event is delivered.
5dc30fda9ebf #OTHER by mawalch
mawalch
parents: 5887
diff changeset
  6298
            "/ therefore, allow for the activate of the completionMenu and its button event to be processed.
5dc30fda9ebf #OTHER by mawalch
mawalch
parents: 5887
diff changeset
  6299
            "/ before forcing it to be closed...
5dc30fda9ebf #OTHER by mawalch
mawalch
parents: 5887
diff changeset
  6300
            completionSupport startTimeoutForEditViewLostFocus.
5dc30fda9ebf #OTHER by mawalch
mawalch
parents: 5887
diff changeset
  6301
        ].
1816
0b9380a0cc7e only take keyboardFocus (and show cursor)
Claus Gittinger <cg@exept.de>
parents: 1811
diff changeset
  6302
    ].
0b9380a0cc7e only take keyboardFocus (and show cursor)
Claus Gittinger <cg@exept.de>
parents: 1811
diff changeset
  6303
4821
b108cc2ff7e9 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4820
diff changeset
  6304
    "Modified (format): / 06-11-2013 / 15:37:31 / cg"
1807
30526cb1acfc category and comment
Claus Gittinger <cg@exept.de>
parents: 1804
diff changeset
  6305
!
30526cb1acfc category and comment
Claus Gittinger <cg@exept.de>
parents: 1804
diff changeset
  6306
30526cb1acfc category and comment
Claus Gittinger <cg@exept.de>
parents: 1804
diff changeset
  6307
showFocus:explicit
30526cb1acfc category and comment
Claus Gittinger <cg@exept.de>
parents: 1804
diff changeset
  6308
    "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
  6309
     displayed, show the cursor when I got the focus"
30526cb1acfc category and comment
Claus Gittinger <cg@exept.de>
parents: 1804
diff changeset
  6310
5239
0312ca8fd55e class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5226
diff changeset
  6311
    self hasKeyboardFocus:true.
1807
30526cb1acfc category and comment
Claus Gittinger <cg@exept.de>
parents: 1804
diff changeset
  6312
    self showCursor.
30526cb1acfc category and comment
Claus Gittinger <cg@exept.de>
parents: 1804
diff changeset
  6313
    super showFocus:explicit
30526cb1acfc category and comment
Claus Gittinger <cg@exept.de>
parents: 1804
diff changeset
  6314
30526cb1acfc category and comment
Claus Gittinger <cg@exept.de>
parents: 1804
diff changeset
  6315
    "Modified: 11.12.1996 / 16:56:54 / cg"
1918
3ac07b97b4f7 use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents: 1902
diff changeset
  6316
!
3ac07b97b4f7 use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents: 1902
diff changeset
  6317
4967
5af7718d4f2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4966
diff changeset
  6318
showNoFocus:explicit
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6319
    "the view lost the keyboard focus
4967
5af7718d4f2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4966
diff changeset
  6320
     (either explicit, via tabbing; or implicit, by pointer movement)
5af7718d4f2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4966
diff changeset
  6321
      - change any display attributes as req'd."
5af7718d4f2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4966
diff changeset
  6322
5af7718d4f2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4966
diff changeset
  6323
    super showNoFocus:explicit.
5149
cc14f4e4157d class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5146
diff changeset
  6324
cc14f4e4157d class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5146
diff changeset
  6325
    "/ cg: only do this for an explicit change (i.e. by tabbing),
cc14f4e4157d class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5146
diff changeset
  6326
    "/ not when the focus is lost normally (because this also happens when
cc14f4e4157d class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5146
diff changeset
  6327
    "/ 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
  6328
    "/ completer. Otherwise, completion does not work when clocking into the list.
cc14f4e4157d class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5146
diff changeset
  6329
    explicit ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  6330
        completionSupport notNil ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  6331
            completionSupport release.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  6332
        ].
4818
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  6333
    ].
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  6334
!
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  6335
1918
3ac07b97b4f7 use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents: 1902
diff changeset
  6336
wantsFocusWithPointerEnter
3ac07b97b4f7 use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents: 1902
diff changeset
  6337
    "return true, if I want the focus when
3ac07b97b4f7 use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents: 1902
diff changeset
  6338
     the mouse pointer enters"
3ac07b97b4f7 use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents: 1902
diff changeset
  6339
3296
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
  6340
    (UserPreferences current focusFollowsMouse ~~ false
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
  6341
     and:[(styleSheet at:#'editText.requestFocusOnPointerEnter' default:true)
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
  6342
     and:[self enabled
4781
11d53632e47e class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4775
diff changeset
  6343
     and:[true "self isReadOnly not"]]]
4097
233d27a2b0a0 comment/format in: #wantsFocusWithPointerEnter
Claus Gittinger <cg@exept.de>
parents: 4089
diff changeset
  6344
    ) ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  6345
        ^ true
1918
3ac07b97b4f7 use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents: 1902
diff changeset
  6346
    ].
3ac07b97b4f7 use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents: 1902
diff changeset
  6347
3ac07b97b4f7 use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents: 1902
diff changeset
  6348
    ^ false
1807
30526cb1acfc category and comment
Claus Gittinger <cg@exept.de>
parents: 1804
diff changeset
  6349
! !
30526cb1acfc category and comment
Claus Gittinger <cg@exept.de>
parents: 1804
diff changeset
  6350
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6351
!EditTextView methodsFor:'formatting'!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6352
4237
Claus Gittinger <cg@exept.de>
parents: 4226
diff changeset
  6353
executekeyboardMacroNamed:macroName
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6354
    "try to execute the keyboard macro;
4371
a631db2025af changed: #executekeyboardMacroNamed:
Claus Gittinger <cg@exept.de>
parents: 4360
diff changeset
  6355
     return true if that worked, false otherwise"
a631db2025af changed: #executekeyboardMacroNamed:
Claus Gittinger <cg@exept.de>
parents: 4360
diff changeset
  6356
4482
0530a2d95b4b class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 4481
diff changeset
  6357
    |cmdMacro|
0530a2d95b4b class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 4481
diff changeset
  6358
0530a2d95b4b class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 4481
diff changeset
  6359
    cmdMacro := UserPreferences current functionKeySequences at:macroName ifAbsent:[^ false].
4371
a631db2025af changed: #executekeyboardMacroNamed:
Claus Gittinger <cg@exept.de>
parents: 4360
diff changeset
  6360
    self
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  6361
        undoableDo:[ self executeKeyboardMacro:cmdMacro ]
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  6362
        info: macroName.
4371
a631db2025af changed: #executekeyboardMacroNamed:
Claus Gittinger <cg@exept.de>
parents: 4360
diff changeset
  6363
    ^ true
4238
5f7125996b44 changed:
Stefan Vogel <sv@exept.de>
parents: 4237
diff changeset
  6364
5f7125996b44 changed:
Stefan Vogel <sv@exept.de>
parents: 4237
diff changeset
  6365
    "
4483
5b71475eddbc class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 4482
diff changeset
  6366
      EditTextView open
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  6367
                contents:'bla';
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  6368
                selectAll;
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  6369
                executekeyboardMacroNamed:#IndentBy4.
4483
5b71475eddbc class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 4482
diff changeset
  6370
      EditTextView open
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  6371
                contents:'bla';
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  6372
                selectAll;
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  6373
                executekeyboardMacroNamed:#blabla.
4238
5f7125996b44 changed:
Stefan Vogel <sv@exept.de>
parents: 4237
diff changeset
  6374
    "
4371
a631db2025af changed: #executekeyboardMacroNamed:
Claus Gittinger <cg@exept.de>
parents: 4360
diff changeset
  6375
a631db2025af changed: #executekeyboardMacroNamed:
Claus Gittinger <cg@exept.de>
parents: 4360
diff changeset
  6376
    "Modified: / 14-02-2012 / 11:17:27 / cg"
4237
Claus Gittinger <cg@exept.de>
parents: 4226
diff changeset
  6377
!
Claus Gittinger <cg@exept.de>
parents: 4226
diff changeset
  6378
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6379
indent
3221
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  6380
    "indent a line-range - this is done by searching for the
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  6381
     last non-empty line before the selection, and changing the indent
4742
a00cb40ee392 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4738
diff changeset
  6382
     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
  6383
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6384
    |start end|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6385
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6386
    selectionStartLine isNil ifTrue:[^ self].
3221
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  6387
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6388
    start := selectionStartLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6389
    end := selectionEndLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6390
    (selectionEndCol == 0) ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  6391
        end := end - 1
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6392
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6393
    self unselect.
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6394
    self
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  6395
        undoableDo:[self indentFromLine:start toLine:end]
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  6396
        info:'Indent'
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6397
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6398
4237
Claus Gittinger <cg@exept.de>
parents: 4226
diff changeset
  6399
indentBy4
5050
a1157f4a40ce class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5045
diff changeset
  6400
    self indentBy:4. "/ self executekeyboardMacroNamed:#IndentBy4.
a1157f4a40ce class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5045
diff changeset
  6401
a1157f4a40ce class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5045
diff changeset
  6402
    "Modified: / 06-04-2011 / 18:52:40 / cg"
a1157f4a40ce class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5045
diff changeset
  6403
!
a1157f4a40ce class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5045
diff changeset
  6404
a1157f4a40ce class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5045
diff changeset
  6405
indentBy8
a1157f4a40ce class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5045
diff changeset
  6406
    self indentBy:8. "/ self executekeyboardMacroNamed:#IndentBy4.
4237
Claus Gittinger <cg@exept.de>
parents: 4226
diff changeset
  6407
Claus Gittinger <cg@exept.de>
parents: 4226
diff changeset
  6408
    "Modified: / 06-04-2011 / 18:52:40 / cg"
Claus Gittinger <cg@exept.de>
parents: 4226
diff changeset
  6409
!
Claus Gittinger <cg@exept.de>
parents: 4226
diff changeset
  6410
5050
a1157f4a40ce class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5045
diff changeset
  6411
indentBy:n
a1157f4a40ce class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5045
diff changeset
  6412
    |line1 line2|
a1157f4a40ce class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5045
diff changeset
  6413
a1157f4a40ce class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5045
diff changeset
  6414
    line1 := self selectionStartLine.
a1157f4a40ce class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5045
diff changeset
  6415
    line2 := self selectionEndLine.
a1157f4a40ce class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5045
diff changeset
  6416
    line1 isNil ifTrue:[
5833
584a6e4d283a #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 5826
diff changeset
  6417
        line1 := self cursorLine.
584a6e4d283a #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 5826
diff changeset
  6418
        line1 notNil ifTrue:[
584a6e4d283a #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 5826
diff changeset
  6419
            line2 := line1
584a6e4d283a #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 5826
diff changeset
  6420
        ]
5769
32db0c4a851c #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 5761
diff changeset
  6421
    ] ifFalse:[
5833
584a6e4d283a #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 5826
diff changeset
  6422
        line2 notNil ifTrue:[
584a6e4d283a #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 5826
diff changeset
  6423
            self selectionEndCol == 0 ifTrue:[ line2 := line2 - 1 ].
584a6e4d283a #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 5826
diff changeset
  6424
        ].
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6425
    ].
5050
a1157f4a40ce class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5045
diff changeset
  6426
    line1 notNil ifTrue:[
5833
584a6e4d283a #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 5826
diff changeset
  6427
        self indentFromLine:line1 toLine:line2 by:n.
5050
a1157f4a40ce class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5045
diff changeset
  6428
    ]
a1157f4a40ce class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5045
diff changeset
  6429
!
a1157f4a40ce class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5045
diff changeset
  6430
a1157f4a40ce class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5045
diff changeset
  6431
indentByTab
a1157f4a40ce class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5045
diff changeset
  6432
    self indentBy:((tabPositions == self class tab4Positions) ifTrue:4 ifFalse:8)
a1157f4a40ce class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5045
diff changeset
  6433
!
a1157f4a40ce class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5045
diff changeset
  6434
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6435
indentFromLine:start toLine:end
3221
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  6436
    "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
  6437
     last non-empty line before start, and change the indent
4742
a00cb40ee392 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4738
diff changeset
  6438
     of the selected line-range based on that line's indent."
a00cb40ee392 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4738
diff changeset
  6439
4811
e868808b229e class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4803
diff changeset
  6440
    |leftStart delta|
474
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  6441
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  6442
    leftStart := self leftIndentForLine:start.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6443
    (leftStart == 0) ifTrue:[^ self].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6444
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6445
    delta := leftStart - (self leftIndentOfLine:start).
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6446
    (delta == 0) ifTrue:[^ self].
4811
e868808b229e class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4803
diff changeset
  6447
    self indentFromLine:start toLine:end by:delta
e868808b229e class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4803
diff changeset
  6448
!
e868808b229e class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4803
diff changeset
  6449
e868808b229e class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4803
diff changeset
  6450
indentFromLine:start toLine:end by:delta
e868808b229e class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4803
diff changeset
  6451
    "indent a line-range - this is done by searching for the
e868808b229e class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4803
diff changeset
  6452
     last non-empty line before start, and change the indent
e868808b229e class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4803
diff changeset
  6453
     of the selected line-range based on that line's indent."
e868808b229e class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4803
diff changeset
  6454
e868808b229e class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4803
diff changeset
  6455
    |d line spaces anyChange|
e868808b229e class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4803
diff changeset
  6456
e868808b229e class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4803
diff changeset
  6457
    (delta == 0) ifTrue:[^ self].
6226
b7628412aff5 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6210
diff changeset
  6458
b7628412aff5 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6210
diff changeset
  6459
    (self checkModificationsAllowedFlashIfNot:true) ifFalse:[ ^ self].
b7628412aff5 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6210
diff changeset
  6460
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6461
    (delta > 0) ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  6462
        spaces := String new:delta
4742
a00cb40ee392 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4738
diff changeset
  6463
    ].
a00cb40ee392 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4738
diff changeset
  6464
a00cb40ee392 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4738
diff changeset
  6465
    anyChange := false.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6466
    start to:end do:[:lineNr |
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  6467
        line := self listAt:lineNr.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  6468
        line notNil ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  6469
            line isBlank ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  6470
                self basicListAt:lineNr put:nil
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  6471
            ] ifFalse:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  6472
                (delta > 0) ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  6473
                    line := spaces , line.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  6474
                    widthOfWidestLine notNil ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  6475
                        widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:line).
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  6476
                    ]
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  6477
                ] ifFalse:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  6478
                    "check if deletion is ok"
6249
bc2cc528500c #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6241
diff changeset
  6479
                    d := delta negated.
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  6480
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  6481
                    line size > d ifTrue:[
6249
bc2cc528500c #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6241
diff changeset
  6482
                        (line copyTo:d) withoutSeparators isEmpty ifTrue:[
bc2cc528500c #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6241
diff changeset
  6483
                            line := line copyFrom:(d+1)
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  6484
                        ]
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  6485
                    ].
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  6486
                    widthOfWidestLine := nil
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  6487
                ].
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  6488
                self replaceLine:lineNr with:line.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  6489
                anyChange := true.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  6490
            ]
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  6491
        ]
4742
a00cb40ee392 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4738
diff changeset
  6492
    ].
a00cb40ee392 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4738
diff changeset
  6493
a00cb40ee392 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4738
diff changeset
  6494
    anyChange ifTrue:[ self textChanged ].
a00cb40ee392 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4738
diff changeset
  6495
3221
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  6496
    "/ self redrawFromLine:start to:end
474
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  6497
6226
b7628412aff5 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6210
diff changeset
  6498
    "Modified: / 11-11-2017 / 12:54:33 / cg"
474
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  6499
!
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  6500
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  6501
leftIndentForLine:lineNr
6612
dd61bcd8d7da #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6610
diff changeset
  6502
    "compute an appropriate indent for a line.
dd61bcd8d7da #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6610
diff changeset
  6503
     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
  6504
     and returning its indent.
6612
dd61bcd8d7da #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6610
diff changeset
  6505
     If the previous line ends with a bracket, adjust by the tab spacing as required.
4823
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  6506
     cg: changed: only look for the single previous line."
474
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  6507
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  6508
    "SHOULD GO TO ListView"
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  6509
6612
dd61bcd8d7da #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6610
diff changeset
  6510
    |line lnr indent 
dd61bcd8d7da #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6610
diff changeset
  6511
     endsWithOpeningBracket endsWithClosingBracket bracketStrings language|
dd61bcd8d7da #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6610
diff changeset
  6512
dd61bcd8d7da #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6610
diff changeset
  6513
    endsWithOpeningBracket := endsWithClosingBracket := [:line | false].
6613
745a9c495c42 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  6514
    language := self editedLanguage ? SmalltalkLanguage instance.
745a9c495c42 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  6515
745a9c495c42 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  6516
    bracketStrings := language bracketStrings ? #().
745a9c495c42 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  6517
    endsWithOpeningBracket := 
745a9c495c42 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  6518
        [:line |
745a9c495c42 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  6519
            bracketStrings contains:[:pair | line endsWith:(pair first)].
745a9c495c42 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  6520
        ].
745a9c495c42 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  6521
    endsWithClosingBracket := 
745a9c495c42 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  6522
        [:line |
745a9c495c42 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  6523
            bracketStrings contains:[:pair | line endsWith:(pair second)].
745a9c495c42 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  6524
        ].
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  6525
474
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  6526
    lnr := lineNr.
6147
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  6527
    [lnr > 1] whileTrue:[        
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  6528
        lnr  := lnr - 1.
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  6529
        line := self listAt:lnr.
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  6530
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  6531
        line notEmptyOrNil ifTrue:[
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  6532
            indent := (line indexOfNonSeparatorStartingAt:1) - 1.
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  6533
            indent >= 0 ifTrue:[
6613
745a9c495c42 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  6534
                (endsWithOpeningBracket value:line) ifTrue:[
745a9c495c42 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  6535
                    "/ ^ indent + 4
745a9c495c42 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  6536
                    ^ (self nextTabAfter:indent+1)-1
6147
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  6537
                ].
6613
745a9c495c42 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  6538
                "/ no, not with kr indentation style
745a9c495c42 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  6539
                "/ (endsWithClosingBracket value:line) ifTrue:[
745a9c495c42 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  6540
                "/     "/ ^ indent - 4
745a9c495c42 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  6541
                "/     ^ (self prevTabBefore:indent)-1
745a9c495c42 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  6542
                "/ ].
6147
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  6543
                ^ indent
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  6544
            ]
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  6545
        ]
474
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  6546
    ].
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  6547
    ^ 0
474
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  6548
6147
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  6549
    "Created: / 05-03-1996 / 14:58:53 / cg"
17a8d15d9b88 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6137
diff changeset
  6550
    "Modified (format): / 25-04-2017 / 12:57:44 / cg"
6613
745a9c495c42 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6612
diff changeset
  6551
    "Modified: / 26-06-2019 / 23:05:47 / Claus Gittinger"
4237
Claus Gittinger <cg@exept.de>
parents: 4226
diff changeset
  6552
!
Claus Gittinger <cg@exept.de>
parents: 4226
diff changeset
  6553
Claus Gittinger <cg@exept.de>
parents: 4226
diff changeset
  6554
undentBy4
5050
a1157f4a40ce class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5045
diff changeset
  6555
    self undentBy:4. "/ self executekeyboardMacroNamed:#UndentBy4.
a1157f4a40ce class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5045
diff changeset
  6556
a1157f4a40ce class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5045
diff changeset
  6557
    "Modified: / 06-04-2011 / 18:52:49 / cg"
a1157f4a40ce class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5045
diff changeset
  6558
!
a1157f4a40ce class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5045
diff changeset
  6559
a1157f4a40ce class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5045
diff changeset
  6560
undentBy8
a1157f4a40ce class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5045
diff changeset
  6561
    self undentBy:8. "/ self executekeyboardMacroNamed:#UndentBy4.
4237
Claus Gittinger <cg@exept.de>
parents: 4226
diff changeset
  6562
Claus Gittinger <cg@exept.de>
parents: 4226
diff changeset
  6563
    "Modified: / 06-04-2011 / 18:52:49 / cg"
5050
a1157f4a40ce class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5045
diff changeset
  6564
!
a1157f4a40ce class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5045
diff changeset
  6565
a1157f4a40ce class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5045
diff changeset
  6566
undentBy:n
a1157f4a40ce class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5045
diff changeset
  6567
    self indentBy:(n negated)
a1157f4a40ce class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5045
diff changeset
  6568
!
a1157f4a40ce class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5045
diff changeset
  6569
a1157f4a40ce class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5045
diff changeset
  6570
undentByTab
a1157f4a40ce class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5045
diff changeset
  6571
    self undentBy:((tabPositions == self class tab4Positions) ifTrue:4 ifFalse:8).
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  6572
! !
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  6573
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  6574
!EditTextView methodsFor:'initialization'!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  6575
941
f06fa4d47f26 fetch device resources early
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  6576
fetchDeviceResources
f06fa4d47f26 fetch device resources early
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  6577
    "fetch device colors, to avoid reallocation at redraw time"
f06fa4d47f26 fetch device resources early
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  6578
f06fa4d47f26 fetch device resources early
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  6579
    super fetchDeviceResources.
f06fa4d47f26 fetch device resources early
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  6580
5643
921578f80870 device access
Claus Gittinger <cg@exept.de>
parents: 5593
diff changeset
  6581
    cursorFgColor notNil ifTrue:[cursorFgColor := cursorFgColor onDevice:device].
921578f80870 device access
Claus Gittinger <cg@exept.de>
parents: 5593
diff changeset
  6582
    cursorBgColor notNil ifTrue:[cursorBgColor := cursorBgColor onDevice:device].
921578f80870 device access
Claus Gittinger <cg@exept.de>
parents: 5593
diff changeset
  6583
    cursorNoFocusFgColor notNil ifTrue:[cursorNoFocusFgColor := cursorNoFocusFgColor onDevice:device].
941
f06fa4d47f26 fetch device resources early
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  6584
f06fa4d47f26 fetch device resources early
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  6585
    "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
  6586
    "Modified: 18.2.1997 / 15:02:46 / cg"
941
f06fa4d47f26 fetch device resources early
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  6587
!
f06fa4d47f26 fetch device resources early
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  6588
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6589
initEvents
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6590
    "enable enter/leave events in addition"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6591
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6592
    super initEvents.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6593
    self enableEnterLeaveEvents
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6594
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6595
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6596
initStyle
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6597
    "initialize style specific stuff"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6598
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6599
    super initStyle.
4576
c9d937d20173 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4566
diff changeset
  6600
    "/ lineSpacing := 2.       "/ for underwave - also looks better
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6601
    lockUpdates := false.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6602
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6603
    cursorFgColor := DefaultCursorForegroundColor.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6604
    cursorFgColor isNil ifTrue:[cursorFgColor := bgColor].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6605
    cursorBgColor := DefaultCursorBackgroundColor.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6606
    cursorBgColor isNil ifTrue:[cursorBgColor := fgColor].
4721
59fc420ce5b0 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4715
diff changeset
  6607
    cursorType isNil ifTrue:[cursorType := DefaultCursorType].
59fc420ce5b0 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4715
diff changeset
  6608
    cursorTypeNoFocus isNil ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  6609
        cursorTypeNoFocus := cursorType.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  6610
        DefaultCursorTypeNoFocus notNil ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  6611
            cursorTypeNoFocus := DefaultCursorTypeNoFocus.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  6612
        ]
1534
bcb211e1b41a read noFocus cursorStyle from styleSheet
Claus Gittinger <cg@exept.de>
parents: 1533
diff changeset
  6613
    ].
1022
4362861fe15e allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents: 1018
diff changeset
  6614
    cursorNoFocusFgColor := DefaultCursorNoFocusForegroundColor.
4362861fe15e allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents: 1018
diff changeset
  6615
    cursorNoFocusFgColor isNil ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  6616
        cursorType ~~ #block ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  6617
            cursorNoFocusFgColor := cursorBgColor
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  6618
        ] ifFalse:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  6619
            cursorNoFocusFgColor := cursorFgColor
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  6620
        ]
1022
4362861fe15e allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents: 1018
diff changeset
  6621
    ].
4362861fe15e allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents: 1018
diff changeset
  6622
2088
b2beb67b1a98 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2085
diff changeset
  6623
    "Modified: / 15.12.1999 / 22:27:45 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6624
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6625
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6626
initialize
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6627
    "initialize a new EditTextView;
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6628
     setup some instance variables"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6629
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6630
    super initialize.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6631
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6632
    self level:-1.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6633
    readOnly := false.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6634
    fixedSize := false.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6635
    exceptionBlock := [:errorText | ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6636
    cursorShown := prevCursorState := true.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6637
    cursorLine := 1.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6638
    cursorVisibleLine := 1.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6639
    cursorCol := 1.
5251
259d72b38bd7 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5244
diff changeset
  6640
    cursorLineHolder := ValueHolder with:1.
259d72b38bd7 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5244
diff changeset
  6641
    cursorColHolder := ValueHolder with:1.
2119
2aa585fc62a3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2117
diff changeset
  6642
    modifiedChannel := ValueHolder with:false.
2aa585fc62a3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2117
diff changeset
  6643
    acceptChannel := ValueHolder with:false.
1437
ab84b08a9f9c allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
  6644
    acceptChannel addDependent:self.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6645
    showMatchingParenthesis := false.
3296
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
  6646
    hasKeyboardFocus := false.
323
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
  6647
    tabMeansNextField := false.
6614
228cd1c3eac9 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6613
diff changeset
  6648
    "/ autoIndent := UserPreferences current autoIndentInCodeView asValue.
228cd1c3eac9 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6613
diff changeset
  6649
    autoIndent := false asValue.
5251
259d72b38bd7 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5244
diff changeset
  6650
    editMode := ValueHolder with:EditMode insertMode.
259d72b38bd7 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5244
diff changeset
  6651
    learnMode := ValueHolder with:false.
2131
858209ba8509 cursor movement default
Claus Gittinger <cg@exept.de>
parents: 2129
diff changeset
  6652
    cursorMovementWhenUpdating := #beginOfText.
4048
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
  6653
    lastReplacementInfo := LastReplacementInfo new.
1596
0bbdb4e9fc43 made st80Mode also an inst-flag;
Claus Gittinger <cg@exept.de>
parents: 1591
diff changeset
  6654
3683
5891af82a177 middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents: 3650
diff changeset
  6655
    "/ enable drop by default
2589
62794ae04446 support drop
ca
parents: 2580
diff changeset
  6656
    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
  6657
5dcc2912bcb6 undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents: 2984
diff changeset
  6658
    undoSupport := UndoSupport for:self.
5251
259d72b38bd7 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5244
diff changeset
  6659
    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
  6660
87d60a4b098b Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4801
diff changeset
  6661
    "Modified: / 27-09-2013 / 09:41:32 / Jan Vrany <jan.vrany@fit.cvut.cz>"
6614
228cd1c3eac9 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6613
diff changeset
  6662
    "Modified (comment): / 26-06-2019 / 23:21:46 / Claus Gittinger"
4696
428c8bc44cfb refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents: 4694
diff changeset
  6663
!
428c8bc44cfb refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents: 4694
diff changeset
  6664
4801
69a5bff7b5cd Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4786
diff changeset
  6665
initializeCompletionSupport
69a5bff7b5cd Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4786
diff changeset
  6666
    |supportClass|
69a5bff7b5cd Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4786
diff changeset
  6667
69a5bff7b5cd Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4786
diff changeset
  6668
    completionSupport isNil ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  6669
        (supportClass := self completionSupportClass) notNil ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  6670
            completionSupport := supportClass for:self.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  6671
        ].
4696
428c8bc44cfb refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents: 4694
diff changeset
  6672
    ].
4801
69a5bff7b5cd Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4786
diff changeset
  6673
69a5bff7b5cd Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4786
diff changeset
  6674
    "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
  6675
!
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  6676
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  6677
release
4801
69a5bff7b5cd Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4786
diff changeset
  6678
    completionSupport notNil ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  6679
        completionSupport release
4771
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  6680
    ].
6517
7a141e818635 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6514
diff changeset
  6681
    CharacterInputViewSingleton notNil ifTrue:[
7a141e818635 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6514
diff changeset
  6682
        CharacterInputViewSingleton consumingView == self ifTrue:[
7a141e818635 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6514
diff changeset
  6683
            CharacterInputViewSingleton closeRequest.
7a141e818635 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6514
diff changeset
  6684
            CharacterInputViewSingleton := nil
7a141e818635 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6514
diff changeset
  6685
        ]
7a141e818635 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6514
diff changeset
  6686
    ].
7a141e818635 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6514
diff changeset
  6687
4771
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  6688
    super release
6517
7a141e818635 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6514
diff changeset
  6689
7a141e818635 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6514
diff changeset
  6690
    "Modified: / 08-01-2019 / 18:16:31 / Claus Gittinger"
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  6691
! !
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  6692
2580
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  6693
!EditTextView methodsFor:'macros'!
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  6694
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  6695
executeLearnedKeyboardMacro
4673
575d2d398823 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4666
diff changeset
  6696
    "replay the characters as learned previously"
575d2d398823 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4666
diff changeset
  6697
6548
59a6fdf4dd26 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6543
diff changeset
  6698
    (self learnMode not and:[learnedMacro size ~~ 0]) ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  6699
        ExecutingMacroQuery
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  6700
            answer:true
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  6701
            do:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  6702
                learnedMacro do:[:event |
6436
210307378a50 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6412
diff changeset
  6703
                    self
210307378a50 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6412
diff changeset
  6704
                        dispatchEvent:event
210307378a50 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6412
diff changeset
  6705
                        withFocusOn:nil
210307378a50 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6412
diff changeset
  6706
                        delegate:false
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  6707
                ]
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  6708
            ].
2580
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  6709
    ] ifFalse:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  6710
        self flash:'no macro'.
2580
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  6711
    ].
6436
210307378a50 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6412
diff changeset
  6712
6548
59a6fdf4dd26 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6543
diff changeset
  6713
    "Modified: / 01-03-2019 / 14:54:46 / Claus Gittinger"
2580
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  6714
!
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  6715
2795
1f7b5f242eee learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents: 2792
diff changeset
  6716
learnMode
3793
5a6074a257c1 learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents: 3790
diff changeset
  6717
    "true if currently learning"
5a6074a257c1 learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents: 3790
diff changeset
  6718
2795
1f7b5f242eee learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents: 2792
diff changeset
  6719
    ^ (learnMode value ? false).
1f7b5f242eee learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents: 2792
diff changeset
  6720
!
1f7b5f242eee learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents: 2792
diff changeset
  6721
2580
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  6722
learnMode:aBoolean
3793
5a6074a257c1 learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents: 3790
diff changeset
  6723
    "toggle the learn-mode"
5a6074a257c1 learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents: 3790
diff changeset
  6724
2580
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  6725
    |fg bg|
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  6726
2795
1f7b5f242eee learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents: 2792
diff changeset
  6727
    self learnModeHolder value:aBoolean.
1f7b5f242eee learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents: 2792
diff changeset
  6728
1f7b5f242eee learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents: 2792
diff changeset
  6729
    aBoolean ifTrue:[
5795
ee8125645546 #OTHER by stefan
Stefan Vogel <sv@exept.de>
parents: 5787
diff changeset
  6730
        learnedMacro := OrderedCollection new.
ee8125645546 #OTHER by stefan
Stefan Vogel <sv@exept.de>
parents: 5787
diff changeset
  6731
        fg := self whiteColor.
ee8125645546 #OTHER by stefan
Stefan Vogel <sv@exept.de>
parents: 5787
diff changeset
  6732
        bg := self blackColor.
2580
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  6733
    ] ifFalse:[
5795
ee8125645546 #OTHER by stefan
Stefan Vogel <sv@exept.de>
parents: 5787
diff changeset
  6734
        cursorFgColor := fg := (DefaultCursorForegroundColor ? bgColor).
ee8125645546 #OTHER by stefan
Stefan Vogel <sv@exept.de>
parents: 5787
diff changeset
  6735
        cursorBgColor := bg := (DefaultCursorBackgroundColor ? fgColor).
2580
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  6736
    ].
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  6737
    self cursorForegroundColor:fg backgroundColor:bg.
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  6738
!
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  6739
2795
1f7b5f242eee learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents: 2792
diff changeset
  6740
learnModeHolder
4673
575d2d398823 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4666
diff changeset
  6741
    "a holder returning true, if in learn mode"
575d2d398823 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4666
diff changeset
  6742
2795
1f7b5f242eee learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents: 2792
diff changeset
  6743
    learnMode isNil ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  6744
        learnMode := ValueHolder with:false
2795
1f7b5f242eee learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents: 2792
diff changeset
  6745
    ].
1f7b5f242eee learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents: 2792
diff changeset
  6746
    ^ learnMode
1f7b5f242eee learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents: 2792
diff changeset
  6747
!
1f7b5f242eee learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents: 2792
diff changeset
  6748
4673
575d2d398823 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4666
diff changeset
  6749
rememberLearnedMacroAs: nameString
575d2d398823 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4666
diff changeset
  6750
    Macros isNil ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  6751
        Macros := Dictionary new.
4673
575d2d398823 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4666
diff changeset
  6752
    ].
575d2d398823 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4666
diff changeset
  6753
    Macros at:nameString put:learnedMacro
575d2d398823 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4666
diff changeset
  6754
!
575d2d398823 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4666
diff changeset
  6755
2580
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  6756
toggleLearnMode
3793
5a6074a257c1 learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents: 3790
diff changeset
  6757
    "toggle the learn-mode"
5a6074a257c1 learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents: 3790
diff changeset
  6758
5a6074a257c1 learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents: 3790
diff changeset
  6759
    self learnMode:(self learnMode not).
2580
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  6760
! !
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  6761
4449
59fe55c937ea changed: #openFileBrowserOnIt
Claus Gittinger <cg@exept.de>
parents: 4430
diff changeset
  6762
!EditTextView methodsFor:'menu & menu actions'!
121
claus
parents: 118
diff changeset
  6763
2680
208d99c47d7c babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents: 2677
diff changeset
  6764
babelFishTranslate:fromToModeString
5962
0636ffb5a147 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5937
diff changeset
  6765
    "translate the selected text and paste it after the selection.
0636ffb5a147 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5937
diff changeset
  6766
     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
  6767
208d99c47d7c babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents: 2677
diff changeset
  6768
    |original translated|
208d99c47d7c babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents: 2677
diff changeset
  6769
208d99c47d7c babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents: 2677
diff changeset
  6770
    original := self selectionAsString.
208d99c47d7c babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents: 2677
diff changeset
  6771
    original size == 0 ifTrue:[^ self].
208d99c47d7c babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents: 2677
diff changeset
  6772
208d99c47d7c babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents: 2677
diff changeset
  6773
    self withWaitCursorDo:[
5962
0636ffb5a147 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5937
diff changeset
  6774
        (HostNameLookupError , SOAP::SoapImplError) handle:[:ex |
0636ffb5a147 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5937
diff changeset
  6775
            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
  6776
        ] do:[
0636ffb5a147 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5937
diff changeset
  6777
            translated := SOAP::BabelFishClient new 
0636ffb5a147 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5937
diff changeset
  6778
                            translate:original mode:fromToModeString.
0636ffb5a147 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5937
diff changeset
  6779
        ]
2680
208d99c47d7c babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents: 2677
diff changeset
  6780
    ].
208d99c47d7c babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents: 2677
diff changeset
  6781
208d99c47d7c babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents: 2677
diff changeset
  6782
    "/ v pasteOrReplace:translated
208d99c47d7c babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents: 2677
diff changeset
  6783
    self cursorLine:(self selectionEndLine) col:(self selectionEndCol + 1).
208d99c47d7c babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents: 2677
diff changeset
  6784
    self unselect.
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6785
    self
5962
0636ffb5a147 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5937
diff changeset
  6786
        undoablePaste:translated
0636ffb5a147 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5937
diff changeset
  6787
        info:'Translate'
3495
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  6788
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  6789
    "Modified: / 28-07-2007 / 13:27:21 / cg"
2680
208d99c47d7c babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents: 2677
diff changeset
  6790
!
208d99c47d7c babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents: 2677
diff changeset
  6791
5689
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  6792
copySelection
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  6793
    "copy contents into smalltalk copybuffer.
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  6794
     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
  6795
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  6796
    self hasSelection ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  6797
        self setCursorLine:selectionEndLine col:selectionEndCol+1
5689
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  6798
    ].
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  6799
    super copySelection.
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  6800
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  6801
    "Created: / 30-04-2016 / 21:07:10 / cg"
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  6802
!
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  6803
121
claus
parents: 118
diff changeset
  6804
cut
claus
parents: 118
diff changeset
  6805
    "cut selection into copybuffer"
claus
parents: 118
diff changeset
  6806
3324
1297aecf6699 delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents: 3313
diff changeset
  6807
    self deleteCopyToClipboard:true
121
claus
parents: 118
diff changeset
  6808
!
claus
parents: 118
diff changeset
  6809
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6810
defaultForGotoLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6811
    "return a default value to show in the gotoLine box"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6812
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6813
    cursorLine notNil ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  6814
        ^ cursorLine
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6815
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6816
    ^ super defaultForGotoLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6817
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6818
3324
1297aecf6699 delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents: 3313
diff changeset
  6819
deleteCopyToClipboard:toClipboard
1297aecf6699 delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents: 3313
diff changeset
  6820
    "cut selection into copybuffer"
1297aecf6699 delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents: 3313
diff changeset
  6821
4129
34908a157d21 changed: #deleteCopyToClipboard:
fm
parents: 4126
diff changeset
  6822
    |line col history sel |
3324
1297aecf6699 delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents: 3313
diff changeset
  6823
6226
b7628412aff5 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6210
diff changeset
  6824
    (self checkModificationsAllowedFlashIfNot:true) ifFalse:[^ self].
3324
1297aecf6699 delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents: 3313
diff changeset
  6825
1297aecf6699 delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents: 3313
diff changeset
  6826
    sel := self selection.
1297aecf6699 delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents: 3313
diff changeset
  6827
    sel notNil ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  6828
        self setLastStringToReplace: sel.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  6829
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  6830
        line := selectionStartLine.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  6831
        col := selectionStartCol.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  6832
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  6833
        toClipboard ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  6834
            "
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  6835
             remember in CopyBuffer
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  6836
            "
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  6837
            self setClipboardText:sel. "/ lastString.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  6838
        ].
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  6839
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  6840
        "
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  6841
         append to DeleteHistory (if there is one)
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  6842
        "
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  6843
        history := Smalltalk at:#DeleteHistory.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  6844
        history notNil ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  6845
            history addAll:(sel asStringCollection).
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  6846
            history size > 1000 ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  6847
                history := history copyFrom:(history size - 1000)
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  6848
            ].
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  6849
        ].
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  6850
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  6851
        "
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  6852
         now, delete it
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  6853
        "
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  6854
        self
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  6855
            undoableDo:[self deleteSelection]
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  6856
            info:'Delete'.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  6857
        lastReplacementInfo lastReplacement: nil
3324
1297aecf6699 delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents: 3313
diff changeset
  6858
    ] ifFalse:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  6859
        "
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  6860
         a cut without selection will search&cut again
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  6861
        "
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  6862
        self undoableDo:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  6863
            self again
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  6864
        ]
3324
1297aecf6699 delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents: 3313
diff changeset
  6865
    ]
1297aecf6699 delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents: 3313
diff changeset
  6866
6226
b7628412aff5 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6210
diff changeset
  6867
    "Modified: / 11-11-2017 / 12:53:45 / cg"
3324
1297aecf6699 delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents: 3313
diff changeset
  6868
!
1297aecf6699 delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents: 3313
diff changeset
  6869
428
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  6870
editMenu
5977
a1ac33c0e445 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5972
diff changeset
  6871
    "return the view's middleButtonMenu"
428
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  6872
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6873
    <resource: #keyboard (#Again #AgainForAll #Copy #Cut #Paste #Accept
5826
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6874
                          #Find #GotoLine #SaveAs #Print
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6875
                          #PasteFromHistory #Join #Wrap #Undo #Redo
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6876
                          #ToggleAutoIndent #ToggleInsertMode
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6877
                          #LearnKeyboardMacro #ExecuteKeyboardMacro )>
1261
bdb18f73205c resource flag: #menu -> #programMenu
Claus Gittinger <cg@exept.de>
parents: 1198
diff changeset
  6878
    <resource: #programMenu>
1054
d699ecd13e60 menu resource
Claus Gittinger <cg@exept.de>
parents: 1049
diff changeset
  6879
6241
ca8af4b44137 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6232
diff changeset
  6880
    |items m sub translateItems sortItems miscItems toolItems convertItems subSubMenu toolSubMenu
ca8af4b44137 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6232
diff changeset
  6881
     transSubMenu sortSubMenu convertSubMenu what undoIdx redoIdx sensor main mainItems|
1515
9e9b65bd6efb care for nil sensor
Claus Gittinger <cg@exept.de>
parents: 1495
diff changeset
  6882
2460
Claus Gittinger <cg@exept.de>
parents: 2438
diff changeset
  6883
    items := #(
5826
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6884
                    ('Redo'             redo           Redo        )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6885
                    ('Again (for All)'  multipleAgain  AgainForAll )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6886
                    ('-'                                        )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6887
                    ('Search...'        search         Find     )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6888
                    ('Goto Line...'     gotoLine       GotoLine )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6889
                    ('-'                                        )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6890
                    ('Tools'            tools                   )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6891
                    ('Font...'           changeFont             )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6892
                    ('Insert Unicode...' insertUnicode )
6599
c74062ad83c7 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6586
diff changeset
  6893
            ).        
4213
6045bffe7299 changed: #editMenu
Claus Gittinger <cg@exept.de>
parents: 4199
diff changeset
  6894
    CharacterSetView notNil ifTrue:[
5826
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6895
        items := items ,
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6896
                    #(
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6897
                        ('Special Characters...'    specialCharacters  OpenSpecialCharacterWindow )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6898
                    ).
4213
6045bffe7299 changed: #editMenu
Claus Gittinger <cg@exept.de>
parents: 4199
diff changeset
  6899
    ].
6599
c74062ad83c7 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6586
diff changeset
  6900
    self showLineLimitInMenu ifTrue:[
c74062ad83c7 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6586
diff changeset
  6901
        items := items ,
c74062ad83c7 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6586
diff changeset
  6902
                    #(
c74062ad83c7 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6586
diff changeset
  6903
                        ('Set Line Limit...'               doSetLineLimit                         )
c74062ad83c7 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6586
diff changeset
  6904
                    ).
c74062ad83c7 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6586
diff changeset
  6905
    ].                                
c74062ad83c7 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6586
diff changeset
  6906
4213
6045bffe7299 changed: #editMenu
Claus Gittinger <cg@exept.de>
parents: 4199
diff changeset
  6907
    items := items , #(
5826
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6908
                    ('-'                                        )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6909
                    ('Save As...'       save           SaveAs   )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6910
                    ('Print'            doPrint        Print    )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6911
                    ('='                                        )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6912
                    ('Misc'             misc           ShiftCtrl) ).
2460
Claus Gittinger <cg@exept.de>
parents: 2438
diff changeset
  6913
2866
9dd71df46f73 specialCharacters menu item
Claus Gittinger <cg@exept.de>
parents: 2857
diff changeset
  6914
    miscItems := #(
5826
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6915
                    ('AutoIndent \c'    autoIndent:                  ToggleAutoIndent )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6916
                    ('InsertMode \c'    insertMode:                  ToggleInsertMode )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6917
                    ('-'                                        )
6134
97a51db349db #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6096
diff changeset
  6918
                    ('Copy Box'         copySelectionBox             CopyBox )
97a51db349db #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6096
diff changeset
  6919
                    ('Paste Box'        pasteOrReplaceBox            PasteBox )
5826
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6920
                    ('Paste Previous...'   pasteOrReplaceFromHistory PasteFromHistory )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6921
                    ('Join Lines'       joinLines                    Join )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6922
                    ('Wrap Lines...'    wrapLines                    Wrap )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6923
                    ('-'                                        )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6924
                    ('Learn Macro'      learnMode:                   LearnKeyboardMacro)
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6925
                    ('Execute Macro'    executeLearnedKeyboardMacro  ExecuteKeyboardMacro )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6926
                    ('-'                                        )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6927
                    ('Insert File...'           insertFile          )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6928
                    ('Insert URL Contents...'   insertURL           )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6929
                    ('Insert new UUID'      insertUUID          )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6930
                    ('Insert Date && Time'  insertDateAndTime   )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6931
                    ('-'                                        )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6932
                    ('Insert File as String Literal...' insertFileAsStringLiteral  )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6933
                    ('Paste as String Literal'          pasteAsStringLiteral       )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6934
                ).
4213
6045bffe7299 changed: #editMenu
Claus Gittinger <cg@exept.de>
parents: 4199
diff changeset
  6935
"/    CharacterSetView notNil ifTrue:[
6045bffe7299 changed: #editMenu
Claus Gittinger <cg@exept.de>
parents: 4199
diff changeset
  6936
"/        miscItems := miscItems ,
6045bffe7299 changed: #editMenu
Claus Gittinger <cg@exept.de>
parents: 4199
diff changeset
  6937
"/                    #(
5529
0b33c7ac879d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 5525
diff changeset
  6938
"/                        ('-'                                        )
4213
6045bffe7299 changed: #editMenu
Claus Gittinger <cg@exept.de>
parents: 4199
diff changeset
  6939
"/                        ('Special Characters...'    specialCharacters  OpenSpecialCharacterWindow )
5529
0b33c7ac879d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 5525
diff changeset
  6940
"/                        ('Font...'                  changeFont              )
4213
6045bffe7299 changed: #editMenu
Claus Gittinger <cg@exept.de>
parents: 4199
diff changeset
  6941
"/                    ).
5529
0b33c7ac879d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 5525
diff changeset
  6942
"/    ] ifFalse:[
0b33c7ac879d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 5525
diff changeset
  6943
"/        miscItems := miscItems ,
0b33c7ac879d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 5525
diff changeset
  6944
"/                #(
0b33c7ac879d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 5525
diff changeset
  6945
"/                    ('Font...'                  changeFont              )
0b33c7ac879d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 5525
diff changeset
  6946
"/"/                    ('Encoding...'      changeEncoding          )
0b33c7ac879d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 5525
diff changeset
  6947
"/                ).
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  6948
"/    ].
2866
9dd71df46f73 specialCharacters menu item
Claus Gittinger <cg@exept.de>
parents: 2857
diff changeset
  6949
2680
208d99c47d7c babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents: 2677
diff changeset
  6950
    translateItems := #(
5826
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6951
                    ('English -> German'      (babelFishTranslate: 'en_de')   )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6952
                    ('English -> French'      (babelFishTranslate: 'en_fr')   )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6953
                    ('English -> Italian'     (babelFishTranslate: 'en_it')   )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6954
                    ('English -> Spanish'     (babelFishTranslate: 'en_es')   )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6955
                    ('English -> Portuguese'  (babelFishTranslate: 'en_pt')   )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6956
                    ('-'                                        )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6957
                    ('German -> English'      (babelFishTranslate: 'de_en')   )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6958
                    ('French -> English'      (babelFishTranslate: 'fr_en')   )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6959
                    ('Italian -> English'     (babelFishTranslate: 'it_en')   )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6960
                    ('Spanish -> English'     (babelFishTranslate: 'es_en')   )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6961
                    ('Portuguese -> English'  (babelFishTranslate: 'pt_en')   )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6962
              ).
3221
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  6963
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  6964
    sortItems := #(
5826
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6965
                    ('Lines'                            (sortSelection:ignoreCase: #lines false)        )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6966
                    ('Lines by First Word'              (sortSelection:ignoreCase: #linesByFirstWord false)     )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6967
                    ('Lines by n''th Word'              (sortSelection:ignoreCase: #linesByNthWord false)       )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6968
                    ('Lines by n''th Number'            (sortSelection:ignoreCase: #linesByNthNumber false)     )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6969
                    ('Lines by n''th Hex Number'        (sortSelection:ignoreCase: #linesByNthHexNumber false)     )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6970
                    ('Words'                            (sortSelection:ignoreCase: #words false)        )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6971
                    ('-'                                                      )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6972
                    ('Lines (ignore case)'               (sortSelection:ignoreCase: #lines true)         )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6973
                    ('Lines by First Word (ignore case)' (sortSelection:ignoreCase: #linesByFirstWord true)      )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6974
                    ('Lines by n''th Word (ignore case)' (sortSelection:ignoreCase: #linesByNthWord true)        )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6975
                    ('Words (ignore case)'               (sortSelection:ignoreCase: #words true)         )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6976
                    ('-'                                                      )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6977
                    ('By Line Length'                    (sortSelection:ignoreCase: #linesByLength nil)         )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6978
                    ('Reverse'                           (sortSelection:ignoreCase: #reverse       nil)         )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6979
              ).
2680
208d99c47d7c babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents: 2677
diff changeset
  6980
2762
e29673db4ddb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2757
diff changeset
  6981
    toolItems := #(
5826
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6982
                    ('Indent'                      indent                     )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6983
                    ('Toggle Case'      convertSelectionToLowercaseOrUppercaseOrUppercaseFirst   ConvertSelectionToLowercaseOrUppercaseOrUppercaseFirst)
6241
ca8af4b44137 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6232
diff changeset
  6984
                    ('Sort'                        sortMenu                       )
5826
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6985
                    ('Split...'                    splitLinesAtCharacterOrString )
6241
ca8af4b44137 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6232
diff changeset
  6986
                    ('Convert...'                  convertMenu )
5826
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6987
                    ('-'                                                      )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6988
                    ('Google Spell Check'          googleSpellingSuggestion   )
6241
ca8af4b44137 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6232
diff changeset
  6989
                    ('Builtin Spell Check'         internalSpellingSuggestion )
ca8af4b44137 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6232
diff changeset
  6990
                    ('Translate'                   babelFishTranslateMenu     )
5826
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6991
                    ('Compare with Clipboard...'   compareWithClipboard       )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6992
                    ('Compare with File...'        compareWithFile            )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6993
              ).
2762
e29673db4ddb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2757
diff changeset
  6994
6241
ca8af4b44137 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6232
diff changeset
  6995
    convertItems := #(
ca8af4b44137 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6232
diff changeset
  6996
                    ('Base64 Decode'               selectionDecodeBase64     )
ca8af4b44137 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6232
diff changeset
  6997
                    ('Base64 Encode'               selectionEncodeBase64     )
ca8af4b44137 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6232
diff changeset
  6998
                    ('Rot13'                       selectionRot13            )
ca8af4b44137 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6232
diff changeset
  6999
              ).
ca8af4b44137 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6232
diff changeset
  7000
6359
7c4a24875876 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6354
diff changeset
  7001
    toolItems := toolItems , #(
7c4a24875876 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6354
diff changeset
  7002
                    ('-'                                                      )
7c4a24875876 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6354
diff changeset
  7003
                    ('Open FileBrowser on It'      openFileBrowserOnIt        )
7c4a24875876 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6354
diff changeset
  7004
                    ('Open WebBrowser on It'       openWebBrowserOnIt         )
7c4a24875876 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6354
diff changeset
  7005
              ).
7c4a24875876 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6354
diff changeset
  7006
3623
f99c70d99425 close door to fileBrowser and workspace
Claus Gittinger <cg@exept.de>
parents: 3595
diff changeset
  7007
    Smalltalk isStandAloneApp ifFalse:[
5826
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  7008
        toolItems := toolItems , #(
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  7009
                        ('-'                                                      )
6564
60c2954e9dff #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6563
diff changeset
  7010
                        ('Open Workspace with It'      openWorkspaceWithIt        OpenWorkspaceOnIt)
5826
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  7011
                        ('Inspect Selected String'     inspectSelectedString      )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  7012
                  ).
3623
f99c70d99425 close door to fileBrowser and workspace
Claus Gittinger <cg@exept.de>
parents: 3595
diff changeset
  7013
    ].
f99c70d99425 close door to fileBrowser and workspace
Claus Gittinger <cg@exept.de>
parents: 3595
diff changeset
  7014
2460
Claus Gittinger <cg@exept.de>
parents: 2438
diff changeset
  7015
    sub := PopUpMenu itemList:items resources:resources performer:model.
2461
54d220735048 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2460
diff changeset
  7016
    sub receiver:self.
2460
Claus Gittinger <cg@exept.de>
parents: 2438
diff changeset
  7017
6241
ca8af4b44137 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6232
diff changeset
  7018
    toolSubMenu := PopUpMenu itemList:toolItems resources:resources performer:model.
ca8af4b44137 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6232
diff changeset
  7019
    toolSubMenu receiver:self.
ca8af4b44137 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6232
diff changeset
  7020
    sub subMenuAt:#tools put:toolSubMenu.
ca8af4b44137 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6232
diff changeset
  7021
ca8af4b44137 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6232
diff changeset
  7022
    transSubMenu := PopUpMenu itemList:translateItems resources:resources performer:model.
ca8af4b44137 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6232
diff changeset
  7023
    transSubMenu receiver:self.
ca8af4b44137 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6232
diff changeset
  7024
    toolSubMenu subMenuAt:#babelFishTranslateMenu put:transSubMenu.
ca8af4b44137 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6232
diff changeset
  7025
ca8af4b44137 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6232
diff changeset
  7026
    sortSubMenu := PopUpMenu itemList:sortItems resources:resources performer:model.
ca8af4b44137 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6232
diff changeset
  7027
    sortSubMenu receiver:self.
ca8af4b44137 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6232
diff changeset
  7028
    toolSubMenu subMenuAt:#sortMenu put:sortSubMenu.
ca8af4b44137 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6232
diff changeset
  7029
ca8af4b44137 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6232
diff changeset
  7030
    convertSubMenu := PopUpMenu itemList:convertItems resources:resources performer:model.
ca8af4b44137 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6232
diff changeset
  7031
    convertSubMenu receiver:self.
ca8af4b44137 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6232
diff changeset
  7032
    toolSubMenu subMenuAt:#convertMenu put:convertSubMenu.
ca8af4b44137 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6232
diff changeset
  7033
ca8af4b44137 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6232
diff changeset
  7034
    subSubMenu := PopUpMenu itemList:miscItems resources:resources performer:model.
ca8af4b44137 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6232
diff changeset
  7035
    subSubMenu receiver:self.
6614
228cd1c3eac9 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6613
diff changeset
  7036
    subSubMenu checkToggleAt:#autoIndent: put:(self autoIndent).
6241
ca8af4b44137 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6232
diff changeset
  7037
    subSubMenu checkToggleAt:#insertMode: put:(self isInInsertMode).
ca8af4b44137 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6232
diff changeset
  7038
    subSubMenu checkToggleAt:#learnMode: put:(self learnModeHolder value).
ca8af4b44137 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6232
diff changeset
  7039
ca8af4b44137 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6232
diff changeset
  7040
    sub subMenuAt:#misc put:subSubMenu.
2866
9dd71df46f73 specialCharacters menu item
Claus Gittinger <cg@exept.de>
parents: 2857
diff changeset
  7041
3495
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  7042
    mainItems := #(
5826
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  7043
                    ('Undo'    undo             Undo   )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  7044
                    ('Again'   again            Again  )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  7045
                    ('-'                               )
6134
97a51db349db #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6096
diff changeset
  7046
                    ('Cut'     cut              Cut    )).
6586
066c7ebceb05 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 6572
diff changeset
  7047
    (self sensor metaDown or:[self sensor altDown]) ifTrue:[
6134
97a51db349db #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6096
diff changeset
  7048
        mainItems := mainItems , #(
97a51db349db #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6096
diff changeset
  7049
                    ('Copy Box'    copySelectionBox    CopyBox   )
97a51db349db #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6096
diff changeset
  7050
                    ('Paste Box'   pasteOrReplaceBox   PasteBox  ))
97a51db349db #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6096
diff changeset
  7051
    ] ifFalse:[    
97a51db349db #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6096
diff changeset
  7052
        mainItems := mainItems , #(
6586
066c7ebceb05 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 6572
diff changeset
  7053
                      ('Copy'      copySelection    Copy   )
066c7ebceb05 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 6572
diff changeset
  7054
                      ('Paste'     pasteOrReplace   Paste  )
6477
9fb3de4fdc0f #UI_ENHANCEMENT by cgexept.de
Claus Gittinger <cg@exept.de>
parents: 6469
diff changeset
  7055
                      ('Paste...'  pasteOrReplaceFromHistory PasteFromHistory ))
6134
97a51db349db #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6096
diff changeset
  7056
    ].
97a51db349db #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6096
diff changeset
  7057
    mainItems := mainItems , #(
5826
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  7058
                    ('-'                               )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  7059
                    ('Accept'  accept           Accept )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  7060
                    ('='                               )
6134
97a51db349db #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6096
diff changeset
  7061
                    ('More'    others           Ctrl   )).
97a51db349db #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6096
diff changeset
  7062
3495
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  7063
    main := PopUpMenu itemList:mainItems resources:resources.
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  7064
    main subMenuAt:#others put:sub.
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  7065
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  7066
    sensor := self sensor.
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  7067
    (sensor notNil and:[sensor ctrlDown]) ifTrue:[
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  7068
       sensor shiftDown ifTrue:[
6241
ca8af4b44137 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6232
diff changeset
  7069
            m := subSubMenu
5826
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  7070
        ] ifFalse:[
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  7071
            m := sub
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  7072
        ]
428
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  7073
    ] ifFalse:[
5826
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  7074
        m := main
428
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  7075
    ].
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  7076
4742
a00cb40ee392 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4738
diff changeset
  7077
    "/ the 'Smalltalk at:' code is here to
a00cb40ee392 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4738
diff changeset
  7078
    "/ avoid making the SOAP package a prerequisite for this package (libwidg)
4373
22fb03e6d08a class definition
Claus Gittinger <cg@exept.de>
parents: 4371
diff changeset
  7079
    (Smalltalk at:#'SOAP::GoogleClient') isNil ifTrue:[
5826
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  7080
        "/ GoogleClient new spellingSuggestionOf: 'Smmalltlaak and Soaap'.
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  7081
        m disable:#googleSpellingSuggestion
2676
cc61fa88a3fb google spelling;
Claus Gittinger <cg@exept.de>
parents: 2660
diff changeset
  7082
    ].
4742
a00cb40ee392 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4738
diff changeset
  7083
    (Smalltalk at:#'RBSpellChecker') isNil ifTrue:[
5826
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  7084
        m disable:#internalSpellingSuggestion
4742
a00cb40ee392 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4738
diff changeset
  7085
    ].
2676
cc61fa88a3fb google spelling;
Claus Gittinger <cg@exept.de>
parents: 2660
diff changeset
  7086
3811
a56e6f74ee4d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3801
diff changeset
  7087
    HTTPInterface isNil ifTrue:[
5826
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  7088
        m disableAll:#(insertURL)
3811
a56e6f74ee4d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3801
diff changeset
  7089
    ].
a56e6f74ee4d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3801
diff changeset
  7090
1733
c5139b7402f0 use self isReadonly; readOnly may now be a valueHolder.
Claus Gittinger <cg@exept.de>
parents: 1732
diff changeset
  7091
    self isReadOnly ifTrue:[
5826
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  7092
        m disableAll:#(accept undo again multipleAgain redo
6134
97a51db349db #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6096
diff changeset
  7093
                       paste pasteOrReplace pasteOrReplaceBox pasteOrReplaceFromHistory
5826
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  7094
                       cut indent autoIndent: insertMode:
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  7095
                       insertFile insertFileAsStringLiteral insertURL
6241
ca8af4b44137 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6232
diff changeset
  7096
                       babelFishTranslateMenu googleSpellingSuggestion sortMenu
5826
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  7097
                       convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
6228
4b49d1ffff92 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6227
diff changeset
  7098
                       splitLinesAtCharacterOrString
5826
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  7099
                       joinLines wrapLines insertUUID insertDateAndTime pasteAsStringLiteral
6241
ca8af4b44137 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6232
diff changeset
  7100
                       insertUnicode specialCharacters convertMenu)
428
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  7101
    ].
2817
7c82a9535b96 not ifTrue -> ifFalse
Claus Gittinger <cg@exept.de>
parents: 2815
diff changeset
  7102
    self hasSelectionForCopy ifFalse:[
5826
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  7103
        m disable:#copySelection.
6134
97a51db349db #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6096
diff changeset
  7104
        m disable:#copySelectionBox.
428
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  7105
    ].
2416
56acdd9e31b5 lifted mkeyboardMacro handling from Workspace to EditTextView
Claus Gittinger <cg@exept.de>
parents: 2406
diff changeset
  7106
    self hasSelection ifFalse:[
6241
ca8af4b44137 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6232
diff changeset
  7107
        m disableAll:#(cut googleSpellingSuggestion babelFishTranslateMenu openFileBrowserOnIt
6359
7c4a24875876 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6354
diff changeset
  7108
                       openWebBrowserOnIt
6241
ca8af4b44137 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6232
diff changeset
  7109
                       openWorkspaceWithIt sortMenu indent splitLinesAtCharacterOrString inspectSelectedString
ca8af4b44137 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6232
diff changeset
  7110
                       convertMenu).
2762
e29673db4ddb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2757
diff changeset
  7111
    ] ifTrue:[
5826
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  7112
        (Error handle:[:ex |
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  7113
            ex return:false
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  7114
        ] do:[
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  7115
            |fn|
6374
bbde223c59ec #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6359
diff changeset
  7116
            fn := self selectionAsString withoutSeparators.
bbde223c59ec #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6359
diff changeset
  7117
            fn asFilename exists or:[ fn withoutQuotes asFilename exists ]
5826
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  7118
        ]) ifFalse:[
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  7119
            m disableAll:#(openFileBrowserOnIt).
6359
7c4a24875876 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6354
diff changeset
  7120
        ].
7c4a24875876 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6354
diff changeset
  7121
        (Error handle:[:ex |
7c4a24875876 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6354
diff changeset
  7122
            ex return:false
7c4a24875876 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6354
diff changeset
  7123
        ] do:[
6374
bbde223c59ec #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6359
diff changeset
  7124
            |url|
bbde223c59ec #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6359
diff changeset
  7125
            url := self selectionAsString withoutSeparators.
bbde223c59ec #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6359
diff changeset
  7126
            #('http' 'https' 'ftp') includes:url asURL method
6359
7c4a24875876 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6354
diff changeset
  7127
        ]) ifFalse:[
7c4a24875876 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6354
diff changeset
  7128
            m disableAll:#(openWebBrowserOnIt).
5826
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  7129
        ]
428
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  7130
    ].
2569
b499c81c58ae added hasUndoAction query.
Claus Gittinger <cg@exept.de>
parents: 2560
diff changeset
  7131
    self hasUndoAction ifFalse:[
5826
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  7132
        m disable:#undo.
3115
b75128334006 info string in undo
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
  7133
    ] ifTrue:[
5826
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  7134
        what := undoSupport undoActionInfo.
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  7135
        what notNil ifTrue:[
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  7136
            undoIdx := m indexOf:#undo.
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  7137
            m labelAt:undoIdx put:(resources string:'Undo (%1)' with:what).
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  7138
        ]
1818
aa16d9b96e40 fixed cut to not compress multiple blanks.
Claus Gittinger <cg@exept.de>
parents: 1817
diff changeset
  7139
    ].
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  7140
    self hasRedoAction ifFalse:[
5826
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  7141
        sub disable:#redo.
3569
d3eec21d0ece also show \"what-would-be-done\" in redo item
Claus Gittinger <cg@exept.de>
parents: 3566
diff changeset
  7142
    ] ifTrue:[
5826
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  7143
        what := undoSupport redoActionInfo.
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  7144
        what notNil ifTrue:[
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  7145
            redoIdx := sub indexOf:#redo.
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  7146
            sub labelAt:redoIdx put:(resources string:'Redo (%1)' with:what).
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  7147
        ]
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  7148
    ].
5216
8d6eef5d09c3 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5194
diff changeset
  7149
    self canAccept ifFalse:[
5826
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  7150
        m disable:#accept
1108
3d14bb6bceb7 added disableAccept
Claus Gittinger <cg@exept.de>
parents: 1082
diff changeset
  7151
    ].
428
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  7152
    ^ m.
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  7153
6241
ca8af4b44137 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6232
diff changeset
  7154
    "Modified: / 30-11-2017 / 15:06:03 / cg"
6614
228cd1c3eac9 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6613
diff changeset
  7155
    "Modified: / 26-06-2019 / 23:17:26 / Claus Gittinger"
428
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  7156
!
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  7157
2544
48ab4ed67816 shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  7158
getTextSelectionFromHistory
6328
d3e900c5526f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 6314
diff changeset
  7159
    "present the copyBufferHistory as a shortened list (first line of each),
d3e900c5526f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 6314
diff changeset
  7160
     and let user select from it.
d3e900c5526f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 6314
diff changeset
  7161
     Return the corresponding copyBuffer text or nil.
d3e900c5526f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 6314
diff changeset
  7162
     Used with 'Paste Previous' menu function"
d3e900c5526f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 6314
diff changeset
  7163
     
d3e900c5526f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 6314
diff changeset
  7164
    |sel listOfPasteTextLines box history|
2544
48ab4ed67816 shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  7165
5643
921578f80870 device access
Claus Gittinger <cg@exept.de>
parents: 5593
diff changeset
  7166
    history := device getCopyBufferHistory copy.
6452
180a72d98a19 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6436
diff changeset
  7167
180a72d98a19 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6436
diff changeset
  7168
    "/ the list presents each first line only
6328
d3e900c5526f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 6314
diff changeset
  7169
    listOfPasteTextLines := 
d3e900c5526f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 6314
diff changeset
  7170
        history collect:[:entry |
d3e900c5526f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 6314
diff changeset
  7171
            |text shown|
d3e900c5526f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 6314
diff changeset
  7172
d3e900c5526f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 6314
diff changeset
  7173
            text := entry asString string asCollectionOfLines.
d3e900c5526f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 6314
diff changeset
  7174
            shown := text detect:[:line| line notEmptyOrNil] ifNone:['      '].
d3e900c5526f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 6314
diff changeset
  7175
            text size > 1 ifTrue:[
d3e900c5526f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 6314
diff changeset
  7176
                shown := shown,(resources string:' ... [%1 lines]' with:text size).
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7177
            ].
6328
d3e900c5526f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 6314
diff changeset
  7178
            shown
d3e900c5526f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 6314
diff changeset
  7179
        ].
4165
869b207a6964 changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents: 4162
diff changeset
  7180
2544
48ab4ed67816 shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  7181
    box := ListSelectionBox
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7182
                title:(resources string:'Clipboard History')
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7183
                okText:(resources string:'Paste')
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7184
                abortText:(resources string:'Cancel')
6328
d3e900c5526f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 6314
diff changeset
  7185
                list:listOfPasteTextLines
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7186
                action:[:idx | idx notNil ifTrue:[sel := history at:idx]].
4165
869b207a6964 changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents: 4162
diff changeset
  7187
    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
  7188
    box useIndex:true.
48ab4ed67816 shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  7189
    box show.
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  7190
    ^ sel.
4165
869b207a6964 changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents: 4162
diff changeset
  7191
869b207a6964 changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents: 4162
diff changeset
  7192
    "Modified: / 25-08-2010 / 22:02:14 / cg"
6328
d3e900c5526f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 6314
diff changeset
  7193
    "Modified (format): / 27-05-2018 / 10:24:58 / Claus Gittinger"
2544
48ab4ed67816 shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  7194
!
48ab4ed67816 shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  7195
48ab4ed67816 shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  7196
getTextSelectionOrTextSelectionFromHistory
2730
61a2f1981ac6 Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents: 2725
diff changeset
  7197
61a2f1981ac6 Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents: 2725
diff changeset
  7198
    self sensor shiftDown ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7199
        ^ self getTextSelectionFromHistory
2544
48ab4ed67816 shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  7200
    ].
2724
23f4e16dc4f4 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2720
diff changeset
  7201
4285
8487c7a8fab0 changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents: 4275
diff changeset
  7202
    "/ return either the (xterm-) selection or the clipBoard depending on
8487c7a8fab0 changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents: 4275
diff changeset
  7203
    "/ the Ctrl-Key state.
8487c7a8fab0 changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents: 4275
diff changeset
  7204
8487c7a8fab0 changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents: 4275
diff changeset
  7205
    "/ ouch - this used to be ok for ALT-c / ALT-v,
8487c7a8fab0 changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents: 4275
diff changeset
  7206
    "/ but no longer works with CTRL-c / CTRL-v.
8487c7a8fab0 changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents: 4275
diff changeset
  7207
    ^ self getClipboardText:#clipboard
8487c7a8fab0 changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents: 4275
diff changeset
  7208
8487c7a8fab0 changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents: 4275
diff changeset
  7209
"/    ^ self
8487c7a8fab0 changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents: 4275
diff changeset
  7210
"/        getClipboardText:(self sensor ctrlDown
8487c7a8fab0 changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents: 4275
diff changeset
  7211
"/                            ifTrue:[#selection]
8487c7a8fab0 changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents: 4275
diff changeset
  7212
"/                            ifFalse:[#clipboard])
8487c7a8fab0 changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents: 4275
diff changeset
  7213
8487c7a8fab0 changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents: 4275
diff changeset
  7214
    "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
  7215
!
48ab4ed67816 shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  7216
2676
cc61fa88a3fb google spelling;
Claus Gittinger <cg@exept.de>
parents: 2660
diff changeset
  7217
googleSpellingSuggestion
cc61fa88a3fb google spelling;
Claus Gittinger <cg@exept.de>
parents: 2660
diff changeset
  7218
    "insert the google-spelling suggestion for the selected text.
cc61fa88a3fb google spelling;
Claus Gittinger <cg@exept.de>
parents: 2660
diff changeset
  7219
     Requires that the SOAP stuff is loaded and working."
cc61fa88a3fb google spelling;
Claus Gittinger <cg@exept.de>
parents: 2660
diff changeset
  7220
2677
afb234f8b822 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2676
diff changeset
  7221
    |text suggestion|
2676
cc61fa88a3fb google spelling;
Claus Gittinger <cg@exept.de>
parents: 2660
diff changeset
  7222
cc61fa88a3fb google spelling;
Claus Gittinger <cg@exept.de>
parents: 2660
diff changeset
  7223
    self withWaitCursorDo:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7224
        text := self selection asString string withoutSeparators.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7225
        text size == 0 ifTrue:[^ self].
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7226
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7227
        "/ the 'Smalltalk at:' code is here to
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7228
        "/ avoid making the SOAP package a prerequisite for this package (libwidg)
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7229
        (Smalltalk at:#'SOAP::SoapImplError') handle:[:ex |
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7230
            Dialog warn:('Spelling correction failed - WEB Service error:\\%1.' bindWith:ex description allBold) withCRs.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7231
            ^ self.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7232
        ] do:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7233
            suggestion := (Smalltalk at:#'SOAP::GoogleClient') new spellingSuggestionOf:text.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7234
        ].
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7235
        suggestion size == 0 ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7236
            self information:('No spelling suggestion from Google for: ' , text).
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7237
            Transcript showCR:('No spelling suggestion from Google for: ' , text).
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7238
            ^ self.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7239
        ].
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7240
    ].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7241
    self
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7242
        undoablePaste:suggestion
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7243
        info:'Spelling Suggestion'.
3495
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  7244
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  7245
    "Modified: / 28-07-2007 / 13:25:10 / cg"
2676
cc61fa88a3fb google spelling;
Claus Gittinger <cg@exept.de>
parents: 2660
diff changeset
  7246
!
cc61fa88a3fb google spelling;
Claus Gittinger <cg@exept.de>
parents: 2660
diff changeset
  7247
3595
9277e3a4d2e9 paste date and time added
Claus Gittinger <cg@exept.de>
parents: 3583
diff changeset
  7248
insertDateAndTime
6274
18d07b563ab9 #DOCUMENTATION by mawalch
mawalch
parents: 6270
diff changeset
  7249
    "insert the current date and time string"
3595
9277e3a4d2e9 paste date and time added
Claus Gittinger <cg@exept.de>
parents: 3583
diff changeset
  7250
9277e3a4d2e9 paste date and time added
Claus Gittinger <cg@exept.de>
parents: 3583
diff changeset
  7251
    typeOfSelection := nil.
3683
5891af82a177 middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents: 3650
diff changeset
  7252
    self
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7253
        undoableDo:[ self pasteOrReplace:(Timestamp now printStringRFC1123Format)]
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7254
        info:'Paste Date and Time'
6274
18d07b563ab9 #DOCUMENTATION by mawalch
mawalch
parents: 6270
diff changeset
  7255
18d07b563ab9 #DOCUMENTATION by mawalch
mawalch
parents: 6270
diff changeset
  7256
    "Modified (comment): / 25-01-2018 / 19:10:40 / mawalch"
3595
9277e3a4d2e9 paste date and time added
Claus Gittinger <cg@exept.de>
parents: 3583
diff changeset
  7257
!
9277e3a4d2e9 paste date and time added
Claus Gittinger <cg@exept.de>
parents: 3583
diff changeset
  7258
2676
cc61fa88a3fb google spelling;
Claus Gittinger <cg@exept.de>
parents: 2660
diff changeset
  7259
insertFile
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  7260
    "insert contents of a file
2676
cc61fa88a3fb google spelling;
Claus Gittinger <cg@exept.de>
parents: 2660
diff changeset
  7261
     - ask user for filename using a fileSelectionBox."
cc61fa88a3fb google spelling;
Claus Gittinger <cg@exept.de>
parents: 2660
diff changeset
  7262
3731
041b0c7ad557 +insert as literal
Claus Gittinger <cg@exept.de>
parents: 3725
diff changeset
  7263
    self insertFileAsStringLiteral:false
041b0c7ad557 +insert as literal
Claus Gittinger <cg@exept.de>
parents: 3725
diff changeset
  7264
!
041b0c7ad557 +insert as literal
Claus Gittinger <cg@exept.de>
parents: 3725
diff changeset
  7265
041b0c7ad557 +insert as literal
Claus Gittinger <cg@exept.de>
parents: 3725
diff changeset
  7266
insertFileAsStringLiteral
041b0c7ad557 +insert as literal
Claus Gittinger <cg@exept.de>
parents: 3725
diff changeset
  7267
    "insert a file's contents as a string literal.
041b0c7ad557 +insert as literal
Claus Gittinger <cg@exept.de>
parents: 3725
diff changeset
  7268
     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
  7269
     to make it a legal string literal"
041b0c7ad557 +insert as literal
Claus Gittinger <cg@exept.de>
parents: 3725
diff changeset
  7270
041b0c7ad557 +insert as literal
Claus Gittinger <cg@exept.de>
parents: 3725
diff changeset
  7271
    self insertFileAsStringLiteral:true
041b0c7ad557 +insert as literal
Claus Gittinger <cg@exept.de>
parents: 3725
diff changeset
  7272
!
041b0c7ad557 +insert as literal
Claus Gittinger <cg@exept.de>
parents: 3725
diff changeset
  7273
041b0c7ad557 +insert as literal
Claus Gittinger <cg@exept.de>
parents: 3725
diff changeset
  7274
insertFileAsStringLiteral:asStringLiteral
041b0c7ad557 +insert as literal
Claus Gittinger <cg@exept.de>
parents: 3725
diff changeset
  7275
    "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
  7276
     - ask user for filename using a fileSelectionBox."
041b0c7ad557 +insert as literal
Claus Gittinger <cg@exept.de>
parents: 3725
diff changeset
  7277
3409
d650e3ae9085 insert-file menu item cares for current selection being a filename
Claus Gittinger <cg@exept.de>
parents: 3406
diff changeset
  7278
    |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
  7279
d650e3ae9085 insert-file menu item cares for current selection being a filename
Claus Gittinger <cg@exept.de>
parents: 3406
diff changeset
  7280
    ((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
  7281
    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
  7282
    and:[ selFn isRegularFile ]])
d650e3ae9085 insert-file menu item cares for current selection being a filename
Claus Gittinger <cg@exept.de>
parents: 3406
diff changeset
  7283
    ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7284
        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
  7285
    ].
2757
b98097eaf8dc Stc cannot handle thisContext restart in true-Block.
Stefan Vogel <sv@exept.de>
parents: 2756
diff changeset
  7286
b98097eaf8dc Stc cannot handle thisContext restart in true-Block.
Stefan Vogel <sv@exept.de>
parents: 2756
diff changeset
  7287
    [
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7288
        |why|
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7289
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7290
        file := Dialog
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7291
            requestFileName:(resources string:'Insert Contents Of:')
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7292
            default:initial
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7293
            ok:(resources string:'Insert')
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7294
            abort:(resources string:'Cancel')
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7295
            pattern:nil
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7296
            fromDirectory:directoryForFileDialog.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7297
        file isNil ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7298
            "cancel"
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7299
            ^ self.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7300
        ].
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7301
        file := file asFilename.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7302
        directoryForFileDialog := file.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7303
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7304
        ok := file isReadable and:[file isDirectory not].
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7305
        ok ifFalse:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7306
            file isReadable ifFalse:[
6543
4007370ee6aa #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 6517
diff changeset
  7307
                why := '"%1" is unreadable.\\Please try again.'
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7308
            ] ifTrue:[
6543
4007370ee6aa #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 6517
diff changeset
  7309
                why := '"%1" is a directory.\\Please try again.'
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7310
            ].
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7311
            Dialog warn:(resources stringWithCRs:why with:file pathName).
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7312
        ].
2909
a43e1343718f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2901
diff changeset
  7313
    ] doUntil:[ok].
2757
b98097eaf8dc Stc cannot handle thisContext restart in true-Block.
Stefan Vogel <sv@exept.de>
parents: 2756
diff changeset
  7314
5063
103ce513648a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5060
diff changeset
  7315
    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
  7316
    self
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7317
        undoableDo:[ self paste:(asStringLiteral ifTrue:[text storeString] ifFalse:[text]) ]
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7318
        info:'Paste File'
3495
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  7319
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  7320
    "Modified: / 28-07-2007 / 13:23:32 / cg"
6543
4007370ee6aa #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 6517
diff changeset
  7321
    "Modified: / 21-02-2019 / 17:42:47 / Claus Gittinger"
3495
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  7322
!
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  7323
3811
a56e6f74ee4d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3801
diff changeset
  7324
insertURL
a56e6f74ee4d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3801
diff changeset
  7325
    "insert contents of a URL
a56e6f74ee4d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3801
diff changeset
  7326
     - ask user for URL using a dialog."
a56e6f74ee4d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3801
diff changeset
  7327
a56e6f74ee4d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3801
diff changeset
  7328
    self insertURLAsStringLiteral:false
a56e6f74ee4d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3801
diff changeset
  7329
!
a56e6f74ee4d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3801
diff changeset
  7330
a56e6f74ee4d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3801
diff changeset
  7331
insertURLAsStringLiteral:asStringLiteral
a56e6f74ee4d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3801
diff changeset
  7332
    "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
  7333
     - ask user for filename using a fileSelectionBox."
a56e6f74ee4d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3801
diff changeset
  7334
a56e6f74ee4d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3801
diff changeset
  7335
    |sel url text response initial|
a56e6f74ee4d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3801
diff changeset
  7336
a56e6f74ee4d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3801
diff changeset
  7337
    (sel := self selectionAsString) notEmptyOrNil
a56e6f74ee4d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3801
diff changeset
  7338
    ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7339
        initial := sel.
3811
a56e6f74ee4d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3801
diff changeset
  7340
    ].
a56e6f74ee4d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3801
diff changeset
  7341
a56e6f74ee4d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3801
diff changeset
  7342
    url := Dialog
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7343
        request:(resources string:'Insert Contents of URL:')
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7344
        initialAnswer:initial
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7345
        okLabel:(resources string:'Insert')
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7346
        title:(resources string:'URL').
3811
a56e6f74ee4d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3801
diff changeset
  7347
    url isNil ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7348
        "cancel"
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7349
        ^ self.
3811
a56e6f74ee4d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3801
diff changeset
  7350
    ].
6514
bc98c57dfaaa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6477
diff changeset
  7351
bc98c57dfaaa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6477
diff changeset
  7352
    self withWaitCursorDo:[
bc98c57dfaaa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6477
diff changeset
  7353
        response := HTTPInterface get:url.
bc98c57dfaaa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6477
diff changeset
  7354
    ].
3811
a56e6f74ee4d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3801
diff changeset
  7355
    response isErrorResponse ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7356
        Dialog warn:(resources string:'Could not fetch the document: %1' with:url).
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7357
        ^ self.
3811
a56e6f74ee4d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3801
diff changeset
  7358
    ].
a56e6f74ee4d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3801
diff changeset
  7359
    text := response data asString.
a56e6f74ee4d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3801
diff changeset
  7360
a56e6f74ee4d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3801
diff changeset
  7361
    self
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7362
        undoableDo:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7363
            self paste:(asStringLiteral ifTrue:[text storeString] ifFalse:[text])
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7364
        ]
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7365
        info:'Insert Contents of URL'
6514
bc98c57dfaaa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6477
diff changeset
  7366
bc98c57dfaaa #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6477
diff changeset
  7367
    "Modified: / 20-12-2018 / 10:27:46 / Claus Gittinger"
3811
a56e6f74ee4d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3801
diff changeset
  7368
!
a56e6f74ee4d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3801
diff changeset
  7369
3495
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  7370
insertUUID
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  7371
    "insert a new UUID's string"
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  7372
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  7373
    typeOfSelection := nil.
3683
5891af82a177 middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents: 3650
diff changeset
  7374
    self
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7375
        undoableDo:[ self pasteOrReplace:(UUID genUUID printString)]
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7376
        info:'Paste New UUID'
3495
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  7377
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  7378
    "Created: / 28-07-2007 / 13:01:16 / cg"
2676
cc61fa88a3fb google spelling;
Claus Gittinger <cg@exept.de>
parents: 2660
diff changeset
  7379
!
cc61fa88a3fb google spelling;
Claus Gittinger <cg@exept.de>
parents: 2660
diff changeset
  7380
4940
73e7031a4a85 class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 4889
diff changeset
  7381
insertUnicode
73e7031a4a85 class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 4889
diff changeset
  7382
    "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
  7383
73e7031a4a85 class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 4889
diff changeset
  7384
    |unicodePoint unicodeChar unicodeString|
73e7031a4a85 class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 4889
diff changeset
  7385
5904
76febd97d52d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5890
diff changeset
  7386
    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
  7387
    unicodeString size < 2 ifTrue:[
5904
76febd97d52d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5890
diff changeset
  7388
        ^ self.
4940
73e7031a4a85 class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 4889
diff changeset
  7389
    ].
73e7031a4a85 class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 4889
diff changeset
  7390
    (unicodeString second = $+ and:['Uu' includes:unicodeString first]) ifTrue:[
5904
76febd97d52d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5890
diff changeset
  7391
        unicodePoint := Integer readFrom:(unicodeString copyFrom:3) radix:16 onError:[^ self].
4940
73e7031a4a85 class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 4889
diff changeset
  7392
    ] ifFalse:[
5904
76febd97d52d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5890
diff changeset
  7393
        unicodePoint := Integer readFrom:unicodeString onError:[^ self].
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7394
    ].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7395
4940
73e7031a4a85 class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 4889
diff changeset
  7396
    unicodeChar := Character value:unicodePoint.
73e7031a4a85 class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 4889
diff changeset
  7397
    self keyPress:unicodeChar x:0 y:0.
73e7031a4a85 class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 4889
diff changeset
  7398
    self keyRelease:unicodeChar x:0 y:0.
73e7031a4a85 class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 4889
diff changeset
  7399
!
73e7031a4a85 class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 4889
diff changeset
  7400
5331
1d78ee0cb88b class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5325
diff changeset
  7401
inspectSelectedString
1d78ee0cb88b class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5325
diff changeset
  7402
    "inspect the selected text"
1d78ee0cb88b class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5325
diff changeset
  7403
1d78ee0cb88b class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5325
diff changeset
  7404
    self selectionAsString inspect.
1d78ee0cb88b class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5325
diff changeset
  7405
!
1d78ee0cb88b class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5325
diff changeset
  7406
4742
a00cb40ee392 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4738
diff changeset
  7407
internalSpellingSuggestion
a00cb40ee392 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4738
diff changeset
  7408
    "insert the internal-spelling suggestion for the selected text.
a00cb40ee392 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4738
diff changeset
  7409
     Requires that the RefactoryBrowser/line/spelCheck stuff is loaded."
a00cb40ee392 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4738
diff changeset
  7410
a00cb40ee392 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4738
diff changeset
  7411
    |text suggestions best|
a00cb40ee392 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4738
diff changeset
  7412
a00cb40ee392 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4738
diff changeset
  7413
    self withWaitCursorDo:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7414
        text := self selection asString string withoutSeparators.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7415
        text size == 0 ifTrue:[^ self].
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7416
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7417
        suggestions := RBSpellChecker default bestMatchesFor:text.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7418
        suggestions size == 0 ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7419
            self information:('No spelling suggestion from builtin checker for: ' , text).
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7420
            Transcript showCR:('No spelling suggestion from builtin checker for: ' , text).
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7421
            ^ self.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7422
        ].
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7423
        Transcript showCR:suggestions.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7424
        best := suggestions first.
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7425
    ].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7426
    self
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7427
        undoablePaste:best
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7428
        info:'Spelling Suggestion'.
4742
a00cb40ee392 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4738
diff changeset
  7429
!
a00cb40ee392 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4738
diff changeset
  7430
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  7431
paste
1289
e2dcc5fe612c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1287
diff changeset
  7432
    "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
  7433
     Then paste at cursor position."
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  7434
2989
5dcc2912bcb6 undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents: 2984
diff changeset
  7435
    self checkModificationsAllowed ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7436
        self withSelfAndTextForPasteDo:[:me :text |
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7437
            me unselect.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7438
            me undoablePaste:text
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7439
        ]
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  7440
    ]
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  7441
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  7442
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  7443
paste:someText
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  7444
    "paste someText at cursor"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  7445
3825
184c9b081973 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3816
diff changeset
  7446
    self paste:someText withCR:false
184c9b081973 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3816
diff changeset
  7447
!
184c9b081973 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3816
diff changeset
  7448
184c9b081973 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3816
diff changeset
  7449
paste:someText withCR:withCR
184c9b081973 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3816
diff changeset
  7450
    "paste someText at cursor"
184c9b081973 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3816
diff changeset
  7451
2856
bc6bb86d4d2e character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents: 2854
diff changeset
  7452
    |s nLines startLine startCol l1 l2 c1 c2 codingErrorReported|
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  7453
1480
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  7454
    self checkModificationsAllowed ifFalse:[^ self].
6399
b3bc4be4a579 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6390
diff changeset
  7455
    someText isEmptyOrNil ifTrue:[^ self].
2853
f8c1d3963b49 preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents: 2846
diff changeset
  7456
f8c1d3963b49 preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents: 2846
diff changeset
  7457
    s := someText.
2856
bc6bb86d4d2e character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents: 2854
diff changeset
  7458
    codingErrorReported := false.
bc6bb86d4d2e character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents: 2854
diff changeset
  7459
    CharacterEncoderError handle:[:ex |
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7460
        |code msg|
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7461
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7462
        code := ex parameter.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7463
        codingErrorReported ifFalse:[
6399
b3bc4be4a579 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6390
diff changeset
  7464
            msg := 'Cannot represent pasted string in this view''s encoding (',gc characterEncoding,').'.
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7465
            code notNil ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7466
                msg := msg , '\\Reason: No representation for ' , (code radixPrintStringRadix:16).
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7467
            ].
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7468
            Dialog warn:(resources stringWithCRs:msg).
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7469
            codingErrorReported := true.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7470
        ].
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7471
        ex proceedWith:ex defaultValue
2856
bc6bb86d4d2e character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents: 2854
diff changeset
  7472
    ] do:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7473
        s isString ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7474
            s encoding ~~ gc characterEncoding ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7475
                s := s encodeFrom:(s encoding) into:gc characterEncoding.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7476
            ].
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7477
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7478
            s := s asStringCollection.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7479
            (someText endsWith:Character cr) ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7480
                "/ s := s copyWith:nil.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7481
                s := s copyWith:'' "/ an empty line at the end
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7482
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7483
            ]
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7484
        ] ifFalse:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7485
            s isStringCollection ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7486
                s := s encodeFrom:(s encoding) into:gc characterEncoding.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7487
            ] ifFalse:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7488
                (self
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7489
                    confirm:(resources
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7490
                        stringWithCRs:'Selection (%1) is not convertable to Text.\\Paste storeString ?'
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7491
                        with:s class name)) ifFalse:[^ self].
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7492
                s := StringCollection with:s storeString .
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7493
                "/ ^ self
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7494
            ].
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7495
        ].
2856
bc6bb86d4d2e character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents: 2854
diff changeset
  7496
    ].
bc6bb86d4d2e character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents: 2854
diff changeset
  7497
2853
f8c1d3963b49 preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents: 2846
diff changeset
  7498
    (nLines := s size) == 0 ifTrue:[^ self].
f8c1d3963b49 preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents: 2846
diff changeset
  7499
    (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
  7500
f8c1d3963b49 preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents: 2846
diff changeset
  7501
    typeOfSelection := #paste.
f8c1d3963b49 preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents: 2846
diff changeset
  7502
f8c1d3963b49 preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents: 2846
diff changeset
  7503
    startLine := l1 := cursorLine.
f8c1d3963b49 preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents: 2846
diff changeset
  7504
    startCol := c1 := cursorCol.
3180
609f340fd96c paste - do not expand tabs!
Michael Beyl <mb@exept.de>
parents: 3161
diff changeset
  7505
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7506
    "do not autoindent here.
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7507
     It does make things very ugly, in the inspector
5194
24c790b5d279 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5153
diff changeset
  7508
     (try inspecting a multiline string)..."
24c790b5d279 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5153
diff changeset
  7509
    self withAutoIndent:false do:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7510
        "do not expand tabs into spaces here -
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7511
         they get expanded in basicWithoutRedrawInsertStringWithoutCRs:aString atLine:lineNr col:colNr.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7512
         Some Subviews want to paste with unexpanded tabs!!"
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7513
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7514
        self insertLines:s withCR:withCR.
5194
24c790b5d279 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5153
diff changeset
  7515
    ].
2853
f8c1d3963b49 preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents: 2846
diff changeset
  7516
    l2 := cursorLine.
f8c1d3963b49 preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents: 2846
diff changeset
  7517
    c2 := (cursorCol - 1).
f8c1d3963b49 preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents: 2846
diff changeset
  7518
    self selectFromLine:l1 col:c1 toLine:l2 col:c2.
f8c1d3963b49 preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents: 2846
diff changeset
  7519
    typeOfSelection := #paste. "/ sigh - cleared by #selectFromLine:
f8c1d3963b49 preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents: 2846
diff changeset
  7520
4328
ea91d179b5f0 changed:
Claus Gittinger <cg@exept.de>
parents: 4289
diff changeset
  7521
    "Modified: / 14-02-1996 / 11:14:14 / stefan"
4360
fe77e479d95a comment/format in:
Claus Gittinger <cg@exept.de>
parents: 4328
diff changeset
  7522
    "Modified: / 25-01-2012 / 00:31:30 / cg"
6399
b3bc4be4a579 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6390
diff changeset
  7523
    "Modified: / 22-08-2018 / 08:29:13 / Claus Gittinger"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  7524
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  7525
3731
041b0c7ad557 +insert as literal
Claus Gittinger <cg@exept.de>
parents: 3725
diff changeset
  7526
pasteAsStringLiteral
041b0c7ad557 +insert as literal
Claus Gittinger <cg@exept.de>
parents: 3725
diff changeset
  7527
    "insert clipboard string as a string literal.
041b0c7ad557 +insert as literal
Claus Gittinger <cg@exept.de>
parents: 3725
diff changeset
  7528
     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
  7529
     to make it a legal string literal"
041b0c7ad557 +insert as literal
Claus Gittinger <cg@exept.de>
parents: 3725
diff changeset
  7530
041b0c7ad557 +insert as literal
Claus Gittinger <cg@exept.de>
parents: 3725
diff changeset
  7531
    typeOfSelection := nil.
041b0c7ad557 +insert as literal
Claus Gittinger <cg@exept.de>
parents: 3725
diff changeset
  7532
    self
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7533
        undoableDo:[ self pasteOrReplace:(self getClipboardText asString string storeString) ]
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7534
        info:'Paste as String Literal'
3731
041b0c7ad557 +insert as literal
Claus Gittinger <cg@exept.de>
parents: 3725
diff changeset
  7535
!
041b0c7ad557 +insert as literal
Claus Gittinger <cg@exept.de>
parents: 3725
diff changeset
  7536
6134
97a51db349db #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6096
diff changeset
  7537
pasteBox
97a51db349db #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6096
diff changeset
  7538
    "paste the copybuffer as a box; 
97a51db349db #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6096
diff changeset
  7539
     if there is a selection, unselect first.
97a51db349db #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6096
diff changeset
  7540
     Then paste at cursor position."
97a51db349db #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6096
diff changeset
  7541
97a51db349db #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6096
diff changeset
  7542
    self checkModificationsAllowed ifTrue:[
97a51db349db #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6096
diff changeset
  7543
        self withSelfAndTextForPasteDo:[:me :text |
97a51db349db #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6096
diff changeset
  7544
            me unselect.
97a51db349db #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6096
diff changeset
  7545
            me undoablePasteBox:text
97a51db349db #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6096
diff changeset
  7546
        ]
97a51db349db #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6096
diff changeset
  7547
    ]
97a51db349db #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6096
diff changeset
  7548
97a51db349db #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6096
diff changeset
  7549
    "Created: / 14-03-2017 / 16:34:16 / cg"
97a51db349db #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6096
diff changeset
  7550
!
97a51db349db #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6096
diff changeset
  7551
97a51db349db #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6096
diff changeset
  7552
pasteBox:someText
97a51db349db #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6096
diff changeset
  7553
    "paste someText at cursor"
97a51db349db #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6096
diff changeset
  7554
97a51db349db #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6096
diff changeset
  7555
    self pasteBox:someText withCR:false
97a51db349db #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6096
diff changeset
  7556
97a51db349db #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6096
diff changeset
  7557
    "Created: / 14-03-2017 / 16:35:08 / cg"
97a51db349db #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6096
diff changeset
  7558
!
97a51db349db #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6096
diff changeset
  7559
97a51db349db #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6096
diff changeset
  7560
pasteBox:someText withCR:withCR
97a51db349db #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6096
diff changeset
  7561
    "paste someText at cursor"
97a51db349db #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6096
diff changeset
  7562
97a51db349db #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6096
diff changeset
  7563
    |lines nLines startLine startCol l1 l2 c1 c2|
97a51db349db #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6096
diff changeset
  7564
97a51db349db #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6096
diff changeset
  7565
    self checkModificationsAllowed ifFalse:[^ self].
97a51db349db #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6096
diff changeset
  7566
97a51db349db #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6096
diff changeset
  7567
    lines := someText asStringCollection.
97a51db349db #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6096
diff changeset
  7568
    
97a51db349db #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6096
diff changeset
  7569
    (nLines := lines size) == 0 ifTrue:[^ self].
97a51db349db #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6096
diff changeset
  7570
    (nLines == 1 and:[(lines at:1) size == 0]) ifTrue:[^ self].
97a51db349db #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6096
diff changeset
  7571
97a51db349db #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6096
diff changeset
  7572
    typeOfSelection := #paste.
97a51db349db #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6096
diff changeset
  7573
97a51db349db #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6096
diff changeset
  7574
    startLine := l1 := cursorLine.
97a51db349db #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6096
diff changeset
  7575
    startCol := c1 := cursorCol.
97a51db349db #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6096
diff changeset
  7576
97a51db349db #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6096
diff changeset
  7577
    "do not autoindent here.
97a51db349db #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6096
diff changeset
  7578
     It does make things very ugly, in the inspector
97a51db349db #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6096
diff changeset
  7579
     (try inspecting a multiline string)..."
97a51db349db #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6096
diff changeset
  7580
    self withAutoIndent:false do:[
97a51db349db #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6096
diff changeset
  7581
        "do not expand tabs into spaces here -
97a51db349db #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6096
diff changeset
  7582
         they get expanded in basicWithoutRedrawInsertStringWithoutCRs:aString atLine:lineNr col:colNr.
97a51db349db #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6096
diff changeset
  7583
         Some Subviews want to paste with unexpanded tabs!!"
97a51db349db #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6096
diff changeset
  7584
97a51db349db #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6096
diff changeset
  7585
        lines do:[:eachLine |
97a51db349db #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6096
diff changeset
  7586
            self insertString:eachLine atLine:l1 col:startCol.
97a51db349db #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6096
diff changeset
  7587
            l1 := l1 + 1.
97a51db349db #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6096
diff changeset
  7588
        ].    
97a51db349db #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6096
diff changeset
  7589
    ].
97a51db349db #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6096
diff changeset
  7590
    l2 := cursorLine.
97a51db349db #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6096
diff changeset
  7591
    c2 := (cursorCol - 1).
97a51db349db #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6096
diff changeset
  7592
    self selectFromLine:l1 col:c1 toLine:l2 col:c2.
97a51db349db #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6096
diff changeset
  7593
    typeOfSelection := #paste. "/ sigh - cleared by #selectFromLine:
97a51db349db #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6096
diff changeset
  7594
97a51db349db #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6096
diff changeset
  7595
    "Created: / 14-03-2017 / 16:39:11 / cg"
97a51db349db #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6096
diff changeset
  7596
!
97a51db349db #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6096
diff changeset
  7597
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  7598
pasteOrReplace
1289
e2dcc5fe612c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1287
diff changeset
  7599
    "paste the copybuffer; if there is a selection, replace it.
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  7600
     otherwise paste at cursor position.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  7601
     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
  7602
     to allow multiple paste operations in a row."
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  7603
2724
23f4e16dc4f4 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2720
diff changeset
  7604
    self withSelfAndTextForPasteDo:[:me :text | me pasteOrReplace:text]
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  7605
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  7606
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  7607
pasteOrReplace:someText
1289
e2dcc5fe612c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1287
diff changeset
  7608
    "paste someText; if there is a selection, replace it.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  7609
     otherwise paste at cursor position. Replace is not done
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  7610
     for originating by a paste, to allow multiple
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  7611
     paste."
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  7612
1480
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  7613
    self checkModificationsAllowed ifFalse:[^ self].
2989
5dcc2912bcb6 undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents: 2984
diff changeset
  7614
5dcc2912bcb6 undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents: 2984
diff changeset
  7615
    self undoableDo:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7616
        ((self hasSelection == true) and:[typeOfSelection ~~ #paste]) ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7617
            self replace:someText
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7618
        ] ifFalse:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7619
            self paste:someText.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7620
        ]
3542
30ed44ed0178 +joinLines (CTRL-j);
Claus Gittinger <cg@exept.de>
parents: 3517
diff changeset
  7621
    ] info:'Paste/Replace'.
1289
e2dcc5fe612c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1287
diff changeset
  7622
2107
9d44232af0a0 textSelection fixes (added newLine) for MSDOS;
Claus Gittinger <cg@exept.de>
parents: 2101
diff changeset
  7623
    "Modified: / 30.1.2000 / 02:33:00 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  7624
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  7625
6134
97a51db349db #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6096
diff changeset
  7626
pasteOrReplaceBox
97a51db349db #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6096
diff changeset
  7627
    "paste the copybuffer as a box; 
97a51db349db #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6096
diff changeset
  7628
     if there is a selection, unselect first.
97a51db349db #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6096
diff changeset
  7629
     Then paste at cursor position."
97a51db349db #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6096
diff changeset
  7630
97a51db349db #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6096
diff changeset
  7631
    self pasteBox
97a51db349db #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6096
diff changeset
  7632
97a51db349db #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6096
diff changeset
  7633
    "Created: / 14-03-2017 / 16:40:08 / cg"
97a51db349db #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6096
diff changeset
  7634
!
97a51db349db #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6096
diff changeset
  7635
5387
b94d35da3ad6 class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 5371
diff changeset
  7636
pasteOrReplaceByKeyPress
b94d35da3ad6 class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 5371
diff changeset
  7637
    "paste a previous item from the copybuffer history.
b94d35da3ad6 class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 5371
diff changeset
  7638
     (i.e. repaste some previously deleted or copied text)"
b94d35da3ad6 class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 5371
diff changeset
  7639
b94d35da3ad6 class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 5371
diff changeset
  7640
    |text|
b94d35da3ad6 class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 5371
diff changeset
  7641
6226
b7628412aff5 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6210
diff changeset
  7642
    (self checkModificationsAllowedFlashIfNot:true) ifFalse:[^ self].
b7628412aff5 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6210
diff changeset
  7643
5387
b94d35da3ad6 class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 5371
diff changeset
  7644
    text := self getClipboardText:#clipboard.
b94d35da3ad6 class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 5371
diff changeset
  7645
    text notNil ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7646
        self pasteOrReplace:text
5387
b94d35da3ad6 class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 5371
diff changeset
  7647
    ]
6226
b7628412aff5 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6210
diff changeset
  7648
b7628412aff5 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6210
diff changeset
  7649
    "Modified: / 11-11-2017 / 12:52:54 / cg"
5387
b94d35da3ad6 class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 5371
diff changeset
  7650
!
b94d35da3ad6 class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 5371
diff changeset
  7651
3474
357e16440725 slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents: 3473
diff changeset
  7652
pasteOrReplaceFromHistory
357e16440725 slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents: 3473
diff changeset
  7653
    "paste a previous item from the copybuffer history.
357e16440725 slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents: 3473
diff changeset
  7654
     (i.e. repaste some previously deleted or copied text)"
357e16440725 slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents: 3473
diff changeset
  7655
357e16440725 slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents: 3473
diff changeset
  7656
    |text|
357e16440725 slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents: 3473
diff changeset
  7657
6226
b7628412aff5 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6210
diff changeset
  7658
    (self checkModificationsAllowedFlashIfNot:true) ifFalse:[^ self].
b7628412aff5 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6210
diff changeset
  7659
3474
357e16440725 slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents: 3473
diff changeset
  7660
    text := self getTextSelectionFromHistory.
357e16440725 slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents: 3473
diff changeset
  7661
    text notNil ifTrue:[
6452
180a72d98a19 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6436
diff changeset
  7662
        "/ move to top of list.
180a72d98a19 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6436
diff changeset
  7663
        device rememberInCopyBufferHistory:text.
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7664
        self pasteOrReplace:text
3474
357e16440725 slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents: 3473
diff changeset
  7665
    ]
6226
b7628412aff5 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6210
diff changeset
  7666
b7628412aff5 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6210
diff changeset
  7667
    "Modified: / 11-11-2017 / 12:52:42 / cg"
3474
357e16440725 slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents: 3473
diff changeset
  7668
!
357e16440725 slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents: 3473
diff changeset
  7669
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  7670
replace
1289
e2dcc5fe612c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1287
diff changeset
  7671
    "replace the selection by the contents of the copybuffer"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  7672
3269
03d04670a5d2 replace is a no op, if there is no selection
Claus Gittinger <cg@exept.de>
parents: 3268
diff changeset
  7673
    self hasSelection ifFalse:[^ self].
03d04670a5d2 replace is a no op, if there is no selection
Claus Gittinger <cg@exept.de>
parents: 3268
diff changeset
  7674
    self checkModificationsAllowed ifFalse:[^ self].
03d04670a5d2 replace is a no op, if there is no selection
Claus Gittinger <cg@exept.de>
parents: 3268
diff changeset
  7675
03d04670a5d2 replace is a no op, if there is no selection
Claus Gittinger <cg@exept.de>
parents: 3268
diff changeset
  7676
    self withSelfAndTextForPasteDo:[:me :text |
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7677
        me undoableDo:[ me replace:text ]
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7678
        info:'Replace'
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  7679
    ]
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  7680
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  7681
121
claus
parents: 118
diff changeset
  7682
replace:someText
1289
e2dcc5fe612c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1287
diff changeset
  7683
    "replace the selection by someText"
121
claus
parents: 118
diff changeset
  7684
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  7685
    |selected selectedString
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  7686
     selStartLine selStartCol selEndLine selEndCol|
121
claus
parents: 118
diff changeset
  7687
1480
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  7688
    self checkModificationsAllowed ifFalse:[^ self].
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  7689
3130
c0f39f9f28d6 undoable keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3127
diff changeset
  7690
    self undoableDo:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7691
        selected := self selection.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7692
        selected isNil ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7693
            ^ self paste:someText
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7694
        ].
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7695
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7696
        self deleteSelection.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7697
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7698
        "take care, if we replace a selection without space by a word selected
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7699
         with one - in this case we usually do not want the space.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7700
         But, if we replace a word-selected selection by something without a
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7701
         space, we DO want the space added."
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7702
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7703
        selected size == 1 ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7704
            selectedString := selected at:1.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7705
        ].
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7706
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7707
        someText size == 1 ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7708
            |cutOffSpace addSpace replacement replacementString|
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7709
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7710
            cutOffSpace := false.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7711
            addSpace := false.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7712
            replacement := someText copyFrom:1.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7713
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7714
            selectedString notNil ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7715
                ((selectedString startsWith:' ') or:[selectedString endsWith:' ']) ifFalse:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7716
                   "selection has no space"
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7717
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7718
                    ((selectStyle == #wordleft) or:[selectStyle == #wordRight]) ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7719
                        cutOffSpace := true
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7720
                    ]
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7721
                ] ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7722
                    addSpace := true
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7723
                ]
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7724
            ].
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7725
            replacementString := replacement at:1.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7726
            cutOffSpace ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7727
                (replacementString startsWith:' ') ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7728
                    replacementString := replacementString withoutSpaces
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7729
                ].
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7730
            ] ifFalse:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7731
                selectStyle == #wordLeft ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7732
                    "want a space at left"
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7733
                    (replacementString startsWith:' ') ifFalse:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7734
                        replacementString := replacementString withoutSpaces.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7735
                        replacementString := ' ' , replacementString
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7736
                    ]
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7737
                ].
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7738
                selectStyle == #wordRight ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7739
                    "want a space at right"
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7740
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7741
                    (replacementString endsWith:' ') ifFalse:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7742
                        replacementString := replacementString withoutSpaces.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7743
                        replacementString := replacementString , ' '
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7744
                    ]
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7745
                ].
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7746
            ].
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7747
            replacement at:1 put: replacementString.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7748
            self paste:replacement.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7749
        ] ifFalse:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7750
            self paste:someText
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7751
        ].
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7752
        self setLastStringToReplace: selectedString.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7753
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7754
        lastReplacementInfo lastReplacement: someText.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7755
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7756
        selStartLine := selectionStartLine.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7757
        selStartCol := self selectionStartCol.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7758
        selEndLine := selectionEndLine.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7759
        selEndCol := self selectionEndCol.
3130
c0f39f9f28d6 undoable keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3127
diff changeset
  7760
    ]
3542
30ed44ed0178 +joinLines (CTRL-j);
Claus Gittinger <cg@exept.de>
parents: 3517
diff changeset
  7761
    info:'Replace'
362
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  7762
1480
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  7763
    "Modified: / 14.2.1996 / 10:37:02 / stefan"
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  7764
    "Modified: / 5.4.1998 / 16:55:28 / cg"
121
claus
parents: 118
diff changeset
  7765
!
claus
parents: 118
diff changeset
  7766
3430
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  7767
searchReplace
3683
5891af82a177 middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents: 3650
diff changeset
  7768
    "search for a string - show a box to enter searchpattern
3430
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  7769
     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
  7770
     - 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
  7771
3430
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  7772
    |searchBox patternHolder replacePatternHolder caseHolder flag ign initialString bindings bldr search modal replace action|
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  7773
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  7774
    modal := false "(UserPreferences current searchDialogIsModal)".
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  7775
    lastSearchDirection := #forward.
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  7776
    ign := lastSearchIgnoredCase ? LastSearchIgnoredCase ? true.
5251
259d72b38bd7 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5244
diff changeset
  7777
    caseHolder := ValueHolder with:ign.
259d72b38bd7 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5244
diff changeset
  7778
    patternHolder := ValueHolder with:''.
259d72b38bd7 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5244
diff changeset
  7779
    replacePatternHolder := ValueHolder with:''.
3430
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  7780
    lastSearchPattern notNil ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7781
        initialString := lastSearchPattern
3430
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  7782
    ].
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  7783
    self hasSelectionWithinSingleLine ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7784
        initialString := self selectionAsString
3430
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  7785
    ].
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  7786
    initialString isNil ifTrue:[
6548
59a6fdf4dd26 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6543
diff changeset
  7787
        LastSearchPatterns size ~~ 0 ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7788
            initialString := LastSearchPatterns first
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7789
        ]
3430
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  7790
    ].
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  7791
    initialString notNil ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7792
        patternHolder value:initialString.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7793
        replacePatternHolder value:initialString.
3430
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  7794
    ].
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  7795
    flag := true.
3683
5891af82a177 middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents: 3650
diff changeset
  7796
    search := [:fwd |
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7797
            self
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7798
                search:patternHolder value
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7799
                ignoreCase:caseHolder value
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7800
                forward:fwd.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7801
        ].
3683
5891af82a177 middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents: 3650
diff changeset
  7802
    replace := [:all |
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7803
            self
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7804
                replace:patternHolder value
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7805
                by:replacePatternHolder value
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7806
                all:all
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7807
                ignoreCase:caseHolder value
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7808
        ].
3430
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  7809
    bindings := IdentityDictionary new.
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  7810
    bindings at:#searchPattern put:patternHolder.
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  7811
    bindings at:#replacePattern put:replacePatternHolder.
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  7812
    modal ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7813
        bindings at:#nextAction
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7814
            put:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7815
                flag := true.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7816
                action := search.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7817
                searchBox doAccept.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7818
            ].
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7819
        bindings at:#prevAction
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7820
            put:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7821
                flag := false.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7822
                action := search.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7823
                searchBox doAccept.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7824
            ].
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7825
        bindings at:#replaceAction
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7826
            put:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7827
                flag := false.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7828
                action := replace.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7829
                searchBox doAccept.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7830
            ].
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7831
        bindings at:#replaceAllAction
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7832
            put:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7833
                flag := true.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7834
                action := replace.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7835
                searchBox doAccept.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7836
            ].
3430
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  7837
    ] ifFalse:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7838
        bindings at:#nextAction put:[ search value:true. ].
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7839
        bindings at:#prevAction put:[ search value:false. ].
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7840
        bindings at:#replaceAction put:[ replace value:false. ].
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7841
        bindings at:#replaceAllAction put:[ replace value:true. ].
3430
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  7842
    ].
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  7843
    bindings at:#ignoreCase put:caseHolder.
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  7844
    bindings at:#patternList put:LastSearchPatterns.
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  7845
    modal ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7846
        searchBox := SimpleDialog new.
3430
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  7847
    ] ifFalse:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7848
        searchBox := ApplicationModel new.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7849
        searchBox createBuilder.
3430
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  7850
    ].
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  7851
    searchBox resources:(self resources).
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  7852
    bldr := searchBox builder.
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  7853
    bldr addBindings:bindings.
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  7854
    searchBox allButOpenFrom:(self class searchReplaceDialogSpec).
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  7855
    (bldr componentAt:#nextButton) cursor:(Cursor thumbsUp).
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  7856
    (bldr componentAt:#prevButton) cursor:(Cursor thumbsUp).
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  7857
    (bldr componentAt:#cancelButton) cursor:(Cursor thumbsDown).
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  7858
    modal ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7859
        searchBox openDialog.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7860
        searchBox accepted ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7861
            action value:flag
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7862
        ].
3430
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  7863
    ] ifFalse:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7864
        (bldr componentAt:#nextButton) isReturnButton:false.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7865
        (bldr componentAt:#cancelButton)
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7866
            label:(resources string:'Close');
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7867
            action:[ searchBox closeRequest ].
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7868
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7869
        "/ searchBox masterApplication:self application.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7870
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7871
        self topView beMaster.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7872
        (searchBox window)
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7873
            beSlave;
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7874
            openInGroup:(self windowGroup).
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7875
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7876
        "/ searchBox window open.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7877
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7878
        searchBox window assignKeyboardFocusToFirstKeyboardConsumer.
3430
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  7879
    ]
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  7880
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  7881
    "Modified: / 11-07-2006 / 11:20:06 / fm"
6548
59a6fdf4dd26 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6543
diff changeset
  7882
    "Modified: / 01-03-2019 / 14:55:01 / Claus Gittinger"
3430
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  7883
!
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  7884
6241
ca8af4b44137 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6232
diff changeset
  7885
selectionDecodeBase64
ca8af4b44137 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6232
diff changeset
  7886
    self paste:(Base64Coder decode:self selectionAsString) asString
ca8af4b44137 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6232
diff changeset
  7887
ca8af4b44137 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6232
diff changeset
  7888
    "Created: / 30-11-2017 / 15:07:31 / cg"
ca8af4b44137 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6232
diff changeset
  7889
!
ca8af4b44137 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6232
diff changeset
  7890
ca8af4b44137 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6232
diff changeset
  7891
selectionEncodeBase64
ca8af4b44137 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6232
diff changeset
  7892
    self paste:(Base64Coder encode:self selectionAsString)
ca8af4b44137 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6232
diff changeset
  7893
ca8af4b44137 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6232
diff changeset
  7894
    "Created: / 30-11-2017 / 15:07:34 / cg"
ca8af4b44137 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6232
diff changeset
  7895
!
ca8af4b44137 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6232
diff changeset
  7896
ca8af4b44137 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6232
diff changeset
  7897
selectionRot13
ca8af4b44137 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6232
diff changeset
  7898
    "a naive caesar cypher"
ca8af4b44137 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6232
diff changeset
  7899
    
ca8af4b44137 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6232
diff changeset
  7900
    self paste:(self selectionAsString rot13)
ca8af4b44137 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6232
diff changeset
  7901
ca8af4b44137 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6232
diff changeset
  7902
    "Created: / 30-11-2017 / 15:07:50 / cg"
ca8af4b44137 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6232
diff changeset
  7903
!
ca8af4b44137 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6232
diff changeset
  7904
121
claus
parents: 118
diff changeset
  7905
showDeleted
claus
parents: 118
diff changeset
  7906
    "open a readonly editor on all deleted text"
claus
parents: 118
diff changeset
  7907
claus
parents: 118
diff changeset
  7908
    |v|
claus
parents: 118
diff changeset
  7909
claus
parents: 118
diff changeset
  7910
    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
  7911
    v readOnly:true.
121
claus
parents: 118
diff changeset
  7912
    v topView label:'deleted text'.
2624
22d352e56c27 preps for special characters
Claus Gittinger <cg@exept.de>
parents: 2617
diff changeset
  7913
!
22d352e56c27 preps for special characters
Claus Gittinger <cg@exept.de>
parents: 2617
diff changeset
  7914
6599
c74062ad83c7 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6586
diff changeset
  7915
showLineLimitInMenu
c74062ad83c7 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6586
diff changeset
  7916
    "only for text collectors"
c74062ad83c7 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6586
diff changeset
  7917
c74062ad83c7 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6586
diff changeset
  7918
    ^ false.
c74062ad83c7 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6586
diff changeset
  7919
c74062ad83c7 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6586
diff changeset
  7920
    "Created: / 06-06-2019 / 11:22:09 / Claus Gittinger"
c74062ad83c7 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6586
diff changeset
  7921
!
c74062ad83c7 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 6586
diff changeset
  7922
3221
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  7923
sort:how ignoreCase:ignoreCase fromLine:start toLine:end
4763
89bf20c2e8f5 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4753
diff changeset
  7924
    "sort/reorder the selected lines.
89bf20c2e8f5 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4753
diff changeset
  7925
     how:
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7926
        #lines
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7927
        #linesByFirstWord
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7928
        #linesByNthWord
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7929
        #linesByNthNumber
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7930
        #linesByNthHexNumber
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7931
        #words
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7932
        #linesByLength
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7933
        #reverse
4763
89bf20c2e8f5 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4753
diff changeset
  7934
    "
89bf20c2e8f5 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4753
diff changeset
  7935
89bf20c2e8f5 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4753
diff changeset
  7936
    |lines extractor innerExtractor fetcher operation lineWise nStr n s words|
3221
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  7937
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  7938
    lineWise := true.
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  7939
4763
89bf20c2e8f5 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4753
diff changeset
  7940
    how == #reverse ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7941
        operation := [:lines | lines reverse].
4763
89bf20c2e8f5 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4753
diff changeset
  7942
    ] ifFalse:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7943
        operation := [:linesOrWords |
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7944
                        linesOrWords sort:[:item1 :item2 | (fetcher value:item1) < (fetcher value:item2)]
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7945
                     ].
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7946
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7947
        how == #linesByLength ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7948
            fetcher := [:l | l size].
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7949
        ] ifFalse:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7950
            how == #lines ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7951
                extractor := [:l | l withoutLeadingSeparators].
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7952
            ] ifFalse:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7953
                how == #linesByFirstWord ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7954
                    extractor := [:l | ((l asCollectionOfWords select:[:w | w isEmpty or:[w first isLetterOrDigit]]) at:1 ifAbsent:'')].
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7955
                ] ifFalse:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7956
                    ((how == #linesByNthWord) or:[ how == #linesByNthNumber  or:[ how == #linesByNthHexNumber]]) ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7957
                        nStr := Dialog request:'Word/Column (1..)' initialAnswer:(LastColumnNumberForSort ? 2).
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7958
                        nStr isEmptyOrNil ifTrue:[^ self].
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7959
                        n := Integer readFrom:nStr onError:[^ self].
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7960
                        LastColumnNumberForSort := n.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7961
                        extractor := [:l | ((l string asCollectionOfWords) at:n ifAbsent:'')].
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7962
                        how == #linesByNthNumber ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7963
                            innerExtractor := extractor.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7964
                            extractor := [:l | Integer readFrom:(innerExtractor value:l) onError:0]
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7965
                        ] ifFalse:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7966
                            how == #linesByNthHexNumber ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7967
                                innerExtractor := extractor.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7968
                                extractor := [:l |
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7969
                                    |s|
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7970
                                    s := innerExtractor value:l.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7971
                                    (s startsWith:'16r') ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7972
                                        (Integer readSmalltalkSyntaxFrom:s) ? 0
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7973
                                    ] ifFalse:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7974
                                        Integer readFrom:s radix:16 onError:[ 0 ]
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7975
                                    ]
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7976
                                ]
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7977
                            ]
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7978
                        ].
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7979
                    ] ifFalse:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7980
                        how == #words ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7981
                            lineWise := false.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7982
                            extractor := [:w | w].
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7983
                        ] ifFalse:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7984
                            self error:'unknown sort criteria: ', how printString.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7985
                        ]
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7986
                    ]
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7987
                ]
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7988
            ].
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7989
            ignoreCase ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7990
                fetcher := [:l | (extractor value:l) asLowercase].
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7991
            ] ifFalse:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7992
                fetcher := extractor.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7993
            ].
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7994
        ].
3221
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  7995
    ].
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  7996
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  7997
    lineWise ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7998
        "process the lines of the selection (aka a collection of lines)"
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  7999
        start == end ifTrue:[^ self ].
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8000
        lines := (start to:end) collect:[:lineNr | (self listAt:lineNr) ? ''].
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8001
        lines := operation value:lines.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8002
        (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
  8003
    ] ifFalse:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8004
        "process the whole selection as a string"
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8005
        s := self selectionAsString.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8006
        words := s asCollectionOfWords.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8007
        words := operation value:words.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8008
        s := words asStringCollection asStringWith:Character space.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8009
        self replace:s.
4763
89bf20c2e8f5 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4753
diff changeset
  8010
    ].
3221
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  8011
    self textChanged.
4373
22fb03e6d08a class definition
Claus Gittinger <cg@exept.de>
parents: 4371
diff changeset
  8012
4414
308d40ee857b changed: #sort:ignoreCase:fromLine:toLine:
Claus Gittinger <cg@exept.de>
parents: 4396
diff changeset
  8013
    "Modified: / 31-03-2012 / 10:59:28 / cg"
3221
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  8014
!
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  8015
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  8016
sortSelection:how ignoreCase:ignoreCase
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  8017
    "sort the selected lines"
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  8018
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  8019
    |start end|
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  8020
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  8021
    selectionStartLine isNil ifTrue:[^ self].
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  8022
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  8023
    start := selectionStartLine.
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  8024
    end := selectionEndLine.
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  8025
    (selectionEndCol == 0) ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8026
        end := end - 1
3221
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  8027
    ].
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  8028
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  8029
    self
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8030
        undoableDo:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8031
            self sort:how ignoreCase:ignoreCase fromLine:start toLine:end
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8032
        ]
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8033
        info:'Sort'
4373
22fb03e6d08a class definition
Claus Gittinger <cg@exept.de>
parents: 4371
diff changeset
  8034
22fb03e6d08a class definition
Claus Gittinger <cg@exept.de>
parents: 4371
diff changeset
  8035
    "Modified (format): / 15-02-2012 / 16:52:53 / cg"
3221
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  8036
!
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  8037
2624
22d352e56c27 preps for special characters
Claus Gittinger <cg@exept.de>
parents: 2617
diff changeset
  8038
specialCharacters
6517
7a141e818635 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6514
diff changeset
  8039
    "open the special characters input window"
7a141e818635 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6514
diff changeset
  8040
7a141e818635 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6514
diff changeset
  8041
    "CharacterInputViewSingleton := nil"
7a141e818635 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6514
diff changeset
  8042
    
7a141e818635 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6514
diff changeset
  8043
    (CharacterInputViewSingleton notNil and:[CharacterInputViewSingleton isOpen]) ifTrue:[
7a141e818635 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6514
diff changeset
  8044
        CharacterInputViewSingleton consumingView:self.
7a141e818635 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6514
diff changeset
  8045
        CharacterInputViewSingleton topView raiseDeiconified.
7a141e818635 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6514
diff changeset
  8046
    ] ifFalse:[
7a141e818635 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6514
diff changeset
  8047
        CharacterInputViewSingleton :=
7a141e818635 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6514
diff changeset
  8048
            CharacterSetView
7a141e818635 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6514
diff changeset
  8049
                openAsInputFor:self
7a141e818635 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6514
diff changeset
  8050
                label:(resources string:'Special Character Input')
7a141e818635 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6514
diff changeset
  8051
                clickLabel:(resources string:'Click to Insert Character').
7a141e818635 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6514
diff changeset
  8052
    ].
7a141e818635 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6514
diff changeset
  8053
7a141e818635 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6514
diff changeset
  8054
    "Modified (comment): / 08-01-2019 / 18:24:13 / Claus Gittinger"
2866
9dd71df46f73 specialCharacters menu item
Claus Gittinger <cg@exept.de>
parents: 2857
diff changeset
  8055
!
9dd71df46f73 specialCharacters menu item
Claus Gittinger <cg@exept.de>
parents: 2857
diff changeset
  8056
5370
9b04537dc868 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5367
diff changeset
  8057
splitLinesAtCharacterOrString
9b04537dc868 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5367
diff changeset
  8058
    "ask user for the character and split after it"
9b04537dc868 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5367
diff changeset
  8059
9b04537dc868 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5367
diff changeset
  8060
    |sel in out separator record|
9b04537dc868 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5367
diff changeset
  8061
9b04537dc868 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5367
diff changeset
  8062
    selectionStartLine isNil ifTrue:[^ self].
6227
ff84138a7915 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6226
diff changeset
  8063
    self checkModificationsAllowed ifFalse:[^ self].
5370
9b04537dc868 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5367
diff changeset
  8064
9b04537dc868 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5367
diff changeset
  8065
    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
  8066
    separator isEmptyOrNil ifTrue:[^ self].
9b04537dc868 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5367
diff changeset
  8067
9b04537dc868 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5367
diff changeset
  8068
    sel := self selectionAsString.
9b04537dc868 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5367
diff changeset
  8069
    in := sel readStream.
5887
46f1b58748aa #OTHER by stefan
Stefan Vogel <sv@exept.de>
parents: 5882
diff changeset
  8070
    out := CharacterWriteStream on:''.
5370
9b04537dc868 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5367
diff changeset
  8071
    [in atEnd] whileFalse:[
5887
46f1b58748aa #OTHER by stefan
Stefan Vogel <sv@exept.de>
parents: 5882
diff changeset
  8072
        record := in throughAll:separator.
46f1b58748aa #OTHER by stefan
Stefan Vogel <sv@exept.de>
parents: 5882
diff changeset
  8073
        out nextPutLine:record.
5370
9b04537dc868 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5367
diff changeset
  8074
    ].
9b04537dc868 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5367
diff changeset
  8075
    self
5887
46f1b58748aa #OTHER by stefan
Stefan Vogel <sv@exept.de>
parents: 5882
diff changeset
  8076
        undoableDo:[
46f1b58748aa #OTHER by stefan
Stefan Vogel <sv@exept.de>
parents: 5882
diff changeset
  8077
            self replaceSelectionBy:(out contents).
46f1b58748aa #OTHER by stefan
Stefan Vogel <sv@exept.de>
parents: 5882
diff changeset
  8078
        ]
46f1b58748aa #OTHER by stefan
Stefan Vogel <sv@exept.de>
parents: 5882
diff changeset
  8079
        info:'Split Selection'
6227
ff84138a7915 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6226
diff changeset
  8080
ff84138a7915 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6226
diff changeset
  8081
    "Modified: / 15-11-2017 / 11:56:45 / cg"
5370
9b04537dc868 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5367
diff changeset
  8082
!
9b04537dc868 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5367
diff changeset
  8083
2989
5dcc2912bcb6 undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents: 2984
diff changeset
  8084
undoablePaste:someText
3495
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  8085
    self undoablePaste:someText info:nil.
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  8086
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  8087
    "Modified: / 28-07-2007 / 13:25:46 / cg"
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  8088
!
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  8089
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  8090
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
  8091
    self
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8092
        undoableDo:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8093
            self paste:someText.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8094
        ]
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8095
        info:infoOrNil
3495
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  8096
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  8097
    "Created: / 28-07-2007 / 13:25:30 / cg"
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  8098
!
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  8099
6134
97a51db349db #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6096
diff changeset
  8100
undoablePasteBox:someText
97a51db349db #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6096
diff changeset
  8101
    self undoablePasteBox:someText info:nil.
97a51db349db #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6096
diff changeset
  8102
97a51db349db #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6096
diff changeset
  8103
    "Created: / 14-03-2017 / 16:34:31 / cg"
97a51db349db #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6096
diff changeset
  8104
!
97a51db349db #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6096
diff changeset
  8105
97a51db349db #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6096
diff changeset
  8106
undoablePasteBox:someText info:infoOrNil
97a51db349db #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6096
diff changeset
  8107
    self
97a51db349db #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6096
diff changeset
  8108
        undoableDo:[
97a51db349db #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6096
diff changeset
  8109
            self pasteBox:someText.
97a51db349db #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6096
diff changeset
  8110
        ]
97a51db349db #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6096
diff changeset
  8111
        info:infoOrNil
97a51db349db #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6096
diff changeset
  8112
97a51db349db #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6096
diff changeset
  8113
    "Created: / 14-03-2017 / 16:34:55 / cg"
97a51db349db #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6096
diff changeset
  8114
!
97a51db349db #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 6096
diff changeset
  8115
3495
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  8116
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
  8117
    self
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8118
        undoableDo:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8119
            self pasteOrReplace:someText.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8120
        ]
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8121
        info:infoOrNil
3495
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  8122
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  8123
    "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
  8124
!
5dcc2912bcb6 undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents: 2984
diff changeset
  8125
4114
321416257cc5 added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents: 4110
diff changeset
  8126
undoablePasteReplacingAll:someText info:infoOrNil
321416257cc5 added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents: 4110
diff changeset
  8127
    self
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8128
        undoableDo:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8129
            self selectAll.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8130
            self pasteOrReplace:someText.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8131
        ]
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8132
        info:infoOrNil
4114
321416257cc5 added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents: 4110
diff changeset
  8133
321416257cc5 added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents: 4110
diff changeset
  8134
    "Created: / 28-07-2007 / 13:25:30 / cg"
321416257cc5 added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents: 4110
diff changeset
  8135
!
321416257cc5 added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents: 4110
diff changeset
  8136
2724
23f4e16dc4f4 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2720
diff changeset
  8137
withSelfAndTextForPasteDo:aBlock
23f4e16dc4f4 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2720
diff changeset
  8138
    "common code for paste/replace of the copybuffer"
23f4e16dc4f4 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2720
diff changeset
  8139
23f4e16dc4f4 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2720
diff changeset
  8140
    |sel|
23f4e16dc4f4 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2720
diff changeset
  8141
6226
b7628412aff5 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6210
diff changeset
  8142
    (self checkModificationsAllowedFlashIfNot:true) ifFalse:[^ self].
2724
23f4e16dc4f4 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2720
diff changeset
  8143
23f4e16dc4f4 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2720
diff changeset
  8144
    sel := self getTextSelectionOrTextSelectionFromHistory.
23f4e16dc4f4 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2720
diff changeset
  8145
    sel notNil ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8146
        aBlock value:self value:sel.
2724
23f4e16dc4f4 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2720
diff changeset
  8147
    ]
6226
b7628412aff5 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6210
diff changeset
  8148
b7628412aff5 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6210
diff changeset
  8149
    "Modified: / 11-11-2017 / 12:52:31 / cg"
6477
9fb3de4fdc0f #UI_ENHANCEMENT by cgexept.de
Claus Gittinger <cg@exept.de>
parents: 6469
diff changeset
  8150
!
9fb3de4fdc0f #UI_ENHANCEMENT by cgexept.de
Claus Gittinger <cg@exept.de>
parents: 6469
diff changeset
  8151
9fb3de4fdc0f #UI_ENHANCEMENT by cgexept.de
Claus Gittinger <cg@exept.de>
parents: 6469
diff changeset
  8152
withSelfAndTextForPasteFromHistoryDo:aBlock
9fb3de4fdc0f #UI_ENHANCEMENT by cgexept.de
Claus Gittinger <cg@exept.de>
parents: 6469
diff changeset
  8153
    "common code for paste/replace from the copyBuffer history"
9fb3de4fdc0f #UI_ENHANCEMENT by cgexept.de
Claus Gittinger <cg@exept.de>
parents: 6469
diff changeset
  8154
9fb3de4fdc0f #UI_ENHANCEMENT by cgexept.de
Claus Gittinger <cg@exept.de>
parents: 6469
diff changeset
  8155
    |sel|
9fb3de4fdc0f #UI_ENHANCEMENT by cgexept.de
Claus Gittinger <cg@exept.de>
parents: 6469
diff changeset
  8156
9fb3de4fdc0f #UI_ENHANCEMENT by cgexept.de
Claus Gittinger <cg@exept.de>
parents: 6469
diff changeset
  8157
    (self checkModificationsAllowedFlashIfNot:true) ifFalse:[^ self].
9fb3de4fdc0f #UI_ENHANCEMENT by cgexept.de
Claus Gittinger <cg@exept.de>
parents: 6469
diff changeset
  8158
    sel := self getTextSelectionFromHistory.
9fb3de4fdc0f #UI_ENHANCEMENT by cgexept.de
Claus Gittinger <cg@exept.de>
parents: 6469
diff changeset
  8159
    sel notNil ifTrue:[
9fb3de4fdc0f #UI_ENHANCEMENT by cgexept.de
Claus Gittinger <cg@exept.de>
parents: 6469
diff changeset
  8160
        aBlock value:self value:sel.
9fb3de4fdc0f #UI_ENHANCEMENT by cgexept.de
Claus Gittinger <cg@exept.de>
parents: 6469
diff changeset
  8161
    ]
9fb3de4fdc0f #UI_ENHANCEMENT by cgexept.de
Claus Gittinger <cg@exept.de>
parents: 6469
diff changeset
  8162
9fb3de4fdc0f #UI_ENHANCEMENT by cgexept.de
Claus Gittinger <cg@exept.de>
parents: 6469
diff changeset
  8163
    "Modified: / 11-11-2017 / 12:52:31 / cg"
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  8164
! !
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  8165
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8166
!EditTextView methodsFor:'private'!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8167
3880
d8882158de6b beepInEditor flag
Claus Gittinger <cg@exept.de>
parents: 3868
diff changeset
  8168
beep
5244
261cf00fc93b class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5239
diff changeset
  8169
    "output an audible beep or bell on my screen device"
261cf00fc93b class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5239
diff changeset
  8170
6262
5b9bf7c3c828 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 6249
diff changeset
  8171
    super beepInEditor
3880
d8882158de6b beepInEditor flag
Claus Gittinger <cg@exept.de>
parents: 3868
diff changeset
  8172
!
d8882158de6b beepInEditor flag
Claus Gittinger <cg@exept.de>
parents: 3868
diff changeset
  8173
331
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
  8174
checkModificationsAllowed
6226
b7628412aff5 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6210
diff changeset
  8175
    "check if the text can be modified (i.e. is not readOnly), return true or false.
b7628412aff5 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6210
diff changeset
  8176
     If not, and an exceptionBlock has been defined, evaluate it.
b7628412aff5 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6210
diff changeset
  8177
     The exceptionBlock can be provided by the application or user of the textView,
b7628412aff5 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6210
diff changeset
  8178
     and may show a warnBox or whatever, or ask again.
b7628412aff5 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6210
diff changeset
  8179
     It can return true to allow the modification"
1300
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  8180
1733
c5139b7402f0 use self isReadonly; readOnly may now be a valueHolder.
Claus Gittinger <cg@exept.de>
parents: 1732
diff changeset
  8181
    self isReadOnly ifTrue: [
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8182
        exceptionBlock isNil ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8183
            ^ false
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8184
        ].
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8185
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8186
        (exceptionBlock value:'Text may not be modified') ~~ true ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8187
            ^ false
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8188
        ]
331
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
  8189
    ].
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
  8190
    ^ true
1300
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  8191
6226
b7628412aff5 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6210
diff changeset
  8192
    "Modified: / 17-06-1998 / 15:51:10 / cg"
b7628412aff5 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6210
diff changeset
  8193
    "Modified (comment): / 11-11-2017 / 12:49:29 / cg"
b7628412aff5 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6210
diff changeset
  8194
!
b7628412aff5 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6210
diff changeset
  8195
b7628412aff5 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6210
diff changeset
  8196
checkModificationsAllowedFlashIfNot:doFlashIfNot
b7628412aff5 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6210
diff changeset
  8197
    "check if the text can be modified (i.e. is not readOnly), return true or false.
b7628412aff5 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6210
diff changeset
  8198
     If not, and an exceptionBlock has been defined, evaluate it.
b7628412aff5 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6210
diff changeset
  8199
     The exceptionBlock can be provided by the application or user of the textView,
b7628412aff5 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6210
diff changeset
  8200
     and may show a warnBox or whatever, or ask again.
b7628412aff5 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6210
diff changeset
  8201
     It can return true to allow the modification.
b7628412aff5 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6210
diff changeset
  8202
     If either no exceptionBlock was defined or it returned false,
b7628412aff5 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6210
diff changeset
  8203
     and doFlashIfNot is true then flash the view to tell the user."
b7628412aff5 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6210
diff changeset
  8204
b7628412aff5 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6210
diff changeset
  8205
    self isReadOnly ifTrue: [
b7628412aff5 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6210
diff changeset
  8206
        (exceptionBlock isNil 
b7628412aff5 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6210
diff changeset
  8207
        or:[(exceptionBlock value:'Text may not be modified') ~~ true]) ifTrue:[
b7628412aff5 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6210
diff changeset
  8208
            doFlashIfNot ifTrue:[
b7628412aff5 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6210
diff changeset
  8209
                self flashReadOnly
b7628412aff5 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6210
diff changeset
  8210
            ].    
b7628412aff5 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6210
diff changeset
  8211
            ^ false
b7628412aff5 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6210
diff changeset
  8212
        ].
b7628412aff5 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6210
diff changeset
  8213
    ].
b7628412aff5 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6210
diff changeset
  8214
    ^ true
b7628412aff5 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6210
diff changeset
  8215
b7628412aff5 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6210
diff changeset
  8216
    "Created: / 11-11-2017 / 12:52:00 / cg"
331
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
  8217
!
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
  8218
2596
933689d5bd9c alternative selection color
Claus Gittinger <cg@exept.de>
parents: 2589
diff changeset
  8219
currentSelectionBgColor
933689d5bd9c alternative selection color
Claus Gittinger <cg@exept.de>
parents: 2589
diff changeset
  8220
    typeOfSelection == #paste ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8221
        ^ DefaultAlternativeSelectionBackgroundColor ? selectionBgColor
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8222
    ].
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8223
    "/ hasKeyboardFocus ifFalse:[^ Color lightGrey].
2596
933689d5bd9c alternative selection color
Claus Gittinger <cg@exept.de>
parents: 2589
diff changeset
  8224
    ^ super currentSelectionBgColor
933689d5bd9c alternative selection color
Claus Gittinger <cg@exept.de>
parents: 2589
diff changeset
  8225
933689d5bd9c alternative selection color
Claus Gittinger <cg@exept.de>
parents: 2589
diff changeset
  8226
    "
933689d5bd9c alternative selection color
Claus Gittinger <cg@exept.de>
parents: 2589
diff changeset
  8227
     DefaultAlternativeSelectionBackgroundColor := Color yellow blendWith:Color green
933689d5bd9c alternative selection color
Claus Gittinger <cg@exept.de>
parents: 2589
diff changeset
  8228
    "
933689d5bd9c alternative selection color
Claus Gittinger <cg@exept.de>
parents: 2589
diff changeset
  8229
!
933689d5bd9c alternative selection color
Claus Gittinger <cg@exept.de>
parents: 2589
diff changeset
  8230
933689d5bd9c alternative selection color
Claus Gittinger <cg@exept.de>
parents: 2589
diff changeset
  8231
currentSelectionFgColor
933689d5bd9c alternative selection color
Claus Gittinger <cg@exept.de>
parents: 2589
diff changeset
  8232
    typeOfSelection == #paste ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8233
        ^ DefaultAlternativeSelectionForegroundColor ? selectionFgColor
2596
933689d5bd9c alternative selection color
Claus Gittinger <cg@exept.de>
parents: 2589
diff changeset
  8234
    ].
933689d5bd9c alternative selection color
Claus Gittinger <cg@exept.de>
parents: 2589
diff changeset
  8235
    ^ super currentSelectionFgColor
933689d5bd9c alternative selection color
Claus Gittinger <cg@exept.de>
parents: 2589
diff changeset
  8236
!
933689d5bd9c alternative selection color
Claus Gittinger <cg@exept.de>
parents: 2589
diff changeset
  8237
3996
d0b0d69334ed added: #resetVariablesBeforeNewSearch
fm
parents: 3982
diff changeset
  8238
resetVariablesBeforeNewSearch
4451
71e8b21c63ce comment in: #resetVariablesBeforeNewSearch
Claus Gittinger <cg@exept.de>
parents: 4449
diff changeset
  8239
    "clear the autosearch action, when the first pattern is searched for"
3996
d0b0d69334ed added: #resetVariablesBeforeNewSearch
fm
parents: 3982
diff changeset
  8240
d0b0d69334ed added: #resetVariablesBeforeNewSearch
fm
parents: 3982
diff changeset
  8241
    super resetVariablesBeforeNewSearch.
d0b0d69334ed added: #resetVariablesBeforeNewSearch
fm
parents: 3982
diff changeset
  8242
d0b0d69334ed added: #resetVariablesBeforeNewSearch
fm
parents: 3982
diff changeset
  8243
    "/ new search invalidates remembered string
4048
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
  8244
    lastStringFromReplaceForNextSearch := nil.
4451
71e8b21c63ce comment in: #resetVariablesBeforeNewSearch
Claus Gittinger <cg@exept.de>
parents: 4449
diff changeset
  8245
71e8b21c63ce comment in: #resetVariablesBeforeNewSearch
Claus Gittinger <cg@exept.de>
parents: 4449
diff changeset
  8246
    "Modified (comment): / 07-03-2012 / 23:21:06 / cg"
3996
d0b0d69334ed added: #resetVariablesBeforeNewSearch
fm
parents: 3982
diff changeset
  8247
!
d0b0d69334ed added: #resetVariablesBeforeNewSearch
fm
parents: 3982
diff changeset
  8248
4053
31117d801975 added: #setLastStringToReplace:
fm
parents: 4051
diff changeset
  8249
setLastStringToReplace: aString
31117d801975 added: #setLastStringToReplace:
fm
parents: 4051
diff changeset
  8250
31117d801975 added: #setLastStringToReplace:
fm
parents: 4051
diff changeset
  8251
    "This method will set the information coming from the last replace into the replacementInfo"
31117d801975 added: #setLastStringToReplace:
fm
parents: 4051
diff changeset
  8252
31117d801975 added: #setLastStringToReplace:
fm
parents: 4051
diff changeset
  8253
    |lastReplaceIgnoredCase|
31117d801975 added: #setLastStringToReplace:
fm
parents: 4051
diff changeset
  8254
4064
140eda842f20 added: #hasSearchActionSelection
fm
parents: 4053
diff changeset
  8255
    "/ 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
  8256
    self clearSearchAction.
140eda842f20 added: #hasSearchActionSelection
fm
parents: 4053
diff changeset
  8257
4053
31117d801975 added: #setLastStringToReplace:
fm
parents: 4051
diff changeset
  8258
    lastReplacementInfo lastStringToReplace: aString.
31117d801975 added: #setLastStringToReplace:
fm
parents: 4051
diff changeset
  8259
    lastStringFromReplaceForNextSearch := aString.
31117d801975 added: #setLastStringToReplace:
fm
parents: 4051
diff changeset
  8260
31117d801975 added: #setLastStringToReplace:
fm
parents: 4051
diff changeset
  8261
    "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
  8262
    lastReplaceIgnoredCase := (typeOfSelection == #search)
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8263
                                ifTrue: [lastSearchIgnoredCase]
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8264
                                ifFalse: [nil].
4053
31117d801975 added: #setLastStringToReplace:
fm
parents: 4051
diff changeset
  8265
    lastReplacementInfo lastReplaceIgnoredCase: lastReplaceIgnoredCase.
31117d801975 added: #setLastStringToReplace:
fm
parents: 4051
diff changeset
  8266
!
31117d801975 added: #setLastStringToReplace:
fm
parents: 4051
diff changeset
  8267
2225
65ac7cbffc60 added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents: 2213
diff changeset
  8268
suppressEmphasisInSelection
65ac7cbffc60 added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents: 2213
diff changeset
  8269
    "selection is shown without emphasis"
65ac7cbffc60 added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents: 2213
diff changeset
  8270
65ac7cbffc60 added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents: 2213
diff changeset
  8271
    ^ true
65ac7cbffc60 added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents: 2213
diff changeset
  8272
!
65ac7cbffc60 added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents: 2213
diff changeset
  8273
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8274
textChanged
522
aa9458e4643e indent/undent did not trigger a modify
ca
parents: 503
diff changeset
  8275
    "my text was modified (internally).
aa9458e4643e indent/undent did not trigger a modify
ca
parents: 503
diff changeset
  8276
     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
  8277
     contentsChanged, which is triggered when the size has changed, and
4635
6218b92cce91 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4630
diff changeset
  8278
     is used to notify scrollers, other views etc.).
6218b92cce91 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4630
diff changeset
  8279
5979
faad087b3207 #DOCUMENTATION by stefan
Stefan Vogel <sv@exept.de>
parents: 5977
diff changeset
  8280
     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
  8281
     (not sending contentsChanged, but textChanged),
6218b92cce91 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4630
diff changeset
  8282
     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
  8283
641
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  8284
    self contentsChanged.
1015
caf7265128b9 clear modified on accept.
Claus Gittinger <cg@exept.de>
parents: 1013
diff changeset
  8285
    self modified:true.
5774
3a1531b4c933 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 5773
diff changeset
  8286
    dependents notNil ifTrue:[ self changed:#textChanged ].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8287
    contentsWasSaved := false
641
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  8288
1015
caf7265128b9 clear modified on accept.
Claus Gittinger <cg@exept.de>
parents: 1013
diff changeset
  8289
    "Modified: 14.2.1997 / 16:58:38 / cg"
2207
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  8290
!
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  8291
2617
a9b1af787406 typo on method name
Claus Gittinger <cg@exept.de>
parents: 2606
diff changeset
  8292
textChangedButNoSizeChange
2207
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  8293
    "my text was modified (internally).
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  8294
     Sent whenever text has been edited (not to confuse with
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  8295
     contentsChanged, which is triggered when the size has changed, and
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  8296
     is used to notify scrollers, other views etc.)"
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  8297
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  8298
    self modified:true.
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  8299
    contentsWasSaved := false
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  8300
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  8301
    "Modified: 14.2.1997 / 16:58:38 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8302
! !
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8303
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8304
!EditTextView methodsFor:'queries'!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8305
5216
8d6eef5d09c3 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5194
diff changeset
  8306
canAccept
8d6eef5d09c3 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5194
diff changeset
  8307
    "true if text can be accepts.
8d6eef5d09c3 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5194
diff changeset
  8308
     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
  8309
8d6eef5d09c3 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5194
diff changeset
  8310
    ^ acceptEnabled ~~ false
8d6eef5d09c3 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5194
diff changeset
  8311
!
8d6eef5d09c3 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5194
diff changeset
  8312
8d6eef5d09c3 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5194
diff changeset
  8313
canCut
8d6eef5d09c3 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5194
diff changeset
  8314
    "true if there is a selection possibly to be cut.
8d6eef5d09c3 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5194
diff changeset
  8315
     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
  8316
8d6eef5d09c3 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5194
diff changeset
  8317
    self isReadOnly ifTrue:[ ^ false ].
8d6eef5d09c3 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5194
diff changeset
  8318
    ^ self hasSelection
8d6eef5d09c3 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5194
diff changeset
  8319
!
8d6eef5d09c3 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5194
diff changeset
  8320
8d6eef5d09c3 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5194
diff changeset
  8321
canDoAgain
8d6eef5d09c3 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5194
diff changeset
  8322
    "true if there is a possible repeat last edit operation.
8d6eef5d09c3 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5194
diff changeset
  8323
     Used to disable the menu if there is nothing"
8d6eef5d09c3 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5194
diff changeset
  8324
8d6eef5d09c3 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5194
diff changeset
  8325
    self isReadOnly ifTrue:[ ^ false ].
5972
957ca3b2afb0 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5962
diff changeset
  8326
    ^ lastReplacementInfo lastStringToReplace notNil
957ca3b2afb0 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5962
diff changeset
  8327
957ca3b2afb0 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5962
diff changeset
  8328
    "Modified: / 19-11-2016 / 20:19:02 / cg"
5216
8d6eef5d09c3 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5194
diff changeset
  8329
!
8d6eef5d09c3 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5194
diff changeset
  8330
1526
7676f301bb8f added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents: 1515
diff changeset
  8331
currentLine
7676f301bb8f added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents: 1515
diff changeset
  8332
    "the current line (for relative gotos)"
7676f301bb8f added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents: 1515
diff changeset
  8333
7676f301bb8f added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents: 1515
diff changeset
  8334
    ^ cursorLine
7676f301bb8f added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents: 1515
diff changeset
  8335
7676f301bb8f added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents: 1515
diff changeset
  8336
    "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
  8337
!
7676f301bb8f added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents: 1515
diff changeset
  8338
4064
140eda842f20 added: #hasSearchActionSelection
fm
parents: 4053
diff changeset
  8339
hasSearchActionSelection
140eda842f20 added: #hasSearchActionSelection
fm
parents: 4053
diff changeset
  8340
140eda842f20 added: #hasSearchActionSelection
fm
parents: 4053
diff changeset
  8341
    ^ typeOfSelection == #searchAction
140eda842f20 added: #hasSearchActionSelection
fm
parents: 4053
diff changeset
  8342
!
140eda842f20 added: #hasSearchActionSelection
fm
parents: 4053
diff changeset
  8343
1878
d93809bda6c8 added #isKeyboardConsumer
Claus Gittinger <cg@exept.de>
parents: 1850
diff changeset
  8344
isKeyboardConsumer
d93809bda6c8 added #isKeyboardConsumer
Claus Gittinger <cg@exept.de>
parents: 1850
diff changeset
  8345
    "return true, if the receiver is a keyboard consumer;
5283
9c75aed7c274 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5260
diff changeset
  8346
     Return true here if not readOnly, redefined from SimpleView."
1878
d93809bda6c8 added #isKeyboardConsumer
Claus Gittinger <cg@exept.de>
parents: 1850
diff changeset
  8347
3476
41dde91ae706 isKeyboardConsumer: returns false if readOnly
ca
parents: 3474
diff changeset
  8348
    ^ self isReadOnly not
1878
d93809bda6c8 added #isKeyboardConsumer
Claus Gittinger <cg@exept.de>
parents: 1850
diff changeset
  8349
!
d93809bda6c8 added #isKeyboardConsumer
Claus Gittinger <cg@exept.de>
parents: 1850
diff changeset
  8350
997
615a5a19c5bf specClass
ca
parents: 991
diff changeset
  8351
specClass
1390
99674e1d9c85 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
  8352
    "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
  8353
997
615a5a19c5bf specClass
ca
parents: 991
diff changeset
  8354
    self class == EditTextView ifTrue:[^ TextEditorSpec].
1049
24360c8891d6 specClass query
Claus Gittinger <cg@exept.de>
parents: 1037
diff changeset
  8355
    ^ super specClass
24360c8891d6 specClass query
Claus Gittinger <cg@exept.de>
parents: 1037
diff changeset
  8356
1390
99674e1d9c85 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
  8357
    "Modified: / 31.10.1997 / 19:48:19 / cg"
997
615a5a19c5bf specClass
ca
parents: 991
diff changeset
  8358
!
615a5a19c5bf specClass
ca
parents: 991
diff changeset
  8359
324
9eec6d69e155 better Tab key handling
Claus Gittinger <cg@exept.de>
parents: 323
diff changeset
  8360
tabMeansNextField
323
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
  8361
    "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
  8362
313
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  8363
    "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
  8364
1733
c5139b7402f0 use self isReadonly; readOnly may now be a valueHolder.
Claus Gittinger <cg@exept.de>
parents: 1732
diff changeset
  8365
    ^ self isReadOnly or:[tabMeansNextField]
324
9eec6d69e155 better Tab key handling
Claus Gittinger <cg@exept.de>
parents: 323
diff changeset
  8366
9eec6d69e155 better Tab key handling
Claus Gittinger <cg@exept.de>
parents: 323
diff changeset
  8367
    "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
  8368
!
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  8369
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8370
widthOfContents
6230
db7708cf8cdb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 6228
diff changeset
  8371
    "return the width of the contents in pixels.
db7708cf8cdb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 6228
diff changeset
  8372
    
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8373
     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
  8374
     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
  8375
     line (and possibly see the cursor behind the line)"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8376
697
0f258f02e8ea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 693
diff changeset
  8377
    |w dev|
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8378
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8379
    w := super widthOfContents.
5643
921578f80870 device access
Claus Gittinger <cg@exept.de>
parents: 5593
diff changeset
  8380
    (dev := device ) isNil ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8381
        "/ really don't know ...
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8382
        dev := Screen current
606
682579fa3b62 fixed #widthOfContents if no device is known
Claus Gittinger <cg@exept.de>
parents: 597
diff changeset
  8383
    ].
6230
db7708cf8cdb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 6228
diff changeset
  8384
    "/ add width of a space (so cursor is always seen)
4889
3ee5b37416a1 class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 4884
diff changeset
  8385
    ^ w + (gc font widthOn:dev)
697
0f258f02e8ea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 693
diff changeset
  8386
6230
db7708cf8cdb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 6228
diff changeset
  8387
    "Modified: / 28-05-1996 / 19:32:25 / cg"
db7708cf8cdb #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 6228
diff changeset
  8388
    "Modified (comment): / 19-11-2017 / 14:05:16 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8389
! !
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8390
1588
e2e4ceeed3da category change
Claus Gittinger <cg@exept.de>
parents: 1585
diff changeset
  8391
!EditTextView methodsFor:'realization'!
e2e4ceeed3da category change
Claus Gittinger <cg@exept.de>
parents: 1585
diff changeset
  8392
e2e4ceeed3da category change
Claus Gittinger <cg@exept.de>
parents: 1585
diff changeset
  8393
realize
e2e4ceeed3da category change
Claus Gittinger <cg@exept.de>
parents: 1585
diff changeset
  8394
    "make the view visible - scroll to make the cursor visible."
e2e4ceeed3da category change
Claus Gittinger <cg@exept.de>
parents: 1585
diff changeset
  8395
e2e4ceeed3da category change
Claus Gittinger <cg@exept.de>
parents: 1585
diff changeset
  8396
    super realize.
e2e4ceeed3da category change
Claus Gittinger <cg@exept.de>
parents: 1585
diff changeset
  8397
e2e4ceeed3da category change
Claus Gittinger <cg@exept.de>
parents: 1585
diff changeset
  8398
    self makeCursorVisible.
5643
921578f80870 device access
Claus Gittinger <cg@exept.de>
parents: 5593
diff changeset
  8399
    cursorFgColor := cursorFgColor onDevice:device.
921578f80870 device access
Claus Gittinger <cg@exept.de>
parents: 5593
diff changeset
  8400
    cursorBgColor := cursorBgColor onDevice:device.
1588
e2e4ceeed3da category change
Claus Gittinger <cg@exept.de>
parents: 1585
diff changeset
  8401
e2e4ceeed3da category change
Claus Gittinger <cg@exept.de>
parents: 1585
diff changeset
  8402
    "Modified: 20.12.1996 / 14:16:05 / cg"
e2e4ceeed3da category change
Claus Gittinger <cg@exept.de>
parents: 1585
diff changeset
  8403
    "Created: 24.7.1997 / 18:24:12 / cg"
e2e4ceeed3da category change
Claus Gittinger <cg@exept.de>
parents: 1585
diff changeset
  8404
! !
e2e4ceeed3da category change
Claus Gittinger <cg@exept.de>
parents: 1585
diff changeset
  8405
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8406
!EditTextView methodsFor:'redrawing'!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8407
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8408
redrawCursorIfBetweenVisibleLine:startVisLine and:endVisLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8409
    "redraw the cursor, if it sits in a line range"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8410
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8411
    cursorShown ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8412
        cursorVisibleLine notNil ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8413
            (cursorVisibleLine between:startVisLine and:endVisLine) ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8414
                self drawCursorCharacter
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8415
            ]
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8416
        ]
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8417
    ]
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  8418
!
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  8419
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8420
redrawCursorIfInVisibleLine:visLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8421
    "redraw the cursor, if it sits in visible line"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8422
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8423
    cursorShown ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8424
        (visLine == cursorVisibleLine) ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8425
            self drawCursorCharacter
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8426
        ]
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8427
    ]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8428
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8429
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8430
redrawFromVisibleLine:startVisLine to:endVisLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8431
    "redraw a visible line range"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8432
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8433
    super redrawFromVisibleLine:startVisLine to:endVisLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8434
    self redrawCursorIfBetweenVisibleLine:startVisLine and:endVisLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8435
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8436
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8437
redrawVisibleLine:visLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8438
    "redraw a visible line"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8439
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8440
    super redrawVisibleLine:visLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8441
    self redrawCursorIfInVisibleLine:visLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8442
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8443
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8444
redrawVisibleLine:visLine col:colNr
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8445
    "redraw the single character in visibleline at colNr"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8446
3510
4bd0b20bd05d cursor-only redrawing, with vertical-insertion cursor
Claus Gittinger <cg@exept.de>
parents: 3495
diff changeset
  8447
    super redrawVisibleLine:visLine col:colNr.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8448
    cursorShown ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8449
        (visLine == cursorVisibleLine) ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8450
            (colNr == cursorCol) ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8451
                self drawCursorCharacter.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8452
                ^ self
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8453
            ]
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8454
        ]
3510
4bd0b20bd05d cursor-only redrawing, with vertical-insertion cursor
Claus Gittinger <cg@exept.de>
parents: 3495
diff changeset
  8455
    ].
4bd0b20bd05d cursor-only redrawing, with vertical-insertion cursor
Claus Gittinger <cg@exept.de>
parents: 3495
diff changeset
  8456
4bd0b20bd05d cursor-only redrawing, with vertical-insertion cursor
Claus Gittinger <cg@exept.de>
parents: 3495
diff changeset
  8457
    "Modified: / 05-11-2007 / 17:35:53 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8458
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8459
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8460
redrawVisibleLine:visLine from:startCol
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8461
    "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
  8462
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8463
    super redrawVisibleLine:visLine from:startCol.
4494
dfe81ebdd5d6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
  8464
    cursorShown ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8465
        self redrawCursorIfInVisibleLine:visLine
4494
dfe81ebdd5d6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
  8466
    ]
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8467
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8468
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8469
redrawVisibleLine:visLine from:startCol to:endCol
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8470
    "redraw a visible line from startCol to endCol"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8471
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8472
    super redrawVisibleLine:visLine from:startCol to:endCol.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8473
    self redrawCursorIfInVisibleLine:visLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8474
! !
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8475
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8476
!EditTextView methodsFor:'scrolling'!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8477
2331
218a017dc1f3 additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents: 2323
diff changeset
  8478
additionalMarginForHorizontalScroll
218a017dc1f3 additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents: 2323
diff changeset
  8479
    "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
  8480
     width of the document would allow.
218a017dc1f3 additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents: 2323
diff changeset
  8481
     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
  8482
     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
  8483
     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
  8484
4889
3ee5b37416a1 class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 4884
diff changeset
  8485
    ^ 10 max:gc font width
2331
218a017dc1f3 additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents: 2323
diff changeset
  8486
!
218a017dc1f3 additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents: 2323
diff changeset
  8487
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8488
halfPageDown
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8489
    "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
  8490
     within the real text  "
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8491
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8492
    |prevCursorLine|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8493
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8494
    prevCursorLine := cursorVisibleLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8495
    super halfPageDown.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8496
    self cursorVisibleLine:prevCursorLine col:cursorCol
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8497
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8498
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8499
halfPageUp
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8500
    "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
  8501
     within the real text  "
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
    |prevCursorLine|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8504
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8505
    prevCursorLine := cursorVisibleLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8506
    super halfPageUp.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8507
    self cursorVisibleLine:prevCursorLine col:cursorCol
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8508
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8509
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8510
originChanged:delta
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8511
    "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
  8512
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8513
    super originChanged:delta.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8514
    "
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8515
     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
  8516
    "
2422
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  8517
    self updateCursorVisibleLine.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8518
    prevCursorState ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8519
        self showCursor
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8520
    ]
1577
4e487247ad33 dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents: 1568
diff changeset
  8521
4e487247ad33 dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents: 1568
diff changeset
  8522
    "Modified: / 17.6.1998 / 16:13:24 / cg"
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
originWillChange
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8526
    "sent before scrolling - have to hide the cursor"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8527
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8528
    prevCursorState := cursorShown.
1601
57dde4dfee7e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  8529
    "/ cursorShown := false.
1591
d84c117e71cc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1590
diff changeset
  8530
    cursorShown ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8531
        self hideCursor
1591
d84c117e71cc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1590
diff changeset
  8532
    ]
d84c117e71cc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1590
diff changeset
  8533
1601
57dde4dfee7e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  8534
    "Modified: / 6.7.1998 / 13:07:23 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8535
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8536
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8537
pageDown
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8538
    "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
  8539
     within the real text  "
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8540
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8541
    |prevCursorLine|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8542
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8543
    prevCursorLine := cursorVisibleLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8544
    super pageDown.
6184
5c47cff0a192 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 6171
diff changeset
  8545
    prevCursorLine notNil ifTrue:[
5c47cff0a192 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 6171
diff changeset
  8546
        "https://expeccoalm.exept.de/D204551"
5c47cff0a192 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 6171
diff changeset
  8547
        self cursorVisibleLine:prevCursorLine col:cursorCol.
5c47cff0a192 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 6171
diff changeset
  8548
    ].
5c47cff0a192 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 6171
diff changeset
  8549
5c47cff0a192 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 6171
diff changeset
  8550
    "Modified: / 18-07-2017 / 12:31:47 / stefan"
259
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
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8553
pageUp
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8554
    "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
  8555
     within the real text  "
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8556
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8557
    |prevCursorLine|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8558
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8559
    prevCursorLine := cursorVisibleLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8560
    super pageUp.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8561
    self cursorVisibleLine:prevCursorLine col:cursorCol
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
!EditTextView methodsFor:'searching'!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8565
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8566
searchBwd:pattern ifAbsent:aBlock
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8567
    "do a backward search"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8568
2822
08ceab3fc237 search refactored;
Claus Gittinger <cg@exept.de>
parents: 2819
diff changeset
  8569
    self searchBwd:pattern ignoreCase:false ifAbsent:aBlock
1339
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  8570
!
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  8571
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  8572
searchBwd:pattern ignoreCase:ign ifAbsent:aBlock
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  8573
    "do a backward search"
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  8574
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  8575
    cursorLine isNil ifTrue:[^ self].
4464
bbdc850e9d93 search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents: 4458
diff changeset
  8576
    super searchBwd:pattern ignoreCase:ign ifAbsent:aBlock
3580
c9d10df2b8bc StringSearchTool
fm
parents: 3578
diff changeset
  8577
!
c9d10df2b8bc StringSearchTool
fm
parents: 3578
diff changeset
  8578
c9d10df2b8bc StringSearchTool
fm
parents: 3578
diff changeset
  8579
searchBwd:pattern ignoreCase:ign startingAtLine:startLine col:startCol ifAbsent:aBlock
c9d10df2b8bc StringSearchTool
fm
parents: 3578
diff changeset
  8580
    "do a backward search"
c9d10df2b8bc StringSearchTool
fm
parents: 3578
diff changeset
  8581
c9d10df2b8bc StringSearchTool
fm
parents: 3578
diff changeset
  8582
    cursorLine isNil ifTrue:[^ self].
c9d10df2b8bc StringSearchTool
fm
parents: 3578
diff changeset
  8583
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  8584
    self
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8585
        searchBackwardFor:pattern
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8586
        ignoreCase:ign
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8587
        startingAtLine:startLine col:startCol
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8588
        ifFound:[:line :col :endColOrNil |
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8589
            self cursorMovementAllowed ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8590
                self cursorLine:line col:col.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8591
            ].
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8592
            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
  8593
"/            self makeLineVisible:cursorLine
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8594
            typeOfSelection := #search]
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8595
        ifAbsent:aBlock
1339
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  8596
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  8597
    "Modified: 9.10.1997 / 13:02:13 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8598
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8599
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8600
searchForAndSelectMatchingParenthesis
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8601
    "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
  8602
2554
ec6aca20825f refactored
Claus Gittinger <cg@exept.de>
parents: 2544
diff changeset
  8603
    self searchForAndSelectMatchingParenthesisFromLine:cursorLine col:cursorCol
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8604
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8605
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8606
searchForMatchingParenthesis
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  8607
    "search for a matching parenthesis starting at cursor position.
6096
27f0da22dc30 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 6091
diff changeset
  8608
     Search for the corresponding character is done forward if it's an opening,
27f0da22dc30 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 6091
diff changeset
  8609
     backwards if it's a closing parenthesis.
27f0da22dc30 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 6091
diff changeset
  8610
     Positions the cursor if found, beeps if not"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8611
2822
08ceab3fc237 search refactored;
Claus Gittinger <cg@exept.de>
parents: 2819
diff changeset
  8612
    self cursorMovementAllowed ifFalse:[^ self].
08ceab3fc237 search refactored;
Claus Gittinger <cg@exept.de>
parents: 2819
diff changeset
  8613
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  8614
    self
6096
27f0da22dc30 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 6091
diff changeset
  8615
        searchForMatchingParenthesisFromLine:cursorLine col:cursorCol
27f0da22dc30 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 6091
diff changeset
  8616
        ifFound:[:line :col | self cursorLine:line col:col]
27f0da22dc30 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 6091
diff changeset
  8617
        ifNotFound:[self showNotFound]
6262
5b9bf7c3c828 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 6249
diff changeset
  8618
        onError:[self beepInEditor]
6096
27f0da22dc30 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 6091
diff changeset
  8619
27f0da22dc30 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 6091
diff changeset
  8620
    "Modified: / 09-10-1997 / 12:56:30 / cg"
27f0da22dc30 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 6091
diff changeset
  8621
    "Modified (comment): / 13-02-2017 / 20:10:54 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8622
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8623
3967
64bc48cd8e8b do not take search string from selection
fm
parents: 3963
diff changeset
  8624
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
  8625
    "do a forward search"
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  8626
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  8627
    cursorLine isNil ifTrue:[^ self].
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8628
    self
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8629
        searchForwardFor:pattern
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8630
        ignoreCase:ign
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8631
        match: match
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8632
        startingAtLine:startLine col:startCol
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8633
        ifFound:[:line :col :endColOrNil|
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8634
            self cursorMovementAllowed ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8635
                self cursorLine:line col:col.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8636
            ].
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8637
            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
  8638
"/            self makeLineVisible:cursorLine
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8639
            typeOfSelection := #search
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8640
        ]
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8641
        ifAbsent:aBlock
1339
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  8642
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  8643
    "Modified: 9.10.1997 / 12:57:47 / cg"
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  8644
    "Created: 9.10.1997 / 13:01:12 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8645
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8646
3967
64bc48cd8e8b do not take search string from selection
fm
parents: 3963
diff changeset
  8647
searchFwd:pattern ignoreCase:ign startingAtLine:startLine col:startCol ifAbsent:aBlock
64bc48cd8e8b do not take search string from selection
fm
parents: 3963
diff changeset
  8648
    "do a forward search"
64bc48cd8e8b do not take search string from selection
fm
parents: 3963
diff changeset
  8649
64bc48cd8e8b do not take search string from selection
fm
parents: 3963
diff changeset
  8650
    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
  8651
!
64bc48cd8e8b do not take search string from selection
fm
parents: 3963
diff changeset
  8652
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8653
searchFwd:pattern startingAtLine:startLine col:startCol ifAbsent:aBlock
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8654
    "do a forward search"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8655
2822
08ceab3fc237 search refactored;
Claus Gittinger <cg@exept.de>
parents: 2819
diff changeset
  8656
    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
  8657
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8658
3982
79e6af2d27b1 fixes in searchBar
fm
parents: 3976
diff changeset
  8659
searchPatternForSearchBar
79e6af2d27b1 fixes in searchBar
fm
parents: 3976
diff changeset
  8660
79e6af2d27b1 fixes in searchBar
fm
parents: 3976
diff changeset
  8661
    "Returns the next searchPattern from the user selection or from the autoSearch"
79e6af2d27b1 fixes in searchBar
fm
parents: 3976
diff changeset
  8662
79e6af2d27b1 fixes in searchBar
fm
parents: 3976
diff changeset
  8663
    |searchPattern|
79e6af2d27b1 fixes in searchBar
fm
parents: 3976
diff changeset
  8664
4138
fm
parents: 4136
diff changeset
  8665
    searchPattern := self searchPatternFromUserSelectionOrReplace.
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  8666
    searchPattern isNil
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8667
        ifTrue: [searchPattern := lastSearchPattern]
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8668
        ifFalse: [lastSearchPattern := searchPattern].
3982
79e6af2d27b1 fixes in searchBar
fm
parents: 3976
diff changeset
  8669
    ^ searchPattern
79e6af2d27b1 fixes in searchBar
fm
parents: 3976
diff changeset
  8670
!
79e6af2d27b1 fixes in searchBar
fm
parents: 3976
diff changeset
  8671
3578
9d43beca1e85 searchForward with match argument
fm
parents: 3572
diff changeset
  8672
setSearchPatternWithMatchEscapes: match
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8673
    "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
  8674
     cursor to start of pattern"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8675
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8676
    |sel|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8677
559
3ff87e9447c6 keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents: 522
diff changeset
  8678
    "/
3967
64bc48cd8e8b do not take search string from selection
fm
parents: 3963
diff changeset
  8679
    "/ 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
  8680
    "/ original string (for search after again)
4121
9232089c04c2 comment/format in: #setSearchPatternWithMatchEscapes:
fm
parents: 4119
diff changeset
  8681
    "/ 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
  8682
    "/
4249
44daffb1b034 comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents: 4248
diff changeset
  8683
"/    (lastStringFromReplaceForNextSearch notNil
44daffb1b034 comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents: 4248
diff changeset
  8684
"/     and:[typeOfSelection ~~ #search]) ifTrue:[
44daffb1b034 comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents: 4248
diff changeset
  8685
"/        lastStringFromReplaceForNextSearch isString ifTrue:[
44daffb1b034 comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents: 4248
diff changeset
  8686
"/            lastSearchPattern := lastStringFromReplaceForNextSearch.
44daffb1b034 comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents: 4248
diff changeset
  8687
"/        ] ifFalse:[
44daffb1b034 comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents: 4248
diff changeset
  8688
"/            lastSearchPattern := lastStringFromReplaceForNextSearch asStringWithoutFinalCR.
44daffb1b034 comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents: 4248
diff changeset
  8689
"/        ].
44daffb1b034 comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents: 4248
diff changeset
  8690
"/        ^ self
44daffb1b034 comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents: 4248
diff changeset
  8691
"/    ].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8692
559
3ff87e9447c6 keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents: 522
diff changeset
  8693
    "/
3ff87e9447c6 keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents: 522
diff changeset
  8694
    "/ if there is a selection:
3ff87e9447c6 keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents: 522
diff changeset
  8695
    "/    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
  8696
    "/    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
  8697
    "/    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
  8698
    "/    (to allow search-paste to be repeated)
3ff87e9447c6 keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents: 522
diff changeset
  8699
    "/
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8700
    sel := self selection.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8701
    sel notNil ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8702
        (lastSearchPattern isNil
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8703
        or:[typeOfSelection ~~ #paste and:[typeOfSelection ~~ #search]]
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8704
        ) ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8705
            self cursorLine:selectionStartLine col:selectionStartCol.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8706
            lastSearchPattern := sel asStringWithoutFinalCR.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8707
            match ifTrue:[lastSearchPattern := lastSearchPattern withMatchEscapes].
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8708
        ]
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8709
    ]
559
3ff87e9447c6 keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents: 522
diff changeset
  8710
4249
44daffb1b034 comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents: 4248
diff changeset
  8711
    "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
  8712
!
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
  8713
5717
94a8cc3be8ec #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 5710
diff changeset
  8714
showMatch:pattern isMatch:isMatch atLine:line col:col endCol:encColOrNil
94a8cc3be8ec #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 5710
diff changeset
  8715
    super showMatch:pattern isMatch:isMatch atLine:line col:col endCol:encColOrNil.
4484
38f88010834c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4483
diff changeset
  8716
    typeOfSelection := #search.
38f88010834c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4483
diff changeset
  8717
!
38f88010834c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4483
diff changeset
  8718
2756
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
  8719
startPositionForSearchBackward
2822
08ceab3fc237 search refactored;
Claus Gittinger <cg@exept.de>
parents: 2819
diff changeset
  8720
    ^ self startPositionForSearchBackwardBasedOnCursorOrSelection
08ceab3fc237 search refactored;
Claus Gittinger <cg@exept.de>
parents: 2819
diff changeset
  8721
!
08ceab3fc237 search refactored;
Claus Gittinger <cg@exept.de>
parents: 2819
diff changeset
  8722
08ceab3fc237 search refactored;
Claus Gittinger <cg@exept.de>
parents: 2819
diff changeset
  8723
startPositionForSearchBackwardBasedOnCursorOrSelection
2756
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
  8724
    |startLine startCol|
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
  8725
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
  8726
    selectionStartLine notNil ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8727
        startLine := selectionStartLine.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8728
        startCol := selectionStartCol
2756
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
  8729
    ] ifFalse:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8730
        cursorLine isNil ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8731
            startLine := list size.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8732
            startCol := self listAt:startLine size.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8733
        ] ifFalse:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8734
            startLine := cursorLine min:list size.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8735
            startCol := cursorCol
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8736
        ]
2756
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
  8737
    ].
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
  8738
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
  8739
    ^ startCol @ cursorLine
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
  8740
!
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
  8741
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
  8742
startPositionForSearchForward
2822
08ceab3fc237 search refactored;
Claus Gittinger <cg@exept.de>
parents: 2819
diff changeset
  8743
    ^ self startPositionForSearchForwardBasedOnCursorOrSelection
08ceab3fc237 search refactored;
Claus Gittinger <cg@exept.de>
parents: 2819
diff changeset
  8744
!
08ceab3fc237 search refactored;
Claus Gittinger <cg@exept.de>
parents: 2819
diff changeset
  8745
08ceab3fc237 search refactored;
Claus Gittinger <cg@exept.de>
parents: 2819
diff changeset
  8746
startPositionForSearchForwardBasedOnCursorOrSelection
2756
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
  8747
    |startCol|
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
  8748
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  8749
    "/ 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
  8750
    "/ 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
  8751
    startCol := cursorCol.
4424
b38e9e3b483b changed: #startPositionForSearchForwardBasedOnCursorOrSelection
Claus Gittinger <cg@exept.de>
parents: 4421
diff changeset
  8752
    self hasSelection ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8753
        ^ selectionEndCol @ selectionEndLine.
4424
b38e9e3b483b changed: #startPositionForSearchForwardBasedOnCursorOrSelection
Claus Gittinger <cg@exept.de>
parents: 4421
diff changeset
  8754
    ] ifFalse:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8755
        (cursorLine == 1 and:[cursorCol == 1]) ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8756
            startCol := 0
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8757
        ].
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8758
        startCol := startCol min:(self at:cursorLine) size
2756
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
  8759
    ].
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
  8760
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
  8761
    ^ startCol @ cursorLine
4424
b38e9e3b483b changed: #startPositionForSearchForwardBasedOnCursorOrSelection
Claus Gittinger <cg@exept.de>
parents: 4421
diff changeset
  8762
b38e9e3b483b changed: #startPositionForSearchForwardBasedOnCursorOrSelection
Claus Gittinger <cg@exept.de>
parents: 4421
diff changeset
  8763
    "Modified (format): / 24-05-2012 / 13:58:37 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8764
! !
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8765
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8766
!EditTextView methodsFor:'selections'!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8767
3023
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  8768
addToSelectionAfter:aBlock
5145
b87b83495631 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5142
diff changeset
  8769
    <resource: #obsolete>
b87b83495631 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5142
diff changeset
  8770
b87b83495631 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5142
diff changeset
  8771
    "evaluate aBlock while unselected.
b87b83495631 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5142
diff changeset
  8772
     Restore the previous selection afterwards.
b87b83495631 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5142
diff changeset
  8773
     CG: I am not sure, if this is a leftover and is still used at all.
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8774
         It is therefore temporarily marked as obsolete. Please check
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8775
         and let me know."
3023
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  8776
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  8777
    |startLine startCol endLine endCol |
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  8778
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  8779
    self hasSelection ifTrue: [
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8780
        startLine := selectionStartLine .
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8781
        startCol := selectionStartCol .
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8782
        endLine := selectionEndLine .
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8783
        endCol := selectionEndCol .
3023
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  8784
    ] ifFalse: [
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8785
        startLine := endLine :=  cursorLine .
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8786
        startCol := endCol := cursorCol .
3023
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  8787
    ].
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  8788
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  8789
    "deselectim a provedu presun kurzoru..."
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  8790
    self unselect .
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  8791
    aBlock value .
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  8792
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  8793
    "funguje dost mizerne, jen na jednom radku..."
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  8794
    (startCol - cursorCol) abs <= (endCol - cursorCol) abs
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8795
        ifTrue: [
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8796
            startCol := cursorCol.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8797
        ] ifFalse: [
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8798
            endCol := cursorCol - 1.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8799
        ].
3023
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  8800
    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
  8801
!
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  8802
1850
82516928e791 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1849
diff changeset
  8803
autoMoveCursorToEndOfSelection
82516928e791 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1849
diff changeset
  8804
    "return true, if the cursor should be automatically moved to the
82516928e791 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1849
diff changeset
  8805
     end of a selection.
3963
c315f087d655 comment in: #autoMoveCursorToEndOfSelection
Claus Gittinger <cg@exept.de>
parents: 3945
diff changeset
  8806
     Redefined to return false in terminalViews, where the cursor should
1850
82516928e791 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1849
diff changeset
  8807
     not be affected by selecting"
82516928e791 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1849
diff changeset
  8808
82516928e791 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1849
diff changeset
  8809
    ^ true
82516928e791 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1849
diff changeset
  8810
!
82516928e791 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1849
diff changeset
  8811
2606
6a3ab90d339f redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents: 2599
diff changeset
  8812
changeTypeOfSelectionTo:newType
6a3ab90d339f redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents: 2599
diff changeset
  8813
    typeOfSelection ~~ newType ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8814
        typeOfSelection := newType.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8815
        selectionStartLine notNil ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8816
            self
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8817
                redrawFromLine:selectionStartLine col:selectionStartCol
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8818
                toLine:selectionEndLine col:selectionEndCol
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8819
        ].
2606
6a3ab90d339f redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents: 2599
diff changeset
  8820
    ].
6a3ab90d339f redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents: 2599
diff changeset
  8821
!
6a3ab90d339f redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents: 2599
diff changeset
  8822
4707
f6ac835a1cf6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4701
diff changeset
  8823
findNextWordAfterSelectionAndAddToSelection
f6ac835a1cf6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4701
diff changeset
  8824
    |selStartCol selStartLine selEndCol selEndLine|
f6ac835a1cf6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4701
diff changeset
  8825
f6ac835a1cf6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4701
diff changeset
  8826
    selectionStartCol isNil ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8827
        self selectWordUnderCursor.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8828
        ^ self
4707
f6ac835a1cf6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4701
diff changeset
  8829
    ].
f6ac835a1cf6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4701
diff changeset
  8830
f6ac835a1cf6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4701
diff changeset
  8831
    selStartCol := selectionStartCol.
f6ac835a1cf6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4701
diff changeset
  8832
    selEndCol := selectionEndCol.
f6ac835a1cf6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4701
diff changeset
  8833
    selStartLine := selectionStartLine.
f6ac835a1cf6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4701
diff changeset
  8834
    selEndLine := selectionEndLine.
f6ac835a1cf6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4701
diff changeset
  8835
f6ac835a1cf6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4701
diff changeset
  8836
    self cursorToNextWord.
f6ac835a1cf6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4701
diff changeset
  8837
    self selectWordUnderCursor.
f6ac835a1cf6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4701
diff changeset
  8838
f6ac835a1cf6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4701
diff changeset
  8839
    self selectFromLine:selStartLine col:selStartCol toLine:selectionEndLine col:selectionEndCol.
f6ac835a1cf6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4701
diff changeset
  8840
!
f6ac835a1cf6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4701
diff changeset
  8841
4138
fm
parents: 4136
diff changeset
  8842
searchPatternFromUserSelectionOrReplace
fm
parents: 4136
diff changeset
  8843
fm
parents: 4136
diff changeset
  8844
    |sel searchPattern|
fm
parents: 4136
diff changeset
  8845
fm
parents: 4136
diff changeset
  8846
    "/
fm
parents: 4136
diff changeset
  8847
    "/ if the last operation was a replace, set pattern to last
fm
parents: 4136
diff changeset
  8848
    "/ original string (for search after again)
fm
parents: 4136
diff changeset
  8849
    "/
fm
parents: 4136
diff changeset
  8850
    (lastStringFromReplaceForNextSearch notNil
fm
parents: 4136
diff changeset
  8851
     and:[typeOfSelection ~~ #search]) ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8852
        lastStringFromReplaceForNextSearch isString ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8853
            searchPattern := lastStringFromReplaceForNextSearch.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8854
        ] ifFalse:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8855
            searchPattern := lastStringFromReplaceForNextSearch asStringWithoutFinalCR.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8856
        ].
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8857
        ^ searchPattern
4138
fm
parents: 4136
diff changeset
  8858
    ].
fm
parents: 4136
diff changeset
  8859
fm
parents: 4136
diff changeset
  8860
    "/
fm
parents: 4136
diff changeset
  8861
    "/ if there is a selection:
fm
parents: 4136
diff changeset
  8862
    "/    if there was no previous search, take it as search pattern.
fm
parents: 4136
diff changeset
  8863
    "/    if there was a previous search, only take the selection if
fm
parents: 4136
diff changeset
  8864
    "/    it did not result from a paste.
fm
parents: 4136
diff changeset
  8865
    "/    (to allow search-paste to be repeated)
fm
parents: 4136
diff changeset
  8866
    "/
fm
parents: 4136
diff changeset
  8867
    sel := self selection.
fm
parents: 4136
diff changeset
  8868
    sel notNil ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8869
        typeOfSelection ~~ #search ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8870
            typeOfSelection ~~ #paste ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8871
                self cursorLine:selectionStartLine col:selectionStartCol.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8872
                searchPattern := sel asStringWithoutFinalCR.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8873
            ]
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8874
        ].
4138
fm
parents: 4136
diff changeset
  8875
    ].
fm
parents: 4136
diff changeset
  8876
fm
parents: 4136
diff changeset
  8877
    ^ searchPattern
fm
parents: 4136
diff changeset
  8878
!
fm
parents: 4136
diff changeset
  8879
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8880
selectAll
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8881
    "select the whole text.
5593
ad41e448d7a8 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 5581
diff changeset
  8882
     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
  8883
     cursor to be moved in this case."
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8884
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8885
    list isNil ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8886
        self unselect
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8887
    ] ifFalse:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8888
        super selectFromLine:1 col:1 toLine:(list size + 1) col:0.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8889
        typeOfSelection := nil
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8890
    ]
1082
ccc3aa4268c1 better #selectAll
Claus Gittinger <cg@exept.de>
parents: 1054
diff changeset
  8891
ccc3aa4268c1 better #selectAll
Claus Gittinger <cg@exept.de>
parents: 1054
diff changeset
  8892
    "Modified: 28.2.1997 / 19:14:54 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8893
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8894
4117
470a3086aaa9 added: #selectAllInitially
sr
parents: 4114
diff changeset
  8895
selectAllInitially
470a3086aaa9 added: #selectAllInitially
sr
parents: 4114
diff changeset
  8896
    "select the whole text. This is called only once during the initialization
470a3086aaa9 added: #selectAllInitially
sr
parents: 4114
diff changeset
  8897
     for editFields which are shown in a table or tree.
470a3086aaa9 added: #selectAllInitially
sr
parents: 4114
diff changeset
  8898
     The selectAll is called via this method to allow for easier redefinition and
470a3086aaa9 added: #selectAllInitially
sr
parents: 4114
diff changeset
  8899
     to distinguish auto-select from user-initiated selects."
470a3086aaa9 added: #selectAllInitially
sr
parents: 4114
diff changeset
  8900
470a3086aaa9 added: #selectAllInitially
sr
parents: 4114
diff changeset
  8901
    self selectAll
470a3086aaa9 added: #selectAllInitially
sr
parents: 4114
diff changeset
  8902
!
470a3086aaa9 added: #selectAllInitially
sr
parents: 4114
diff changeset
  8903
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8904
selectCursorLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8905
    "select cursorline"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8906
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  8907
    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
  8908
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8909
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8910
selectCursorLineFromBeginning
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8911
    "select cursorline up to cursor position"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8912
823
fc61564f7832 escape selects up to previous character
Claus Gittinger <cg@exept.de>
parents: 785
diff changeset
  8913
    cursorCol > 1 ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8914
        self selectFromLine:cursorLine col:1
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8915
                     toLine:cursorLine col:(cursorCol-1)
823
fc61564f7832 escape selects up to previous character
Claus Gittinger <cg@exept.de>
parents: 785
diff changeset
  8916
    ]
fc61564f7832 escape selects up to previous character
Claus Gittinger <cg@exept.de>
parents: 785
diff changeset
  8917
fc61564f7832 escape selects up to previous character
Claus Gittinger <cg@exept.de>
parents: 785
diff changeset
  8918
    "Modified: 16.8.1996 / 19:14:14 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8919
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8920
6354
3fcb3ef259c1 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6339
diff changeset
  8921
selectCursorLineToEnd
3fcb3ef259c1 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6339
diff changeset
  8922
    "select cursorline from cursor position to the end"
3fcb3ef259c1 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6339
diff changeset
  8923
3fcb3ef259c1 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6339
diff changeset
  8924
    self selectFromLine:cursorLine col:cursorCol
3fcb3ef259c1 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6339
diff changeset
  8925
         toLine:(cursorLine+1) col:0
3fcb3ef259c1 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6339
diff changeset
  8926
3fcb3ef259c1 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6339
diff changeset
  8927
    "Created: / 16-06-2018 / 00:46:21 / Claus Gittinger"
3fcb3ef259c1 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6339
diff changeset
  8928
!
3fcb3ef259c1 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6339
diff changeset
  8929
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8930
selectExpandCursorLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8931
    "expand selection by one line or select cursorline"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8932
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8933
    selectionStartLine isNil ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8934
        self selectCursorLine
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8935
    ] ifFalse:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8936
        self selectFromLine:selectionStartLine col:selectionStartCol
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8937
                     toLine:cursorLine+1 col:0.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8938
        self makeLineVisible:selectionEndLine
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8939
    ]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8940
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8941
4257
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  8942
selectFromBeginOfLine
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  8943
    "select the text from the beginning of the current line to the current cursor position."
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  8944
4430
61c074a935cf fixed: #selectFromBeginOfLine
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4424
diff changeset
  8945
    | newCursorCol ln |
4271
3ce604308987 changed:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4258
diff changeset
  8946
4257
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  8947
    list isNil ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8948
        self unselect
4257
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  8949
    ] ifFalse:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8950
        cursorCol > 1 ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8951
            ln := list at: cursorLine.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8952
            newCursorCol := ln notEmptyOrNil ifTrue:[ln indexOfNonSeparator] ifFalse:[1].
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8953
            self selectFromLine:cursorLine col:newCursorCol toLine:cursorLine col:cursorCol-1.
6207
7a5c2914e422 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6203
diff changeset
  8954
            "/ cursorCol := newCursorCol.
7a5c2914e422 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6203
diff changeset
  8955
            self setCursorCol:newCursorCol.
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8956
            typeOfSelection := nil
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8957
        ]
4257
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  8958
    ]
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  8959
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  8960
    "Created: / 28-06-2011 / 22:47:04 / cg"
4430
61c074a935cf fixed: #selectFromBeginOfLine
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4424
diff changeset
  8961
    "Modified: / 18-07-2012 / 17:00:26 / Jan Vrany <jan.vrany@fit.cvut.cz>"
4257
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  8962
!
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  8963
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8964
selectFromBeginning
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8965
    "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
  8966
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8967
    |col|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8968
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8969
    list isNil ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8970
        self unselect
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8971
    ] ifFalse:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8972
        cursorCol == 0 ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8973
            col := 0
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8974
        ] ifFalse:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8975
            col := cursorCol - 1
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8976
        ].
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8977
        super selectFromLine:1 col:1 toLine:cursorLine col:col.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8978
        typeOfSelection := nil
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8979
    ]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8980
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8981
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8982
selectFromLine:startLine col:startCol toLine:endLine col:endCol
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8983
    "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
  8984
     for easier editing. Also typeOfSelection is nilled here."
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8985
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8986
    super selectFromLine:startLine col:startCol toLine:endLine col:endCol.
1850
82516928e791 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1849
diff changeset
  8987
    (selectionEndLine notNil and:[self autoMoveCursorToEndOfSelection]) ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8988
        self cursorLine:selectionEndLine col:(selectionEndCol + 1).
1198
1c5390d2d3fb care for failed selection when positioning cursor.
ca
parents: 1177
diff changeset
  8989
    ].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8990
    typeOfSelection := nil
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8991
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8992
4257
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  8993
selectToEndOfLine
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  8994
    "select the text from the current cursor position to the end of the current line"
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  8995
4271
3ce604308987 changed:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4258
diff changeset
  8996
    | newCursorCol line |
3ce604308987 changed:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4258
diff changeset
  8997
4257
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  8998
    list isNil ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  8999
        self unselect
4257
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  9000
    ] ifFalse:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  9001
        cursorCol >= 1 ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  9002
            line := list at: cursorLine.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  9003
            newCursorCol := line size.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  9004
            [ newCursorCol > 1 and:[(line at:newCursorCol) isSeparator] ]
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  9005
                whileTrue:[newCursorCol := newCursorCol - 1].
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  9006
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  9007
            self selectFromLine:cursorLine col:cursorCol toLine:cursorLine col: newCursorCol.
6207
7a5c2914e422 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6203
diff changeset
  9008
            "/ cursorCol := newCursorCol.
7a5c2914e422 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 6203
diff changeset
  9009
            self setCursorCol:newCursorCol.
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  9010
            typeOfSelection := nil
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  9011
        ]
4257
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  9012
    ]
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  9013
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  9014
    "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
  9015
    "Modified: / 30-06-2011 / 19:51:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
4257
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  9016
!
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  9017
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  9018
selectUpToEnd
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  9019
    "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
  9020
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  9021
    list isNil ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  9022
        self unselect
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  9023
    ] ifFalse:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  9024
        super selectFromLine:cursorLine col:cursorCol toLine:(list size + 1) col:0.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  9025
        typeOfSelection := nil
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  9026
    ]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  9027
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  9028
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  9029
selectWordUnderCursor
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  9030
    "select the word under the cursor"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  9031
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  9032
    self selectWordAtLine:cursorLine col:cursorCol
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  9033
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  9034
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  9035
unselect
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  9036
    "forget and unhilight selection - must take care of cursor here"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  9037
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  9038
    |wasOn|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  9039
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  9040
    wasOn := self hideCursor.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  9041
    super unselect.
2606
6a3ab90d339f redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents: 2599
diff changeset
  9042
    typeOfSelection := nil.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  9043
    wasOn ifTrue:[self showCursor]
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  9044
! !
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  9045
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  9046
!EditTextView methodsFor:'undo & again'!
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  9047
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9048
addUndo:action
2989
5dcc2912bcb6 undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents: 2984
diff changeset
  9049
    ^ undoSupport addUndo:action.
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9050
!
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9051
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  9052
again
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  9053
    "repeat the last action (which was a cut or replace).
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  9054
     If current selection is not last string, search forward to
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  9055
     next occurrence of it before repeating the last operation."
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  9056
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  9057
    |s l c sel savedSelectStyle startColForSearch
4051
4fdd00fbdc60 changed:
fm
parents: 4048
diff changeset
  9058
     lastStringToReplace lastReplaceIgnoredCase lastReplaceWasMatch|
4048
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
  9059
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
  9060
    lastStringToReplace := lastReplacementInfo lastStringToReplace.
4010
9c22bd531240 lastStringToReplace to use in again
fm
parents: 3996
diff changeset
  9061
    lastStringToReplace isNil ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  9062
        ^ false
2579
74d3798f4200 do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents: 2574
diff changeset
  9063
    ].
4048
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
  9064
    lastReplaceIgnoredCase := lastReplacementInfo lastReplaceIgnoredCase.
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
  9065
    lastReplaceWasMatch := lastReplacementInfo lastReplaceWasMatch.
2579
74d3798f4200 do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents: 2574
diff changeset
  9066
3127
29767bf8a215 better info of replace action (compound-undo-action has info, too)
Claus Gittinger <cg@exept.de>
parents: 3115
diff changeset
  9067
    self undoableDo:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  9068
        s := lastStringToReplace asString.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  9069
        "remove final cr"
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  9070
        (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
  9071
    "/        s := s withoutSpaces.        "XXX - replacing text with spaces ..."
4010
9c22bd531240 lastStringToReplace to use in again
fm
parents: 3996
diff changeset
  9072
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  9073
        "set lastStringToReplace as the next search string
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  9074
         and set lastReplaceIgnoredCase as the next search ignored case flag"
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  9075
        lastStringFromReplaceForNextSearch := s.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  9076
        lastSearchIgnoredCase := lastReplaceIgnoredCase.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  9077
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  9078
        savedSelectStyle := selectStyle.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  9079
        selectStyle := nil.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  9080
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  9081
        sel := self selection.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  9082
6156
d7ca039c3bfb #OTHER by mawalch
mawalch
parents: 6154
diff changeset
  9083
        "if we are already there (after a find), omit search"
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  9084
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  9085
        (sel notNil and:[sel asString withoutSeparators = s]) ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  9086
            l := selectionStartLine "cursorLine".
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  9087
            c := selectionStartCol "cursorCol".
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  9088
            self deleteSelection.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  9089
            lastReplacementInfo lastReplacement notNil ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  9090
                self insertLines:lastReplacementInfo lastReplacement asStringCollection withCR:false.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  9091
                self selectFromLine:l col:c toLine:cursorLine col:(cursorCol - 1).
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  9092
                typeOfSelection := #paste
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  9093
            ].
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  9094
            selectStyle := savedSelectStyle.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  9095
            ^ true
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  9096
        ].
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  9097
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  9098
        sel isEmptyOrNil ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  9099
            startColForSearch := cursorCol - 1
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  9100
        ] ifFalse:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  9101
            startColForSearch := selectionEndCol ? (cursorCol - 1)
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  9102
        ].
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  9103
        self
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  9104
            searchForwardFor:s
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  9105
            ignoreCase: lastReplaceIgnoredCase
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  9106
            match: lastReplaceWasMatch
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  9107
            startingAtLine:cursorLine col:startColForSearch
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  9108
            ifFound:
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  9109
                [
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  9110
                    :line :col |
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  9111
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  9112
                    |repl|
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  9113
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  9114
                    self selectFromLine:line col:col
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  9115
                                 toLine:line col:(col + s size - 1).
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  9116
                    self makeLineVisible:line.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  9117
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  9118
                    self deleteSelection.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  9119
                    lastReplacementInfo lastReplacement notNil ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  9120
                        lastReplacementInfo lastReplacement isString ifFalse:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  9121
                            repl := lastReplacementInfo lastReplacement asString "withoutSpaces"
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  9122
                        ] ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  9123
                            repl := lastReplacementInfo lastReplacement "withoutSpaces".
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  9124
                        ].
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  9125
                        self insertLines:repl asStringCollection withCR:false.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  9126
                        self selectFromLine:line col:col toLine:cursorLine col:(cursorCol - 1).
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  9127
                        undoSupport actionInfo:'replace'.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  9128
                    ].
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  9129
                    selectStyle := savedSelectStyle.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  9130
                    typeOfSelection := #paste.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  9131
                    ^ true
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  9132
                ]
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  9133
            ifAbsent:
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  9134
                [
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  9135
                    self sensor compressKeyPressEventsWithKey:#Again.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  9136
                    self showNotFound.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  9137
                    selectStyle := savedSelectStyle.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  9138
                    ^ false
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  9139
                ].
3127
29767bf8a215 better info of replace action (compound-undo-action has info, too)
Claus Gittinger <cg@exept.de>
parents: 3115
diff changeset
  9140
    ].
2730
61a2f1981ac6 Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents: 2725
diff changeset
  9141
61a2f1981ac6 Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents: 2725
diff changeset
  9142
    ^ true.
501
13fc7b9ce5cb fixed (?) again-replace
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  9143
6156
d7ca039c3bfb #OTHER by mawalch
mawalch
parents: 6154
diff changeset
  9144
    "Modified: / 09-10-1996 / 16:14:11 / cg"
d7ca039c3bfb #OTHER by mawalch
mawalch
parents: 6154
diff changeset
  9145
    "Modified (comment): / 17-05-2017 / 16:19:32 / mawalch"
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  9146
!
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  9147
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9148
hasRedoAction
2989
5dcc2912bcb6 undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents: 2984
diff changeset
  9149
    ^ undoSupport hasRedoAction.
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9150
!
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9151
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9152
hasUndoAction
2989
5dcc2912bcb6 undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents: 2984
diff changeset
  9153
    ^ undoSupport hasUndoAction.
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9154
!
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9155
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  9156
multipleAgain
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  9157
    "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
  9158
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  9159
    [self again] whileTrue:[]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  9160
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  9161
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9162
nonUndoableDo:aBlock
2989
5dcc2912bcb6 undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents: 2984
diff changeset
  9163
    undoSupport nonUndoableDo:aBlock.
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9164
!
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9165
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9166
redo
3780
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  9167
    "undo the last undo"
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  9168
2989
5dcc2912bcb6 undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents: 2984
diff changeset
  9169
    undoSupport hasRedoAction ifFalse:[
6262
5b9bf7c3c828 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 6249
diff changeset
  9170
        self beepInEditor
2989
5dcc2912bcb6 undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents: 2984
diff changeset
  9171
    ] ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  9172
        undoSupport redo.
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9173
    ]
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9174
!
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9175
121
claus
parents: 118
diff changeset
  9176
undo
3780
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  9177
    "undo the last edit operation"
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  9178
2989
5dcc2912bcb6 undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents: 2984
diff changeset
  9179
    undoSupport hasUndoAction ifFalse:[
6262
5b9bf7c3c828 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 6249
diff changeset
  9180
        self beepInEditor
2989
5dcc2912bcb6 undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents: 2984
diff changeset
  9181
    ] ifTrue:[
5834
60d6d5a839d3 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5833
diff changeset
  9182
        undoSupport undo.
60d6d5a839d3 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5833
diff changeset
  9183
        self makeSelectionVisible.
60d6d5a839d3 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5833
diff changeset
  9184
        self makeCursorVisible.
121
claus
parents: 118
diff changeset
  9185
    ]
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9186
!
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9187
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9188
undoableDo:aBlock
3495
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  9189
    self undoableDo:aBlock info:nil.
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  9190
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  9191
    "Modified: / 28-07-2007 / 13:20:14 / cg"
3130
c0f39f9f28d6 undoable keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3127
diff changeset
  9192
!
c0f39f9f28d6 undoable keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3127
diff changeset
  9193
c0f39f9f28d6 undoable keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3127
diff changeset
  9194
undoableDo:aBlock info:aString
5689
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  9195
    |selectionRestore|
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  9196
3154
42bf7ebd54c8 refadctored intention revealing code:
Claus Gittinger <cg@exept.de>
parents: 3150
diff changeset
  9197
    self checkModificationsAllowed ifFalse:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  9198
        "/ will trigger an error-dialog there (no need for undo-carekeeping)
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  9199
        aBlock value.
3154
42bf7ebd54c8 refadctored intention revealing code:
Claus Gittinger <cg@exept.de>
parents: 3150
diff changeset
  9200
    ] ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  9201
        undoSupport isInTransaction ifFalse:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  9202
            selectionRestore := RestoreSelectionAndCursor new
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  9203
                                    cursorLine:cursorLine cursorCol:cursorCol
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  9204
                                    selectionStartLine:selectionStartLine selectionStartCol:selectionStartCol
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  9205
                                    selectionEndLine:selectionEndLine selectionEndCol:selectionEndCol
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  9206
                                    info:nil.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  9207
        ].
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  9208
        undoSupport
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  9209
            undoableDo:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  9210
                aBlock value.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  9211
                selectionRestore notNil ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  9212
                    undoSupport transactionNotEmpty ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  9213
                        undoSupport addUndoFirst:selectionRestore
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  9214
                    ].
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  9215
                ].
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  9216
            ]
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  9217
            info:aString.
5689
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  9218
    ].
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  9219
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  9220
    "Modified: / 30-04-2016 / 21:08:30 / cg"
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9221
! !
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9222
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9223
!EditTextView::EditAction class methodsFor:'instance creation'!
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9224
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9225
line1:arg1 col1:arg2 line2:arg3 col2:arg4
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9226
    ^ self new line1:arg1 col1:arg2 line2:arg3 col2:arg4
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9227
!
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9228
3115
b75128334006 info string in undo
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
  9229
line1:arg1 col1:arg2 line2:arg3 col2:arg4 info:info
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  9230
    ^ (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
  9231
!
b75128334006 info string in undo
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
  9232
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9233
line:arg1 col:arg2 character:arg3
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9234
    ^ self new line:arg1 col:arg2 character:arg3
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9235
!
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9236
3115
b75128334006 info string in undo
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
  9237
line:arg1 col:arg2 character:arg3 info:info
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  9238
    ^ (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
  9239
!
b75128334006 info string in undo
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
  9240
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9241
line:arg1 col:arg2 characters:arg3 info:info
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9242
    ^ (self new line:arg1 col:arg2 characters:arg3) info:info
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9243
!
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9244
3156
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  9245
line:arg1 col:arg2 info:arg3
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  9246
    ^ self new line:arg1 col:arg2 info:arg3
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  9247
!
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  9248
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9249
line:arg1 col:arg2 string:arg3
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9250
    ^ self new line:arg1 col:arg2 string:arg3
3115
b75128334006 info string in undo
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
  9251
!
b75128334006 info string in undo
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
  9252
b75128334006 info string in undo
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
  9253
line:arg1 col:arg2 string:arg3 info:info
b75128334006 info string in undo
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
  9254
    ^ (self new line:arg1 col:arg2 string:arg3) info:info
3130
c0f39f9f28d6 undoable keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3127
diff changeset
  9255
!
c0f39f9f28d6 undoable keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3127
diff changeset
  9256
c0f39f9f28d6 undoable keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3127
diff changeset
  9257
line:arg1 string:arg3 info:info
c0f39f9f28d6 undoable keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3127
diff changeset
  9258
    ^ (self new line:arg1 string:arg3) info:info
3131
8f21dba07d24 undoable format
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
  9259
!
8f21dba07d24 undoable format
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
  9260
8f21dba07d24 undoable format
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
  9261
text:arg info:info
8f21dba07d24 undoable format
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
  9262
    ^ (self new text:arg) info:info
3115
b75128334006 info string in undo
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
  9263
! !
b75128334006 info string in undo
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
  9264
b75128334006 info string in undo
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
  9265
!EditTextView::EditAction methodsFor:'accessing'!
b75128334006 info string in undo
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
  9266
b75128334006 info string in undo
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
  9267
info
b75128334006 info string in undo
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
  9268
    ^ userFriendlyInfo
b75128334006 info string in undo
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
  9269
!
b75128334006 info string in undo
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
  9270
b75128334006 info string in undo
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
  9271
info:aString
b75128334006 info string in undo
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
  9272
    userFriendlyInfo := aString
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9273
! !
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9274
3400
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9275
!EditTextView::EditAction methodsFor:'combining'!
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9276
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9277
canCombineWithPreviousPasteStringAction: aPasteStringAction
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9278
    ^ false.
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9279
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9280
    "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
  9281
! !
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9282
3156
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  9283
!EditTextView::EditAction methodsFor:'queries'!
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  9284
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  9285
canCombineWithNext:nextAction
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  9286
    ^ false
5710
7757eb8d4d3e #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5689
diff changeset
  9287
!
7757eb8d4d3e #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5689
diff changeset
  9288
7757eb8d4d3e #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5689
diff changeset
  9289
isRestoreSelectionAndCursor
7757eb8d4d3e #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5689
diff changeset
  9290
    ^ false
3156
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  9291
! !
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  9292
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9293
!EditTextView::DeleteRange methodsFor:'accessing'!
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9294
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  9295
line1:line1Arg col1:col1Arg line2:line2Arg col2:col2Arg
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9296
    "set instance variables (automatically generated)"
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9297
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9298
    self assert:(line1Arg notNil).
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9299
    self assert:(col1Arg notNil).
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9300
    self assert:(line2Arg notNil).
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9301
    self assert:(col2Arg notNil).
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9302
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9303
    line1 := line1Arg.
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9304
    col1 := col1Arg.
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9305
    line2 := line2Arg.
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9306
    col2 := col2Arg.
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9307
! !
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9308
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9309
!EditTextView::DeleteRange methodsFor:'execution'!
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9310
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  9311
executeIn:editor
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9312
    editor unselect.
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  9313
    editor
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  9314
        deleteFromLine:line1
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  9315
        col:col1
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  9316
        toLine:line2
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  9317
        col:col2.
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9318
    editor cursorLine:line1 col:col1.
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9319
! !
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9320
3156
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  9321
!EditTextView::DeleteCharacters methodsFor:'accessing'!
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  9322
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  9323
col1
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  9324
    ^ col1
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  9325
!
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  9326
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  9327
col2
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  9328
    ^ col2
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  9329
!
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  9330
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  9331
line
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  9332
    ^ line
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  9333
!
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  9334
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  9335
line:lineArg col1:col1Arg col2:col2Arg
3156
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  9336
    "set instance variables (automatically generated)"
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  9337
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  9338
    self assert:(lineArg notNil).
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  9339
    self assert:(col1Arg notNil).
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  9340
    self assert:(col2Arg notNil).
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  9341
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  9342
    line := lineArg.
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  9343
    col1 := col1Arg.
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  9344
    col2 := col2Arg.
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  9345
!
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  9346
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  9347
line:lineArg col:colArg info:infoArg
3156
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  9348
    self assert:(lineArg notNil).
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  9349
    self assert:(colArg notNil).
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  9350
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  9351
    line := lineArg.
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  9352
    col1 := col2 := colArg.
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  9353
    self info:infoArg.
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  9354
! !
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  9355
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  9356
!EditTextView::DeleteCharacters methodsFor:'combining'!
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  9357
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  9358
canCombineWithNext:anotherAction
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  9359
    ^ anotherAction perform:#canCombineWithPreviousDeleteCharactersAction: with:self ifNotUnderstood:false
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  9360
!
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  9361
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  9362
canCombineWithPreviousDeleteCharactersAction:previousDeleteAction
3156
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  9363
    "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
  9364
     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
  9365
     (i.e. single-character typing)"
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  9366
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  9367
    previousDeleteAction line == line ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  9368
        previousDeleteAction col2 == (col1-1) ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  9369
            ^ true
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  9370
        ].
3156
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  9371
    ].
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  9372
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  9373
    ^ false
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  9374
!
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  9375
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  9376
combineWithNext:nextDeleteAction
3156
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  9377
    self assert:(line == nextDeleteAction line).
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  9378
    self assert:(col2 == (nextDeleteAction col1 - 1)).
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  9379
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  9380
    col2 := nextDeleteAction col2.
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  9381
    userFriendlyInfo := 'insert ' , (col2 - col1 + 1) printString
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  9382
! !
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  9383
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  9384
!EditTextView::DeleteCharacters methodsFor:'execution'!
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  9385
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  9386
executeIn:editor
3156
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  9387
    editor unselect.
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  9388
    editor
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  9389
        deleteFromLine:line
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  9390
        col:col1
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  9391
        toLine:line
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  9392
        col:col2.
3156
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  9393
    editor cursorLine:line col:col1.
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  9394
! !
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  9395
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9396
!EditTextView::EditMode class methodsFor:'constants'!
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9397
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9398
insertAndSelectMode
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9399
    ^ InsertAndSelectMode
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9400
!
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9401
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9402
insertMode
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9403
    ^ InsertMode
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9404
!
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9405
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9406
overwriteMode
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9407
    ^ OverwriteMode
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9408
! !
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9409
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9410
!EditTextView::EditMode class methodsFor:'queries'!
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9411
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9412
isInsertAndSelectMode
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9413
    ^ false
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9414
!
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9415
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9416
isInsertMode
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9417
    ^ false
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9418
!
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9419
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9420
symbolicName
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9421
    self subclassResponsibility
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9422
! !
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9423
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9424
!EditTextView::EditMode::InsertAndSelectMode class methodsFor:'info'!
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9425
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9426
infoPrintString
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9427
    ^ 'IS'
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9428
! !
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9429
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9430
!EditTextView::EditMode::InsertAndSelectMode class methodsFor:'queries'!
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9431
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9432
isInsertAndSelectMode
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9433
    ^ true
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9434
!
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9435
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9436
isInsertMode
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9437
    ^ true
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9438
! !
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9439
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9440
!EditTextView::EditMode::InsertMode class methodsFor:'info'!
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9441
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9442
infoPrintString
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9443
    ^ 'I'
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9444
! !
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9445
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9446
!EditTextView::EditMode::InsertMode class methodsFor:'queries'!
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9447
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9448
isInsertMode
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9449
    ^ true
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9450
! !
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9451
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9452
!EditTextView::EditMode::OverwriteMode class methodsFor:'info'!
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9453
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9454
infoPrintString
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9455
    ^ 'O'
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9456
! !
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9457
4048
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
  9458
!EditTextView::LastReplacementInfo methodsFor:'accessing'!
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
  9459
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
  9460
lastReplaceIgnoredCase
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
  9461
    ^ lastReplaceIgnoredCase ? false
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
  9462
!
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
  9463
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
  9464
lastReplaceIgnoredCase:something
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
  9465
    lastReplaceIgnoredCase := something.
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
  9466
!
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
  9467
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
  9468
lastReplaceWasMatch
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
  9469
    ^ lastReplaceWasMatch ? false
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
  9470
!
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
  9471
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
  9472
lastReplaceWasMatch:something
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
  9473
    lastReplaceWasMatch := something.
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
  9474
!
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
  9475
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
  9476
lastReplacement
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
  9477
    ^ lastReplacement
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
  9478
!
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
  9479
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
  9480
lastReplacement:something
4053
31117d801975 added: #setLastStringToReplace:
fm
parents: 4051
diff changeset
  9481
"/Transcript showCR: 'lastReplacement:', something printString.
4048
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
  9482
    lastReplacement := something.
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
  9483
!
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
  9484
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
  9485
lastStringToReplace
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
  9486
    ^ lastStringToReplace
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
  9487
!
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
  9488
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
  9489
lastStringToReplace:something
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
  9490
    lastStringToReplace := something.
4818
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  9491
!
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  9492
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  9493
previousReplacements
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  9494
    ^ previousReplacements ? #()
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  9495
!
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  9496
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  9497
stillCollectingInput
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  9498
    ^ stillCollectingInput
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  9499
!
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  9500
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  9501
stillCollectingInput:aBoolean
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  9502
    stillCollectingInput := aBoolean.
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  9503
! !
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  9504
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  9505
!EditTextView::LastReplacementInfo methodsFor:'history'!
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  9506
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  9507
rememberReplacement
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  9508
    "remember the previous replacement (called when a new one appears).
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  9509
     Mostly for the benefit of the code completion..."
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  9510
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  9511
    |oldString newString|
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  9512
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  9513
    oldString := lastStringToReplace.
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  9514
    newString := lastReplacement.
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  9515
    (oldString notEmptyOrNil and:[newString notEmptyOrNil]) ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  9516
        previousReplacements isNil ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  9517
            previousReplacements := OrderedCollection new.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  9518
        ].
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  9519
        previousReplacements := previousReplacements reject:[:entry | entry key = oldString].
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  9520
        previousReplacements addFirst:(oldString -> newString).
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  9521
        previousReplacements size > 20 ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  9522
            previousReplacements removeLast.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  9523
        ]
4818
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  9524
    ].
4048
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
  9525
! !
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
  9526
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9527
!EditTextView::PasteString methodsFor:'accessing'!
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9528
3400
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9529
col
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9530
    ^ col
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9531
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9532
    "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
  9533
!
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9534
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9535
col2
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9536
    ^ col + string size - 1
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9537
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9538
    "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
  9539
!
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9540
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9541
line
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9542
    ^ line
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9543
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9544
    "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
  9545
!
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9546
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  9547
line:lineArg col:colArg string:stringArg
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9548
    self assert:(lineArg notNil).
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9549
    self assert:(colArg notNil).
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9550
    self assert:(stringArg notNil).
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9551
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9552
    line := lineArg.
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9553
    col := colArg.
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9554
    string := stringArg.
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9555
!
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9556
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9557
line:lineArg col:colArg string:stringArg selected:selectedArg
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9558
    self assert:(lineArg notNil).
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9559
    self assert:(colArg notNil).
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9560
    self assert:(stringArg notNil).
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9561
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9562
    line := lineArg.
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9563
    col := colArg.
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9564
    string := stringArg.
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9565
    selected := selectedArg.
3400
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9566
!
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9567
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9568
string
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9569
    ^ string
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9570
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9571
    "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
  9572
! !
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9573
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9574
!EditTextView::PasteString methodsFor:'combining'!
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9575
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9576
canCombineWithNext:anotherAction
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9577
    ^ anotherAction canCombineWithPreviousPasteStringAction:self
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9578
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9579
    "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
  9580
!
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9581
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9582
canCombineWithPreviousPasteStringAction: previousPasteAction
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9583
    "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
  9584
     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
  9585
     (i.e. single-character deletes)"
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9586
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9587
    previousPasteAction line == line ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  9588
        previousPasteAction col == (self col2+1) ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  9589
            ^ true
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  9590
        ].
3400
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9591
    ].
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9592
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9593
    ^ false
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9594
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9595
    "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
  9596
!
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9597
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9598
combineWithNext:nextPasteAction
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9599
    |s1 s2|
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9600
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9601
    self assert:(line == nextPasteAction line).
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9602
    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
  9603
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9604
    s1 := nextPasteAction string.
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9605
    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
  9606
    s2 := string.
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9607
    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
  9608
3683
5891af82a177 middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents: 3650
diff changeset
  9609
    string := s1, s2.
3400
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9610
    col := nextPasteAction col.
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9611
    userFriendlyInfo := 'delete ' , string size printString
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9612
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9613
    "Created: / 25-09-2006 / 12:24:10 / cg"
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9614
! !
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9615
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9616
!EditTextView::PasteString methodsFor:'execution'!
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9617
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  9618
executeIn:editor
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9619
    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
  9620
    editor paste:string.
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9621
    selected ~~ true ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  9622
        editor unselect
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9623
    ].
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9624
! !
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9625
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9626
!EditTextView::ReplaceCharacter methodsFor:'accessing'!
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9627
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9628
col
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9629
    ^ col
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9630
!
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9631
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9632
col1
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9633
    ^ col
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9634
!
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9635
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9636
col2
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9637
    ^ col
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9638
!
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9639
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9640
line
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9641
    ^ line
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9642
!
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9643
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  9644
line:lineArg col:colArg character:characterArg
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9645
    line := lineArg.
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9646
    col := colArg.
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9647
    character := characterArg.
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9648
! !
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9649
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9650
!EditTextView::ReplaceCharacter methodsFor:'execution'!
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9651
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  9652
executeIn:editor
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  9653
    editor
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  9654
        replace:character
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  9655
        atLine:line
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  9656
        col:col.
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9657
    editor cursorLine:line col:col.
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  9658
! !
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  9659
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9660
!EditTextView::ReplaceCharacters methodsFor:'accessing'!
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9661
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9662
characters
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9663
    ^ characters
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9664
!
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9665
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9666
col1
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9667
    ^ col1
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9668
!
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9669
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9670
col2
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9671
    ^ col2
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9672
!
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9673
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9674
line
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9675
    ^ line
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9676
!
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9677
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9678
line:lineArg col:colArg character:characterArg
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9679
    line := lineArg.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9680
    col1 := col2 := colArg.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9681
    characters := characterArg asString.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9682
!
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9683
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9684
line:lineArg col:colArg characters:charactersArg
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9685
    line := lineArg.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9686
    col1 := colArg.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9687
    characters := charactersArg asString.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9688
    col2 := col1 + charactersArg size - 1
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9689
! !
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9690
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9691
!EditTextView::ReplaceCharacters methodsFor:'combining'!
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9692
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9693
canCombineWithNext:anotherAction
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9694
    ^ anotherAction perform:#canCombineWithPreviousReplaceCharactersAction: with:self ifNotUnderstood:false
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9695
!
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9696
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9697
canCombineWithPreviousReplaceCharactersAction:previousReplaceAction
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9698
    "I will combine only if we both are single character deletes,
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9699
     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
  9700
     (i.e. single-character typing)"
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9701
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9702
    previousReplaceAction line == line ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  9703
        previousReplaceAction col2 == (col1-1) ifTrue:[
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  9704
            ^ true
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  9705
        ].
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9706
    ].
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9707
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9708
    ^ false
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9709
!
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9710
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9711
combineWithNext:nextReplaceAction
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9712
    self assert:(line == nextReplaceAction line).
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9713
    self assert:(self col2 == (nextReplaceAction col1 - 1)).
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9714
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9715
    col2 := nextReplaceAction col2.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9716
    userFriendlyInfo := 'replace ' , (col2 - col1 + 1) printString.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9717
    characters := characters , nextReplaceAction characters.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9718
! !
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9719
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9720
!EditTextView::ReplaceCharacters methodsFor:'execution'!
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9721
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9722
executeIn:editor
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9723
    editor
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  9724
        replaceString:characters
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  9725
        atLine:line
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  9726
        col:col1.
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9727
    editor cursorLine:line col:col1.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9728
! !
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9729
3131
8f21dba07d24 undoable format
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
  9730
!EditTextView::ReplaceContents methodsFor:'accessing'!
8f21dba07d24 undoable format
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
  9731
8f21dba07d24 undoable format
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
  9732
text:something
8f21dba07d24 undoable format
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
  9733
    text := something.
8f21dba07d24 undoable format
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
  9734
! !
8f21dba07d24 undoable format
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
  9735
8f21dba07d24 undoable format
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
  9736
!EditTextView::ReplaceContents methodsFor:'execution'!
8f21dba07d24 undoable format
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
  9737
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  9738
executeIn:editor
3131
8f21dba07d24 undoable format
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
  9739
    editor contents:text
8f21dba07d24 undoable format
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
  9740
! !
8f21dba07d24 undoable format
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
  9741
3130
c0f39f9f28d6 undoable keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3127
diff changeset
  9742
!EditTextView::ReplaceLine methodsFor:'accessing'!
c0f39f9f28d6 undoable keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3127
diff changeset
  9743
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  9744
line:lineArg string:stringArg
3130
c0f39f9f28d6 undoable keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3127
diff changeset
  9745
    line := lineArg.
c0f39f9f28d6 undoable keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3127
diff changeset
  9746
    text := stringArg.
c0f39f9f28d6 undoable keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3127
diff changeset
  9747
! !
c0f39f9f28d6 undoable keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3127
diff changeset
  9748
c0f39f9f28d6 undoable keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3127
diff changeset
  9749
!EditTextView::ReplaceLine methodsFor:'execution'!
c0f39f9f28d6 undoable keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3127
diff changeset
  9750
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  9751
executeIn:editor
3130
c0f39f9f28d6 undoable keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3127
diff changeset
  9752
    editor list at:line put:text.
c0f39f9f28d6 undoable keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3127
diff changeset
  9753
    editor invalidateLine:line
c0f39f9f28d6 undoable keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3127
diff changeset
  9754
! !
c0f39f9f28d6 undoable keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3127
diff changeset
  9755
3402
d6545009a22b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3400
diff changeset
  9756
!EditTextView::ReplaceLines methodsFor:'accessing'!
d6545009a22b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3400
diff changeset
  9757
d6545009a22b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3400
diff changeset
  9758
line:lineArg lines:lineCollectionArg
d6545009a22b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3400
diff changeset
  9759
    line := lineArg.
d6545009a22b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3400
diff changeset
  9760
    text := lineCollectionArg.
d6545009a22b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3400
diff changeset
  9761
d6545009a22b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3400
diff changeset
  9762
    "Created: / 09-10-2006 / 10:35:22 / cg"
d6545009a22b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3400
diff changeset
  9763
! !
d6545009a22b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3400
diff changeset
  9764
d6545009a22b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3400
diff changeset
  9765
!EditTextView::ReplaceLines methodsFor:'execution'!
d6545009a22b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3400
diff changeset
  9766
d6545009a22b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3400
diff changeset
  9767
executeIn:editor
d6545009a22b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3400
diff changeset
  9768
    |lnr|
d6545009a22b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3400
diff changeset
  9769
d6545009a22b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3400
diff changeset
  9770
    lnr := line.
d6545009a22b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3400
diff changeset
  9771
    text do:[:eachLine |
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  9772
        editor list at:lnr put:eachLine.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  9773
        editor invalidateLine:lnr.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  9774
        lnr := lnr + 1.
3402
d6545009a22b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3400
diff changeset
  9775
    ].
d6545009a22b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3400
diff changeset
  9776
d6545009a22b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3400
diff changeset
  9777
    "Modified: / 09-10-2006 / 10:39:16 / cg"
d6545009a22b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3400
diff changeset
  9778
! !
d6545009a22b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3400
diff changeset
  9779
5689
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  9780
!EditTextView::RestoreSelectionAndCursor methodsFor:'accessing'!
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  9781
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  9782
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
  9783
    cursorLine := cursorLineArg.
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  9784
    cursorCol := cursorColArg.
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  9785
    selectionStartLine := selectionStartLineArg.
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  9786
    selectionStartCol := selectionStartColArg.
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  9787
    selectionEndLine := selectionEndLineArg.
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  9788
    selectionEndCol := selectionEndColArg.
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  9789
!
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  9790
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  9791
cursorLine:cursorLineArg cursorCol:cursorColArg
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  9792
        selectionStartLine:selectionStartLineArg selectionStartCol:selectionStartColArg
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  9793
        selectionEndLine:selectionEndLineArg selectionEndCol:selectionEndColArg
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  9794
        info:info
5689
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  9795
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  9796
    cursorLine := cursorLineArg.
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  9797
    cursorCol := cursorColArg.
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  9798
    selectionStartLine := selectionStartLineArg.
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  9799
    selectionStartCol := selectionStartColArg.
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  9800
    selectionEndLine := selectionEndLineArg.
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  9801
    selectionEndCol := selectionEndColArg.
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  9802
    userFriendlyInfo := info.
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  9803
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  9804
    "Created: / 30-04-2016 / 20:21:18 / cg"
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  9805
! !
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  9806
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  9807
!EditTextView::RestoreSelectionAndCursor methodsFor:'execution'!
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  9808
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  9809
executeIn:editor
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  9810
    (selectionStartLine notNil and:[selectionEndLine notNil
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  9811
    and:[selectionStartCol notNil and:[selectionEndCol notNil]]]) ifTrue:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  9812
        editor setCursorLine:cursorLine col:cursorCol.
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  9813
        editor selectFromLine:selectionStartLine col:selectionStartCol toLine:selectionEndLine col:selectionEndCol
5689
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  9814
    ] ifFalse:[
6152
3184f94c684c #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 6150
diff changeset
  9815
        editor cursorLine:cursorLine col:cursorCol.
5689
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  9816
    ].
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  9817
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  9818
    "Created: / 30-04-2016 / 20:14:55 / cg"
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  9819
! !
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  9820
5710
7757eb8d4d3e #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5689
diff changeset
  9821
!EditTextView::RestoreSelectionAndCursor methodsFor:'queries'!
7757eb8d4d3e #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5689
diff changeset
  9822
7757eb8d4d3e #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5689
diff changeset
  9823
isRestoreSelectionAndCursor
7757eb8d4d3e #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5689
diff changeset
  9824
    ^ true
7757eb8d4d3e #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5689
diff changeset
  9825
! !
7757eb8d4d3e #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5689
diff changeset
  9826
865
d42c7c99e67d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 840
diff changeset
  9827
!EditTextView class methodsFor:'documentation'!
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  9828
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  9829
version
5361
d39070e004c1 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5357
diff changeset
  9830
    ^ '$Header$'
3945
295e4733f3a5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3915
diff changeset
  9831
!
295e4733f3a5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3915
diff changeset
  9832
295e4733f3a5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3915
diff changeset
  9833
version_CVS
5361
d39070e004c1 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5357
diff changeset
  9834
    ^ '$Header$'
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  9835
! !
4481
76c592c0ae9c class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 4475
diff changeset
  9836