EditTextView.st
author HG Automerge
Mon, 26 Dec 2016 10:26:48 +0000
branchjv
changeset 6023 1df17efc16f7
parent 6007 b3495a467b79
parent 6015 9984d88f5e98
child 6063 ef1842cb1d75
permissions -rw-r--r--
Merge
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
4823
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
     3
              All Rights Reserved
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
     4
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
     5
 This software is furnished under a license and may be used
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
     6
 only in accordance with the terms of that license and with the
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
     8
 be provided or otherwise made available to, or used by, any
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
     9
 other person.  No title to or ownership of the software is
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    10
 hereby transferred.
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    11
"
2184
fb634dc3e606 learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents: 2157
diff changeset
    12
"{ Package: 'stx:libwidg' }"
fb634dc3e606 learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents: 2157
diff changeset
    13
5239
0312ca8fd55e class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5226
diff changeset
    14
"{ NameSpace: Smalltalk }"
0312ca8fd55e class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5226
diff changeset
    15
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    16
TextView subclass:#EditTextView
4826
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
    17
	instanceVariableNames:'cursorLine cursorVisibleLine cursorCol cursorShown
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
    18
		prevCursorState readOnly modifiedChannel fixedSize exceptionBlock
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
    19
		cursorFgColor cursorBgColor cursorNoFocusFgColor cursorType
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
    20
		cursorTypeNoFocus typeOfSelection lastAction replacing
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
    21
		showMatchingParenthesis hasKeyboardFocus acceptAction lockUpdates
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
    22
		tabMeansNextField autoIndent insertMode editMode trimBlankLines
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
    23
		wordWrap replacementWordSelectStyle acceptChannel acceptEnabled
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
    24
		st80Mode disableIfInvisible cursorMovementWhenUpdating learnMode
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
    25
		learnedMacro cursorLineHolder cursorColHolder tabRequiresControl
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
    26
		undoSupport lastStringFromReplaceForNextSearch
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
    27
		lastReplacementInfo completionSupport codeAspectHolder'
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
    28
	classVariableNames:'DefaultCursorForegroundColor DefaultCursorBackgroundColor
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
    29
		DefaultCursorType DefaultCursorNoFocusForegroundColor
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
    30
		DefaultCursorTypeNoFocus LastColumnNumberForSort Macros'
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
    31
	poolDictionaries:''
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
    32
	category:'Views-Text'
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    33
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    34
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
    35
Object subclass:#EditAction
4826
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
    36
	instanceVariableNames:'userFriendlyInfo'
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
    37
	classVariableNames:''
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
    38
	poolDictionaries:''
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
    39
	privateIn:EditTextView
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
    40
!
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
    41
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
    42
EditTextView::EditAction subclass:#DeleteRange
4826
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
    43
	instanceVariableNames:'line1 col1 line2 col2'
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
    44
	classVariableNames:''
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
    45
	poolDictionaries:''
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
    46
	privateIn:EditTextView
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
    47
!
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
    48
3156
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
    49
EditTextView::EditAction subclass:#DeleteCharacters
4826
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
    50
	instanceVariableNames:'line col1 col2'
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
    51
	classVariableNames:''
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
    52
	poolDictionaries:''
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
    53
	privateIn:EditTextView
3156
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
    54
!
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
    55
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
    56
Object subclass:#EditMode
4826
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
    57
	instanceVariableNames:''
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
    58
	classVariableNames:''
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
    59
	poolDictionaries:''
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
    60
	privateIn:EditTextView
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
    61
!
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
    62
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
    63
EditTextView::EditMode subclass:#InsertAndSelectMode
4826
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
    64
	instanceVariableNames:''
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
    65
	classVariableNames:''
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
    66
	poolDictionaries:''
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
    67
	privateIn:EditTextView::EditMode
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
    68
!
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
    69
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
    70
EditTextView::EditMode subclass:#InsertMode
4826
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
    71
	instanceVariableNames:''
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
    72
	classVariableNames:''
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
    73
	poolDictionaries:''
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
    74
	privateIn:EditTextView::EditMode
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
    75
!
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
    76
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
    77
EditTextView::EditMode subclass:#OverwriteMode
4826
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
    78
	instanceVariableNames:''
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
    79
	classVariableNames:'InsertMode OverwriteMode InsertAndSelectMode'
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
    80
	poolDictionaries:''
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
    81
	privateIn:EditTextView::EditMode
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
    82
!
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
    83
3813
8d719ca5812d dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3811
diff changeset
    84
Query subclass:#ExecutingMacroQuery
4826
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
    85
	instanceVariableNames:''
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
    86
	classVariableNames:''
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
    87
	poolDictionaries:''
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
    88
	privateIn:EditTextView
3813
8d719ca5812d dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3811
diff changeset
    89
!
8d719ca5812d dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3811
diff changeset
    90
4048
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
    91
Object subclass:#LastReplacementInfo
4826
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
    92
	instanceVariableNames:'lastReplacement lastStringToReplace lastReplaceWasMatch
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
    93
		lastReplaceIgnoredCase stillCollectingInput previousReplacements'
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
    94
	classVariableNames:''
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
    95
	poolDictionaries:''
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
    96
	privateIn:EditTextView
4048
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
    97
!
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
    98
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
    99
EditTextView::EditAction subclass:#PasteString
4826
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
   100
	instanceVariableNames:'line col string selected'
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
   101
	classVariableNames:''
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
   102
	poolDictionaries:''
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
   103
	privateIn:EditTextView
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
   104
!
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
   105
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
   106
EditTextView::EditAction subclass:#ReplaceCharacter
4826
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
   107
	instanceVariableNames:'line col character'
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
   108
	classVariableNames:''
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
   109
	poolDictionaries:''
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
   110
	privateIn:EditTextView
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
   111
!
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
   112
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
   113
EditTextView::EditAction subclass:#ReplaceCharacters
4826
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
   114
	instanceVariableNames:'line col1 col2 characters'
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
   115
	classVariableNames:''
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
   116
	poolDictionaries:''
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
   117
	privateIn:EditTextView
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
   118
!
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
   119
3131
8f21dba07d24 undoable format
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
   120
EditTextView::EditAction subclass:#ReplaceContents
4826
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
   121
	instanceVariableNames:'text'
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
   122
	classVariableNames:''
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
   123
	poolDictionaries:''
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
   124
	privateIn:EditTextView
3131
8f21dba07d24 undoable format
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
   125
!
8f21dba07d24 undoable format
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
   126
3130
c0f39f9f28d6 undoable keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3127
diff changeset
   127
EditTextView::EditAction subclass:#ReplaceLine
4826
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
   128
	instanceVariableNames:'line text'
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
   129
	classVariableNames:''
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
   130
	poolDictionaries:''
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
   131
	privateIn:EditTextView
3130
c0f39f9f28d6 undoable keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3127
diff changeset
   132
!
c0f39f9f28d6 undoable keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3127
diff changeset
   133
3402
d6545009a22b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3400
diff changeset
   134
EditTextView::EditAction subclass:#ReplaceLines
4826
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
   135
	instanceVariableNames:'line text'
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
   136
	classVariableNames:''
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
   137
	poolDictionaries:''
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
   138
	privateIn:EditTextView
3402
d6545009a22b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3400
diff changeset
   139
!
d6545009a22b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3400
diff changeset
   140
5689
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
   141
EditTextView::EditAction subclass:#RestoreSelectionAndCursor
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
   142
	instanceVariableNames:'cursorLine cursorCol selectionStartLine selectionStartCol
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
   143
		selectionEndLine selectionEndCol'
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
   144
	classVariableNames:''
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
   145
	poolDictionaries:''
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
   146
	privateIn:EditTextView
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
   147
!
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
   148
865
d42c7c99e67d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 840
diff changeset
   149
!EditTextView class methodsFor:'documentation'!
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   150
33
5eeef3ea8ebd added access methods for cursorLine & cursorCol
claus
parents: 25
diff changeset
   151
copyright
5eeef3ea8ebd added access methods for cursorLine & cursorCol
claus
parents: 25
diff changeset
   152
"
5eeef3ea8ebd added access methods for cursorLine & cursorCol
claus
parents: 25
diff changeset
   153
 COPYRIGHT (c) 1989 by Claus Gittinger
4823
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   154
              All Rights Reserved
33
5eeef3ea8ebd added access methods for cursorLine & cursorCol
claus
parents: 25
diff changeset
   155
5eeef3ea8ebd added access methods for cursorLine & cursorCol
claus
parents: 25
diff changeset
   156
 This software is furnished under a license and may be used
5eeef3ea8ebd added access methods for cursorLine & cursorCol
claus
parents: 25
diff changeset
   157
 only in accordance with the terms of that license and with the
5eeef3ea8ebd added access methods for cursorLine & cursorCol
claus
parents: 25
diff changeset
   158
 inclusion of the above copyright notice.   This software may not
5eeef3ea8ebd added access methods for cursorLine & cursorCol
claus
parents: 25
diff changeset
   159
 be provided or otherwise made available to, or used by, any
5eeef3ea8ebd added access methods for cursorLine & cursorCol
claus
parents: 25
diff changeset
   160
 other person.  No title to or ownership of the software is
5eeef3ea8ebd added access methods for cursorLine & cursorCol
claus
parents: 25
diff changeset
   161
 hereby transferred.
5eeef3ea8ebd added access methods for cursorLine & cursorCol
claus
parents: 25
diff changeset
   162
"
5eeef3ea8ebd added access methods for cursorLine & cursorCol
claus
parents: 25
diff changeset
   163
!
5eeef3ea8ebd added access methods for cursorLine & cursorCol
claus
parents: 25
diff changeset
   164
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   165
documentation
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   166
"
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   167
    a view for editable text - adds editing functionality to TextView
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
   168
    Also, it adds accept functionality, and defines a new actionBlock:
297
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   169
    acceptAction to be performed for accept
125
claus
parents: 123
diff changeset
   170
claus
parents: 123
diff changeset
   171
    If used with a model, this is informed by sending it a changeMsg with
claus
parents: 123
diff changeset
   172
    the current contents as argument.
297
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   173
    (however, it is possible to define both changeMsg and acceptAction)
125
claus
parents: 123
diff changeset
   174
309
b5c9d68e95e1 new tabbing scheme (asking via #canTab); new focus change (passing explicit to showFocus/noFocus);
Claus Gittinger <cg@exept.de>
parents: 297
diff changeset
   175
    Please read the historic notice in the ListView class.
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   176
586
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 567
diff changeset
   177
    [Instance variables:]
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   178
5988
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   179
        cursorLine              <Number>        line where cursor sits (1..)
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   180
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   181
        cursorVisibleLine       <Number>        visible line where cursor sits (1..nLinesShown)
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   182
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   183
        cursorCol               <Number>        col where cursor sits (1..)
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   184
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   185
        cursorShown             <Boolean>       true, if cursor is currently shown
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   186
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   187
        readOnly                <Boolean>       true, if text may not be edited
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   188
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   189
        modifiedChannel         <ValueHolder>   holding true, if text has been modified.
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   190
                                                cleared on accept.
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   191
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   192
        acceptChannel           <ValueHolder>   holding true, if text has been accepted.
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   193
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   194
        fixedSize               <Boolean>       true, if no lines may be added/removed
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   195
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   196
        exceptionBlock          <Block>         block to be evaluated when readonly text is about to be modified
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   197
                                                if it returns true, the modification will be done anyway.
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   198
                                                if it returns anything else, the modification is not done.
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   199
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   200
        cursorFgColor           <Color>         color used for cursor drawing
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   201
        cursorBgColor           <Color>         color used for cursor drawing
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   202
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   203
        cursorType              <Symbol>        how the cursor is drawn; currently implemented
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   204
                                                are #none, #block (solid-block cursor), #ibeam
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   205
                                                (vertical bar at insertion point)
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   206
                                                and #caret (caret below insertion-point).
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   207
                                                see cursorType: for an up-to-date list.
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   208
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   209
        cursorTypeNoFocus       <Symbol>        like above, if view has no focus
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   210
                                                nil means: hide the cursor.
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   211
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   212
        undoAction              <Block>         block which undoes last cut, paste or replace
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   213
                                                (not yet fully implemented)
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   214
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   215
        typeOfSelection         <Symbol>        #paste, if selection created by paste, nil otherwise
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   216
                                                this affects the next keyPress: if #paste it does not
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   217
                                                replace; otherwise it replaces the selection.
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   218
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   219
        lastCut                 <String>        last cut or replaced string
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   220
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   221
        lastReplacementInfo     <LastReplacementInfo>        holds the information about the last replace action
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   222
                                                             lastStringToReplace is the string to be replaced by lastReplacement
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   223
                                                             lastReplacement is the string to replace lastStringToReplace
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   224
4053
31117d801975 added: #setLastStringToReplace:
fm
parents: 4051
diff changeset
   225
        lastStringFromReplaceForNextSearch   <String>        string to be taken be the next search action 
5988
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   226
                                                             (cleared after a new selection)
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   227
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   228
        replacing               <Boolean>       true if entered characters replace last selection
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   229
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   230
        showMatchingParenthesis <Boolean>       if true, shows matching parenthesis
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   231
                                                when entering one; this is the default.
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   232
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   233
        hasKeyboardFocus        <Boolean>       true if this view has the focus
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   234
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   235
        acceptAction            <Block>         accept action - evaluated passing the contents as
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   236
                                                argument
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   237
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   238
        tabMeansNextField       <Boolean>       if true, Tab is ignored as input and shifts keyboard
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   239
                                                focus to the next field. For editTextViews, this is false
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   240
                                                by default (i.e. tabs can be entered into the text).
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   241
                                                For some subclasses (inputFields), this may be true.
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   242
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   243
        trimBlankLines          <Boolean>       if true, trailing blanks are
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   244
                                                removed when editing.
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   245
                                                Also, empty lines are represented as nil in the lines collection.
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   246
                                                Default is true.
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   247
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   248
        wordWrap                <Boolean>       Currently not used.
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   249
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   250
        lockUpdates             <Boolean>       internal, private
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   251
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   252
        prevCursorState         <Boolean>       temporary, private
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   253
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   254
        cursorMovementWhenUpdating
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   255
                                <Symbol>        defines where the cursor is to be positioned if the
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   256
                                                model changes its value by some outside activity
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   257
                                                (i.e. not by user input into the field).
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   258
                                                Can be one of:
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   259
                                                    #keep / nil     -> stay where it was
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   260
                                                    #endOfText      -> cursor to the end
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   261
                                                    #endOfLine      -> stay in the line, but move to end
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   262
                                                    #beginOfText    -> cursor to the beginning
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   263
                                                    #beginOfLine    -> stay in the line, but move to begin
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   264
                                                The default is #beginOfText
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   265
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   266
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   267
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   268
        dropTarget              <DropTarget|nil> drop operation descriptor or nil (drop disabled)
2589
62794ae04446 support drop
ca
parents: 2580
diff changeset
   269
62794ae04446 support drop
ca
parents: 2580
diff changeset
   270
2712
e83d71c9bdec ST80Mode classVariables is now UserPreferences.st80EditMode
Claus Gittinger <cg@exept.de>
parents: 2707
diff changeset
   271
    userPreference values:
5988
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   272
        userPreferences.st80EditMode
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   273
                                <Boolean>       if true, cursor positioning is
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   274
                                                done as in vi or ST80; i.e.
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   275
                                                wysiwyg mode is somewhat relaxed,
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   276
                                                in that the cursor cannot be
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   277
                                                positioned behind a lines end.
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   278
                                                This is not yet completely implemented.
33
5eeef3ea8ebd added access methods for cursorLine & cursorCol
claus
parents: 25
diff changeset
   279
    used globals:
5eeef3ea8ebd added access methods for cursorLine & cursorCol
claus
parents: 25
diff changeset
   280
5988
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   281
        DeleteHistory           <Text>          last 1000 lines of deleted text
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   282
                                                (but only if this variable exists already)
586
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 567
diff changeset
   283
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 567
diff changeset
   284
    [styleSheet parameters:]
121
claus
parents: 118
diff changeset
   285
5988
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   286
        textCursorForegroundColor <Color>          cursor fg color; default: text background
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   287
        textCursorBackgroundColor <Color>          cursor bg color; default: text foreground
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   288
        textCursorNoFocusForegroundColor
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   289
                                  <Color>          cursor fg color if no focus; default: cursor fg color
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   290
        textCursorType            <Symbol>         cursor type; default:  #block
586
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 567
diff changeset
   291
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 567
diff changeset
   292
    [author:]
5988
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   293
        Claus Gittinger
586
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 567
diff changeset
   294
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 567
diff changeset
   295
    [see also:]
5988
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   296
        CodeView Workspace TextView ListView
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
   297
        EditField
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   298
"
297
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   299
!
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   300
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   301
examples
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   302
"
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   303
  non MVC operation:
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   304
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   305
    basic setup:
4823
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   306
                                                                        [exBegin]
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   307
        |top textView|
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   308
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   309
        top := StandardSystemView new.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   310
        top extent:300@200.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   311
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   312
        textView := EditTextView new.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   313
        textView origin:0.0 @ 0.0 corner:1.0 @ 1.0.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   314
        top addSubView:textView.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   315
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   316
        textView contents:('/etc/hosts' asFilename contentsOfEntireFile).
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   317
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   318
        top open.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   319
                                                                        [exEnd]
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   320
297
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   321
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   322
    with vertical scrollbar:
4823
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   323
                                                                        [exBegin]
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   324
        |top scrollView textView|
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   325
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   326
        top := StandardSystemView new.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   327
        top extent:300@200.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   328
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   329
        scrollView := ScrollableView for:EditTextView.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   330
        textView := scrollView scrolledView.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   331
        scrollView origin:0.0 @ 0.0 corner:1.0 @ 1.0.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   332
        top addSubView:scrollView.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   333
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   334
        textView contents:('/etc/hosts' asFilename contentsOfEntireFile).
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   335
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   336
        top open.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   337
                                                                        [exEnd]
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   338
297
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   339
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   340
    with horizontal & vertical scrollbars:
4823
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   341
                                                                        [exBegin]
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   342
        |top scrollView textView|
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   343
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   344
        top := StandardSystemView new.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   345
        top extent:300@200.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   346
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   347
        scrollView := HVScrollableView for:EditTextView.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   348
        textView := scrollView scrolledView.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   349
        scrollView origin:0.0 @ 0.0 corner:1.0 @ 1.0.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   350
        top addSubView:scrollView.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   351
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   352
        textView contents:('/etc/hosts' asFilename contentsOfEntireFile).
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   353
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   354
        top open.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   355
                                                                        [exEnd]
297
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   356
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   357
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   358
    set the action for accept:
4823
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   359
                                                                        [exBegin]
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   360
        |top textView|
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   361
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   362
        top := StandardSystemView new.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   363
        top extent:300@200.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   364
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   365
        textView := EditTextView new.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   366
        textView origin:0.0 @ 0.0 corner:1.0 @ 1.0.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   367
        top addSubView:textView.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   368
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   369
        textView contents:('/etc/hosts' asFilename contentsOfEntireFile).
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   370
        textView acceptAction:[:contents |
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   371
                                Transcript showCR:'will not overwrite the file with:'.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   372
                                Transcript showCR:contents asString
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   373
                              ].
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   374
        top open.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   375
                                                                        [exEnd]
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   376
297
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   377
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   378
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
   379
    non-string (text) items:
4823
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   380
                                                                        [exBegin]
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   381
        |top textView list|
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   382
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   383
        list := '/etc/hosts' asFilename contentsOfEntireFile asStringCollection.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   384
        1 to:list size by:2 do:[:nr |
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   385
            list at:nr put:(Text string:(list at:nr)
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   386
                                 emphasis:(Array with:#bold with:(#color->Color red)))
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   387
        ].
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   388
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   389
        top := StandardSystemView new.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   390
        top extent:300@200.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   391
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   392
        textView := EditTextView new.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   393
        textView origin:0.0 @ 0.0 corner:1.0 @ 1.0.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   394
        top addSubView:textView.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   395
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   396
        textView contents:list.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   397
        top open.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   398
                                                                        [exEnd]
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
   399
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
   400
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
   401
297
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   402
  MVC operation:
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   403
    (the examples model here is a plug simulating a real model;
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   404
     real world applications would not use a plug ..)
4823
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   405
                                                                        [exBegin]
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   406
        |top textView model|
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   407
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   408
        model := Plug new.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   409
        model respondTo:#accepted:
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   410
                   with:[:newContents |
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   411
                                Transcript showCR:'will not overwrite the file with:'.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   412
                                Transcript showCR:newContents asString
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   413
                        ].
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   414
        model respondTo:#getList
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   415
                   with:['/etc/hosts' asFilename contentsOfEntireFile].
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   416
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   417
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   418
        top := StandardSystemView new.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   419
        top extent:300@200.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   420
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   421
        textView := EditTextView new.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   422
        textView origin:0.0 @ 0.0 corner:1.0 @ 1.0.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   423
        top addSubView:textView.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   424
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   425
        textView listMessage:#getList;
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   426
                 model:model;
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   427
                 changeMessage:#accepted:;
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   428
                 aspect:#list.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   429
        top open.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   430
                                                                        [exEnd]
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   431
297
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   432
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   433
    two textViews on the same model:
4823
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   434
                                                                        [exBegin]
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   435
        |top1 textView1 top2 textView2 model currentContents|
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   436
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   437
        model := Plug new.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   438
        model respondTo:#accepted:
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   439
                   with:[:newContents |
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   440
                                Transcript showCR:'accepted:'.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   441
                                Transcript showCR:newContents asString.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   442
                                currentContents := newContents.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   443
                                model changed:#contents
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   444
                        ].
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   445
        model respondTo:#getList
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   446
                   with:[Transcript showCR:'query'.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   447
                         currentContents].
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   448
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   449
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   450
        top1 := StandardSystemView new.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   451
        top1 extent:300@200.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   452
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   453
        textView1 := EditTextView new.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   454
        textView1 origin:0.0 @ 0.0 corner:1.0 @ 1.0.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   455
        top1 addSubView:textView1.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   456
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   457
        textView1 listMessage:#getList;
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   458
                  model:model;
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   459
                  aspect:#contents;
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   460
                  changeMessage:#accepted:.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   461
        top1 open.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   462
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   463
        top2 := StandardSystemView new.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   464
        top2 extent:300@200.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   465
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   466
        textView2 := EditTextView new.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   467
        textView2 origin:0.0 @ 0.0 corner:1.0 @ 1.0.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   468
        top2 addSubView:textView2.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   469
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   470
        textView2 listMessage:#getList;
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   471
                  model:model;
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   472
                  aspect:#contents;
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   473
                  changeMessage:#accepted:.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   474
        top2 open.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   475
                                                                        [exEnd]
297
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   476
"
4978
0eb26aed1456 Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4977
diff changeset
   477
!
0eb26aed1456 Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4977
diff changeset
   478
0eb26aed1456 Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4977
diff changeset
   479
selection_and_cursor_movement
0eb26aed1456 Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4977
diff changeset
   480
"
0eb26aed1456 Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4977
diff changeset
   481
Changes done to implement 'standard' behaviour (that's how vast majority of widgets used in todays desktops behaves)
0eb26aed1456 Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4977
diff changeset
   482
as opposed to 'traditional' which is what how it was in St/X 'ever since'
0eb26aed1456 Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4977
diff changeset
   483
0eb26aed1456 Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4977
diff changeset
   484
* Numerous off-by-one bugs
0eb26aed1456 Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4977
diff changeset
   485
0eb26aed1456 Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4977
diff changeset
   486
* Extending selection by dragging:
0eb26aed1456 Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4977
diff changeset
   487
  Scenario:
0eb26aed1456 Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4977
diff changeset
   488
    1. Select & drag to expand beggining of the selection (i.e., drag from 'end' to 'beggining'
0eb26aed1456 Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4977
diff changeset
   489
    2. Stop dragging
0eb26aed1456 Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4977
diff changeset
   490
    3. Press Shift-Left / Shift-Right (to refine selection)
0eb26aed1456 Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4977
diff changeset
   491
0eb26aed1456 Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4977
diff changeset
   492
    Traditional ST/X: end of selection is moved
0eb26aed1456 Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4977
diff changeset
   493
    Standard:  beginning of selection is moved
0eb26aed1456 Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4977
diff changeset
   494
      (checked on Notepad, Gedit (GTK+), Sublime (Win+Lin), Eclipse, Firefox)
0eb26aed1456 Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4977
diff changeset
   495
0eb26aed1456 Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4977
diff changeset
   496
* Extending selection by Shift-Home / Shift-End
0eb26aed1456 Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4977
diff changeset
   497
  Scenario:
0eb26aed1456 Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4977
diff changeset
   498
    1. Position cursor in the middle of the line
0eb26aed1456 Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4977
diff changeset
   499
    2. Press Shift-Home (line for beginning should be selected)
0eb26aed1456 Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4977
diff changeset
   500
    3. Press Shift-Right (to refine selection)
0eb26aed1456 Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4977
diff changeset
   501
0eb26aed1456 Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4977
diff changeset
   502
    Traditional ST/X: end of selection is moved
0eb26aed1456 Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4977
diff changeset
   503
    Standard:  beginning of selection is moved
0eb26aed1456 Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4977
diff changeset
   504
      (checked on Notepad, Gedit (GTK+), Sublime (Win+Lin), Eclipse, Firefox)
0eb26aed1456 Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4977
diff changeset
   505
0eb26aed1456 Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4977
diff changeset
   506
* Selection flip by Shift-Home / Shift-End
0eb26aed1456 Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4977
diff changeset
   507
  Scenario A:
0eb26aed1456 Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4977
diff changeset
   508
    1. Position cursor in the middle of the line to column C
0eb26aed1456 Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4977
diff changeset
   509
    2. Press Shift-Home (line from beginning should be selected)
0eb26aed1456 Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4977
diff changeset
   510
    2. Press Shift-End
0eb26aed1456 Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4977
diff changeset
   511
0eb26aed1456 Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4977
diff changeset
   512
    Traditional ST/X: end of selection is moved so whole line is selected
0eb26aed1456 Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4977
diff changeset
   513
    Standard: Selection 'flips' so part of line from column C to the end is selected
0eb26aed1456 Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4977
diff changeset
   514
      (checked on Notepad, Gedit (GTK+), Sublime (Win+Lin), Eclipse, Firefox)
0eb26aed1456 Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4977
diff changeset
   515
0eb26aed1456 Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4977
diff changeset
   516
  Scenario B:
0eb26aed1456 Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4977
diff changeset
   517
    1. Position cursor in the middle of the line to column C
0eb26aed1456 Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4977
diff changeset
   518
    2. Press Shift-End (column C to the end of line should be selected)
0eb26aed1456 Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4977
diff changeset
   519
    2. Press Shift-Home
0eb26aed1456 Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4977
diff changeset
   520
0eb26aed1456 Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4977
diff changeset
   521
    Traditional ST/X: beginning of selection is moved so whole line is selected
0eb26aed1456 Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4977
diff changeset
   522
    Standard: Selection 'flips' so part of line from the beginning to column C is selected
0eb26aed1456 Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4977
diff changeset
   523
      (checked on Notepad, Gedit (GTK+), Sublime (Win+Lin), Eclipse, Firefox)
0eb26aed1456 Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4977
diff changeset
   524
0eb26aed1456 Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4977
diff changeset
   525
  NOTE: This could be controlled by 
0eb26aed1456 Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4977
diff changeset
   526
    UserPreferences current selectionExtensionMode
0eb26aed1456 Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4977
diff changeset
   527
0eb26aed1456 Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4977
diff changeset
   528
0eb26aed1456 Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4977
diff changeset
   529
* Extending selection with Ctrl-Shift-Left / Ctrl-Shift-Right
0eb26aed1456 Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4977
diff changeset
   530
  Scenario A:
0eb26aed1456 Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4977
diff changeset
   531
    1. Position cursor in the middle of the line to column C
0eb26aed1456 Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4977
diff changeset
   532
    2. Select word
0eb26aed1456 Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4977
diff changeset
   533
    3. Press Ctrl-Shift-Right, Ctrl-Shift-Right
0eb26aed1456 Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4977
diff changeset
   534
0eb26aed1456 Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4977
diff changeset
   535
    Traditional ST/X: nothing happens at all
0eb26aed1456 Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4977
diff changeset
   536
    Standard: Selection is extended to include a space (first press) and a word right to previously selected one
0eb26aed1456 Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4977
diff changeset
   537
      (checked on Notepad, Gedit (GTK+), Sublime (Win+Lin), Eclipse, Firefox)
0eb26aed1456 Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4977
diff changeset
   538
297
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   539
"
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   540
! !
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   541
865
d42c7c99e67d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 840
diff changeset
   542
!EditTextView class methodsFor:'defaults'!
59
450ce95a72a4 *** empty log message ***
claus
parents: 46
diff changeset
   543
4801
69a5bff7b5cd Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4786
diff changeset
   544
defaultCompletionSupportClass
69a5bff7b5cd Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4786
diff changeset
   545
    ^ nil
69a5bff7b5cd Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4786
diff changeset
   546
69a5bff7b5cd Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4786
diff changeset
   547
    "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
   548
!
428c8bc44cfb refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents: 4694
diff changeset
   549
1419
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   550
st80Mode
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   551
    "return true, if the st80 editing mode is turned on.
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   552
     This setting affects the behavior of the cursor, when positioned
5909
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
   553
     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
   554
     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
   555
     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
   556
     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
   557
2647
23dca8f032c3 changed st80Mode from classVar to userPreferences value
Claus Gittinger <cg@exept.de>
parents: 2627
diff changeset
   558
    ^ UserPreferences current st80EditMode
1419
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   559
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   560
   "
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   561
    EditTextView st80Mode:true
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   562
    EditTextView st80Mode:false
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   563
   "
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   564
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   565
    "Modified: / 16.1.1998 / 22:54:57 / cg"
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   566
!
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   567
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   568
st80Mode:aBoolean
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   569
    "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
   570
     beyond the end of a line or the last line.
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
   571
     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
   572
     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
   573
     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
   574
2647
23dca8f032c3 changed st80Mode from classVar to userPreferences value
Claus Gittinger <cg@exept.de>
parents: 2627
diff changeset
   575
    UserPreferences current st80EditMode:aBoolean.
1419
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   576
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   577
   "
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   578
    EditTextView st80Mode:true
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   579
    EditTextView st80Mode:false
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   580
   "
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   581
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   582
    "Modified: / 16.1.1998 / 22:55:19 / cg"
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   583
!
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   584
59
450ce95a72a4 *** empty log message ***
claus
parents: 46
diff changeset
   585
updateStyleCache
440
2beb33cb0146 added style resource directive
Claus Gittinger <cg@exept.de>
parents: 428
diff changeset
   586
    "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
   587
1390
99674e1d9c85 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
   588
    <resource: #style (#'textCursor.foregroundColor' #'textCursor.backgroundColor'
4823
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   589
                       #'textCursor.noFocusForegroundColor'
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   590
                       #'textCursor.type'
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   591
                       #'textCursor.typeNoFocus'
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   592
                       #'editText.st80Mode')>
1355
6725ab9cc6f5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
   593
6725ab9cc6f5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
   594
    DefaultCursorForegroundColor := StyleSheet colorAt:'textCursor.foregroundColor'.
6725ab9cc6f5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
   595
    DefaultCursorBackgroundColor := StyleSheet colorAt:'textCursor.backgroundColor'.
6725ab9cc6f5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
   596
    DefaultCursorNoFocusForegroundColor := StyleSheet colorAt:'textCursor.noFocusForegroundColor'.
6725ab9cc6f5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
   597
    DefaultCursorType := StyleSheet at:'textCursor.type' default:#block.
1534
bcb211e1b41a read noFocus cursorStyle from styleSheet
Claus Gittinger <cg@exept.de>
parents: 1533
diff changeset
   598
    DefaultCursorTypeNoFocus := StyleSheet at:'textCursor.typeNoFocus'.
bcb211e1b41a read noFocus cursorStyle from styleSheet
Claus Gittinger <cg@exept.de>
parents: 1533
diff changeset
   599
1419
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   600
    "
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   601
     self updateStyleCache
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   602
    "
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   603
1534
bcb211e1b41a read noFocus cursorStyle from styleSheet
Claus Gittinger <cg@exept.de>
parents: 1533
diff changeset
   604
    "Modified: / 20.5.1998 / 04:27:41 / cg"
59
450ce95a72a4 *** empty log message ***
claus
parents: 46
diff changeset
   605
! !
450ce95a72a4 *** empty log message ***
claus
parents: 46
diff changeset
   606
3431
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   607
!EditTextView class methodsFor:'specs'!
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   608
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   609
searchReplaceDialogSpec
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   610
    "This resource specification was automatically generated
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   611
     by the UIPainter of ST/X."
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   612
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   613
    "Do not manually edit this!! If it is corrupted,
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   614
     the UIPainter may not be able to read the specification."
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   615
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   616
    "
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   617
     UIPainter new openOnClass:DAPASX::ProjectEditorTextView andSelector:#searchReplaceDialogSpec
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   618
    "
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   619
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   620
    <resource: #canvas>
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   621
3683
5891af82a177 middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents: 3650
diff changeset
   622
    ^
3431
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   623
     #(FullSpec
4823
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   624
        name: searchReplaceDialogSpec
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   625
        window:
3431
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   626
       (WindowSpec
4823
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   627
          label: 'String Search and Replace'
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   628
          name: 'String Search and Replace'
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   629
          min: (Point 283 196)
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   630
          max: (Point 283 196)
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   631
          bounds: (Rectangle 0 0 279 192)
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   632
        )
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   633
        component:
3431
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   634
       (SpecCollection
4823
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   635
          collection: (
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   636
           (LabelSpec
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   637
              label: 'Search Pattern:'
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   638
              name: 'label'
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   639
              layout: (LayoutFrame 1 0.0 3 0 -1 1.0 20 0)
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   640
              level: 0
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   641
              translateLabel: true
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   642
              adjust: left
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   643
            )
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   644
           (ComboBoxSpec
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   645
              name: 'patternComboBox'
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   646
              layout: (LayoutFrame 3 0.0 26 0 -3 1.0 48 0)
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   647
              tabable: true
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   648
              model: searchPattern
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   649
              immediateAccept: false
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   650
              acceptOnLeave: true
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   651
              acceptOnReturn: true
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   652
              acceptOnTab: true
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   653
              acceptOnLostFocus: true
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   654
              acceptOnPointerLeave: false
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   655
              autoSelectInitialText: true
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   656
              comboList: patternList
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   657
            )
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   658
           (ComboBoxSpec
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   659
              name: 'replaceComboBox'
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   660
              layout: (LayoutFrame 3 0.0 76 0 -3 1.0 98 0)
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   661
              tabable: true
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   662
              model: replacePattern
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   663
              immediateAccept: false
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   664
              acceptOnLeave: true
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   665
              acceptOnReturn: true
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   666
              acceptOnTab: true
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   667
              acceptOnLostFocus: true
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   668
              acceptOnPointerLeave: false
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   669
              autoSelectInitialText: true
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   670
              comboList: patternList
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   671
            )
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   672
           (CheckBoxSpec
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   673
              label: 'Ignore Case'
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   674
              name: 'ignoreCaseCheckBox'
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   675
              layout: (LayoutFrame 3 0.0 107 0 -3 1.0 130 0)
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   676
              level: 0
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   677
              tabable: true
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   678
              model: ignoreCase
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   679
              translateLabel: true
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   680
            )
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   681
           (VariableVerticalPanelSpec
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   682
              name: 'VariableVerticalPanel1'
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   683
              layout: (LayoutFrame 0 0 -64 1 0 1 -4 1)
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   684
              component:
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   685
             (SpecCollection
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   686
                collection: (
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   687
                 (HorizontalPanelViewSpec
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   688
                    name: 'HorizontalPanel1'
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   689
                    level: 0
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   690
                    horizontalLayout: fitSpace
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   691
                    verticalLayout: center
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   692
                    horizontalSpace: 3
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   693
                    verticalSpace: 3
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   694
                    ignoreInvisibleComponents: true
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   695
                    reverseOrderIfOKAtLeft: true
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   696
                    component:
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   697
                   (SpecCollection
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   698
                      collection: (
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   699
                       (ActionButtonSpec
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   700
                          label: 'Replace'
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   701
                          name: 'replaceButton'
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   702
                          level: 2
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   703
                          translateLabel: true
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   704
                          tabable: true
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   705
                          model: replaceAction
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   706
                          extent: (Point 134 21)
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   707
                        )
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   708
                       (ActionButtonSpec
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   709
                          label: 'Replace All'
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   710
                          name: 'replaceAllButton'
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   711
                          level: 2
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   712
                          borderWidth: 1
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   713
                          translateLabel: true
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   714
                          tabable: true
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   715
                          model: replaceAllAction
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   716
                          extent: (Point 134 21)
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   717
                        )
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   718
                       )
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   719
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   720
                    )
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   721
                  )
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   722
                 (HorizontalPanelViewSpec
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   723
                    name: 'horizontalPanelView'
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   724
                    level: 0
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   725
                    horizontalLayout: fitSpace
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   726
                    verticalLayout: center
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   727
                    horizontalSpace: 3
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   728
                    verticalSpace: 3
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   729
                    ignoreInvisibleComponents: true
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   730
                    reverseOrderIfOKAtLeft: true
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   731
                    component:
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   732
                   (SpecCollection
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   733
                      collection: (
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   734
                       (ActionButtonSpec
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   735
                          label: 'Cancel'
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   736
                          name: 'cancelButton'
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   737
                          level: 2
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   738
                          translateLabel: true
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   739
                          tabable: true
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   740
                          model: cancel
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   741
                          extent: (Point 88 21)
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   742
                        )
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   743
                       (ActionButtonSpec
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   744
                          label: 'Prev'
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   745
                          name: 'prevButton'
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   746
                          level: 2
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   747
                          translateLabel: true
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   748
                          tabable: true
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   749
                          model: prevAction
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   750
                          extent: (Point 89 21)
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   751
                        )
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   752
                       (ActionButtonSpec
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   753
                          label: 'Next'
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   754
                          name: 'nextButton'
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   755
                          level: 2
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   756
                          borderWidth: 1
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   757
                          translateLabel: true
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   758
                          tabable: true
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   759
                          model: nextAction
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   760
                          isDefault: true
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   761
                          extent: (Point 88 21)
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   762
                        )
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   763
                       )
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   764
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   765
                    )
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   766
                  )
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   767
                 )
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   768
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   769
              )
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   770
              handles: (Any 0.5 1.0)
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   771
            )
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   772
           (LabelSpec
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   773
              label: 'Replace By:'
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   774
              name: 'ReplaceLabel'
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   775
              layout: (LayoutFrame 1 0.0 53 0 -1 1.0 70 0)
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   776
              level: 0
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   777
              translateLabel: true
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   778
              adjust: left
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   779
            )
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   780
           )
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   781
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   782
        )
3431
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   783
      )
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   784
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   785
    "Modified: / 11-10-2006 / 21:05:09 / cg"
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   786
! !
6bf93f206587 searchReplace spec
fm
parents: 3430
diff changeset
   787
2744
cb920467a4b4 method category rename
Claus Gittinger <cg@exept.de>
parents: 2730
diff changeset
   788
!EditTextView methodsFor:'Compatibility-ST80'!
1552
d3d4afaf4c68 dummy ST80 compatibility: #autoAccept:
Claus Gittinger <cg@exept.de>
parents: 1548
diff changeset
   789
d3d4afaf4c68 dummy ST80 compatibility: #autoAccept:
Claus Gittinger <cg@exept.de>
parents: 1548
diff changeset
   790
autoAccept:aBoolean
d3d4afaf4c68 dummy ST80 compatibility: #autoAccept:
Claus Gittinger <cg@exept.de>
parents: 1548
diff changeset
   791
    "ignored for now"
d3d4afaf4c68 dummy ST80 compatibility: #autoAccept:
Claus Gittinger <cg@exept.de>
parents: 1548
diff changeset
   792
2019
b6b078ea3bbf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2018
diff changeset
   793
    "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
   794
!
9bf6cf249376 two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents: 1580
diff changeset
   795
9bf6cf249376 two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents: 1580
diff changeset
   796
continuousAccept:aBoolean
9bf6cf249376 two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents: 1580
diff changeset
   797
    "ignored for now"
9bf6cf249376 two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents: 1580
diff changeset
   798
9bf6cf249376 two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents: 1580
diff changeset
   799
    "Created: / 19.6.1998 / 00:03:49 / cg"
9bf6cf249376 two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents: 1580
diff changeset
   800
!
9bf6cf249376 two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents: 1580
diff changeset
   801
1390
99674e1d9c85 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
   802
cutSelection
99674e1d9c85 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
   803
    self cut
99674e1d9c85 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
   804
99674e1d9c85 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
   805
    "Created: / 31.10.1997 / 03:29:50 / cg"
99674e1d9c85 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
   806
!
99674e1d9c85 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
   807
1590
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   808
deselect
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   809
    "remove the selection"
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   810
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   811
    ^ self unselect
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   812
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   813
    "Created: / 19.6.1998 / 02:41:54 / cg"
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   814
!
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   815
2101
8f2fab818f71 category renamining
Claus Gittinger <cg@exept.de>
parents: 2088
diff changeset
   816
enabled:aBoolean
8f2fab818f71 category renamining
Claus Gittinger <cg@exept.de>
parents: 2088
diff changeset
   817
8f2fab818f71 category renamining
Claus Gittinger <cg@exept.de>
parents: 2088
diff changeset
   818
    self readOnly:aBoolean not
8f2fab818f71 category renamining
Claus Gittinger <cg@exept.de>
parents: 2088
diff changeset
   819
8f2fab818f71 category renamining
Claus Gittinger <cg@exept.de>
parents: 2088
diff changeset
   820
    "Created: / 30.3.1999 / 15:10:23 / stefan"
8f2fab818f71 category renamining
Claus Gittinger <cg@exept.de>
parents: 2088
diff changeset
   821
    "Modified: / 30.3.1999 / 15:10:53 / stefan"
8f2fab818f71 category renamining
Claus Gittinger <cg@exept.de>
parents: 2088
diff changeset
   822
!
8f2fab818f71 category renamining
Claus Gittinger <cg@exept.de>
parents: 2088
diff changeset
   823
1732
2d433e114bbc added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 1717
diff changeset
   824
find:pattern
2d433e114bbc added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 1717
diff changeset
   825
    self searchFwd:pattern ifAbsent:nil
2d433e114bbc added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 1717
diff changeset
   826
2d433e114bbc added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 1717
diff changeset
   827
    "Created: / 29.1.1999 / 19:09:42 / cg"
2d433e114bbc added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 1717
diff changeset
   828
    "Modified: / 29.1.1999 / 19:10:12 / cg"
2d433e114bbc added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 1717
diff changeset
   829
!
2d433e114bbc added #find: (for ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 1717
diff changeset
   830
1294
dac755d4acd3 added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   831
insert:aString at:aCharacterPosition
dac755d4acd3 added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   832
    "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
   833
dac755d4acd3 added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   834
    |line col|
dac755d4acd3 added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   835
dac755d4acd3 added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   836
    line := self lineOfCharacterPosition:aCharacterPosition.
dac755d4acd3 added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   837
    col := aCharacterPosition - (self characterPositionOfLine:line col:1) + 1.
1480
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
   838
    col < 1 ifTrue:[
4823
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
   839
        col := 1
1480
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
   840
    ].
1294
dac755d4acd3 added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   841
    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
   842
dac755d4acd3 added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   843
    "
dac755d4acd3 added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   844
     |top v|
dac755d4acd3 added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   845
dac755d4acd3 added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   846
     top := StandardSystemView new.
dac755d4acd3 added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   847
     top extent:300@300.
dac755d4acd3 added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   848
     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
   849
     top openAndWait.
dac755d4acd3 added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   850
     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
   851
     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
   852
    "
dac755d4acd3 added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   853
1480
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
   854
    "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
   855
!
dac755d4acd3 added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   856
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   857
insertAndSelect:aString at:aCharacterPosition
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   858
    "insert a selected string at aCharacterPosition."
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   859
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   860
    |line col|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   861
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   862
    line := self lineOfCharacterPosition:aCharacterPosition.
2310
861ab02b13b9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2225
diff changeset
   863
    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
   864
    self insertString:aString atLine:line col:col.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   865
    self selectFromLine:line col:col toLine:line col:col + aString size - 1
125
claus
parents: 123
diff changeset
   866
    "
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   867
     |v|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   868
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   869
     v := EditTextView new openAndWait.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   870
     v contents:'1234567890\1234567890\1234567890\' withCRs.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   871
     v insertAndSelect:'<- hello there' at:5.
125
claus
parents: 123
diff changeset
   872
    "
1390
99674e1d9c85 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
   873
!
99674e1d9c85 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
   874
99674e1d9c85 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
   875
pasteSelection
99674e1d9c85 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
   876
    self paste
99674e1d9c85 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
   877
99674e1d9c85 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
   878
    "Created: / 31.10.1997 / 03:28:53 / cg"
1590
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   879
!
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   880
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   881
replaceSelectionWith:aString
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   882
    ^ self replaceSelectionBy:aString
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   883
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   884
    "Created: / 19.6.1998 / 02:42:32 / cg"
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   885
!
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   886
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   887
selectAt:pos
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   888
    "move the cursor before cursorPosition."
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   889
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   890
    self cursorToCharacterPosition:pos
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   891
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   892
    "Modified: / 19.6.1998 / 02:41:28 / cg"
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   893
    "Created: / 19.6.1998 / 02:43:39 / cg"
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   894
!
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   895
2101
8f2fab818f71 category renamining
Claus Gittinger <cg@exept.de>
parents: 2088
diff changeset
   896
textHasChanged
8f2fab818f71 category renamining
Claus Gittinger <cg@exept.de>
parents: 2088
diff changeset
   897
    ^ self modified
8f2fab818f71 category renamining
Claus Gittinger <cg@exept.de>
parents: 2088
diff changeset
   898
8f2fab818f71 category renamining
Claus Gittinger <cg@exept.de>
parents: 2088
diff changeset
   899
    "Created: / 19.6.1998 / 00:09:43 / cg"
2117
b50c6d182e28 added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 2107
diff changeset
   900
!
b50c6d182e28 added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 2107
diff changeset
   901
b50c6d182e28 added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 2107
diff changeset
   902
textHasChanged:aBoolean
b50c6d182e28 added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 2107
diff changeset
   903
    "ST-80 compatibility: set/clear the modified flag."
b50c6d182e28 added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 2107
diff changeset
   904
b50c6d182e28 added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 2107
diff changeset
   905
    self modified:aBoolean
b50c6d182e28 added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 2107
diff changeset
   906
b50c6d182e28 added #textHasChanged: for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 2107
diff changeset
   907
    "Created: / 5.2.2000 / 17:07:59 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   908
! !
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   909
4585
7b31719bf07a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4580
diff changeset
   910
!EditTextView methodsFor:'accessing'!
7b31719bf07a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4580
diff changeset
   911
4803
87d60a4b098b Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4801
diff changeset
   912
codeAspect
87d60a4b098b Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4801
diff changeset
   913
    | codeAspect app |
87d60a4b098b Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4801
diff changeset
   914
87d60a4b098b Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4801
diff changeset
   915
    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
   916
    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
   917
    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
   918
87d60a4b098b Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4801
diff changeset
   919
    "/ Applications should set it explictly, however, to make it behavinh like
87d60a4b098b Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4801
diff changeset
   920
    "/ 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
   921
    ^((app := self topView application) notNil and:[app respondsTo: #codeAspect])
87d60a4b098b Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4801
diff changeset
   922
        ifTrue:[app codeAspect]
87d60a4b098b Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4801
diff changeset
   923
        ifFalse:[nil]
87d60a4b098b Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4801
diff changeset
   924
87d60a4b098b Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4801
diff changeset
   925
    "Created: / 27-09-2013 / 09:53:40 / Jan Vrany <jan.vrany@fit.cvut.cz>"
87d60a4b098b Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4801
diff changeset
   926
!
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
codeAspect: aSymbol
87d60a4b098b Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4801
diff changeset
   929
    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
   930
87d60a4b098b Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4801
diff changeset
   931
    "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
   932
!
87d60a4b098b Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4801
diff changeset
   933
4801
69a5bff7b5cd Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4786
diff changeset
   934
completionSupport
69a5bff7b5cd Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4786
diff changeset
   935
    ^ completionSupport
69a5bff7b5cd Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4786
diff changeset
   936
!
69a5bff7b5cd Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4786
diff changeset
   937
69a5bff7b5cd Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4786
diff changeset
   938
completionSupport:anEditTextViewCompletionSupport
69a5bff7b5cd Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4786
diff changeset
   939
    completionSupport := anEditTextViewCompletionSupport.
69a5bff7b5cd Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4786
diff changeset
   940
!
69a5bff7b5cd Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4786
diff changeset
   941
69a5bff7b5cd Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4786
diff changeset
   942
completionSupportClass
69a5bff7b5cd Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4786
diff changeset
   943
    ^ self class defaultCompletionSupportClass
69a5bff7b5cd Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4786
diff changeset
   944
69a5bff7b5cd Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4786
diff changeset
   945
    "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
   946
!
69a5bff7b5cd Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4786
diff changeset
   947
4609
8b3eb80d04d0 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4595
diff changeset
   948
editedClass
8b3eb80d04d0 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4595
diff changeset
   949
    |cm|
8b3eb80d04d0 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4595
diff changeset
   950
8b3eb80d04d0 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4595
diff changeset
   951
    cm := self editedMethodOrClass.
8b3eb80d04d0 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4595
diff changeset
   952
    cm isBehavior ifTrue:[^ cm].
8b3eb80d04d0 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4595
diff changeset
   953
    cm isMethod ifTrue:[^ cm mclass].
8b3eb80d04d0 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4595
diff changeset
   954
    ^ nil
8b3eb80d04d0 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4595
diff changeset
   955
!
8b3eb80d04d0 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4595
diff changeset
   956
4775
e34752e6214e Pass programming language when asking DWIM to complete code
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4771
diff changeset
   957
editedLanguage
e34752e6214e Pass programming language when asking DWIM to complete code
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4771
diff changeset
   958
    ^ nil
e34752e6214e Pass programming language when asking DWIM to complete code
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4771
diff changeset
   959
e34752e6214e Pass programming language when asking DWIM to complete code
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4771
diff changeset
   960
    "Created: / 18-09-2013 / 14:16:38 / Jan Vrany <jan.vrany@fit.cvut.cz>"
e34752e6214e Pass programming language when asking DWIM to complete code
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4771
diff changeset
   961
!
e34752e6214e Pass programming language when asking DWIM to complete code
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4771
diff changeset
   962
4803
87d60a4b098b Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4801
diff changeset
   963
editedLanguage: aProgrammingLanguage
87d60a4b098b Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4801
diff changeset
   964
    "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
   965
87d60a4b098b Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4801
diff changeset
   966
    "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
   967
!
87d60a4b098b Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4801
diff changeset
   968
4609
8b3eb80d04d0 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4595
diff changeset
   969
editedMethod
8b3eb80d04d0 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4595
diff changeset
   970
    |cm|
8b3eb80d04d0 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4595
diff changeset
   971
8b3eb80d04d0 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4595
diff changeset
   972
    cm := self editedMethodOrClass.
8b3eb80d04d0 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4595
diff changeset
   973
    cm isMethod ifTrue:[^ cm].
8b3eb80d04d0 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4595
diff changeset
   974
    cm isBehavior ifTrue:[^ nil].
8b3eb80d04d0 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4595
diff changeset
   975
    ^ nil
8b3eb80d04d0 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4595
diff changeset
   976
!
8b3eb80d04d0 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4595
diff changeset
   977
8b3eb80d04d0 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4595
diff changeset
   978
editedMethodOrClass
8b3eb80d04d0 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4595
diff changeset
   979
    ^ nil
8b3eb80d04d0 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4595
diff changeset
   980
!
8b3eb80d04d0 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4595
diff changeset
   981
4803
87d60a4b098b Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4801
diff changeset
   982
editedMethodOrClass: methodOrClass
87d60a4b098b Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4801
diff changeset
   983
    "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
   984
87d60a4b098b Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4801
diff changeset
   985
    "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
   986
!
87d60a4b098b Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4801
diff changeset
   987
4585
7b31719bf07a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4580
diff changeset
   988
hasSelectionOrTextInCursorLine
7b31719bf07a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4580
diff changeset
   989
    ^ (self selectionOrTextOfCursorLine:false) notNil
7b31719bf07a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4580
diff changeset
   990
!
7b31719bf07a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4580
diff changeset
   991
4589
f6da08d703f5 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4585
diff changeset
   992
selectionOrTextOfCursorLine
f6da08d703f5 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4585
diff changeset
   993
    ^ self selectionOrTextOfCursorLine:true
f6da08d703f5 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4585
diff changeset
   994
!
f6da08d703f5 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4585
diff changeset
   995
4585
7b31719bf07a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4580
diff changeset
   996
selectionOrTextOfCursorLine:doSelect
7b31719bf07a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4580
diff changeset
   997
    |sel lNr line|
7b31719bf07a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4580
diff changeset
   998
7b31719bf07a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4580
diff changeset
   999
    sel := self selectionAsString.
7b31719bf07a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4580
diff changeset
  1000
    sel notNil ifTrue:[^ sel].
7b31719bf07a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4580
diff changeset
  1001
7b31719bf07a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4580
diff changeset
  1002
    lNr := self cursorLine.
7b31719bf07a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4580
diff changeset
  1003
    line := self listAt:lNr.
7b31719bf07a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4580
diff changeset
  1004
    line notEmptyOrNil ifTrue:[
7b31719bf07a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4580
diff changeset
  1005
        doSelect ifTrue:[
7b31719bf07a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4580
diff changeset
  1006
            self selectLine:lNr.
7b31719bf07a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4580
diff changeset
  1007
        ].
7b31719bf07a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4580
diff changeset
  1008
        ^ line
7b31719bf07a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4580
diff changeset
  1009
    ].
7b31719bf07a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4580
diff changeset
  1010
7b31719bf07a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4580
diff changeset
  1011
    ^ nil
7b31719bf07a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4580
diff changeset
  1012
! !
7b31719bf07a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4580
diff changeset
  1013
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1014
!EditTextView methodsFor:'accessing-behavior'!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1015
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1016
acceptAction
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1017
    "return the action to be performed on accept (or nil)"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1018
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1019
    ^ acceptAction
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1020
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1021
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1022
acceptAction:aBlock
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1023
    "set the action to be performed on accept"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1024
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1025
    acceptAction := aBlock
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1026
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1027
2792
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1028
acceptChannel
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1029
    "return the valueHolder holding true if text was accepted.
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1030
     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
  1031
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1032
    ^ acceptChannel
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1033
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1034
    "Modified: / 30.1.1998 / 14:17:11 / cg"
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1035
!
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1036
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1037
acceptChannel:aValueHolder
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1038
    "set the valueHolder holding true if text was accepted.
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1039
     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
  1040
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1041
    |prev|
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1042
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1043
    prev := acceptChannel.
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1044
    acceptChannel := aValueHolder.
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1045
    self setupChannel:aValueHolder for:nil withOld:prev
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1046
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1047
    "Created: / 30.1.1998 / 14:51:09 / cg"
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1048
!
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1049
1108
3d14bb6bceb7 added disableAccept
Claus Gittinger <cg@exept.de>
parents: 1082
diff changeset
  1050
acceptEnabled:aBoolean
3d14bb6bceb7 added disableAccept
Claus Gittinger <cg@exept.de>
parents: 1082
diff changeset
  1051
    "enable/disable accept. This greys the corresponding item in the menu"
3d14bb6bceb7 added disableAccept
Claus Gittinger <cg@exept.de>
parents: 1082
diff changeset
  1052
3d14bb6bceb7 added disableAccept
Claus Gittinger <cg@exept.de>
parents: 1082
diff changeset
  1053
    acceptEnabled := aBoolean
3d14bb6bceb7 added disableAccept
Claus Gittinger <cg@exept.de>
parents: 1082
diff changeset
  1054
3d14bb6bceb7 added disableAccept
Claus Gittinger <cg@exept.de>
parents: 1082
diff changeset
  1055
    "Created: 7.3.1997 / 11:04:34 / cg"
3d14bb6bceb7 added disableAccept
Claus Gittinger <cg@exept.de>
parents: 1082
diff changeset
  1056
!
3d14bb6bceb7 added disableAccept
Claus Gittinger <cg@exept.de>
parents: 1082
diff changeset
  1057
2792
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1058
accepted
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1059
    "return true if text was accepted"
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1060
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1061
    ^ acceptChannel value
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1062
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1063
    "Created: 14.2.1997 / 16:43:46 / cg"
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1064
!
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1065
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1066
accepted:aBoolean
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1067
    "set/clear the accepted flag.
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1068
     This may force my current contents to be placed into my model."
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1069
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1070
    acceptChannel value:aBoolean.
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1071
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1072
    "Created: / 14.2.1997 / 16:44:01 / cg"
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1073
    "Modified: / 30.1.1998 / 14:20:15 / cg"
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1074
!
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1075
474
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  1076
autoIndent:aBoolean
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  1077
    autoIndent := aBoolean
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  1078
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  1079
    "Created: 5.3.1996 / 14:37:50 / cg"
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  1080
!
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  1081
4803
87d60a4b098b Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4801
diff changeset
  1082
codeAspectHolder
87d60a4b098b Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4801
diff changeset
  1083
    ^ codeAspectHolder
87d60a4b098b Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4801
diff changeset
  1084
!
87d60a4b098b Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4801
diff changeset
  1085
87d60a4b098b Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4801
diff changeset
  1086
codeAspectHolder:something
87d60a4b098b Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4801
diff changeset
  1087
    codeAspectHolder := something.
87d60a4b098b Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4801
diff changeset
  1088
!
87d60a4b098b Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4801
diff changeset
  1089
2774
0415ba0f8cb5 cursorMovement getter
penk
parents: 2762
diff changeset
  1090
cursorMovementWhenUpdating
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1091
    "return what is be done with the cursor,
2774
0415ba0f8cb5 cursorMovement getter
penk
parents: 2762
diff changeset
  1092
     when I get a new text (via the model or the #contents/#list)
0415ba0f8cb5 cursorMovement getter
penk
parents: 2762
diff changeset
  1093
     Allowed arguments are:
4823
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  1094
        #keep / nil     -> stay where it was
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  1095
        #endOfText      -> position cursor to the end
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  1096
        #beginOfText    -> position cursor to the beginning
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  1097
        #endOfLine      -> position cursor to the current lines end
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  1098
        #beginOfLine    -> position cursor to the current lines start
2774
0415ba0f8cb5 cursorMovement getter
penk
parents: 2762
diff changeset
  1099
     The default is #beginOfText.
0415ba0f8cb5 cursorMovement getter
penk
parents: 2762
diff changeset
  1100
     This may be useful for fields which get new values assigned from
0415ba0f8cb5 cursorMovement getter
penk
parents: 2762
diff changeset
  1101
     the program (i.e. not from the user)"
0415ba0f8cb5 cursorMovement getter
penk
parents: 2762
diff changeset
  1102
0415ba0f8cb5 cursorMovement getter
penk
parents: 2762
diff changeset
  1103
    ^ cursorMovementWhenUpdating
0415ba0f8cb5 cursorMovement getter
penk
parents: 2762
diff changeset
  1104
0415ba0f8cb5 cursorMovement getter
penk
parents: 2762
diff changeset
  1105
    "Modified: 16.12.1995 / 16:27:55 / cg"
0415ba0f8cb5 cursorMovement getter
penk
parents: 2762
diff changeset
  1106
!
0415ba0f8cb5 cursorMovement getter
penk
parents: 2762
diff changeset
  1107
2133
47a23fdfc83f comment
Claus Gittinger <cg@exept.de>
parents: 2131
diff changeset
  1108
cursorMovementWhenUpdating:aSymbolOrNil
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1109
    "define what should be done with the cursor,
2133
47a23fdfc83f comment
Claus Gittinger <cg@exept.de>
parents: 2131
diff changeset
  1110
     when I get a new text (via the model or the #contents/#list)
47a23fdfc83f comment
Claus Gittinger <cg@exept.de>
parents: 2131
diff changeset
  1111
     Allowed arguments are:
4823
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  1112
        #keep / nil     -> stay where it was
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  1113
        #endOfText      -> position cursor to the end
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  1114
        #beginOfText    -> position cursor to the beginning
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  1115
        #endOfLine      -> position cursor to the current lines end
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  1116
        #beginOfLine    -> position cursor to the current lines start
2133
47a23fdfc83f comment
Claus Gittinger <cg@exept.de>
parents: 2131
diff changeset
  1117
     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
  1118
     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
  1119
     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
  1120
2133
47a23fdfc83f comment
Claus Gittinger <cg@exept.de>
parents: 2131
diff changeset
  1121
    cursorMovementWhenUpdating := aSymbolOrNil
2129
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  1122
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  1123
    "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
  1124
!
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  1125
2035
6924861adf08 added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents: 2029
diff changeset
  1126
disableIfInvisible:aBoolean
6924861adf08 added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents: 2029
diff changeset
  1127
    disableIfInvisible := aBoolean
6924861adf08 added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents: 2029
diff changeset
  1128
!
6924861adf08 added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents: 2029
diff changeset
  1129
2438
6406f4444ee4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2432
diff changeset
  1130
dontReplaceSelectionOnInput
4742
a00cb40ee392 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4738
diff changeset
  1131
    "remember that the current selection was created by a paste operation
a00cb40ee392 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4738
diff changeset
  1132
     (as opposed to an explicit selection by the user).
a00cb40ee392 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4738
diff changeset
  1133
     This selection will not be replaced by followup user input,
a00cb40ee392 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4738
diff changeset
  1134
     so multiple pastes will be possible."
a00cb40ee392 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4738
diff changeset
  1135
5342
be32b0744ff3 Workaround to fix DNU in selector completion when DWIM-completer is used.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 5340
diff changeset
  1136
    self hasSelection ifTrue:[ 
be32b0744ff3 Workaround to fix DNU in selector completion when DWIM-completer is used.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 5340
diff changeset
  1137
        typeOfSelection := #paste
be32b0744ff3 Workaround to fix DNU in selector completion when DWIM-completer is used.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 5340
diff changeset
  1138
    ].
be32b0744ff3 Workaround to fix DNU in selector completion when DWIM-completer is used.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 5340
diff changeset
  1139
be32b0744ff3 Workaround to fix DNU in selector completion when DWIM-completer is used.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 5340
diff changeset
  1140
    "Modified: / 02-05-2015 / 21:17:27 / Jan Vrany <jan.vrany@fit.cvut.cz>"
2438
6406f4444ee4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2432
diff changeset
  1141
!
6406f4444ee4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2432
diff changeset
  1142
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  1143
editModeHolder
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  1144
    ^ editMode.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  1145
!
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  1146
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  1147
editModeInsert
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  1148
    editMode value:EditMode insertMode
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  1149
!
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  1150
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  1151
editModeInsertAndSelect
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  1152
    editMode value:EditMode insertAndSelectMode
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  1153
!
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  1154
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  1155
editModeOverwrite
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  1156
    editMode value:EditMode overwriteMode
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  1157
!
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  1158
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1159
exceptionBlock:aBlock
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1160
    "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
  1161
     readonly text"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1162
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1163
    exceptionBlock := aBlock
323
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
  1164
!
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
  1165
3296
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
  1166
fixedSize
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
  1167
    "make the texts size fixed (no lines may be added).
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
  1168
     OBSOLETE: use readOnly"
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
  1169
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
  1170
    <resource:#obsolete>
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
  1171
3683
5891af82a177 middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents: 3650
diff changeset
  1172
    |menu|
5891af82a177 middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents: 3650
diff changeset
  1173
3296
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
  1174
    self obsoleteMethodWarning:'use #readOnly:'.
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
  1175
    readOnly == true ifFalse:[
4823
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  1176
        readOnly := true.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  1177
        (menu := self middleButtonMenu) notNil ifTrue:[
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  1178
            menu disableAll:#(cut paste replace indent)
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  1179
        ]
3296
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
  1180
    ]
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
  1181
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
  1182
    "Modified: 14.2.1997 / 17:35:24 / cg"
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
  1183
!
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
  1184
5858
f281506fb025 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5857
diff changeset
  1185
generateTextAfterEndHook:aBlock
f281506fb025 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5857
diff changeset
  1186
    "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
  1187
     when the cursor is moved there.
f281506fb025 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5857
diff changeset
  1188
     For example, disassembly views or memory dumps (hex-dumps),
f281506fb025 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5857
diff changeset
  1189
     which want to automatically generate additional lines lazily,
f281506fb025 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5857
diff changeset
  1190
     but which cannot afford to generate the whole text in advance
f281506fb025 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5857
diff changeset
  1191
     (eg: who wants to disassemble gigabytes?).
5890
5dc30fda9ebf #OTHER by mawalch
mawalch
parents: 5887
diff changeset
  1192
     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
  1193
     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
  1194
     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
  1195
     number, into which the cursor should be moved
5dc30fda9ebf #OTHER by mawalch
mawalch
parents: 5887
diff changeset
  1196
     (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
  1197
     to make the cursor end in the last line which was inserted)"
5890
5dc30fda9ebf #OTHER by mawalch
mawalch
parents: 5887
diff changeset
  1198
5858
f281506fb025 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5857
diff changeset
  1199
    self setAttribute:#generateTextAfterEndHook to:aBlock
f281506fb025 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5857
diff changeset
  1200
!
f281506fb025 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5857
diff changeset
  1201
f281506fb025 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5857
diff changeset
  1202
generateTextBeforeStartHook:aBlock
f281506fb025 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5857
diff changeset
  1203
    "some applications may want to dynamically generate lines above the top
f281506fb025 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5857
diff changeset
  1204
     line, when the cursor is moved there.
f281506fb025 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5857
diff changeset
  1205
     For example, disassembly views or memory dumps (hex-dumps),
f281506fb025 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5857
diff changeset
  1206
     which want to automatically generate additional lines lazily,
f281506fb025 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5857
diff changeset
  1207
     but which cannot afford to generate the whole text in advance
f281506fb025 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5857
diff changeset
  1208
     (eg: who wants to disassemble gigabytes?).
5890
5dc30fda9ebf #OTHER by mawalch
mawalch
parents: 5887
diff changeset
  1209
     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
  1210
     top, getting the new lineNr (i.e < 1) as argument.
5858
f281506fb025 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5857
diff changeset
  1211
     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
  1212
     number, into which the cursor should be moved
5dc30fda9ebf #OTHER by mawalch
mawalch
parents: 5887
diff changeset
  1213
     (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
  1214
     cursor end in the last line which was inserted)"
5890
5dc30fda9ebf #OTHER by mawalch
mawalch
parents: 5887
diff changeset
  1215
5858
f281506fb025 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5857
diff changeset
  1216
    self setAttribute:#generateTextBeforeStartHook to:aBlock
f281506fb025 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5857
diff changeset
  1217
!
f281506fb025 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5857
diff changeset
  1218
477
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  1219
insertMode:aBoolean
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  1220
    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
  1221
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  1222
    "Created: 6.3.1996 / 12:24:05 / cg"
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  1223
!
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  1224
2795
1f7b5f242eee learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents: 2792
diff changeset
  1225
insertModeHolder
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  1226
    ^ BlockValue
4823
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  1227
        with:[:m | m isInsertMode]
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  1228
        argument:(editMode).
3465
a6eb20608b1f BlockValue usage cleanup
Claus Gittinger <cg@exept.de>
parents: 3439
diff changeset
  1229
a6eb20608b1f BlockValue usage cleanup
Claus Gittinger <cg@exept.de>
parents: 3439
diff changeset
  1230
    "Modified: / 08-03-2007 / 22:58:37 / cg"
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  1231
!
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  1232
3683
5891af82a177 middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents: 3650
diff changeset
  1233
isInInsertMode
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  1234
    ^ editMode value isInsertMode
2795
1f7b5f242eee learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents: 2792
diff changeset
  1235
!
1f7b5f242eee learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents: 2792
diff changeset
  1236
5216
8d6eef5d09c3 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5194
diff changeset
  1237
isNotReadOnly
8d6eef5d09c3 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5194
diff changeset
  1238
    "return true, if the text is not readonly."
8d6eef5d09c3 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5194
diff changeset
  1239
8d6eef5d09c3 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5194
diff changeset
  1240
    ^ self isReadOnly not
8d6eef5d09c3 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5194
diff changeset
  1241
!
8d6eef5d09c3 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5194
diff changeset
  1242
2792
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1243
isReadOnly
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1244
    "return true, if the text is readonly."
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1245
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1246
    ^ readOnly value
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
    "Modified: 14.2.1997 / 17:35:56 / cg"
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1249
!
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1250
2796
481d9e54434c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2795
diff changeset
  1251
modeLabelHolder
481d9e54434c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2795
diff changeset
  1252
    "a valueHolder, which contains 'L' (learnMode), I (insertMode) or empty"
481d9e54434c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2795
diff changeset
  1253
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1254
    ^ BlockValue
4041
d3a015f9d5dd changed: #modeLabelHolder
Claus Gittinger <cg@exept.de>
parents: 4011
diff changeset
  1255
        with:[:e :l |
d3a015f9d5dd changed: #modeLabelHolder
Claus Gittinger <cg@exept.de>
parents: 4011
diff changeset
  1256
            self isReadOnly ifTrue:[
d3a015f9d5dd changed: #modeLabelHolder
Claus Gittinger <cg@exept.de>
parents: 4011
diff changeset
  1257
                ''
d3a015f9d5dd changed: #modeLabelHolder
Claus Gittinger <cg@exept.de>
parents: 4011
diff changeset
  1258
            ] ifFalse:[
5724
f0acb1250b87 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 5719
diff changeset
  1259
                l ifTrue:[ 'L' allBold withColor:#red]
4041
d3a015f9d5dd changed: #modeLabelHolder
Claus Gittinger <cg@exept.de>
parents: 4011
diff changeset
  1260
                  ifFalse:[ e infoPrintString]]]
d3a015f9d5dd changed: #modeLabelHolder
Claus Gittinger <cg@exept.de>
parents: 4011
diff changeset
  1261
        argument:(self editModeHolder)
d3a015f9d5dd changed: #modeLabelHolder
Claus Gittinger <cg@exept.de>
parents: 4011
diff changeset
  1262
        argument:(self learnModeHolder).
3465
a6eb20608b1f BlockValue usage cleanup
Claus Gittinger <cg@exept.de>
parents: 3439
diff changeset
  1263
a6eb20608b1f BlockValue usage cleanup
Claus Gittinger <cg@exept.de>
parents: 3439
diff changeset
  1264
    "Modified: / 08-03-2007 / 22:58:59 / cg"
2796
481d9e54434c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2795
diff changeset
  1265
!
481d9e54434c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2795
diff changeset
  1266
2792
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1267
modified
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1268
    "return true if text was modified"
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1269
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1270
    ^ modifiedChannel value
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1271
!
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1272
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1273
modified:aBoolean
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1274
    "set/clear the modified flag"
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1275
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1276
    modifiedChannel value:aBoolean
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1277
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1278
    "Modified: 14.2.1997 / 16:44:05 / cg"
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1279
!
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1280
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1281
modifiedChannel
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1282
    "return the valueHolder holding true if text was modified"
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1283
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1284
    ^ modifiedChannel
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1285
!
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1286
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1287
modifiedChannel:aValueHolder
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1288
    "set the valueHolder holding true if text was modified"
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1289
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1290
    |prev|
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1291
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1292
    prev := modifiedChannel.
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1293
    modifiedChannel := aValueHolder.
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1294
    self setupChannel:aValueHolder for:nil withOld:prev
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1295
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1296
    "Created: / 30.1.1998 / 14:51:32 / cg"
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1297
!
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1298
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1299
readOnly
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1300
    "make the text readonly.
4664
f09d5587253f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4661
diff changeset
  1301
     Obsolete because it is obfuscating (looks like a getter)
f09d5587253f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4661
diff changeset
  1302
     - use #readOnly:"
2792
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1303
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1304
    <resource:#obsolete>
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1305
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1306
    self obsoleteMethodWarning:'use #readOnly:'.
3705
a819d7204ee3 changed #readOnly
Stefan Vogel <sv@exept.de>
parents: 3683
diff changeset
  1307
    self readOnly:true.
2792
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1308
4664
f09d5587253f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4661
diff changeset
  1309
    "Modified: / 14-02-1997 / 17:35:56 / cg"
f09d5587253f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4661
diff changeset
  1310
    "Modified (comment): / 02-08-2013 / 16:46:57 / cg"
2792
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1311
!
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1312
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1313
readOnly:aBoolean
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1314
    "make the text readonly (aBoolean == true) or writable (aBoolean == false).
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1315
     The argument may also be a valueHolder."
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1316
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1317
    readOnly := aBoolean
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1318
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1319
    "Created: 14.2.1997 / 17:35:39 / cg"
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1320
!
508ab005b021 category changes
Claus Gittinger <cg@exept.de>
parents: 2784
diff changeset
  1321
4782
353079ce0c9d class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4781
diff changeset
  1322
reallyModifiedChannel
353079ce0c9d class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4781
diff changeset
  1323
    "return the valueHolder holding true if text was really modified.
353079ce0c9d class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4781
diff changeset
  1324
     For compatibility with views which use the modified flag for syntax highlighting."
353079ce0c9d class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4781
diff changeset
  1325
353079ce0c9d class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4781
diff changeset
  1326
    ^ self modifiedChannel
353079ce0c9d class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4781
diff changeset
  1327
!
353079ce0c9d class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4781
diff changeset
  1328
5909
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  1329
st80EditMode
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  1330
    "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
  1331
     if off, we have the Rand-editor behavior (random access)"
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  1332
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  1333
    ^ st80Mode ? (UserPreferences current st80EditMode)
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  1334
!
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  1335
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  1336
st80EditMode:aBooleanOrNil
4192
0bc8b69bb610 added: #st80Mode:
Claus Gittinger <cg@exept.de>
parents: 4191
diff changeset
  1337
    "set/clear the st80Mode flag.
0bc8b69bb610 added: #st80Mode:
Claus Gittinger <cg@exept.de>
parents: 4191
diff changeset
  1338
     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
  1339
     if off, we have the Rand-editor behavior (random access)
c24842bec834 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5251
diff changeset
  1340
     if nil, the setting follows the current userPref setting."
c24842bec834 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5251
diff changeset
  1341
c24842bec834 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5251
diff changeset
  1342
    st80Mode := aBooleanOrNil
4192
0bc8b69bb610 added: #st80Mode:
Claus Gittinger <cg@exept.de>
parents: 4191
diff changeset
  1343
0bc8b69bb610 added: #st80Mode:
Claus Gittinger <cg@exept.de>
parents: 4191
diff changeset
  1344
    "Created: / 09-11-2010 / 13:55:50 / cg"
0bc8b69bb610 added: #st80Mode:
Claus Gittinger <cg@exept.de>
parents: 4191
diff changeset
  1345
!
0bc8b69bb610 added: #st80Mode:
Claus Gittinger <cg@exept.de>
parents: 4191
diff changeset
  1346
5909
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  1347
st80Mode:aBooleanOrNil
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  1348
    self obsoleteMethodWarning.
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  1349
    self st80EditMode:aBooleanOrNil
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  1350
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  1351
    "Created: / 09-11-2010 / 13:55:50 / cg"
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  1352
!
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  1353
323
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
  1354
tabMeansNextField:aBoolean
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
  1355
    "set/clear tabbing to the next field.
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
  1356
     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
  1357
     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
  1358
     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
  1359
     input fields."
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
  1360
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
  1361
    tabMeansNextField := aBoolean
2779
5ca530482fdd unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 2774
diff changeset
  1362
!
5ca530482fdd unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 2774
diff changeset
  1363
5ca530482fdd unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 2774
diff changeset
  1364
tabRequiresControl
5ca530482fdd unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 2774
diff changeset
  1365
    "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
  1366
     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
  1367
     to allow for easier text entry"
5ca530482fdd unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 2774
diff changeset
  1368
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1369
    ^ tabRequiresControl
2779
5ca530482fdd unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 2774
diff changeset
  1370
!
5ca530482fdd unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 2774
diff changeset
  1371
5ca530482fdd unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 2774
diff changeset
  1372
tabRequiresControl:aBoolean
5ca530482fdd unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 2774
diff changeset
  1373
    "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
  1374
     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
  1375
     to allow for easier text entry"
5ca530482fdd unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 2774
diff changeset
  1376
5ca530482fdd unchecked: tabRequiresControl for VW compatibility
Claus Gittinger <cg@exept.de>
parents: 2774
diff changeset
  1377
    tabRequiresControl := aBoolean
5909
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  1378
!
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  1379
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  1380
trimBlankLines
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  1381
    "If on, the blank lines are trimmed to zero size;
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  1382
     if nil, the setting follows the current userPref setting."
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  1383
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  1384
    ^ trimBlankLines ? (UserPreferences current trimBlankLines)
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  1385
!
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  1386
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  1387
trimBlankLines:aBooleanOrNil
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  1388
    "If on, the blank lines are trimmed to zero size;
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  1389
     if nil, the setting follows the current userPref setting."
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  1390
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  1391
    trimBlankLines := aBooleanOrNil.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1392
! !
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1393
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1394
!EditTextView methodsFor:'accessing-contents'!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1395
1902
302a68c2255e added #at:basicPut: to access a line without change notification.
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
  1396
at:lineNr basicPut:aLine
5413
b21cbb97c038 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5404
diff changeset
  1397
    "change a line without change notification.
b21cbb97c038 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5404
diff changeset
  1398
     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
  1399
302a68c2255e added #at:basicPut: to access a line without change notification.
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
  1400
    (self at:lineNr) = aLine ifFalse:[
4823
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  1401
        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
  1402
    ].
302a68c2255e added #at:basicPut: to access a line without change notification.
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
  1403
!
302a68c2255e added #at:basicPut: to access a line without change notification.
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
  1404
522
aa9458e4643e indent/undent did not trigger a modify
ca
parents: 503
diff changeset
  1405
at:lineNr put:aLine
5413
b21cbb97c038 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5404
diff changeset
  1406
    "replace a line by something new.
b21cbb97c038 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5404
diff changeset
  1407
     this is not undoably, unless you care for yourself"
b21cbb97c038 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5404
diff changeset
  1408
5393
efb824b89cdf class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5390
diff changeset
  1409
    |oldLine|
efb824b89cdf class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5390
diff changeset
  1410
efb824b89cdf class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5390
diff changeset
  1411
    oldLine := (self at:lineNr) ? ''.
efb824b89cdf class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5390
diff changeset
  1412
    (oldLine sameStringAndEmphasisAs: (aLine? '')) ifFalse:[
4823
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  1413
        super at:lineNr put:aLine.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  1414
        self textChanged
522
aa9458e4643e indent/undent did not trigger a modify
ca
parents: 503
diff changeset
  1415
    ].
aa9458e4643e indent/undent did not trigger a modify
ca
parents: 503
diff changeset
  1416
!
aa9458e4643e indent/undent did not trigger a modify
ca
parents: 503
diff changeset
  1417
4700
150468a2ea5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4697
diff changeset
  1418
characterAfterCursor
150468a2ea5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4697
diff changeset
  1419
    "return the character one after the cursor - space if beyond line."
150468a2ea5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4697
diff changeset
  1420
150468a2ea5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4697
diff changeset
  1421
    ^ self characterAtLine:cursorLine col:cursorCol+1
150468a2ea5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4697
diff changeset
  1422
!
150468a2ea5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4697
diff changeset
  1423
1577
4e487247ad33 dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents: 1568
diff changeset
  1424
characterBeforeCursor
4700
150468a2ea5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4697
diff changeset
  1425
    "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
  1426
5142
54457633c096 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5134
diff changeset
  1427
    cursorCol <= 1 ifTrue:[^ nil].
1577
4e487247ad33 dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents: 1568
diff changeset
  1428
4e487247ad33 dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents: 1568
diff changeset
  1429
    ^ self characterAtLine:cursorLine col:cursorCol-1
4e487247ad33 dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents: 1568
diff changeset
  1430
4e487247ad33 dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents: 1568
diff changeset
  1431
    "Created: / 17.6.1998 / 15:16:41 / cg"
4e487247ad33 dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents: 1568
diff changeset
  1432
!
4e487247ad33 dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents: 1568
diff changeset
  1433
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1434
characterUnderCursor
2707
810c994db0b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2696
diff changeset
  1435
    "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
  1436
     For non-block cursors, this is the character immediately to the right
5413
b21cbb97c038 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5404
diff changeset
  1437
     of the insertion-bar or caret. 
b21cbb97c038 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5404
diff changeset
  1438
     For block cursors, this is the highlighted cursor-character"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1439
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1440
    ^ self characterAtLine:cursorLine col:cursorCol
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1441
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1442
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1443
contents
2213
6068f2786bd6 added #contentsAsString
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1444
    "return the contents as a String or Text (i.e. with emphasis)"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1445
5988
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
  1446
    |numLines|
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
  1447
    
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
  1448
    list isNil ifTrue:[^ ''].    
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
  1449
    self trimBlankLines ifTrue:[
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
  1450
        self removeTrailingBlankLines.
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
  1451
    ] ifFalse:[
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
  1452
        "/ the last line does not count, if the cursor is at
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
  1453
        "/ the begining
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
  1454
        cursorCol == 1 ifTrue:[
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
  1455
            numLines := list size.    
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
  1456
            cursorLine == numLines ifTrue:[
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
  1457
                numLines > 1 ifTrue:[
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
  1458
                    (self listAt:numLines) isEmptyOrNil ifTrue:[
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
  1459
                        list grow:numLines-1.
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
  1460
                    ].    
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
  1461
                ].    
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
  1462
            ].    
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
  1463
        ].    
90a6f9e83f75 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5979
diff changeset
  1464
    ].    
3707
8f6bc68b9319 changed #contents - formatting and comments
Stefan Vogel <sv@exept.de>
parents: 3705
diff changeset
  1465
    ^ super contents.
3313
6c2fd7c5a02f CRLF management
fm
parents: 3310
diff changeset
  1466
6c2fd7c5a02f CRLF management
fm
parents: 3310
diff changeset
  1467
    "Modified: / 04-07-2006 / 19:22:32 / fm"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1468
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1469
5413
b21cbb97c038 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5404
diff changeset
  1470
contents:aStringOrStringCollectionOrNil
b21cbb97c038 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5404
diff changeset
  1471
    "replace the whole contents by something new.
5414
87ff3f9cbe55 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5413
diff changeset
  1472
     this is not undoably, unless you care for yourself.
87ff3f9cbe55 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5413
diff changeset
  1473
     See replaceContentsWith:newContents for an undoable version of this"
5413
b21cbb97c038 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5404
diff changeset
  1474
b21cbb97c038 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5404
diff changeset
  1475
    self contents:aStringOrStringCollectionOrNil keepUndoHistory:false.
3249
a4beb76b3f59 code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents: 3241
diff changeset
  1476
!
a4beb76b3f59 code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents: 3241
diff changeset
  1477
a4beb76b3f59 code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents: 3241
diff changeset
  1478
contents:something keepUndoHistory:keepUndoHistory
5414
87ff3f9cbe55 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5413
diff changeset
  1479
    "set the contents and optionally clear the undo history.
87ff3f9cbe55 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5413
diff changeset
  1480
     The contents-change is not undoable."
87ff3f9cbe55 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5413
diff changeset
  1481
3249
a4beb76b3f59 code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents: 3241
diff changeset
  1482
    super contents:something.
a4beb76b3f59 code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents: 3241
diff changeset
  1483
    keepUndoHistory ifFalse:[
4823
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  1484
        undoSupport resetHistories.
3249
a4beb76b3f59 code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents: 3241
diff changeset
  1485
    ].
a4beb76b3f59 code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents: 3241
diff changeset
  1486
!
a4beb76b3f59 code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents: 3241
diff changeset
  1487
2213
6068f2786bd6 added #contentsAsString
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1488
contentsAsString
6068f2786bd6 added #contentsAsString
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1489
    "return the contents as a String (i.e. without emphasis)"
6068f2786bd6 added #contentsAsString
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1490
6068f2786bd6 added #contentsAsString
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1491
    list isNil ifTrue:[^ ''].
6068f2786bd6 added #contentsAsString
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1492
    self removeTrailingBlankLines.
6068f2786bd6 added #contentsAsString
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1493
    ^ (list collect:[:each | each isNil ifTrue:['']
4823
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  1494
                                        ifFalse:[each string]
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  1495
                    ]) asStringWithCRs
2213
6068f2786bd6 added #contentsAsString
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1496
!
6068f2786bd6 added #contentsAsString
Claus Gittinger <cg@exept.de>
parents: 2210
diff changeset
  1497
5067
a5298bf273fa class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5063
diff changeset
  1498
contentsAsStringWithTabs
a5298bf273fa class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5063
diff changeset
  1499
    "return the contents as a String (i.e. without emphasis)
a5298bf273fa class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5063
diff changeset
  1500
     and with leading spaces replaced by tab characters
a5298bf273fa class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5063
diff changeset
  1501
     (i.e. as would be written to a file)"
a5298bf273fa class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5063
diff changeset
  1502
a5298bf273fa class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5063
diff changeset
  1503
    list isNil ifTrue:[^ ''].
a5298bf273fa class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5063
diff changeset
  1504
    self removeTrailingBlankLines.
a5298bf273fa class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5063
diff changeset
  1505
    ^ (list collect:[:each | 
a5298bf273fa class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5063
diff changeset
  1506
        each isNil 
a5298bf273fa class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5063
diff changeset
  1507
            ifTrue:['']
a5298bf273fa class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5063
diff changeset
  1508
            ifFalse:[each string withTabs]
a5298bf273fa class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5063
diff changeset
  1509
       ]) asStringWithCRs
a5298bf273fa class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5063
diff changeset
  1510
!
a5298bf273fa class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5063
diff changeset
  1511
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1512
cursorCol
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1513
    "return the cursors col (1..).
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1514
     This is the absolute col; NOT the visible col"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1515
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1516
    ^ cursorCol
125
claus
parents: 123
diff changeset
  1517
!
claus
parents: 123
diff changeset
  1518
2422
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1519
cursorColHolder
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1520
    "return a valueHolder for the cursors column (1..)."
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1521
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1522
    ^ cursorColHolder
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1523
!
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1524
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1525
cursorLine
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1526
    "return the cursors line (1..).
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1527
     This is the absolute line; NOT the visible line"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1528
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1529
    ^ cursorLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1530
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1531
5400
c8c25c1392f7 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5399
diff changeset
  1532
cursorLineAndColumnLabelHolder
5399
22d3682235f9 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5394
diff changeset
  1533
    "return a valueHolder for the cursors line and column as an info string
22d3682235f9 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5394
diff changeset
  1534
     of the form 'line : col'. 
22d3682235f9 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5394
diff changeset
  1535
     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
  1536
22d3682235f9 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5394
diff changeset
  1537
    ^ BlockValue
22d3682235f9 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5394
diff changeset
  1538
        with:[:l :c | '%1 : %2' bindWith:l with:c]
22d3682235f9 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5394
diff changeset
  1539
        argument:self cursorLineHolder
22d3682235f9 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5394
diff changeset
  1540
        argument:self cursorColHolder
22d3682235f9 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5394
diff changeset
  1541
!
22d3682235f9 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5394
diff changeset
  1542
2422
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1543
cursorLineHolder
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1544
    "return a valueHolder for the cursors line (1..).
2422
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1545
     This is the absolute line; NOT the visible line"
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1546
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1547
    ^ cursorLineHolder
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1548
!
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  1549
4713
e8c9caf13e05 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4707
diff changeset
  1550
lineStringBeforeCursor
e8c9caf13e05 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4707
diff changeset
  1551
    "return the line's string before the cursor.
e8c9caf13e05 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4707
diff changeset
  1552
     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
  1553
e8c9caf13e05 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4707
diff changeset
  1554
    |line|
e8c9caf13e05 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4707
diff changeset
  1555
e8c9caf13e05 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4707
diff changeset
  1556
    line := ((self at:cursorLine) ? '') string.
e8c9caf13e05 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4707
diff changeset
  1557
    line size < (cursorCol-1) ifTrue:[
e8c9caf13e05 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4707
diff changeset
  1558
        ^ line paddedTo:(cursorCol-1)
e8c9caf13e05 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4707
diff changeset
  1559
    ].
e8c9caf13e05 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4707
diff changeset
  1560
    ^ line copyTo:(cursorCol-1)
e8c9caf13e05 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4707
diff changeset
  1561
!
e8c9caf13e05 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4707
diff changeset
  1562
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1563
list:something
5413
b21cbb97c038 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5404
diff changeset
  1564
    "replace the whole contents by something new.
b21cbb97c038 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5404
diff changeset
  1565
     this is not undoably, unless you care for yourself.
b21cbb97c038 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5404
diff changeset
  1566
     position cursor home when setting contents"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1567
2129
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  1568
    |prevCursorLine prevCursorCol|
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  1569
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  1570
    prevCursorLine := cursorLine.
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  1571
    prevCursorCol := cursorCol.
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  1572
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1573
    super list:something.
2129
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  1574
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  1575
    (cursorMovementWhenUpdating == #endOfText
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  1576
    or:[cursorMovementWhenUpdating == #end]) ifTrue:[
4823
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  1577
        ^ self cursorToEndOfText
2129
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  1578
    ].
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  1579
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  1580
    (cursorMovementWhenUpdating == #endOfLine) ifTrue:[
4823
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  1581
        ^ self cursorLine:prevCursorLine col:(self listAt:cursorLine) size + 1.
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1582
    ].
2129
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  1583
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  1584
    (cursorMovementWhenUpdating == #beginOfText
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  1585
    or:[cursorMovementWhenUpdating == #begin]) ifTrue:[
4823
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  1586
        ^ self cursorHome
2129
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  1587
    ].
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  1588
    (cursorMovementWhenUpdating == #beginOfLine) ifTrue:[
4823
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  1589
        ^ 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
  1590
    ].
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  1591
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  1592
    "/ 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
  1593
    "/ self cursorLine:prevCursorLine col:prevCursorCol.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1594
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1595
1476
ac38c8af8585 setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents: 1449
diff changeset
  1596
setContents:something
5413
b21cbb97c038 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5404
diff changeset
  1597
    "replace the whole contents by something new 
b21cbb97c038 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5404
diff changeset
  1598
     AND clear the remembered undo actions"
b21cbb97c038 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5404
diff changeset
  1599
1476
ac38c8af8585 setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents: 1449
diff changeset
  1600
    |selType|
ac38c8af8585 setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents: 1449
diff changeset
  1601
2989
5dcc2912bcb6 undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents: 2984
diff changeset
  1602
    undoSupport resetHistories.
2955
Claus Gittinger <cg@exept.de>
parents: 2954
diff changeset
  1603
1476
ac38c8af8585 setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents: 1449
diff changeset
  1604
    selType := typeOfSelection.
ac38c8af8585 setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents: 1449
diff changeset
  1605
    super setContents:something.
ac38c8af8585 setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents: 1449
diff changeset
  1606
    typeOfSelection := selType.
ac38c8af8585 setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents: 1449
diff changeset
  1607
ac38c8af8585 setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents: 1449
diff changeset
  1608
    "Created: / 31.3.1998 / 23:35:06 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1609
! !
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1610
4609
8b3eb80d04d0 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4595
diff changeset
  1611
!EditTextView methodsFor:'accessing-dimensions'!
8b3eb80d04d0 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4595
diff changeset
  1612
8b3eb80d04d0 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4595
diff changeset
  1613
xOfCursor
4728
af70b9c1d04c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4721
diff changeset
  1614
    |point|
af70b9c1d04c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4721
diff changeset
  1615
af70b9c1d04c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4721
diff changeset
  1616
    cursorVisibleLine isNil ifTrue:[
af70b9c1d04c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4721
diff changeset
  1617
        "/ take the end of the selection, if any
af70b9c1d04c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4721
diff changeset
  1618
        (selectionStartLine notNil 
af70b9c1d04c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4721
diff changeset
  1619
            and:[ self listLineIsVisible:selectionEndLine ])
af70b9c1d04c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4721
diff changeset
  1620
        ifTrue:[
af70b9c1d04c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4721
diff changeset
  1621
            ^ self xOfCol:selectionEndCol inVisibleLine:selectionEndLine.
af70b9c1d04c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4721
diff changeset
  1622
        ].
af70b9c1d04c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4721
diff changeset
  1623
af70b9c1d04c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4721
diff changeset
  1624
"/        point := device 
af70b9c1d04c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4721
diff changeset
  1625
"/                    translatePoint:(device pointerPosition)
af70b9c1d04c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4721
diff changeset
  1626
"/                    fromView:nil
af70b9c1d04c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4721
diff changeset
  1627
"/                    toView:self.
af70b9c1d04c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4721
diff changeset
  1628
"/        ((self bounds) containsPoint:point) ifTrue:[
af70b9c1d04c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4721
diff changeset
  1629
"/            ^ point x
af70b9c1d04c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4721
diff changeset
  1630
"/        ].
af70b9c1d04c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4721
diff changeset
  1631
"/        ^ 0
af70b9c1d04c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4721
diff changeset
  1632
        ^ nil
af70b9c1d04c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4721
diff changeset
  1633
    ].
4609
8b3eb80d04d0 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4595
diff changeset
  1634
    ^self xOfCol:cursorCol inVisibleLine:cursorVisibleLine.
8b3eb80d04d0 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4595
diff changeset
  1635
8b3eb80d04d0 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4595
diff changeset
  1636
    "Created: / 27-05-2005 / 07:43:41 / janfrog"
8b3eb80d04d0 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4595
diff changeset
  1637
! !
4590
e28172cd6041 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4589
diff changeset
  1638
474
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  1639
!EditTextView methodsFor:'accessing-look'!
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  1640
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  1641
cursorForegroundColor:color1 backgroundColor:color2
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  1642
    "set both cursor foreground and cursor background colors"
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  1643
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  1644
    |wasOn|
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  1645
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  1646
    wasOn := self hideCursor.
5643
921578f80870 device access
Claus Gittinger <cg@exept.de>
parents: 5593
diff changeset
  1647
    cursorFgColor := color1 onDevice:device.
921578f80870 device access
Claus Gittinger <cg@exept.de>
parents: 5593
diff changeset
  1648
    cursorBgColor := color2 onDevice:device.
474
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  1649
    wasOn ifTrue:[self showCursor]
1333
56af09878b96 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1325
diff changeset
  1650
!
56af09878b96 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1325
diff changeset
  1651
1899
c98fc612bab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
  1652
cursorType
c98fc612bab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
  1653
    "return the style of the text cursor.
4721
59fc420ce5b0 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4715
diff changeset
  1654
     Currently, supported are: #none
59fc420ce5b0 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4715
diff changeset
  1655
                               #block, #frame, #ibeam, #caret, #solidCaret
59fc420ce5b0 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4715
diff changeset
  1656
                               #bigCaret and #bigSolidCaret"
1899
c98fc612bab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
  1657
c98fc612bab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
  1658
    ^ cursorType
c98fc612bab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
  1659
c98fc612bab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
  1660
    "Modified: / 5.5.1999 / 14:52:33 / cg"
c98fc612bab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
  1661
!
c98fc612bab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
  1662
1333
56af09878b96 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1325
diff changeset
  1663
cursorType:aCursorTypeSymbol
56af09878b96 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1325
diff changeset
  1664
    "set the style of the text cursor.
4721
59fc420ce5b0 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4715
diff changeset
  1665
     Currently, supported are: #none
59fc420ce5b0 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4715
diff changeset
  1666
                               #block, #frame, #ibeam, #caret, #solidCaret
59fc420ce5b0 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4715
diff changeset
  1667
                               #bigCaret and #bigSolidCaret"
1333
56af09878b96 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1325
diff changeset
  1668
1334
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  1669
    cursorType := aCursorTypeSymbol.
1333
56af09878b96 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1325
diff changeset
  1670
56af09878b96 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1325
diff changeset
  1671
    "Created: 21.9.1997 / 13:42:23 / cg"
56af09878b96 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1325
diff changeset
  1672
    "Modified: 21.9.1997 / 13:43:35 / cg"
1334
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  1673
!
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  1674
1899
c98fc612bab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
  1675
cursorTypeNoFocus
c98fc612bab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
  1676
    "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
  1677
     If left unspecified, this is the same as the regular cursorType."
c98fc612bab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
  1678
c98fc612bab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
  1679
    ^ cursorTypeNoFocus
c98fc612bab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
  1680
c98fc612bab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
  1681
    "Created: / 5.5.1999 / 14:52:46 / cg"
c98fc612bab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
  1682
!
c98fc612bab0 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1878
diff changeset
  1683
1334
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  1684
cursorTypeNoFocus:aCursorTypeSymbol
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  1685
    "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
  1686
     If left unspecified, this is the same as the regular cursorType."
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  1687
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  1688
    cursorTypeNoFocus := aCursorTypeSymbol
474
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  1689
! !
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  1690
4048
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
  1691
!EditTextView methodsFor:'accessing-replace'!
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
  1692
4746
39a5681e71ca class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4742
diff changeset
  1693
lastReplacementInfo
39a5681e71ca class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4742
diff changeset
  1694
    ^ lastReplacementInfo
39a5681e71ca class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4742
diff changeset
  1695
!
39a5681e71ca class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4742
diff changeset
  1696
4048
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
  1697
lastStringToReplace: aString
4818
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  1698
!
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  1699
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  1700
previousReplacements
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  1701
    "accessor for the code completion"
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  1702
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  1703
    ^ lastReplacementInfo previousReplacements
4048
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
  1704
! !
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
  1705
2119
2aa585fc62a3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2117
diff changeset
  1706
!EditTextView methodsFor:'change & update'!
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1707
125
claus
parents: 123
diff changeset
  1708
accept
claus
parents: 123
diff changeset
  1709
    "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
  1710
     changeMessage.
c055e993c2f7 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5909
diff changeset
  1711
     Historically, ST/X used a callBack (acceptAction);
c055e993c2f7 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5909
diff changeset
  1712
     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
  1713
     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
  1714
     If there is an acceptAction, it is called."
125
claus
parents: 123
diff changeset
  1715
1108
3d14bb6bceb7 added disableAccept
Claus Gittinger <cg@exept.de>
parents: 1082
diff changeset
  1716
    acceptEnabled == false ifTrue:[
5937
c055e993c2f7 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5909
diff changeset
  1717
        self beep.
c055e993c2f7 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5909
diff changeset
  1718
        ^ self
2035
6924861adf08 added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents: 2029
diff changeset
  1719
    ].
6924861adf08 added disableIfInvisible flag
Claus Gittinger <cg@exept.de>
parents: 2029
diff changeset
  1720
    (disableIfInvisible == true and:[self reallyRealized not]) ifTrue:[
5937
c055e993c2f7 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5909
diff changeset
  1721
        ^ self
1108
3d14bb6bceb7 added disableAccept
Claus Gittinger <cg@exept.de>
parents: 1082
diff changeset
  1722
    ].
3d14bb6bceb7 added disableAccept
Claus Gittinger <cg@exept.de>
parents: 1082
diff changeset
  1723
125
claus
parents: 123
diff changeset
  1724
    lockUpdates := true.
1013
391290c747b3 added an acceptChannel
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
  1725
391290c747b3 added an acceptChannel
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
  1726
    "/
391290c747b3 added an acceptChannel
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
  1727
    "/ ST-80 way of doing it
391290c747b3 added an acceptChannel
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
  1728
    "/
391290c747b3 added an acceptChannel
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
  1729
    model notNil ifTrue:[
5937
c055e993c2f7 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5909
diff changeset
  1730
        self sendChangeMessage:changeMsg with:self argForChangeMessage.
c055e993c2f7 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5909
diff changeset
  1731
        acceptChannel notNil ifTrue:[
c055e993c2f7 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5909
diff changeset
  1732
            acceptChannel value:true withoutNotifying:self.
5525
262b2d21993b #FEATURE
Claus Gittinger <cg@exept.de>
parents: 5489
diff changeset
  1733
        ].    
2999
40d3a383e8db *** empty log message ***
ca
parents: 2989
diff changeset
  1734
    ].
40d3a383e8db *** empty log message ***
ca
parents: 2989
diff changeset
  1735
757
2cc7e423f0ef only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents: 730
diff changeset
  1736
    "/
2cc7e423f0ef only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents: 730
diff changeset
  1737
    "/ ST/X way of doing things
5937
c055e993c2f7 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5909
diff changeset
  1738
    "/ as a historic leftover,
757
2cc7e423f0ef only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents: 730
diff changeset
  1739
    "/ 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
  1740
    "/ - not with the actual string
2cc7e423f0ef only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents: 730
diff changeset
  1741
    "/
2cc7e423f0ef only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents: 730
diff changeset
  1742
    acceptAction notNil ifTrue:[
5937
c055e993c2f7 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5909
diff changeset
  1743
        acceptAction value:self list
757
2cc7e423f0ef only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents: 730
diff changeset
  1744
    ].
2cc7e423f0ef only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents: 730
diff changeset
  1745
125
claus
parents: 123
diff changeset
  1746
    lockUpdates := false.
757
2cc7e423f0ef only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents: 730
diff changeset
  1747
1437
ab84b08a9f9c allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
  1748
    "Modified: / 30.1.1998 / 14:19:00 / cg"
131
claus
parents: 130
diff changeset
  1749
!
claus
parents: 130
diff changeset
  1750
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1751
argForChangeMessage
597
fb42c94a042e commentary
Claus Gittinger <cg@exept.de>
parents: 594
diff changeset
  1752
    "return the argument to be passed with the change notification.
fb42c94a042e commentary
Claus Gittinger <cg@exept.de>
parents: 594
diff changeset
  1753
     Defined as separate method for easier subclassability."
fb42c94a042e commentary
Claus Gittinger <cg@exept.de>
parents: 594
diff changeset
  1754
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1755
    ^ self contents
597
fb42c94a042e commentary
Claus Gittinger <cg@exept.de>
parents: 594
diff changeset
  1756
fb42c94a042e commentary
Claus Gittinger <cg@exept.de>
parents: 594
diff changeset
  1757
    "Modified: 29.4.1996 / 12:42:14 / cg"
121
claus
parents: 118
diff changeset
  1758
!
claus
parents: 118
diff changeset
  1759
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1760
getListFromModel
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1761
    "get my contents from the model.
597
fb42c94a042e commentary
Claus Gittinger <cg@exept.de>
parents: 594
diff changeset
  1762
     Redefined to ignore updates resulting from my own changes
fb42c94a042e commentary
Claus Gittinger <cg@exept.de>
parents: 594
diff changeset
  1763
     (i.e. if lockUpdates is true)."
121
claus
parents: 118
diff changeset
  1764
claus
parents: 118
diff changeset
  1765
    "
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1766
     ignore updates from my own change
121
claus
parents: 118
diff changeset
  1767
    "
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1768
    lockUpdates ifTrue:[
4823
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  1769
        lockUpdates := false.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  1770
        ^ self
121
claus
parents: 118
diff changeset
  1771
    ].
2196
f8c955dd6eb9 validate the cursorLine, when updating from a changed model
Claus Gittinger <cg@exept.de>
parents: 2186
diff changeset
  1772
    super getListFromModel.
3249
a4beb76b3f59 code formatting is now undoable
Claus Gittinger <cg@exept.de>
parents: 3241
diff changeset
  1773
    undoSupport resetHistories.
2196
f8c955dd6eb9 validate the cursorLine, when updating from a changed model
Claus Gittinger <cg@exept.de>
parents: 2186
diff changeset
  1774
f8c955dd6eb9 validate the cursorLine, when updating from a changed model
Claus Gittinger <cg@exept.de>
parents: 2186
diff changeset
  1775
    "/ validate the cursorLine
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  1776
    (cursorLine notNil
2310
861ab02b13b9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2225
diff changeset
  1777
     and:[ cursorLine > list size ]) ifTrue:[
4823
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  1778
        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
  1779
    ].
1437
ab84b08a9f9c allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
  1780
!
ab84b08a9f9c allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
  1781
ab84b08a9f9c allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
  1782
update:something with:aParameter from:changedObject
1438
bed1564b0640 fixed update for acceptChannel
Claus Gittinger <cg@exept.de>
parents: 1437
diff changeset
  1783
    changedObject == acceptChannel ifTrue:[
4823
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  1784
        acceptChannel value == true ifTrue:[
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  1785
            self accept.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  1786
        ].
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  1787
        ^ self.
1437
ab84b08a9f9c allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
  1788
    ].
ab84b08a9f9c allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
  1789
    super update:something with:aParameter from:changedObject
ab84b08a9f9c allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
  1790
ab84b08a9f9c allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
  1791
    "Created: / 30.1.1998 / 14:15:56 / cg"
1439
d1b3ca91ed8a fixed update for acceptChannel
Claus Gittinger <cg@exept.de>
parents: 1438
diff changeset
  1792
    "Modified: / 1.2.1998 / 13:15:55 / cg"
121
claus
parents: 118
diff changeset
  1793
! !
claus
parents: 118
diff changeset
  1794
6015
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1795
!EditTextView methodsFor:'commenting'!
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1796
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1797
commentFrom:line1 to:line2 commentStrings:commentStrings
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1798
    "helper function to comment out a block.
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1799
     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
  1800
     in the first col
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1801
     (if no eol comment is available, a bracketing comment is used)."
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1802
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1803
    |eolComment opening closing|
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1804
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1805
    eolComment := commentStrings at:1.
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1806
    eolComment isNil ifTrue:[
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1807
        opening := (commentStrings at:2) at:1.
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1808
        closing := (commentStrings at:2) at:2.
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1809
        (opening isNil or:[closing isNil]) ifTrue:[^ self].
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1810
    ].
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1811
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1812
    line1 to:line2 do:[:lineNr |
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1813
        |l|
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1814
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1815
        l := self listAt:lineNr.
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1816
        l isNil ifTrue:[l := ''].
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1817
        eolComment notNil ifTrue:[
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1818
            l := eolComment , l
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1819
        ] ifFalse:[
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1820
            l := opening , l , closing
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1821
        ].
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1822
        self replaceLine:lineNr with:l.
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1823
        widthOfWidestLine notNil ifTrue:[
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1824
            widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:l).
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1825
        ].
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1826
    ].
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1827
    self textChanged.
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1828
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1829
    "Created: / 09-11-1997 / 01:05:35 / cg"
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1830
    "Modified: / 09-10-2006 / 10:46:44 / cg"
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1831
!
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1832
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1833
commentSelection:commentStrings
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1834
    "convenient function to comment out a block.
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1835
     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
  1836
     in the first col."
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1837
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1838
    |e commentPair opening closing|
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1839
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1840
    (self checkModificationsAllowed) ifFalse:[ ^ self].
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1841
    commentStrings isNil ifTrue:[ self beep. ^ self].
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1842
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1843
    self
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1844
        undoableDo:[ 
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1845
            selectionStartLine isNil ifTrue:[
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1846
                self commentFrom:cursorLine to:cursorLine commentStrings:commentStrings
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1847
            ] ifFalse:[
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1848
                (selectionStartCol == 1 and:[selectionEndCol == 0]) ifTrue:[
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1849
                    self commentFrom:selectionStartLine to:selectionEndLine-1 commentStrings:commentStrings
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1850
                ] ifFalse:[
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1851
                    commentPair := commentStrings at:2 ifAbsent:nil.
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1852
                    commentPair isNil ifTrue:[
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1853
                        self beep.
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1854
                    ] ifFalse:[
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1855
                        opening := commentPair at:1.
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1856
                        closing := commentPair 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
                        e := selectionEndCol.
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1860
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1861
                        self insertString:closing atLine:selectionEndLine col:e+1.
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1862
                        self insertString:opening atLine:selectionStartLine col:selectionStartCol.
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1863
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1864
                        selectionStartLine == selectionEndLine ifTrue:[e := e + opening size].
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1865
                        self selectFromLine:selectionStartLine col:selectionStartCol
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1866
                                     toLine:selectionEndLine col:e+closing size.
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1867
                    ]
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1868
                ]
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
        ]    
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1871
        info:'Comment'.
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1872
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1873
    "Created: / 9.11.1997 / 01:05:40 / cg"
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1874
    "Modified: / 5.4.1998 / 16:52:23 / cg"
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1875
!
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
uncommentFrom:line1 to:line2 commentStrings:commentStrings
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1878
    "helper function to comment out a block.
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1879
     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
  1880
     in the first col.
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1881
     (if no eol comment is available, a bracketing comment is removed)."
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1882
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1883
    |eolComment opening closing rest|
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1884
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1885
    eolComment := commentStrings at:1.
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1886
    eolComment isNil ifTrue:[
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1887
        opening := (commentStrings at:2) at:1.
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1888
        closing := (commentStrings at:2) at:2.
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1889
        (opening isNil or:[closing isNil]) ifTrue:[^ self].
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1890
    ] ifFalse:[
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1891
        rest := eolComment size + 1.
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1892
    ].
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1893
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1894
    line1 to:line2 do:[:lineNr |
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1895
        |l|
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1896
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1897
        l := self listAt:lineNr.
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1898
        l notNil ifTrue:[
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1899
            eolComment notNil ifTrue:[
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1900
                (l startsWith:eolComment) ifTrue:[
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1901
                    l := l copyFrom:rest
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
                    (l withoutLeadingSeparators startsWith:eolComment) ifTrue:[
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1904
                        "/ only for single lines?
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1905
                        true "line1 = line2" ifTrue:[
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1906
                            |numSpaces|
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1907
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1908
                            numSpaces := l indexOfNonSeparator - 1.
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1909
                            l := l copyFrom:numSpaces+1+rest.
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1910
                            l := (String new:numSpaces),l
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
                    ].    
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1913
                ]
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1914
            ] ifFalse:[
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1915
                ((l startsWith:opening) and:[l endsWith:closing]) ifTrue:[
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1916
                    l := l copyFrom:opening size + 1.
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1917
                    l := l copyButLast:closing size.
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
            ].
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1920
            self replaceLine:lineNr with:l.
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1921
        ]
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1922
    ].
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
    widthOfWidestLine := nil. "/ i.e. unknown
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1925
    self textChanged.
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1926
!
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1927
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1928
uncommentSelection:commentStrings
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1929
    "convenient function to comment out a block.
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1930
     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
  1931
     in the first col."
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
    |e commentPair opening closing sz1 sz2 l1 l2 c1 c2|
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1934
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1935
    (self checkModificationsAllowed) ifFalse:[ ^ self].
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1936
    commentStrings isNil ifTrue:[ self beep. ^ self].
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1937
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1938
    self
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1939
        undoableDo:[
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1940
            selectionStartLine isNil ifTrue:[
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1941
                self uncommentFrom:cursorLine to:cursorLine commentStrings:commentStrings
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1942
            ] ifFalse:[
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1943
                (selectionStartCol == 1 and:[selectionEndCol == 0]) ifTrue:[
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1944
                    self uncommentFrom:selectionStartLine to:selectionEndLine-1 commentStrings:commentStrings
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1945
                ] ifFalse:[
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1946
                    commentPair := commentStrings at:2.
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1947
                    opening := commentPair at:1.
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1948
                    closing := commentPair at:2.
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1949
                    (opening isNil or:[closing isNil]) ifTrue:[^ self].
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1950
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1951
                    sz1 := opening size.
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1952
                    sz2 := closing size.
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1953
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1954
                    ((self
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1955
                        stringAtLine:selectionStartLine
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1956
                        from:selectionStartCol
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1957
                        to:selectionStartCol+sz1 - 1) = opening
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1958
                    and:[(self
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1959
                        stringAtLine:selectionEndLine
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1960
                        from:selectionEndCol - sz2 + 1
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1961
                        to:selectionEndCol) = closing ]) ifTrue:[
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1962
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1963
                        l2 := selectionEndLine.   c2 := selectionEndCol.
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1964
                        l1 := selectionStartLine. c1 := selectionStartCol.
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1965
                        self deleteCharsAtLine:l2 fromCol:c2-sz2+1 toCol:c2.
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1966
                        self deleteCharsAtLine:l1 fromCol:c1 toCol:c1+sz1-1.
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
                        e := c2 - sz2.
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1969
                        l1 == l2 ifTrue:[e := e - sz1].
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1970
                        self selectFromLine:l1 col:c1 toLine:l2 col:e.
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
                ]
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1973
            ].
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
        info:'Uncomment'.
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1976
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1977
    "Modified: / 7.1.1997 / 20:13:32 / cg"
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1978
    "Created: / 9.11.1997 / 01:05:46 / cg"
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1979
! !
9984d88f5e98 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5988
diff changeset
  1980
121
claus
parents: 118
diff changeset
  1981
!EditTextView methodsFor:'cursor handling'!
claus
parents: 118
diff changeset
  1982
4820
8640fa6f128f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4818
diff changeset
  1983
basicCursorReturn
8640fa6f128f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4818
diff changeset
  1984
    "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
  1985
8640fa6f128f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4818
diff changeset
  1986
    |wasOn|
8640fa6f128f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4818
diff changeset
  1987
8640fa6f128f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4818
diff changeset
  1988
    self checkForExistingLine:(cursorLine + 1).
8640fa6f128f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4818
diff changeset
  1989
    cursorVisibleLine notNil ifTrue:[
8640fa6f128f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4818
diff changeset
  1990
        nFullLinesShown notNil ifTrue:[
8640fa6f128f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4818
diff changeset
  1991
            (cursorVisibleLine >= nFullLinesShown) ifTrue:[self scrollDown]
8640fa6f128f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4818
diff changeset
  1992
        ]
8640fa6f128f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4818
diff changeset
  1993
    ].
8640fa6f128f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4818
diff changeset
  1994
8640fa6f128f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4818
diff changeset
  1995
    wasOn := self hideCursor.
8640fa6f128f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4818
diff changeset
  1996
    self setValidatedCursorLine:(cursorLine + 1) col:1.
8640fa6f128f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4818
diff changeset
  1997
    self makeCursorVisibleAndShowCursor:wasOn.
8640fa6f128f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4818
diff changeset
  1998
8640fa6f128f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4818
diff changeset
  1999
    "Modified: 22.5.1996 / 18:27:34 / cg"
8640fa6f128f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4818
diff changeset
  2000
!
8640fa6f128f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4818
diff changeset
  2001
2406
aeabb4ccf07c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2404
diff changeset
  2002
characterPositionOfCursor
aeabb4ccf07c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2404
diff changeset
  2003
    ^ self characterPositionOfLine:cursorLine col:cursorCol
aeabb4ccf07c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2404
diff changeset
  2004
!
aeabb4ccf07c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2404
diff changeset
  2005
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2006
cursorBacktab
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2007
    "move cursor to prev tabstop"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2008
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2009
    self cursorCol:(self prevTabBefore:cursorCol).
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2010
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2011
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2012
cursorCol:newCol
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2013
    "move cursor to some column in the current line"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2014
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2015
    |wasOn|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2016
2822
08ceab3fc237 search refactored;
Claus Gittinger <cg@exept.de>
parents: 2819
diff changeset
  2017
    (cursorCol == newCol) ifTrue:[^ self].
08ceab3fc237 search refactored;
Claus Gittinger <cg@exept.de>
parents: 2819
diff changeset
  2018
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2019
    wasOn := self hideCursor.
2422
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2020
    self setValidatedCursorCol:newCol.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2021
    self makeCursorVisibleAndShowCursor:wasOn.
672
065750d02339 added cursorCol-validation
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  2022
065750d02339 added cursorCol-validation
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  2023
    "Modified: 22.5.1996 / 14:25:53 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2024
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2025
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2026
cursorDown
632
5af2c22002e4 dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
  2027
    "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
  2028
     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
  2029
5af2c22002e4 dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
  2030
    |wasOn|
5af2c22002e4 dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
  2031
5af2c22002e4 dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
  2032
    self cursorDown:1.
5af2c22002e4 dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
  2033
2707
810c994db0b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2696
diff changeset
  2034
    "/ cursor beyond text ?
632
5af2c22002e4 dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
  2035
    cursorLine > list size ifTrue:[
4595
2f1e71ea50ac class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4592
diff changeset
  2036
        wasOn := self hideCursor.
2f1e71ea50ac class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4592
diff changeset
  2037
        self setValidatedCursorLine:(list size + 1) col:cursorCol.
2f1e71ea50ac class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4592
diff changeset
  2038
        self makeCursorVisibleAndShowCursor:wasOn.
2f1e71ea50ac class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4592
diff changeset
  2039
        self beep.
632
5af2c22002e4 dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
  2040
    ].
5af2c22002e4 dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
  2041
1561
db5f27354172 make cursor correctly visible if in partial last line.
Claus Gittinger <cg@exept.de>
parents: 1560
diff changeset
  2042
    "Modified: / 10.6.1998 / 17:00:23 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2043
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2044
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2045
cursorDown:n
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2046
    "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
  2047
5857
006deb952a1e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5856
diff changeset
  2048
    |inLastLine wasOn nv nL cursorColBefore|
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2049
4595
2f1e71ea50ac class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4592
diff changeset
  2050
    (nL := cursorLine) isNil ifTrue:[
5857
006deb952a1e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5856
diff changeset
  2051
        nL := firstLineShown
006deb952a1e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5856
diff changeset
  2052
    ].
006deb952a1e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5856
diff changeset
  2053
006deb952a1e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5856
diff changeset
  2054
    inLastLine := (nL == list size).
5890
5dc30fda9ebf #OTHER by mawalch
mawalch
parents: 5887
diff changeset
  2055
5857
006deb952a1e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5856
diff changeset
  2056
    inLastLine ifTrue:[
5858
f281506fb025 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5857
diff changeset
  2057
        |generateTextAfterEndHook|
5857
006deb952a1e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5856
diff changeset
  2058
006deb952a1e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5856
diff changeset
  2059
        cursorColBefore := cursorCol.
5858
f281506fb025 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5857
diff changeset
  2060
        (generateTextAfterEndHook := self getAttribute:#generateTextAfterEndHook) notNil ifTrue:[
5860
acc60507b977 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5859
diff changeset
  2061
            wasOn := self hideCursor.
acc60507b977 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5859
diff changeset
  2062
            nL := generateTextAfterEndHook value:(nL + n).
acc60507b977 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5859
diff changeset
  2063
            self setValidatedCursorLine:nL col:cursorColBefore.
acc60507b977 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5859
diff changeset
  2064
            self makeCursorVisibleAndShowCursor:wasOn.
acc60507b977 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5859
diff changeset
  2065
            ^ self.
5890
5dc30fda9ebf #OTHER by mawalch
mawalch
parents: 5887
diff changeset
  2066
        ].
4595
2f1e71ea50ac class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4592
diff changeset
  2067
    ].
2f1e71ea50ac class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4592
diff changeset
  2068
2f1e71ea50ac class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4592
diff changeset
  2069
    self st80EditMode ifTrue:[
5857
006deb952a1e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5856
diff changeset
  2070
        nL == list size ifTrue:[
006deb952a1e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5856
diff changeset
  2071
            wasOn := self hideCursor.
006deb952a1e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5856
diff changeset
  2072
            self setValidatedCursorLine:nL col:(self listAt:nL) size + 1.
006deb952a1e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5856
diff changeset
  2073
            self makeCursorVisibleAndShowCursor:wasOn.
006deb952a1e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5856
diff changeset
  2074
            self beep.
006deb952a1e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5856
diff changeset
  2075
            ^ self.
006deb952a1e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5856
diff changeset
  2076
        ]
4595
2f1e71ea50ac class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4592
diff changeset
  2077
    ].
2f1e71ea50ac class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4592
diff changeset
  2078
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2079
    cursorVisibleLine notNil ifTrue:[
5857
006deb952a1e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5856
diff changeset
  2080
        wasOn := self hideCursor.
006deb952a1e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5856
diff changeset
  2081
        nv := cursorVisibleLine + n - 1.
006deb952a1e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5856
diff changeset
  2082
        (nv >= nFullLinesShown) ifTrue:[
006deb952a1e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5856
diff changeset
  2083
            self scrollDown:(nv - nFullLinesShown + 1)
006deb952a1e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5856
diff changeset
  2084
        ].
006deb952a1e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5856
diff changeset
  2085
        self setValidatedCursorLine:(cursorLine + n) col:(cursorColBefore ? cursorCol).
006deb952a1e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5856
diff changeset
  2086
        self makeCursorVisibleAndShowCursor:wasOn.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2087
    ] ifFalse:[
5857
006deb952a1e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5856
diff changeset
  2088
        self setValidatedCursorLine:(nL + n) col:(cursorColBefore ? cursorCol).
006deb952a1e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5856
diff changeset
  2089
        self makeCursorVisible.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2090
    ].
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2091
1561
db5f27354172 make cursor correctly visible if in partial last line.
Claus Gittinger <cg@exept.de>
parents: 1560
diff changeset
  2092
    "Modified: / 10.6.1998 / 16:59:17 / cg"
259
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
121
claus
parents: 118
diff changeset
  2095
cursorHome
597
fb42c94a042e commentary
Claus Gittinger <cg@exept.de>
parents: 594
diff changeset
  2096
    "scroll to top AND move cursor to first line of text."
121
claus
parents: 118
diff changeset
  2097
674
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  2098
    self cursorLine:1 col:1
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  2099
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  2100
"/    |wasOn|
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  2101
"/
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  2102
"/    wasOn := self hideCursor.
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  2103
"/    self scrollToTop.
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  2104
"/    cursorLine := cursorVisibleLine := 1.
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  2105
"/    cursorCol := self validateCursorCol:1 inLine:cursorLine.
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  2106
"/    self makeCursorVisibleAndShowCursor:wasOn.
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  2107
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  2108
    "Modified: 22.5.1996 / 18:26:42 / cg"
121
claus
parents: 118
diff changeset
  2109
!
claus
parents: 118
diff changeset
  2110
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2111
cursorLeft
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2112
    "move cursor to left"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2113
1300
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  2114
    (cursorCol ~~ 1) ifTrue:[
4823
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  2115
        self cursorCol:(cursorCol - 1)
1300
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  2116
    ] ifFalse:[
4823
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  2117
        cursorLine ~~ 1 ifTrue:[
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  2118
            self st80EditMode ifTrue:[
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  2119
                self cursorUp.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  2120
                self cursorToEndOfLine.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  2121
           ]
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  2122
        ]
1300
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  2123
    ]
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  2124
1426
de76570ba19e crsrLeft/crsrRight does not wrap to prev/next line in st80 mode
Claus Gittinger <cg@exept.de>
parents: 1419
diff changeset
  2125
    "Modified: / 23.1.1998 / 12:37:13 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2126
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2127
4126
Claus Gittinger <cg@exept.de>
parents: 4121
diff changeset
  2128
cursorLeft:n
Claus Gittinger <cg@exept.de>
parents: 4121
diff changeset
  2129
    "move cursor to left"
Claus Gittinger <cg@exept.de>
parents: 4121
diff changeset
  2130
Claus Gittinger <cg@exept.de>
parents: 4121
diff changeset
  2131
    n timesRepeat:[
Claus Gittinger <cg@exept.de>
parents: 4121
diff changeset
  2132
        self cursorLeft
Claus Gittinger <cg@exept.de>
parents: 4121
diff changeset
  2133
    ].
Claus Gittinger <cg@exept.de>
parents: 4121
diff changeset
  2134
!
Claus Gittinger <cg@exept.de>
parents: 4121
diff changeset
  2135
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2136
cursorLine:line col:col
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2137
    "this positions onto physical - not visible - line"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2138
5056
9984a425a389 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5050
diff changeset
  2139
    self cursorLine:line col:col makeVisible:true
9984a425a389 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5050
diff changeset
  2140
!
9984a425a389 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5050
diff changeset
  2141
9984a425a389 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5050
diff changeset
  2142
cursorLine:line col:col makeVisible:makeVisibleBoolean
9984a425a389 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5050
diff changeset
  2143
    "this positions onto physical - not visible - line"
9984a425a389 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5050
diff changeset
  2144
676
b65b82a1ffcb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
  2145
    |wasOn newCol|
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2146
2822
08ceab3fc237 search refactored;
Claus Gittinger <cg@exept.de>
parents: 2819
diff changeset
  2147
    ((line == cursorLine) and:[col == cursorCol]) ifTrue:[^ self].
08ceab3fc237 search refactored;
Claus Gittinger <cg@exept.de>
parents: 2819
diff changeset
  2148
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2149
    wasOn := self hideCursor.
2422
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2150
    self setValidatedCursorLine:line.
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2151
672
065750d02339 added cursorCol-validation
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  2152
    (col < 1) ifTrue:[
4823
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  2153
        newCol := 1
672
065750d02339 added cursorCol-validation
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  2154
    ] ifFalse:[
4823
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  2155
        newCol := col.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2156
    ].
2647
23dca8f032c3 changed st80Mode from classVar to userPreferences value
Claus Gittinger <cg@exept.de>
parents: 2627
diff changeset
  2157
    self st80EditMode ifTrue:[
4823
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  2158
        (cursorLine == list size
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  2159
        and:[cursorLine ~~ line]) ifTrue:[
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  2160
            newCol := (self listAt:(list size)) size + 1.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  2161
        ]
1419
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
  2162
    ].
2422
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2163
    self setValidatedCursorCol:newCol.
5056
9984a425a389 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5050
diff changeset
  2164
    makeVisibleBoolean ifTrue:[
9984a425a389 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5050
diff changeset
  2165
        self makeCursorVisibleAndShowCursor:wasOn.
9984a425a389 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5050
diff changeset
  2166
    ] ifFalse:[
9984a425a389 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5050
diff changeset
  2167
        wasOn ifTrue:[self showCursor]
9984a425a389 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5050
diff changeset
  2168
    ].
672
065750d02339 added cursorCol-validation
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  2169
1596
0bbdb4e9fc43 made st80Mode also an inst-flag;
Claus Gittinger <cg@exept.de>
parents: 1591
diff changeset
  2170
    "Modified: / 20.6.1998 / 18:19:06 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2171
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2172
1580
d30e562bea15 allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
  2173
cursorMovementAllowed
d30e562bea15 allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
  2174
    "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
  2175
     (via button-click, or cursor-key with selection).
d30e562bea15 allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
  2176
     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
  2177
     in special subclasses (such as a terminal view), where
d30e562bea15 allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
  2178
     this is not wanted"
d30e562bea15 allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
  2179
d30e562bea15 allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
  2180
    ^ true
d30e562bea15 allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
  2181
d30e562bea15 allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
  2182
    "Created: / 18.6.1998 / 14:11:16 / cg"
d30e562bea15 allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
  2183
!
d30e562bea15 allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
  2184
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2185
cursorReturn
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2186
    "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
  2187
4820
8640fa6f128f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4818
diff changeset
  2188
    self basicCursorReturn
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2189
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2190
5529
0b33c7ac879d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 5525
diff changeset
  2191
cursorReturn:withPossibleAutoIndent
0b33c7ac879d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 5525
diff changeset
  2192
    "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
  2193
0b33c7ac879d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 5525
diff changeset
  2194
    self basicCursorReturn
0b33c7ac879d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 5525
diff changeset
  2195
!
0b33c7ac879d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 5525
diff changeset
  2196
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2197
cursorRight
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2198
    "move cursor to right"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2199
1300
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  2200
    |l|
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  2201
3023
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  2202
    self st80EditMode ifTrue:[
4823
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  2203
        l := (self listAt:cursorLine).
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  2204
        cursorCol >= (l size + 1) ifTrue:[
5529
0b33c7ac879d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 5525
diff changeset
  2205
            cursorLine <= list size ifTrue:[
0b33c7ac879d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 5525
diff changeset
  2206
                self cursorReturn:false. "/ no autoindent
4823
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  2207
            ].
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  2208
            ^ self
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  2209
        ]
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2210
    ].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2211
    self cursorCol:(cursorCol + 1)
1300
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  2212
1596
0bbdb4e9fc43 made st80Mode also an inst-flag;
Claus Gittinger <cg@exept.de>
parents: 1591
diff changeset
  2213
    "Modified: / 20.6.1998 / 18:19:07 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2214
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2215
4126
Claus Gittinger <cg@exept.de>
parents: 4121
diff changeset
  2216
cursorRight:n
Claus Gittinger <cg@exept.de>
parents: 4121
diff changeset
  2217
    "move cursor to right"
Claus Gittinger <cg@exept.de>
parents: 4121
diff changeset
  2218
Claus Gittinger <cg@exept.de>
parents: 4121
diff changeset
  2219
    n timesRepeat:[
Claus Gittinger <cg@exept.de>
parents: 4121
diff changeset
  2220
        self cursorRight
Claus Gittinger <cg@exept.de>
parents: 4121
diff changeset
  2221
    ].
Claus Gittinger <cg@exept.de>
parents: 4121
diff changeset
  2222
!
Claus Gittinger <cg@exept.de>
parents: 4121
diff changeset
  2223
1833
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  2224
cursorShown:aBoolean
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  2225
    "change cursor visibility
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  2226
     return true if cursor was visible before."
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  2227
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  2228
    |oldState|
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  2229
4494
dfe81ebdd5d6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
  2230
    aBoolean == cursorShown ifTrue:[
dfe81ebdd5d6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
  2231
        ^ cursorShown
dfe81ebdd5d6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
  2232
    ].
1833
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  2233
    oldState := cursorShown.
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  2234
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  2235
    aBoolean ifTrue:[
4494
dfe81ebdd5d6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
  2236
        self drawCursor.
1833
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  2237
    ] ifFalse:[
4494
dfe81ebdd5d6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
  2238
        (cursorShown and:[shown]) ifTrue: [
dfe81ebdd5d6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
  2239
            self undrawCursor.
dfe81ebdd5d6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
  2240
        ].
1833
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  2241
    ].
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  2242
    cursorShown := aBoolean.
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  2243
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  2244
    ^ oldState
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  2245
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  2246
    "Modified: / 30.3.1999 / 15:32:43 / stefan"
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  2247
    "Created: / 30.3.1999 / 15:59:30 / stefan"
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  2248
!
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  2249
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2250
cursorTab
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2251
    "move cursor to next tabstop"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2252
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2253
    self cursorCol:(self nextTabAfter:cursorCol).
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2254
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2255
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2256
cursorToBeginOfLine
3020
68a2dfad4e5e CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents: 2999
diff changeset
  2257
    "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
  2258
68a2dfad4e5e CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents: 2999
diff changeset
  2259
    |textStart l|
68a2dfad4e5e CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents: 2999
diff changeset
  2260
68a2dfad4e5e CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents: 2999
diff changeset
  2261
    l := self listAt:cursorLine.
68a2dfad4e5e CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents: 2999
diff changeset
  2262
    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
  2263
    cursorCol > textStart ifTrue:[
4823
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  2264
        self cursorCol:textStart
3020
68a2dfad4e5e CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents: 2999
diff changeset
  2265
    ] ifFalse:[
4823
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  2266
        self cursorCol:1
3020
68a2dfad4e5e CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents: 2999
diff changeset
  2267
    ]
68a2dfad4e5e CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents: 2999
diff changeset
  2268
68a2dfad4e5e CTRL-a (move to begin of line)
Claus Gittinger <cg@exept.de>
parents: 2999
diff changeset
  2269
    "Created: / 8.8.2004 / 18:51:21 / janfrog"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2270
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2271
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2272
cursorToBottom
2129
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  2273
    "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
  2274
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2275
    |wasOn newTop|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2276
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2277
    wasOn := self hideCursor.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2278
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2279
    newTop := list size - nFullLinesShown.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2280
    (newTop < 1) ifTrue:[
4823
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  2281
        newTop := 1
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2282
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2283
    self scrollToLine:newTop.
2422
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2284
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2285
    self setValidatedCursorLine:(list size) col:1.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2286
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2287
    self makeCursorVisibleAndShowCursor:wasOn.
672
065750d02339 added cursorCol-validation
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  2288
674
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  2289
    "Modified: 22.5.1996 / 18:27:45 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2290
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2291
1415
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2292
cursorToCharacterPosition:pos
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2293
    "compute line/col from character position (1..)
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2294
     and move the cursor onto that char"
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2295
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2296
    |line col|
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2297
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2298
    line := self lineOfCharacterPosition:pos.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2299
    col := pos - (self characterPositionOfLine:line col:1) + 1.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2300
    self cursorLine:line col:col
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2301
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2302
    "Created: / 15.1.1998 / 21:55:33 / cg"
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2303
!
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2304
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2305
cursorToEnd
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2306
    "move cursor down below last line of text"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2307
2422
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2308
    |wasOn newTop lineNr line|
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2309
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2310
    lineNr := list size.
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2311
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2312
    cursorLine >= lineNr ifTrue:[
4823
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  2313
        line := self listAt:cursorLine.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  2314
        (line isEmptyOrNil) ifTrue:[
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  2315
            ^ self
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  2316
        ]
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2317
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2318
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2319
    wasOn := self hideCursor.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2320
2422
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2321
    lineNr := lineNr + 1.
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2322
    newTop :=  lineNr - nFullLinesShown.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2323
    (newTop < 1) ifTrue:[
4823
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  2324
        newTop := 1
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2325
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2326
    self scrollToLine:newTop.
2422
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2327
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2328
    self setValidatedCursorLine:lineNr col:1.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2329
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2330
    self makeCursorVisibleAndShowCursor:wasOn.
672
065750d02339 added cursorCol-validation
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  2331
674
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  2332
    "Modified: 22.5.1996 / 18:27:53 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2333
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2334
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2335
cursorToEndOfLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2336
    "move cursor to end of current line"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2337
1300
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  2338
    |line|
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  2339
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  2340
    line := (self listAt:cursorLine).
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  2341
    self cursorCol:(line size + 1)
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  2342
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  2343
    "Modified: 13.8.1997 / 15:34:02 / 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
2129
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  2346
cursorToEndOfText
4288
f68354357ecc changed: #cursorToEndOfText
Claus Gittinger <cg@exept.de>
parents: 4287
diff changeset
  2347
    "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
  2348
f68354357ecc changed: #cursorToEndOfText
Claus Gittinger <cg@exept.de>
parents: 4287
diff changeset
  2349
    |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
  2350
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  2351
    wasOn := self hideCursor.
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  2352
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  2353
    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
  2354
    (newTop < 1) ifTrue:[
4288
f68354357ecc changed: #cursorToEndOfText
Claus Gittinger <cg@exept.de>
parents: 4287
diff changeset
  2355
        newTop := 1
2129
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  2356
    ].
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  2357
    self scrollToLine:newTop.
2422
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2358
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2359
    self setValidatedCursorLine:list size.
4288
f68354357ecc changed: #cursorToEndOfText
Claus Gittinger <cg@exept.de>
parents: 4287
diff changeset
  2360
    lastLineLength := (self listAt:cursorLine) size.
f68354357ecc changed: #cursorToEndOfText
Claus Gittinger <cg@exept.de>
parents: 4287
diff changeset
  2361
    pos := (lastLineLength==0) ifTrue:[0] ifFalse:[lastLineLength+1].
f68354357ecc changed: #cursorToEndOfText
Claus Gittinger <cg@exept.de>
parents: 4287
diff changeset
  2362
    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
  2363
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  2364
    self makeCursorVisibleAndShowCursor:wasOn.
4288
f68354357ecc changed: #cursorToEndOfText
Claus Gittinger <cg@exept.de>
parents: 4287
diff changeset
  2365
4289
d74f746d4c0d comment/format in: #cursorToEndOfText
Claus Gittinger <cg@exept.de>
parents: 4288
diff changeset
  2366
    "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
  2367
!
989228af033d added control over how-to-move-the-cursor when updating text.
Claus Gittinger <cg@exept.de>
parents: 2121
diff changeset
  2368
3310
83368f9014a1 word check
Claus Gittinger <cg@exept.de>
parents: 3303
diff changeset
  2369
cursorToEndOfWord
83368f9014a1 word check
Claus Gittinger <cg@exept.de>
parents: 3303
diff changeset
  2370
    "move the cursor to the end of the word"
83368f9014a1 word check
Claus Gittinger <cg@exept.de>
parents: 3303
diff changeset
  2371
83368f9014a1 word check
Claus Gittinger <cg@exept.de>
parents: 3303
diff changeset
  2372
    (cursorLine > list size) ifTrue:[^ self].
83368f9014a1 word check
Claus Gittinger <cg@exept.de>
parents: 3303
diff changeset
  2373
83368f9014a1 word check
Claus Gittinger <cg@exept.de>
parents: 3303
diff changeset
  2374
    self wordAtLine:cursorLine col:cursorCol do:[
4823
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  2375
        :beginLine :beginCol :endLine :endCol :style |
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  2376
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  2377
        self cursorLine:endLine col:endCol+1
3310
83368f9014a1 word check
Claus Gittinger <cg@exept.de>
parents: 3303
diff changeset
  2378
    ]
83368f9014a1 word check
Claus Gittinger <cg@exept.de>
parents: 3303
diff changeset
  2379
83368f9014a1 word check
Claus Gittinger <cg@exept.de>
parents: 3303
diff changeset
  2380
    "Created: / 28-06-2006 / 19:16:30 / cg"
83368f9014a1 word check
Claus Gittinger <cg@exept.de>
parents: 3303
diff changeset
  2381
!
83368f9014a1 word check
Claus Gittinger <cg@exept.de>
parents: 3303
diff changeset
  2382
131
claus
parents: 130
diff changeset
  2383
cursorToFirstVisibleLine
claus
parents: 130
diff changeset
  2384
    "place cursor into the first visible line; do not scroll."
claus
parents: 130
diff changeset
  2385
claus
parents: 130
diff changeset
  2386
    self cursorLine:(self visibleLineToAbsoluteLine:1) col:1
claus
parents: 130
diff changeset
  2387
!
claus
parents: 130
diff changeset
  2388
claus
parents: 130
diff changeset
  2389
cursorToLastVisibleLine
claus
parents: 130
diff changeset
  2390
    "place cursor into the first visible line; do not scroll."
claus
parents: 130
diff changeset
  2391
claus
parents: 130
diff changeset
  2392
    self cursorLine:(self visibleLineToAbsoluteLine:nFullLinesShown) col:1
claus
parents: 130
diff changeset
  2393
!
claus
parents: 130
diff changeset
  2394
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2395
cursorToNextWord
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2396
    "move the cursor to the beginning of the next word"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2397
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2398
    |col line searching|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2399
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2400
    (cursorLine > list size) ifTrue:[^ self].
2422
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2401
3890
4c5c54cf856b +wrapLines
Claus Gittinger <cg@exept.de>
parents: 3886
diff changeset
  2402
    self 
4707
f6ac835a1cf6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4701
diff changeset
  2403
        wordAtLine:cursorLine col:cursorCol 
f6ac835a1cf6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4701
diff changeset
  2404
        do:[
3890
4c5c54cf856b +wrapLines
Claus Gittinger <cg@exept.de>
parents: 3886
diff changeset
  2405
            :beginLine :beginCol :endLine :endCol :style |
4c5c54cf856b +wrapLines
Claus Gittinger <cg@exept.de>
parents: 3886
diff changeset
  2406
4c5c54cf856b +wrapLines
Claus Gittinger <cg@exept.de>
parents: 3886
diff changeset
  2407
            line := endLine.
4c5c54cf856b +wrapLines
Claus Gittinger <cg@exept.de>
parents: 3886
diff changeset
  2408
            col := endCol + 1.
4c5c54cf856b +wrapLines
Claus Gittinger <cg@exept.de>
parents: 3886
diff changeset
  2409
            searching := true.
4707
f6ac835a1cf6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4701
diff changeset
  2410
            [searching and:[(self characterAtLine:line col:col) isSeparator]] whileTrue:[
3890
4c5c54cf856b +wrapLines
Claus Gittinger <cg@exept.de>
parents: 3886
diff changeset
  2411
                self wordAtLine:line col:col do:[
4c5c54cf856b +wrapLines
Claus Gittinger <cg@exept.de>
parents: 3886
diff changeset
  2412
                    :beginLine :beginCol :endLine :endCol :style |
4c5c54cf856b +wrapLines
Claus Gittinger <cg@exept.de>
parents: 3886
diff changeset
  2413
4c5c54cf856b +wrapLines
Claus Gittinger <cg@exept.de>
parents: 3886
diff changeset
  2414
                    (line > list size) ifTrue:[
4c5c54cf856b +wrapLines
Claus Gittinger <cg@exept.de>
parents: 3886
diff changeset
  2415
                        "break out"
4c5c54cf856b +wrapLines
Claus Gittinger <cg@exept.de>
parents: 3886
diff changeset
  2416
                        searching := false
4c5c54cf856b +wrapLines
Claus Gittinger <cg@exept.de>
parents: 3886
diff changeset
  2417
                    ] ifFalse:[
4c5c54cf856b +wrapLines
Claus Gittinger <cg@exept.de>
parents: 3886
diff changeset
  2418
                        line := endLine.
4c5c54cf856b +wrapLines
Claus Gittinger <cg@exept.de>
parents: 3886
diff changeset
  2419
                        col := endCol + 1.
4c5c54cf856b +wrapLines
Claus Gittinger <cg@exept.de>
parents: 3886
diff changeset
  2420
                    ]
4c5c54cf856b +wrapLines
Claus Gittinger <cg@exept.de>
parents: 3886
diff changeset
  2421
                ]
4c5c54cf856b +wrapLines
Claus Gittinger <cg@exept.de>
parents: 3886
diff changeset
  2422
            ].
4c5c54cf856b +wrapLines
Claus Gittinger <cg@exept.de>
parents: 3886
diff changeset
  2423
            self cursorLine:line col:col
4707
f6ac835a1cf6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4701
diff changeset
  2424
    ]
121
claus
parents: 118
diff changeset
  2425
!
claus
parents: 118
diff changeset
  2426
499
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
  2427
cursorToPreviousWord
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
  2428
    "move the cursor to the beginning of this or the previous word"
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
  2429
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
  2430
    |col line searching l|
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
  2431
2422
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2432
    (cursorLine > list size) ifTrue:[^ self].      "/ this is rubbish
499
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
  2433
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
  2434
    self wordAtLine:cursorLine col:cursorCol do:[
4823
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  2435
        :beginLine :beginCol :endLine :endCol :style |
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  2436
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  2437
        line := beginLine.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  2438
        col := beginCol.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  2439
        style == #wordLeft ifTrue:[
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  2440
            col := col + 1
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  2441
        ].
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  2442
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  2443
        (cursorLine == line
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  2444
        and:[cursorCol == col]) ifTrue:[
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  2445
            searching := true.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  2446
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  2447
            col > 1 ifTrue:[
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  2448
                col := col - 1.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  2449
            ].
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  2450
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  2451
            [searching] whileTrue:[
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  2452
                (col == 1) ifTrue:[
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  2453
                    line == 1 ifTrue:[
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  2454
                        searching := false
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  2455
                    ] ifFalse:[
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  2456
                        line := line - 1.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  2457
                        l := list at:line.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  2458
                        col := l size + 1.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  2459
                    ]
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  2460
                ] ifFalse:[
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  2461
                    (self characterAtLine:line col:col) isSeparator ifFalse:[
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  2462
                        self wordAtLine:line col:col do:[
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  2463
                            :beginLine :beginCol :endLine :endCol :style |
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  2464
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  2465
                            line := beginLine.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  2466
                            col := beginCol.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  2467
                            style == #wordLeft ifTrue:[
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  2468
                                col := col + 1
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  2469
                            ].
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  2470
                            searching := false.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  2471
                        ]
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  2472
                    ] ifTrue:[
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  2473
                        col := col - 1
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  2474
                    ]
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  2475
                ]
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  2476
            ]
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  2477
        ].
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  2478
        self cursorLine:line col:col
499
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
  2479
    ]
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
  2480
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
  2481
    "Created: 8.3.1996 / 21:52:48 / cg"
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
  2482
    "Modified: 8.3.1996 / 22:12:45 / cg"
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
  2483
!
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
  2484
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2485
cursorToTop
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2486
    "move cursor to absolute home"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2487
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2488
    self cursorLine:1 col:1
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2489
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2490
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2491
cursorUp
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2492
    "move cursor up; scroll if at start of visible text"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2493
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2494
    self cursorUp:1
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2495
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2496
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2497
cursorUp:n
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2498
    "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
  2499
5856
a4d4442497d6 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5850
diff changeset
  2500
    |wasOn nv nl cursorColBefore|
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2501
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2502
    cursorLine isNil ifTrue:[
5850
988655795073 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5834
diff changeset
  2503
        self setCursorLine:(firstLineShown + nFullLinesShown - 1).
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2504
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2505
    nl := cursorLine - n.
5850
988655795073 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5834
diff changeset
  2506
    nl < 1 ifTrue:[
5858
f281506fb025 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5857
diff changeset
  2507
        |generateTextBeforeStartHook|
5890
5dc30fda9ebf #OTHER by mawalch
mawalch
parents: 5887
diff changeset
  2508
5856
a4d4442497d6 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5850
diff changeset
  2509
        cursorColBefore := cursorCol.
5858
f281506fb025 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5857
diff changeset
  2510
        (generateTextBeforeStartHook := self getAttribute:#generateTextBeforeStartHook) notNil ifTrue:[
f281506fb025 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5857
diff changeset
  2511
            nl := generateTextBeforeStartHook value:nl
5890
5dc30fda9ebf #OTHER by mawalch
mawalch
parents: 5887
diff changeset
  2512
        ].
5850
988655795073 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5834
diff changeset
  2513
        nl := nl max:1
988655795073 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5834
diff changeset
  2514
    ].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2515
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2516
    (nl ~~ cursorLine) ifTrue: [
5850
988655795073 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5834
diff changeset
  2517
        wasOn := self hideCursor.
988655795073 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5834
diff changeset
  2518
        cursorVisibleLine notNil ifTrue:[
988655795073 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5834
diff changeset
  2519
            nv := cursorVisibleLine - n.
988655795073 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5834
diff changeset
  2520
            nv < 1 ifTrue:[
988655795073 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5834
diff changeset
  2521
                self scrollUp:(nv negated + 1)
988655795073 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5834
diff changeset
  2522
            ].
988655795073 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5834
diff changeset
  2523
        ].
5856
a4d4442497d6 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5850
diff changeset
  2524
        self setValidatedCursorLine:nl col:(cursorColBefore ? cursorCol).
3725
410e861ca010 also makeCursorVisible after cursorUp:
Claus Gittinger <cg@exept.de>
parents: 3707
diff changeset
  2525
"/        wasOn ifTrue:[self showCursor].
5850
988655795073 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5834
diff changeset
  2526
        self makeCursorVisibleAndShowCursor:wasOn.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2527
    ]
672
065750d02339 added cursorCol-validation
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  2528
674
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  2529
    "Modified: 22.5.1996 / 18:28:11 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2530
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2531
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2532
cursorVisibleLine:visibleLineNr col:colNr
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2533
    "put cursor to visibleline/col"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2534
2422
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2535
    |wasOn newCol listLine|
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2536
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2537
    wasOn := self hideCursor.
2422
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2538
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2539
    listLine := self visibleLineToAbsoluteLine:visibleLineNr.
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2540
    self setValidatedCursorLine:listLine.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2541
    cursorVisibleLine := visibleLineNr.
2422
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2542
676
b65b82a1ffcb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
  2543
    newCol := colNr.
b65b82a1ffcb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
  2544
    (newCol < 1) ifTrue:[
4823
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  2545
        newCol := 1
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2546
    ].
2422
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2547
    self setValidatedCursorCol:newCol.
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2548
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2549
    self makeCursorVisibleAndShowCursor:wasOn.
672
065750d02339 added cursorCol-validation
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  2550
1597
5fdcfcedb91c fixed cursor positioning after replaceStringAtCursor.
Claus Gittinger <cg@exept.de>
parents: 1596
diff changeset
  2551
    "Modified: / 20.6.1998 / 18:40:28 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2552
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2553
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2554
cursorX:x y:y
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2555
    "put cursor to position next to x/y coordinate in view"
121
claus
parents: 118
diff changeset
  2556
claus
parents: 118
diff changeset
  2557
    |line col|
claus
parents: 118
diff changeset
  2558
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2559
    line := self visibleLineOfY:y.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2560
    col := self colOfX:x inVisibleLine:line.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2561
    self cursorVisibleLine:line col:col.
121
claus
parents: 118
diff changeset
  2562
!
claus
parents: 118
diff changeset
  2563
claus
parents: 118
diff changeset
  2564
drawCursor
claus
parents: 118
diff changeset
  2565
    "draw the cursor if shown and cursor is visible.
claus
parents: 118
diff changeset
  2566
     (but not, if there is a selection - to avoid confusion)"
claus
parents: 118
diff changeset
  2567
claus
parents: 118
diff changeset
  2568
    shown ifTrue:[
4823
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  2569
        cursorVisibleLine notNil ifTrue:[
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  2570
            self hasSelection ifFalse:[
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  2571
                self drawCursorCharacter
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  2572
            ]
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  2573
        ]
121
claus
parents: 118
diff changeset
  2574
    ]
claus
parents: 118
diff changeset
  2575
!
claus
parents: 118
diff changeset
  2576
claus
parents: 118
diff changeset
  2577
drawCursor:cursorType with:fgColor and:bgColor
claus
parents: 118
diff changeset
  2578
    "draw a cursor; the argument cursorType specifies what type
125
claus
parents: 123
diff changeset
  2579
     of cursor should be drawn.
4721
59fc420ce5b0 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4715
diff changeset
  2580
     Currently, supported are: #none, 
59fc420ce5b0 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4715
diff changeset
  2581
                               #block, #frame, #ibeam, #caret, #solidCaret
4580
d888cfb6a97c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4576
diff changeset
  2582
                               #bigCaret and #bigSolidCaret"
2085
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  2583
2570
590956e81610 Remove unused method vars.
Stefan Vogel <sv@exept.de>
parents: 2569
diff changeset
  2584
    |x y w char y2 x1 x2 oldPaint oldClip|
121
claus
parents: 118
diff changeset
  2585
claus
parents: 118
diff changeset
  2586
    self hasSelection ifTrue:[
4580
d888cfb6a97c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4576
diff changeset
  2587
        "
d888cfb6a97c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4576
diff changeset
  2588
         hide cursor, if there is a selection
d888cfb6a97c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4576
diff changeset
  2589
        "
d888cfb6a97c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4576
diff changeset
  2590
        ^ super redrawVisibleLine:cursorVisibleLine col:cursorCol.
121
claus
parents: 118
diff changeset
  2591
    ].
claus
parents: 118
diff changeset
  2592
1334
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  2593
    cursorType == #none ifTrue:[
4580
d888cfb6a97c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4576
diff changeset
  2594
        ^ self
1334
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  2595
    ].
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  2596
121
claus
parents: 118
diff changeset
  2597
    cursorType == #block ifTrue:[
4829
1073616fcbab class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4826
diff changeset
  2598
        super drawVisibleLine:cursorVisibleLine col:cursorCol with:fgColor and:bgColor.
4580
d888cfb6a97c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4576
diff changeset
  2599
        ^ self
121
claus
parents: 118
diff changeset
  2600
    ].
2429
eed79a96e43b eliminated accesses to leftOffset
Claus Gittinger <cg@exept.de>
parents: 2427
diff changeset
  2601
    x := (self xOfCol:cursorCol inVisibleLine:cursorVisibleLine) - viewOrigin x.
121
claus
parents: 118
diff changeset
  2602
    y := self yOfVisibleLine:cursorVisibleLine.
claus
parents: 118
diff changeset
  2603
1449
2a54bdfff203 eliminated direct refs to paint instvar
Claus Gittinger <cg@exept.de>
parents: 1446
diff changeset
  2604
    oldPaint := self paint. "/ do not clobber GC
121
claus
parents: 118
diff changeset
  2605
    cursorType == #frame ifTrue:[
4580
d888cfb6a97c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4576
diff changeset
  2606
        super redrawVisibleLine:cursorVisibleLine col:cursorCol.
d888cfb6a97c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4576
diff changeset
  2607
d888cfb6a97c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4576
diff changeset
  2608
        char := self characterUnderCursor asString.
4829
1073616fcbab class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4826
diff changeset
  2609
        self paint:bgColor.                       
4889
3ee5b37416a1 class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 4884
diff changeset
  2610
        self displayRectangleX:x y:y width:(gc font widthOf:char) height:fontHeight-2.
133
claus
parents: 132
diff changeset
  2611
    ] ifFalse:[
4580
d888cfb6a97c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4576
diff changeset
  2612
        self paint:bgColor.
d888cfb6a97c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4576
diff changeset
  2613
        cursorType == #ibeam ifTrue:[
d888cfb6a97c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4576
diff changeset
  2614
            x1 := x - 1.
5581
1533cccf60af #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 5578
diff changeset
  2615
            y2 := y + fontHeight - lineSpacing - 1.
4580
d888cfb6a97c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4576
diff changeset
  2616
            self displayLineFromX:x1 y:y toX:x1 y:y2.
d888cfb6a97c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4576
diff changeset
  2617
            self displayLineFromX:x y:y toX:x y:y2.
d888cfb6a97c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4576
diff changeset
  2618
            ^ self
d888cfb6a97c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4576
diff changeset
  2619
        ].
d888cfb6a97c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4576
diff changeset
  2620
d888cfb6a97c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4576
diff changeset
  2621
        cursorType == #Ibeam ifTrue:[
d888cfb6a97c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4576
diff changeset
  2622
            x1 := x - 1.
d888cfb6a97c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4576
diff changeset
  2623
            y := y + 1.
5581
1533cccf60af #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 5578
diff changeset
  2624
            y2 := y + fontHeight - lineSpacing - 1.
4580
d888cfb6a97c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4576
diff changeset
  2625
            self displayLineFromX:x1 y:y toX:x1 y:y2.
d888cfb6a97c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4576
diff changeset
  2626
            self displayLineFromX:x y:y toX:x y:y2.
d888cfb6a97c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4576
diff changeset
  2627
            self displayLineFromX:x1-2 y:y toX:x+2 y:y.
d888cfb6a97c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4576
diff changeset
  2628
            self displayLineFromX:x1-2 y:y2 toX:x+2 y:y2.
d888cfb6a97c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4576
diff changeset
  2629
            ^ self
d888cfb6a97c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4576
diff changeset
  2630
        ].
d888cfb6a97c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4576
diff changeset
  2631
d888cfb6a97c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4576
diff changeset
  2632
        y := y + fontHeight - 3.
d888cfb6a97c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4576
diff changeset
  2633
        ((cursorType == #bigCaret) or:[cursorType == #bigSolidCaret]) ifTrue:[
d888cfb6a97c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4576
diff changeset
  2634
            w := (fontWidth * 2 // 3) max:4.
d888cfb6a97c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4576
diff changeset
  2635
            y2 := y + w + (w//2).
d888cfb6a97c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4576
diff changeset
  2636
        ] ifFalse:[
d888cfb6a97c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4576
diff changeset
  2637
            w := (fontWidth // 2) max:4.
d888cfb6a97c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4576
diff changeset
  2638
            y2 := y + w.
d888cfb6a97c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4576
diff changeset
  2639
        ].
d888cfb6a97c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4576
diff changeset
  2640
        x1 := x - w.
d888cfb6a97c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4576
diff changeset
  2641
        x2 := x + w.
d888cfb6a97c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4576
diff changeset
  2642
d888cfb6a97c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4576
diff changeset
  2643
        oldClip := self clippingRectangleOrNil.
d888cfb6a97c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4576
diff changeset
  2644
        self clippingRectangle:(margin@margin extent:(width-margin) @ (height-margin)).
d888cfb6a97c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4576
diff changeset
  2645
d888cfb6a97c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4576
diff changeset
  2646
        cursorType == #caret ifTrue:[
d888cfb6a97c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4576
diff changeset
  2647
            self lineWidth:2.
d888cfb6a97c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4576
diff changeset
  2648
            self displayLineFromX:x1 y:y2 toX:x y:y.
d888cfb6a97c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4576
diff changeset
  2649
            self displayLineFromX:x y:y toX:x2 y:y2.
d888cfb6a97c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4576
diff changeset
  2650
        ] ifFalse:[
d888cfb6a97c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4576
diff changeset
  2651
            "anything else: solidCaret"
d888cfb6a97c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4576
diff changeset
  2652
d888cfb6a97c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4576
diff changeset
  2653
            self fillPolygon:(Array with:(x1 @ y2)
d888cfb6a97c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4576
diff changeset
  2654
                                    with:(x @ y)
d888cfb6a97c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4576
diff changeset
  2655
                                    with:(x2 @ y2))
d888cfb6a97c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4576
diff changeset
  2656
        ].
d888cfb6a97c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4576
diff changeset
  2657
d888cfb6a97c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4576
diff changeset
  2658
        self clippingRectangle:oldClip
121
claus
parents: 118
diff changeset
  2659
    ].
133
claus
parents: 132
diff changeset
  2660
    self paint:oldPaint.
662
4bcdf0cce3a7 dont let caret cursor become too small (with small fonts)
Claus Gittinger <cg@exept.de>
parents: 655
diff changeset
  2661
2088
b2beb67b1a98 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2085
diff changeset
  2662
    "Modified: / 15.12.1999 / 22:24:17 / cg"
121
claus
parents: 118
diff changeset
  2663
!
claus
parents: 118
diff changeset
  2664
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2665
drawCursorCharacter
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2666
    "draw the cursor.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2667
     (i.e. the cursor if no selection)
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2668
     - helper for many cursor methods"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2669
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2670
    (hasKeyboardFocus
3296
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
  2671
     and:[self enabled
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
  2672
     and:[self isReadOnly not]]) ifTrue:[
4823
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  2673
        self drawFocusCursor
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2674
    ] ifFalse:[
4823
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  2675
        self drawNoFocusCursor
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2676
    ]
1817
1a9e22f755c8 show non-focus cursor when disabled or readOnly
Claus Gittinger <cg@exept.de>
parents: 1816
diff changeset
  2677
1a9e22f755c8 show non-focus cursor when disabled or readOnly
Claus Gittinger <cg@exept.de>
parents: 1816
diff changeset
  2678
    "Modified: / 23.3.1999 / 13:52:48 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2679
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2680
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2681
drawFocusCursor
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2682
    "draw the cursor when the focus is in the view."
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2683
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2684
    self hasSelection ifTrue:[
5260
d062a1aa6b99 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5255
diff changeset
  2685
        ^ super redrawVisibleLine:cursorVisibleLine col:(cursorCol max:1).
1334
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  2686
    ].
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  2687
    cursorType == #none ifTrue:[
4823
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  2688
        ^ self undrawCursor
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2689
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2690
    self drawCursor:cursorType with:cursorFgColor and:cursorBgColor.
1334
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  2691
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  2692
    "Modified: 22.9.1997 / 00:16:38 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2693
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2694
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2695
drawNoFocusCursor
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2696
    "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
  2697
1334
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  2698
    |cType|
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  2699
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2700
    self hasSelection ifTrue:[
4823
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  2701
        ^ super redrawVisibleLine:cursorVisibleLine col:cursorCol.
121
claus
parents: 118
diff changeset
  2702
    ].
1022
4362861fe15e allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents: 1018
diff changeset
  2703
1334
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  2704
    cType := cursorTypeNoFocus ? cursorType.
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  2705
    cType == #none ifTrue:[
4823
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  2706
        ^ self undrawCursor
1334
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  2707
    ].
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  2708
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  2709
    cType == #block ifTrue:[
4823
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  2710
        ^ self drawCursor:#frame with:cursorNoFocusFgColor and:cursorBgColor
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2711
    ].
1022
4362861fe15e allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents: 1018
diff changeset
  2712
1334
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  2713
    ^ self drawCursor:cType with:cursorNoFocusFgColor and:cursorNoFocusFgColor.
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  2714
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  2715
    "Modified: 22.9.1997 / 00:16:13 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2716
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2717
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2718
gotoLine:aLineNumber
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2719
    "position cursor onto line, aLineNumber.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2720
     Make certain that this line is visible"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2721
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2722
    self makeLineVisible:aLineNumber.
2951
eb820ef25acf unselect before gotoLine
Claus Gittinger <cg@exept.de>
parents: 2950
diff changeset
  2723
    self unselect.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2724
    self cursorLine:aLineNumber col:1
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2725
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2726
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2727
hideCursor
1833
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  2728
    "make cursor invisible if currently invisible"
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  2729
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  2730
    ^ self cursorShown:false
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  2731
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  2732
    "Modified: / 30.3.1999 / 16:02:28 / stefan"
121
claus
parents: 118
diff changeset
  2733
!
claus
parents: 118
diff changeset
  2734
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2735
makeCursorVisible
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2736
    "scroll text to make cursorline visible
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2737
     (i.e. to have cursorLine in visible area)"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2738
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2739
    |line col|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2740
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2741
    cursorLine notNil ifTrue:[
4823
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  2742
        line := cursorLine.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  2743
        col := cursorCol.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  2744
        "
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  2745
         if there is a selection, its better to
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  2746
         have its start being visible, instead of the end
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  2747
        "
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  2748
        (selectionStartLine notNil
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  2749
        and:[selectionEndLine notNil]) ifTrue:[
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  2750
            expandingTop ~~ false ifTrue:[
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  2751
                line := selectionStartLine.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  2752
                col := selectionStartCol.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  2753
            ] ifFalse:[
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  2754
                line := selectionEndLine.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  2755
                col := selectionEndCol
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  2756
            ]
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  2757
        ].
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  2758
        self makeLineVisible:line.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  2759
        self makeColVisible:col inLine:line
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2760
    ]
479
fae6d1251888 fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 477
diff changeset
  2761
fae6d1251888 fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 477
diff changeset
  2762
    "Modified: 6.3.1996 / 13:46:46 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2763
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2764
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2765
makeCursorVisibleAndShowCursor:flag
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2766
    "scroll to make cursorLine visible;
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2767
     if flag is true, draw the cursor"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2768
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2769
    self makeCursorVisible.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2770
    flag ifTrue:[self showCursor]
121
claus
parents: 118
diff changeset
  2771
!
claus
parents: 118
diff changeset
  2772
2422
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2773
setCursorCol:colNr
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2774
    "strictly private: set the cursorCol"
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2775
2815
d71f43d7de3e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2796
diff changeset
  2776
    cursorCol := (colNr max:1).
2422
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2777
    cursorColHolder value:cursorCol.
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2778
!
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2779
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2780
setCursorLine:lineNr
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2781
    "strictly private: set the cursorLine"
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2782
3303
add21df4dcb1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3296
diff changeset
  2783
    "/ self assert:(lineNr notNil).
add21df4dcb1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3296
diff changeset
  2784
add21df4dcb1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3296
diff changeset
  2785
    cursorLine := (lineNr ? 1).
2422
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2786
    cursorLineHolder value:cursorLine.
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2787
    self updateCursorVisibleLine.
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2788
!
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2789
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2790
setCursorLine:lineNr col:colNr
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2791
    "strictly private: set the cursorLine, col and update the visibleLine"
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2792
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2793
    self setCursorLine:lineNr.
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2794
    self setCursorCol:colNr.
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2795
!
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2796
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2797
setValidatedCursorCol:colNr
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2798
    "strictly private: set the cursorCol"
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2799
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2800
    self setCursorCol:(self validateCursorCol:colNr inLine:cursorLine).
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2801
!
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2802
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2803
setValidatedCursorLine:lineNr
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2804
    "strictly private: set the cursorLine and update the visibleLine"
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2805
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2806
    self setCursorLine:(self validateCursorLine:lineNr).
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2807
!
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2808
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2809
setValidatedCursorLine:lineNr col:colNr
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2810
    "strictly private: set the cursorLine, col and update the visibleLine"
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2811
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2812
    self setValidatedCursorLine:lineNr.
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2813
    self setValidatedCursorCol:colNr.
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2814
!
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2815
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2816
showCursor
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2817
    "make cursor visible if currently invisible"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2818
1833
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  2819
    ^ self cursorShown:true
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  2820
542d79f7ed5c Move common channels to View.
Stefan Vogel <sv@exept.de>
parents: 1825
diff changeset
  2821
    "Modified: / 30.3.1999 / 16:02:34 / stefan"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2822
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2823
5761
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  2824
singleQuoteSelection
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  2825
    "place single quotes around the selected text"
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  2826
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  2827
    |line1 col1 line2 col2|
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  2828
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  2829
    line1 := self selectionStartLine.
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  2830
    col1 := self selectionStartCol.
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  2831
    line2 := self selectionEndLine.
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  2832
    col2 := self selectionEndCol.
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  2833
    (line1 notNil
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  2834
        and:[ col1 notNil
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  2835
        and:[ line2 notNil
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  2836
        and:[ col2 notNil ]]])
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  2837
    ifTrue:[
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  2838
        self insertString:Character quote asString atLine:line2 col:col2+1.
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  2839
        self insertString:Character quote asString atLine:line1 col:col1.
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  2840
        self selectFromLine:line1 col:col1 toLine:line2 col:col2+2.
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  2841
    ] ifFalse:[
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  2842
        self beep.
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  2843
    ]
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  2844
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  2845
    "Created: / 06-06-2016 / 11:03:36 / cg"
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  2846
!
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  2847
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2848
undrawCursor
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2849
    "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
  2850
2085
4498b1a50d72 fixed undrawCursor, when there is italic text
Claus Gittinger <cg@exept.de>
parents: 2072
diff changeset
  2851
    |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
  2852
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2853
    cursorVisibleLine notNil ifTrue:[
4494
dfe81ebdd5d6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
  2854
        prevCol := cursorCol - 1.
dfe81ebdd5d6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
  2855
dfe81ebdd5d6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
  2856
        "/ if there is any italic stuff in the cursor line,
dfe81ebdd5d6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
  2857
        "/ redraw it completely (because characters overlap).
dfe81ebdd5d6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
  2858
        cursorCol > 1 ifTrue:[
dfe81ebdd5d6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
  2859
            (line := self listAt:cursorLine) notNil ifTrue:[
dfe81ebdd5d6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
  2860
                line hasChangeOfEmphasis ifTrue:[
dfe81ebdd5d6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
  2861
                    line size >= (cursorCol-1) ifTrue:[
dfe81ebdd5d6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
  2862
                        e1 := Text extractEmphasis:#italic from:(line emphasisAt:cursorCol-1).
dfe81ebdd5d6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
  2863
                        line size >= (cursorCol) ifTrue:[
dfe81ebdd5d6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
  2864
                            e2 := Text extractEmphasis:#italic from:(line emphasisAt:cursorCol).
dfe81ebdd5d6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
  2865
                            line size >= (cursorCol+1) ifTrue:[
dfe81ebdd5d6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
  2866
                                e3 := Text extractEmphasis:#italic from:(line emphasisAt:cursorCol+1)
dfe81ebdd5d6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
  2867
                            ].
dfe81ebdd5d6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
  2868
                        ].
dfe81ebdd5d6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
  2869
                    ].
dfe81ebdd5d6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
  2870
                    (e1 notNil or:[e2 notNil or:[e3 notNil]]) ifTrue:[
dfe81ebdd5d6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
  2871
                        ^ super redrawVisibleLine:cursorVisibleLine
dfe81ebdd5d6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
  2872
                    ]
dfe81ebdd5d6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
  2873
                ]
dfe81ebdd5d6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
  2874
            ]
dfe81ebdd5d6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
  2875
        ].
dfe81ebdd5d6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
  2876
dfe81ebdd5d6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
  2877
        ((cursorType == #caret)
dfe81ebdd5d6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
  2878
         or:[cursorType == #solidCaret
dfe81ebdd5d6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
  2879
         or:[cursorType == #bigSolidCaret
dfe81ebdd5d6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
  2880
         or:[cursorType == #bigCaret
dfe81ebdd5d6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
  2881
         or:[cursorType == #Ibeam]]]]) ifTrue:[
dfe81ebdd5d6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
  2882
            "caret-cursor touches 4 characters"
dfe81ebdd5d6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
  2883
            ((cursorCol > 1) and:[fontIsFixedWidth]) ifTrue:[
dfe81ebdd5d6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
  2884
                super redrawVisibleLine:cursorVisibleLine-1 from:prevCol to:cursorCol.
dfe81ebdd5d6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
  2885
                super redrawVisibleLine:cursorVisibleLine from:prevCol to:cursorCol.
dfe81ebdd5d6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
  2886
                super redrawVisibleLine:cursorVisibleLine+1 from:prevCol to:cursorCol.
dfe81ebdd5d6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
  2887
            ] ifFalse:[
dfe81ebdd5d6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
  2888
                "care for left margin"
dfe81ebdd5d6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
  2889
                super redrawVisibleLine:cursorVisibleLine; redrawVisibleLine:cursorVisibleLine+1.
dfe81ebdd5d6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
  2890
            ].
dfe81ebdd5d6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
  2891
            ^ self
dfe81ebdd5d6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
  2892
        ].
dfe81ebdd5d6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
  2893
dfe81ebdd5d6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
  2894
        cursorType == #ibeam ifTrue:[
dfe81ebdd5d6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
  2895
            "ibeam-cursor touches 2 characters"
dfe81ebdd5d6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
  2896
            cursorCol > 1 ifTrue:[
dfe81ebdd5d6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
  2897
                super redrawVisibleLine:cursorVisibleLine from:prevCol to:cursorCol.
dfe81ebdd5d6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
  2898
            ] ifFalse:[
dfe81ebdd5d6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
  2899
                "care for left margin"
dfe81ebdd5d6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
  2900
                super redrawVisibleLine:cursorVisibleLine.
dfe81ebdd5d6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
  2901
            ].
dfe81ebdd5d6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
  2902
            ^ self
dfe81ebdd5d6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
  2903
        ].
dfe81ebdd5d6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
  2904
dfe81ebdd5d6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
  2905
        "block cursor is simple - just one character under cursor"
dfe81ebdd5d6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
  2906
dfe81ebdd5d6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
  2907
        "/ however, if italic characters are involved, we must care
dfe81ebdd5d6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
  2908
        "/ for the chars before/after the cursor.
dfe81ebdd5d6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
  2909
        "/ We redraw the part of the previous character which got
dfe81ebdd5d6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
  2910
        "/ detroyed by the block cursor.
dfe81ebdd5d6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
  2911
        "/ (must change the clip, to avoid destroying the prev-prev character)
dfe81ebdd5d6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
  2912
dfe81ebdd5d6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
  2913
        line := self visibleAt:cursorVisibleLine.
dfe81ebdd5d6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
  2914
        (line notNil and:[line isText]) ifTrue:[
dfe81ebdd5d6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
  2915
            cursorCol > 1 ifTrue:[
dfe81ebdd5d6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
  2916
                oldClip := self clippingRectangleOrNil.
dfe81ebdd5d6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
  2917
                x := (self xOfCol:cursorCol inVisibleLine:cursorVisibleLine) - viewOrigin x.
dfe81ebdd5d6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
  2918
                y := self yOfVisibleLine:cursorVisibleLine.
4889
3ee5b37416a1 class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 4884
diff changeset
  2919
                self clippingRectangle:(x@y extent:((gc font width * 2) @ fontHeight)).
4494
dfe81ebdd5d6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
  2920
                super redrawVisibleLine:cursorVisibleLine from:cursorCol-1 to:cursorCol.
dfe81ebdd5d6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
  2921
                self clippingRectangle:oldClip.
dfe81ebdd5d6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
  2922
                ^ self.
dfe81ebdd5d6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
  2923
            ].
dfe81ebdd5d6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
  2924
        ].
dfe81ebdd5d6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
  2925
        super redrawVisibleLine:cursorVisibleLine col:cursorCol
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2926
    ]
728
3ef81000ee8c new cursorTypes: #bigCaret and #bigSolidCaret
Claus Gittinger <cg@exept.de>
parents: 698
diff changeset
  2927
2088
b2beb67b1a98 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2085
diff changeset
  2928
    "Modified: / 15.12.1999 / 22:25:59 / cg"
121
claus
parents: 118
diff changeset
  2929
!
claus
parents: 118
diff changeset
  2930
2422
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2931
updateCursorVisibleLine
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2932
    "strictly private: set the visibleLine from the cursorLine.
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2933
     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
  2934
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2935
    cursorVisibleLine := self listLineToVisibleLine:cursorLine.
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2936
!
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  2937
672
065750d02339 added cursorCol-validation
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  2938
validateCursorCol:col inLine:line
674
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  2939
    "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
  2940
     Here, no limits are enforced (and col is returned),
5593
ad41e448d7a8 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 5581
diff changeset
  2941
     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
  2942
     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
  2943
1300
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  2944
    |l max|
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  2945
1419
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
  2946
    "/ in ST80 mode,
2707
810c994db0b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2696
diff changeset
  2947
    "/ the cursor may not be positioned beyond the
810c994db0b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2696
diff changeset
  2948
    "/ 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
  2949
3023
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  2950
    self st80EditMode ifTrue:[
4823
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  2951
        l := (self listAt:line).
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  2952
        max := l size + 1.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  2953
        col > max ifTrue:[
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  2954
            ^ max
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  2955
        ]
1300
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  2956
    ].
672
065750d02339 added cursorCol-validation
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  2957
    ^ col
065750d02339 added cursorCol-validation
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  2958
1419
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
  2959
    "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
  2960
    "Modified: / 20.6.1998 / 18:19:24 / cg"
674
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  2961
!
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  2962
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  2963
validateCursorLine:line
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  2964
    "check of line is a valid cursor line; return a fixed line-nr if not.
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  2965
     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
  2966
     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
  2967
     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
  2968
     skip reserved regions"
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  2969
1419
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
  2970
    "/
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
  2971
    "/ in st80Mode, the cursor may not be positioned
5367
7696ee76ebe8 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5361
diff changeset
  2972
    "/ beyond the last line 
7696ee76ebe8 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5361
diff changeset
  2973
    "/ (but it must be posible to place it on one line below the last one 
7696ee76ebe8 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5361
diff changeset
  2974
    "/ - otherwise deleteSelection and some others fail to delete from previousToLastLine)
1419
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
  2975
    "/
3023
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  2976
    self st80EditMode ifTrue:[
5367
7696ee76ebe8 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5361
diff changeset
  2977
        ^ (line min:(list size + 1)) max:1
1419
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
  2978
    ].
674
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  2979
    ^ line
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  2980
1419
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
  2981
    "Created: / 22.5.1996 / 18:22:23 / cg"
1596
0bbdb4e9fc43 made st80Mode also an inst-flag;
Claus Gittinger <cg@exept.de>
parents: 1591
diff changeset
  2982
    "Modified: / 20.6.1998 / 18:19:26 / cg"
672
065750d02339 added cursorCol-validation
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  2983
!
065750d02339 added cursorCol-validation
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  2984
121
claus
parents: 118
diff changeset
  2985
withCursorOffDo:aBlock
claus
parents: 118
diff changeset
  2986
    "evaluate aBlock with cursor off; turn it on afterwards."
claus
parents: 118
diff changeset
  2987
claus
parents: 118
diff changeset
  2988
    (shown not or:[cursorShown not]) ifTrue:[
4823
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  2989
        ^ aBlock value
121
claus
parents: 118
diff changeset
  2990
    ].
claus
parents: 118
diff changeset
  2991
    self hideCursor.
2522
d80496af7eaf #valueNowOrOnUnwindDo: -> #ensure:
Claus Gittinger <cg@exept.de>
parents: 2506
diff changeset
  2992
    aBlock ensure:[
4823
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  2993
        self showCursor
121
claus
parents: 118
diff changeset
  2994
    ]
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2995
! !
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2996
2589
62794ae04446 support drop
ca
parents: 2580
diff changeset
  2997
!EditTextView methodsFor:'drag & drop'!
62794ae04446 support drop
ca
parents: 2580
diff changeset
  2998
62794ae04446 support drop
ca
parents: 2580
diff changeset
  2999
allowDrop:aBoolean
3236
aeb1fe5a6ead drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3235
diff changeset
  3000
    "enable/disable drop support"
aeb1fe5a6ead drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3235
diff changeset
  3001
2589
62794ae04446 support drop
ca
parents: 2580
diff changeset
  3002
    aBoolean ifFalse:[
3907
e4be6bf71a98 Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents: 3890
diff changeset
  3003
        dropTarget := nil.
2589
62794ae04446 support drop
ca
parents: 2580
diff changeset
  3004
    ] ifTrue:[
3907
e4be6bf71a98 Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents: 3890
diff changeset
  3005
        dropTarget isNil ifTrue:[
e4be6bf71a98 Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents: 3890
diff changeset
  3006
            dropTarget := DropTarget 
e4be6bf71a98 Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents: 3890
diff changeset
  3007
                                receiver:self
e4be6bf71a98 Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents: 3890
diff changeset
  3008
                                argument:nil
e4be6bf71a98 Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents: 3890
diff changeset
  3009
                                dropSelector:#'drop:'
e4be6bf71a98 Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents: 3890
diff changeset
  3010
                                canDropSelector:#'canDrop:'
e4be6bf71a98 Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents: 3890
diff changeset
  3011
        ]
3236
aeb1fe5a6ead drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3235
diff changeset
  3012
    ].
aeb1fe5a6ead drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3235
diff changeset
  3013
!
aeb1fe5a6ead drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3235
diff changeset
  3014
3412
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  3015
canDrop:aDropContext
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  3016
    "public from d&d.
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  3017
     I accept textObjects and fileObjects only."
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  3018
4089
c6567fb50316 comment/format in: #canDrop:
Claus Gittinger <cg@exept.de>
parents: 4064
diff changeset
  3019
    "/ 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
  3020
    aDropContext sourceWidget == self ifTrue:[^ false].
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  3021
    ^ self canDropObjects:aDropContext dropObjects
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  3022
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  3023
    "Modified: / 13-10-2006 / 17:41:09 / cg"
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  3024
!
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  3025
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  3026
canDropObjects:aCollectionOfDropObjects
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  3027
    "public from d&d.
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  3028
     I accept textObjects and fileObjects only."
2589
62794ae04446 support drop
ca
parents: 2580
diff changeset
  3029
62794ae04446 support drop
ca
parents: 2580
diff changeset
  3030
    self checkModificationsAllowed ifFalse:[^ false].
62794ae04446 support drop
ca
parents: 2580
diff changeset
  3031
3412
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  3032
    aCollectionOfDropObjects isEmpty ifTrue:[ ^ false ].
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  3033
    ^ aCollectionOfDropObjects conform:[:obj| (obj isTextObject or:[obj isFileObject])]
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  3034
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  3035
    "Created: / 13-10-2006 / 15:56:57 / cg"
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  3036
    "Modified: / 13-10-2006 / 17:41:14 / cg"
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  3037
!
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  3038
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  3039
drop:aDropContext
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  3040
    "public from d&d.
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  3041
     drop objects (new API)"
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  3042
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  3043
    self dropObjects:(aDropContext dropObjects)
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  3044
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  3045
    "Modified: / 13-10-2006 / 17:41:19 / cg"
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  3046
!
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  3047
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  3048
dropFileObject:aDropObject
2589
62794ae04446 support drop
ca
parents: 2580
diff changeset
  3049
    "drop objects
3236
aeb1fe5a6ead drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3235
diff changeset
  3050
     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
  3051
4136
fcce27dfc253 changed: #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  3052
    |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
  3053
e4be6bf71a98 Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents: 3890
diff changeset
  3054
    pasteWhat := #name.
3412
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  3055
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  3056
    fn := aDropObject asFilename.
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  3057
    (fn exists and:[fn isRegularFile]) ifTrue:[
3907
e4be6bf71a98 Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents: 3890
diff changeset
  3058
        enforcedDropMode := UserPreferences current enforcedDropModeForFiles.
e4be6bf71a98 Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents: 3890
diff changeset
  3059
        (enforcedDropMode notNil 
e4be6bf71a98 Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents: 3890
diff changeset
  3060
        and:[enforcedDropMode ~~ #name or:[fn fileSize <= (1024*1024)]]) ifTrue:[
e4be6bf71a98 Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents: 3890
diff changeset
  3061
            pasteWhat := enforcedDropMode.
3886
b50c9304f1d1 better alien file drop
Claus Gittinger <cg@exept.de>
parents: 3880
diff changeset
  3062
        ] ifFalse:[
3907
e4be6bf71a98 Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents: 3890
diff changeset
  3063
            sensor := self sensor.
e4be6bf71a98 Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents: 3890
diff changeset
  3064
            (sensor shiftDown or:[sensor ctrlDown]) ifTrue:[
e4be6bf71a98 Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents: 3890
diff changeset
  3065
                pasteWhat := #name.
3886
b50c9304f1d1 better alien file drop
Claus Gittinger <cg@exept.de>
parents: 3880
diff changeset
  3066
            ] ifFalse:[
3907
e4be6bf71a98 Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents: 3890
diff changeset
  3067
                (sensor metaDown) ifTrue:[
e4be6bf71a98 Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents: 3890
diff changeset
  3068
                    pasteWhat := #contents.
e4be6bf71a98 Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents: 3890
diff changeset
  3069
                ] ifFalse:[
e4be6bf71a98 Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents: 3890
diff changeset
  3070
                    dontAskAgainHolder := false asValue.
e4be6bf71a98 Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents: 3890
diff changeset
  3071
                    answer := Dialog
e4be6bf71a98 Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents: 3890
diff changeset
  3072
                        confirmWithCancel:(resources
e4be6bf71a98 Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents: 3890
diff changeset
  3073
                                            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.'
e4be6bf71a98 Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents: 3890
diff changeset
  3074
                                            with:fn name allBold)
e4be6bf71a98 Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents: 3890
diff changeset
  3075
                        labels:#( 'Cancel' 'Name' 'Contents' )
e4be6bf71a98 Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents: 3890
diff changeset
  3076
                        values:#( nil #name #contents )
e4be6bf71a98 Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents: 3890
diff changeset
  3077
                        default:#contents
e4be6bf71a98 Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents: 3890
diff changeset
  3078
                        check:(resources string:'Do not ask again; instead, always paste the contents of small files.') on:dontAskAgainHolder
e4be6bf71a98 Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents: 3890
diff changeset
  3079
                        title:(resources string:'Drop What').
e4be6bf71a98 Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents: 3890
diff changeset
  3080
                    answer isNil ifTrue:[ ^ self ].
e4be6bf71a98 Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents: 3890
diff changeset
  3081
e4be6bf71a98 Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents: 3890
diff changeset
  3082
                    dontAskAgainHolder value ifTrue:[
e4be6bf71a98 Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents: 3890
diff changeset
  3083
                        UserPreferences current enforcedDropModeForFiles:#contents
e4be6bf71a98 Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents: 3890
diff changeset
  3084
                    ].
e4be6bf71a98 Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents: 3890
diff changeset
  3085
                    pasteWhat := answer.
e4be6bf71a98 Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents: 3890
diff changeset
  3086
                ]
3886
b50c9304f1d1 better alien file drop
Claus Gittinger <cg@exept.de>
parents: 3880
diff changeset
  3087
            ]
b50c9304f1d1 better alien file drop
Claus Gittinger <cg@exept.de>
parents: 3880
diff changeset
  3088
        ].
b50c9304f1d1 better alien file drop
Claus Gittinger <cg@exept.de>
parents: 3880
diff changeset
  3089
    ].
b50c9304f1d1 better alien file drop
Claus Gittinger <cg@exept.de>
parents: 3880
diff changeset
  3090
3907
e4be6bf71a98 Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents: 3890
diff changeset
  3091
    pasteWhat == #name ifTrue:[
3886
b50c9304f1d1 better alien file drop
Claus Gittinger <cg@exept.de>
parents: 3880
diff changeset
  3092
        text := fn pathName
b50c9304f1d1 better alien file drop
Claus Gittinger <cg@exept.de>
parents: 3880
diff changeset
  3093
    ] ifFalse:[
b50c9304f1d1 better alien file drop
Claus Gittinger <cg@exept.de>
parents: 3880
diff changeset
  3094
        self withWaitCursorDo:[
5063
103ce513648a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5060
diff changeset
  3095
            text := fn contentsAsString
4136
fcce27dfc253 changed: #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  3096
        ].
fcce27dfc253 changed: #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  3097
        (app := self application) notNil ifTrue:[
fcce27dfc253 changed: #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  3098
            app droppedFile:fn in:self
fcce27dfc253 changed: #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 4130
diff changeset
  3099
        ].
3886
b50c9304f1d1 better alien file drop
Claus Gittinger <cg@exept.de>
parents: 3880
diff changeset
  3100
    ].
b50c9304f1d1 better alien file drop
Claus Gittinger <cg@exept.de>
parents: 3880
diff changeset
  3101
3799
f6cbe8d860d5 code formatting
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3102
    self 
f6cbe8d860d5 code formatting
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3103
        undoablePaste:text 
f6cbe8d860d5 code formatting
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3104
        info:'Drop File'.
3412
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  3105
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  3106
    "Created: / 13-10-2006 / 17:38:31 / cg"
3495
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  3107
    "Modified: / 28-07-2007 / 13:27:09 / cg"
3412
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
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  3110
dropObject:aDropObject
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  3111
    "drop objects
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  3112
     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
  3113
3415
35ffbeec46d9 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3412
diff changeset
  3114
    |text|
35ffbeec46d9 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3412
diff changeset
  3115
3412
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  3116
    (aDropObject isFileObject) ifTrue:[
3799
f6cbe8d860d5 code formatting
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3117
        self dropFileObject:aDropObject
3412
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  3118
    ] ifFalse:[
3799
f6cbe8d860d5 code formatting
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3119
        aDropObject isTextObject ifTrue:[
f6cbe8d860d5 code formatting
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3120
            text := aDropObject theObject.
f6cbe8d860d5 code formatting
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3121
            text isStringCollection ifTrue:[
f6cbe8d860d5 code formatting
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3122
                text := text asStringWithoutFinalCR
f6cbe8d860d5 code formatting
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3123
            ].
f6cbe8d860d5 code formatting
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3124
        ] ifFalse:[
f6cbe8d860d5 code formatting
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3125
            text := aDropObject theObject asString
f6cbe8d860d5 code formatting
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3126
        ].
f6cbe8d860d5 code formatting
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3127
        self 
f6cbe8d860d5 code formatting
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3128
            undoablePaste:text 
f6cbe8d860d5 code formatting
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3129
            info:'Drop'.
3412
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  3130
    ].
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  3131
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  3132
    "Created: / 13-10-2006 / 17:37:05 / cg"
3495
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  3133
    "Modified: / 28-07-2007 / 13:26:53 / cg"
3412
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  3134
!
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  3135
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  3136
dropObjects:aCollectionOfDropObjects
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  3137
    "public from d&d.
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  3138
     drop objects (old API)"
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  3139
3868
664a888e9c6a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3855
diff changeset
  3140
    aCollectionOfDropObjects do:[:el |
664a888e9c6a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3855
diff changeset
  3141
        self dropObject:el
3412
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  3142
    ].
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  3143
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  3144
    "Created: / 13-10-2006 / 15:59:40 / cg"
e893eef88643 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  3145
    "Modified: / 13-10-2006 / 17:41:23 / cg"
2589
62794ae04446 support drop
ca
parents: 2580
diff changeset
  3146
! !
62794ae04446 support drop
ca
parents: 2580
diff changeset
  3147
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3148
!EditTextView methodsFor:'editing'!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3149
5761
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3150
applyConverterToSelection:converter
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3151
    "apply a converter to the selected text"
4286
83ef1d9faf6d added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents: 4285
diff changeset
  3152
83ef1d9faf6d added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents: 4285
diff changeset
  3153
    |line1 line2|
83ef1d9faf6d added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents: 4285
diff changeset
  3154
83ef1d9faf6d added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents: 4285
diff changeset
  3155
    line1 := self selectionStartLine.
83ef1d9faf6d added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents: 4285
diff changeset
  3156
    line2 := self selectionEndLine.
83ef1d9faf6d added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents: 4285
diff changeset
  3157
    line1 isNil ifTrue:[
83ef1d9faf6d added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents: 4285
diff changeset
  3158
        line1 := self perform:#cursorLine ifNotUnderstood:nil.
83ef1d9faf6d added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents: 4285
diff changeset
  3159
        line1 notNil ifTrue:[
83ef1d9faf6d added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents: 4285
diff changeset
  3160
            line2 := line1
83ef1d9faf6d added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents: 4285
diff changeset
  3161
        ]
83ef1d9faf6d added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents: 4285
diff changeset
  3162
    ].
83ef1d9faf6d added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents: 4285
diff changeset
  3163
    line1 notNil ifTrue:[
83ef1d9faf6d added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents: 4285
diff changeset
  3164
        line1 to:line2 do:[:lineNr |
5761
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3165
            |line col1 col2 newLine|
4286
83ef1d9faf6d added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents: 4285
diff changeset
  3166
83ef1d9faf6d added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents: 4285
diff changeset
  3167
            line := (self listAt:lineNr) copy.
83ef1d9faf6d added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents: 4285
diff changeset
  3168
            line size > 0 ifTrue:[
83ef1d9faf6d added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents: 4285
diff changeset
  3169
                lineNr == line1 ifTrue:[
83ef1d9faf6d added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents: 4285
diff changeset
  3170
                    col1 := selectionStartCol.
83ef1d9faf6d added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents: 4285
diff changeset
  3171
                ] ifFalse:[
83ef1d9faf6d added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents: 4285
diff changeset
  3172
                    col1 := 1.
83ef1d9faf6d added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents: 4285
diff changeset
  3173
                ].
83ef1d9faf6d added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents: 4285
diff changeset
  3174
                lineNr == line2 ifTrue:[
83ef1d9faf6d added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents: 4285
diff changeset
  3175
                    col2 := selectionEndCol.
83ef1d9faf6d added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents: 4285
diff changeset
  3176
                ] ifFalse:[
83ef1d9faf6d added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents: 4285
diff changeset
  3177
                    col2 := (self listAt:lineNr) size.
83ef1d9faf6d added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents: 4285
diff changeset
  3178
                ].
5761
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3179
                newLine := converter value:line value:lineNr value:col1 value:col2.
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3180
                self withoutRedrawAt:lineNr put:newLine.
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3181
                self invalidateLine:lineNr.
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3182
            ].
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3183
        ].
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3184
    ]
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3185
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3186
    "Created: / 06-06-2016 / 10:53:17 / cg"
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3187
!
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3188
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3189
convertSelectionToLowercase
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3190
    "to-lower selected text"
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3191
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3192
    self applyConverterToSelection:[:line :lnr :col1 :col2 |
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3193
        col1 to:col2 do:[:col |
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3194
            |ch|
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3195
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3196
            ch := line at:col.
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3197
            line at:col put:ch asLowercase.
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3198
        ].
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3199
        line.        
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3200
    ].
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3201
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3202
    "Created: / 06-06-2016 / 10:50:28 / cg"
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3203
!
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3204
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3205
convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3206
    "toLower/toUppercaseFirst/toUpper selected text"
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3207
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3208
    self applyConverterToSelection:[:line :lineNr :col1 :col2 |
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3209
        |isAllLower isLowerFirst isAllUpper isUpperFirst
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3210
         makeLowercase makeUppercase makeUppercaseFirst makeLowercaseFirst|
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3211
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3212
        isAllLower := isAllUpper := isUpperFirst := isLowerFirst := true.
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3213
        col1 to:col2 do:[:col |
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3214
            |ch|
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3215
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3216
            ch := line at:col.
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3217
            ch isUppercase ifTrue:[
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3218
                isAllLower := false.
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3219
                col == col1 ifTrue:[
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3220
                    isLowerFirst := false.
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3221
                ].
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3222
            ] ifFalse:[
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3223
                ch isLowercase ifTrue:[
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3224
                    isAllUpper := false.
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3225
                    col == col1 ifTrue:[
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3226
                        isUpperFirst := false.
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3227
                    ].
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3228
                ]
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3229
            ].
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3230
        ].
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3231
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3232
        makeLowercase := makeUppercase := makeUppercaseFirst := makeLowercaseFirst := false.
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3233
        isLowerFirst ifTrue:[
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3234
            makeUppercaseFirst := true.
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3235
        ] ifFalse:[
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3236
            "/ must remember where we come from - otherwise, we end up
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3237
            "/ in upperFirst - lowerFirst cycle.
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3238
            "/ think about a good place to store this state
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3239
            false "(isUpperFirst and:[isAllUpper not])" ifTrue:[
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3240
                makeLowercaseFirst := true.
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3241
             ] ifFalse:[
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3242
                isAllUpper ifTrue:[
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3243
                    makeLowercase := true.
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3244
                ] ifFalse:[
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3245
                    makeUppercase := true.
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3246
                ]
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3247
            ]
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3248
        ].
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3249
        makeUppercaseFirst ifTrue:[
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3250
            line at:col1 put:(line at:col1) asUppercase.
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3251
        ] ifFalse:[
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3252
            makeLowercaseFirst ifTrue:[
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3253
                line at:col1 put:(line at:col1) asLowercase.
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3254
            ] ifFalse:[
4286
83ef1d9faf6d added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents: 4285
diff changeset
  3255
                col1 to:col2 do:[:col |
83ef1d9faf6d added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents: 4285
diff changeset
  3256
                    |ch|
83ef1d9faf6d added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents: 4285
diff changeset
  3257
83ef1d9faf6d added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents: 4285
diff changeset
  3258
                    ch := line at:col.
5761
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3259
                    ch := makeLowercase
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3260
                            ifTrue:[ ch asLowercase ]
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3261
                            ifFalse:[
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3262
                                makeUppercase
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3263
                                    ifTrue:[ ch asUppercase ]
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3264
                                    ifFalse:[
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3265
                                        col == col1
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3266
                                            ifTrue:[ ch asUppercase ]
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3267
                                            ifFalse:[ ch asLowercase ]
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3268
                                    ]
4286
83ef1d9faf6d added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents: 4285
diff changeset
  3269
                            ].
5761
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3270
                    line at:col put:ch.
4286
83ef1d9faf6d added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents: 4285
diff changeset
  3271
                ].
83ef1d9faf6d added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents: 4285
diff changeset
  3272
            ].
83ef1d9faf6d added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents: 4285
diff changeset
  3273
        ].
5761
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3274
        line
4286
83ef1d9faf6d added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents: 4285
diff changeset
  3275
    ]
83ef1d9faf6d added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents: 4285
diff changeset
  3276
83ef1d9faf6d added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents: 4285
diff changeset
  3277
    "Created: / 14-07-2011 / 11:40:26 / cg"
5761
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3278
    "Modified: / 06-06-2016 / 10:57:15 / cg"
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3279
!
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3280
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3281
convertSelectionToUppercase
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3282
    "to-upper selected text"
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3283
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3284
    self applyConverterToSelection:[:line :lnr :col1 :col2 |
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3285
        col1 to:col2 do:[:col |
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3286
            |ch|
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3287
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3288
            ch := line at:col.
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3289
            line at:col put:ch asUppercase.
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3290
        ].
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3291
        line.        
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3292
    ].
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3293
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3294
    "Created: / 06-06-2016 / 11:09:04 / cg"
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3295
!
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3296
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3297
convertSelectionToUppercaseFirst
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3298
    "to-upperFirst selected text"
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3299
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3300
    self applyConverterToSelection:[:line :lnr :col1 :col2 |
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3301
        |state|
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3302
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3303
        state := #first.
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3304
        col1 to:col2 do:[:col |
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3305
            |ch|
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3306
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3307
            ch := line at:col.
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3308
            ch isSeparator ifFalse:[
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3309
                state == #first ifTrue:[
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3310
                    line at:col put:ch asUppercase.
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3311
                    state := #skipRest
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3312
                ]
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3313
            ] ifTrue:[
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3314
                state := #first
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3315
            ]
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3316
        ].
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3317
        line.        
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3318
    ].
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3319
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3320
    "Created: / 06-06-2016 / 10:50:52 / cg"
4286
83ef1d9faf6d added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents: 4285
diff changeset
  3321
!
83ef1d9faf6d added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents: 4285
diff changeset
  3322
313
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  3323
copyAndDeleteSelection
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  3324
    "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
  3325
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  3326
    selectionStartLine notNil ifTrue:[
4823
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  3327
        self setClipboardText:(self selection).
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  3328
        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
  3329
    ].
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  3330
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  3331
    "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
  3332
!
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  3333
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3334
deleteCharAtCursor
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3335
    "delete single character under cursor; does not merge lines"
121
claus
parents: 118
diff changeset
  3336
claus
parents: 118
diff changeset
  3337
    |wasOn|
claus
parents: 118
diff changeset
  3338
claus
parents: 118
diff changeset
  3339
    wasOn := self hideCursor.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3340
    self deleteCharAtLine:cursorLine col:cursorCol.
121
claus
parents: 118
diff changeset
  3341
    wasOn ifTrue:[self showCursor]
claus
parents: 118
diff changeset
  3342
!
claus
parents: 118
diff changeset
  3343
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3344
deleteCharAtLine:lineNr col:colNr
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3345
    "delete a single character at colNr in line lineNr"
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3346
3023
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  3347
    self st80EditMode ifTrue:[
4823
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  3348
        (self listAt:cursorLine) size + 1 = colNr ifTrue:[
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  3349
            | wasOn |
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  3350
            wasOn := self hideCursor.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  3351
            self
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  3352
                cursorReturn;
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  3353
                cursorCol:1;
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  3354
                deleteCharBeforeCursor.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  3355
            wasOn ifTrue:[ self showCursor].
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  3356
            ^ self.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  3357
        ].
3023
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  3358
    ].
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  3359
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3360
    self deleteCharsAtLine:lineNr fromCol:colNr toCol:colNr
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3361
!
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3362
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3363
deleteCharBeforeCursor
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3364
    "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
  3365
4592
60fc44d286f2 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4590
diff changeset
  3366
    |soCol wasOn lineNrAboveCursor ln originalLine prevTab|
121
claus
parents: 118
diff changeset
  3367
claus
parents: 118
diff changeset
  3368
    wasOn := self hideCursor.
4814
6f9c85f3fbfb class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4812
diff changeset
  3369
    (autoIndent and:[ (tabPositions includes:cursorCol)]) ifTrue:[
4592
60fc44d286f2 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4590
diff changeset
  3370
        prevTab := (self prevTabBefore:cursorCol) max:1.
4966
fdd9e824fd05 class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 4940
diff changeset
  3371
        ln := originalLine := (list at:cursorLine ifAbsent:'') ? ''.
4592
60fc44d286f2 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4590
diff changeset
  3372
        ln size < prevTab ifTrue:[
60fc44d286f2 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4590
diff changeset
  3373
            ln := ln , (String new:prevTab withAll:Character space).
60fc44d286f2 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4590
diff changeset
  3374
        ].
60fc44d286f2 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4590
diff changeset
  3375
        (ln copyTo:prevTab) isBlank ifTrue:[
60fc44d286f2 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4590
diff changeset
  3376
            (ln copyFrom:prevTab+1) isBlank ifTrue:[
60fc44d286f2 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4590
diff changeset
  3377
                cursorCol > prevTab ifTrue:[
60fc44d286f2 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4590
diff changeset
  3378
                    self st80EditMode ifTrue:[
60fc44d286f2 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4590
diff changeset
  3379
                        "/ ensure that there is no conflict here: st80EditMode will
60fc44d286f2 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4590
diff changeset
  3380
                        "/ not allow a cursor position beyond the end of line,
5742
0a7b90d7670a #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 5724
diff changeset
  3381
                        "/ so ensure that cursorLine:col: will force us to the beginning of the line
4592
60fc44d286f2 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4590
diff changeset
  3382
                        originalLine size < prevTab ifTrue:[
5742
0a7b90d7670a #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 5724
diff changeset
  3383
                            self checkForExistingLine:cursorLine.    
4771
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  3384
                            self basicListAt:cursorLine put:ln
4592
60fc44d286f2 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4590
diff changeset
  3385
                        ]
60fc44d286f2 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4590
diff changeset
  3386
                    ].
60fc44d286f2 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4590
diff changeset
  3387
                    self cursorLine:cursorLine col:prevTab.
60fc44d286f2 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4590
diff changeset
  3388
                    wasOn ifTrue:[ self showCursor ].
60fc44d286f2 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4590
diff changeset
  3389
                    ^  self
60fc44d286f2 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4590
diff changeset
  3390
                ].
60fc44d286f2 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4590
diff changeset
  3391
            ] ifFalse:[
60fc44d286f2 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4590
diff changeset
  3392
                self deleteFromLine:cursorLine col:prevTab toLine:cursorLine col:cursorCol-1.
60fc44d286f2 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4590
diff changeset
  3393
                self cursorLine:cursorLine col:prevTab.
60fc44d286f2 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4590
diff changeset
  3394
                wasOn ifTrue:[ self showCursor ].
60fc44d286f2 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4590
diff changeset
  3395
                ^  self.
60fc44d286f2 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4590
diff changeset
  3396
            ]
60fc44d286f2 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4590
diff changeset
  3397
        ].
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3398
    ].
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3399
2491
f3e207ae5156 auto indent fix
Claus Gittinger <cg@exept.de>
parents: 2461
diff changeset
  3400
"/        (autoIndent
f3e207ae5156 auto indent fix
Claus Gittinger <cg@exept.de>
parents: 2461
diff changeset
  3401
"/    and:[cursorCol  ~~ 1
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3402
"/    and:[cursorLine <= (list size)]])
2491
f3e207ae5156 auto indent fix
Claus Gittinger <cg@exept.de>
parents: 2461
diff changeset
  3403
"/     ifTrue:[
f3e207ae5156 auto indent fix
Claus Gittinger <cg@exept.de>
parents: 2461
diff changeset
  3404
"/        soCol := (self leftIndentForLine:cursorLine) + 1.
f3e207ae5156 auto indent fix
Claus Gittinger <cg@exept.de>
parents: 2461
diff changeset
  3405
"/
f3e207ae5156 auto indent fix
Claus Gittinger <cg@exept.de>
parents: 2461
diff changeset
  3406
"/        (cursorCol == soCol and:[soCol > 1]) ifTrue:[
f3e207ae5156 auto indent fix
Claus Gittinger <cg@exept.de>
parents: 2461
diff changeset
  3407
"/            ln := list at:cursorLine.
f3e207ae5156 auto indent fix
Claus Gittinger <cg@exept.de>
parents: 2461
diff changeset
  3408
"/            (ln notNil and:[(ln indexOfNonSeparatorStartingAt:1) < soCol]) ifTrue:[
f3e207ae5156 auto indent fix
Claus Gittinger <cg@exept.de>
parents: 2461
diff changeset
  3409
"/                soCol := 1
f3e207ae5156 auto indent fix
Claus Gittinger <cg@exept.de>
parents: 2461
diff changeset
  3410
"/            ]
f3e207ae5156 auto indent fix
Claus Gittinger <cg@exept.de>
parents: 2461
diff changeset
  3411
"/        ]
f3e207ae5156 auto indent fix
Claus Gittinger <cg@exept.de>
parents: 2461
diff changeset
  3412
"/    ] ifFalse:[
4592
60fc44d286f2 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4590
diff changeset
  3413
        soCol := 1.
2491
f3e207ae5156 auto indent fix
Claus Gittinger <cg@exept.de>
parents: 2461
diff changeset
  3414
"/    ].
f3e207ae5156 auto indent fix
Claus Gittinger <cg@exept.de>
parents: 2461
diff changeset
  3415
1419
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
  3416
    (cursorCol ~~ soCol and:[cursorCol ~~ 1]) ifTrue:[
4592
60fc44d286f2 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4590
diff changeset
  3417
        "
60fc44d286f2 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4590
diff changeset
  3418
         somewhere in the middle of a line
60fc44d286f2 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4590
diff changeset
  3419
        "
60fc44d286f2 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4590
diff changeset
  3420
        self cursorLeft.
60fc44d286f2 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4590
diff changeset
  3421
        self deleteCharAtLine:cursorLine col:cursorCol.
1419
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
  3422
    ] ifFalse:[
4592
60fc44d286f2 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4590
diff changeset
  3423
        "
60fc44d286f2 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4590
diff changeset
  3424
         at begin of line - merge with previous line;
60fc44d286f2 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4590
diff changeset
  3425
         except for the very first line.
60fc44d286f2 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4590
diff changeset
  3426
        "
60fc44d286f2 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4590
diff changeset
  3427
        (cursorLine == 1) ifFalse:[
60fc44d286f2 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4590
diff changeset
  3428
            lineNrAboveCursor := self validateCursorLine:(cursorLine - 1).
60fc44d286f2 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4590
diff changeset
  3429
            lineNrAboveCursor < cursorLine ifTrue:[
60fc44d286f2 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4590
diff changeset
  3430
                (lineNrAboveCursor > 0 and:[lineNrAboveCursor > list size]) ifTrue:[
60fc44d286f2 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4590
diff changeset
  3431
                    "/ we are beyond the end of the text.
60fc44d286f2 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4590
diff changeset
  3432
                    "/ move the cursor to the previous line.
60fc44d286f2 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4590
diff changeset
  3433
                    self cursorLine:lineNrAboveCursor col:1.
60fc44d286f2 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4590
diff changeset
  3434
                ] ifFalse:[
60fc44d286f2 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4590
diff changeset
  3435
                    self mergeLine:lineNrAboveCursor removeBlanks:false.
60fc44d286f2 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4590
diff changeset
  3436
                ]
60fc44d286f2 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4590
diff changeset
  3437
            ]
60fc44d286f2 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4590
diff changeset
  3438
        ]
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3439
    ].
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3440
    wasOn ifTrue:[ self showCursor ]
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3441
1419
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
  3442
    "Modified: / 16.1.1998 / 22:33:04 / cg"
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3443
!
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3444
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3445
deleteCharsAtLine:lineNr fromCol:colNr
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3446
    "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
  3447
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3448
    |line|
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3449
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3450
    (line := self listAt:lineNr) notNil ifTrue:[
4823
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  3451
        self deleteCharsAtLine:lineNr fromCol:colNr toCol:(line size)
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3452
    ]
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3453
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3454
!
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3455
4458
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  3456
deleteCharsAtLine:lineNr fromCol:startCol toCol:endCol
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  3457
    "delete characters from startCol to endCol in line lineNr"
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  3458
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  3459
    |deleted|
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  3460
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  3461
    deleted := self textFromLine:lineNr col:startCol toLine:lineNr col:endCol.
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  3462
    self basicDeleteCharsAtLine:lineNr fromCol:startCol toCol:endCol.
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  3463
    self addUndo:(PasteString line:lineNr col:startCol string:deleted info:'delete').
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  3464
!
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  3465
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3466
deleteCharsAtLine:lineNr toCol:colNr
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3467
    "delete characters from start up to colNr in line lineNr"
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
    self deleteCharsAtLine:lineNr fromCol:1 toCol:colNr
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3470
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3471
121
claus
parents: 118
diff changeset
  3472
!
claus
parents: 118
diff changeset
  3473
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3474
deleteCursorLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3475
    "delete the line where the cursor sits"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3476
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3477
    self deleteLine:cursorLine
121
claus
parents: 118
diff changeset
  3478
!
claus
parents: 118
diff changeset
  3479
2385
357e8a1cb2b2 added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents: 2373
diff changeset
  3480
deleteFromCharacterPosition:charPos1 to:charPos2
357e8a1cb2b2 added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents: 2373
diff changeset
  3481
    "delete a substring at a character position"
357e8a1cb2b2 added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents: 2373
diff changeset
  3482
357e8a1cb2b2 added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents: 2373
diff changeset
  3483
    |line1 col1 line2 col2|
357e8a1cb2b2 added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents: 2373
diff changeset
  3484
357e8a1cb2b2 added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents: 2373
diff changeset
  3485
    line1 := self lineOfCharacterPosition:charPos1.
357e8a1cb2b2 added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents: 2373
diff changeset
  3486
    col1 := charPos1 - (self characterPositionOfLine:line1 col:1) + 1.
2725
eccf283b2efb deleteFromCharacterPos - fixed
Claus Gittinger <cg@exept.de>
parents: 2724
diff changeset
  3487
    col1 == 0 ifTrue:[
4823
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  3488
        line1 := line1 - 1.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  3489
        col1 := (self listAt:line1) size + 1.
2725
eccf283b2efb deleteFromCharacterPos - fixed
Claus Gittinger <cg@exept.de>
parents: 2724
diff changeset
  3490
    ].
2385
357e8a1cb2b2 added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents: 2373
diff changeset
  3491
357e8a1cb2b2 added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents: 2373
diff changeset
  3492
    line2 := self lineOfCharacterPosition:charPos2.
357e8a1cb2b2 added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents: 2373
diff changeset
  3493
    col2 := charPos2 - (self characterPositionOfLine:line2 col:1) + 1.
357e8a1cb2b2 added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents: 2373
diff changeset
  3494
357e8a1cb2b2 added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents: 2373
diff changeset
  3495
    self deleteFromLine:line1 col:col1 toLine:line2 col:col2.
357e8a1cb2b2 added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents: 2373
diff changeset
  3496
!
357e8a1cb2b2 added #deleteFromCharacterPosition:to:
Claus Gittinger <cg@exept.de>
parents: 2373
diff changeset
  3497
2954
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3498
deleteFromLine:startLine col:startCol toLine:endLine col:endCol
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3499
    "delete all text from startLine/startCol to endLine/endCol -
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3500
     joining lines if nescessary"
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3501
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3502
    |line newLine lineSize nMore|
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3503
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3504
    self checkModificationsAllowed ifFalse:[ ^ self].
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3505
    list isNil ifTrue:[^ self].
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3506
    startLine > list size ifTrue:[ ^ self]. "/ deleted space below text
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3507
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3508
    (startLine == endLine) ifTrue:[
4225
a0a83ed7368c changed: #deleteFromLine:col:toLine:col:
az
parents: 4213
diff changeset
  3509
        "/ delete chars within a line
a0a83ed7368c changed: #deleteFromLine:col:toLine:col:
az
parents: 4213
diff changeset
  3510
        self deleteCharsAtLine:startLine fromCol:startCol toCol:endCol.
a0a83ed7368c changed: #deleteFromLine:col:toLine:col:
az
parents: 4213
diff changeset
  3511
        ^ self
2954
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3512
    ].
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3513
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3514
    ((startCol == 1) and:[endCol == 0]) ifTrue:[
4225
a0a83ed7368c changed: #deleteFromLine:col:toLine:col:
az
parents: 4213
diff changeset
  3515
        "/ delete full lines only
a0a83ed7368c changed: #deleteFromLine:col:toLine:col:
az
parents: 4213
diff changeset
  3516
        endLine > startLine ifTrue:[
a0a83ed7368c changed: #deleteFromLine:col:toLine:col:
az
parents: 4213
diff changeset
  3517
            self deleteFromLine:startLine toLine:(endLine - 1)
a0a83ed7368c changed: #deleteFromLine:col:toLine:col:
az
parents: 4213
diff changeset
  3518
        ].
a0a83ed7368c changed: #deleteFromLine:col:toLine:col:
az
parents: 4213
diff changeset
  3519
        ^ self
2954
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3520
    ].
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3521
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3522
    "/ delete right rest of 1st line
4786
70fd2d143e7c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4782
diff changeset
  3523
    self deleteCharsAtLine:startLine fromCol:(startCol max:1).
2954
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3524
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3525
    "/ delete the inner lines ...
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3526
    endLine > (startLine + 1) ifTrue:[
4225
a0a83ed7368c changed: #deleteFromLine:col:toLine:col:
az
parents: 4213
diff changeset
  3527
        self deleteFromLine:(startLine + 1) toLine:(endLine - 1)
2954
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3528
    ].
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3529
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3530
    (endCol ~~ 0) ifTrue:[
4225
a0a83ed7368c changed: #deleteFromLine:col:toLine:col:
az
parents: 4213
diff changeset
  3531
        "/ delete the left rest of the last line
a0a83ed7368c changed: #deleteFromLine:col:toLine:col:
az
parents: 4213
diff changeset
  3532
a0a83ed7368c changed: #deleteFromLine:col:toLine:col:
az
parents: 4213
diff changeset
  3533
        self deleteCharsAtLine:(startLine + 1) toCol:endCol.
a0a83ed7368c changed: #deleteFromLine:col:toLine:col:
az
parents: 4213
diff changeset
  3534
a0a83ed7368c changed: #deleteFromLine:col:toLine:col:
az
parents: 4213
diff changeset
  3535
        "/ must add blanks, if startCol lies beyond end of startLine
a0a83ed7368c changed: #deleteFromLine:col:toLine:col:
az
parents: 4213
diff changeset
  3536
        startLine <= list size ifTrue:[
a0a83ed7368c changed: #deleteFromLine:col:toLine:col:
az
parents: 4213
diff changeset
  3537
            line := list at:startLine.
a0a83ed7368c changed: #deleteFromLine:col:toLine:col:
az
parents: 4213
diff changeset
  3538
            lineSize := line size.
a0a83ed7368c changed: #deleteFromLine:col:toLine:col:
az
parents: 4213
diff changeset
  3539
            (startCol > lineSize) ifTrue:[
a0a83ed7368c changed: #deleteFromLine:col:toLine:col:
az
parents: 4213
diff changeset
  3540
                newLine := line.
a0a83ed7368c changed: #deleteFromLine:col:toLine:col:
az
parents: 4213
diff changeset
  3541
                line isNil ifTrue:[
a0a83ed7368c changed: #deleteFromLine:col:toLine:col:
az
parents: 4213
diff changeset
  3542
                    newLine := String new:(startCol - 1)
a0a83ed7368c changed: #deleteFromLine:col:toLine:col:
az
parents: 4213
diff changeset
  3543
                ] ifFalse:[
a0a83ed7368c changed: #deleteFromLine:col:toLine:col:
az
parents: 4213
diff changeset
  3544
                    nMore := startCol - 1 - lineSize.
a0a83ed7368c changed: #deleteFromLine:col:toLine:col:
az
parents: 4213
diff changeset
  3545
                    nMore > 0 ifTrue:[
a0a83ed7368c changed: #deleteFromLine:col:toLine:col:
az
parents: 4213
diff changeset
  3546
                        newLine := line , (line species new:nMore)
a0a83ed7368c changed: #deleteFromLine:col:toLine:col:
az
parents: 4213
diff changeset
  3547
                    ]
a0a83ed7368c changed: #deleteFromLine:col:toLine:col:
az
parents: 4213
diff changeset
  3548
                ].
a0a83ed7368c changed: #deleteFromLine:col:toLine:col:
az
parents: 4213
diff changeset
  3549
                newLine ~~ line ifTrue:[
4771
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  3550
                    self basicListAt:startLine put:newLine.
4225
a0a83ed7368c changed: #deleteFromLine:col:toLine:col:
az
parents: 4213
diff changeset
  3551
                ].
a0a83ed7368c changed: #deleteFromLine:col:toLine:col:
az
parents: 4213
diff changeset
  3552
                "/ TODO: remember old maxwidth of linerange,
a0a83ed7368c changed: #deleteFromLine:col:toLine:col:
az
parents: 4213
diff changeset
  3553
                "/ only clear widthOfWidestLine, if this max
a0a83ed7368c changed: #deleteFromLine:col:toLine:col:
az
parents: 4213
diff changeset
  3554
                "/ length was (one of) the longest.
a0a83ed7368c changed: #deleteFromLine:col:toLine:col:
az
parents: 4213
diff changeset
  3555
                "/ avoids slow delete with huge texts.
a0a83ed7368c changed: #deleteFromLine:col:toLine:col:
az
parents: 4213
diff changeset
  3556
                widthOfWidestLine := nil. "/ i.e. unknown
a0a83ed7368c changed: #deleteFromLine:col:toLine:col:
az
parents: 4213
diff changeset
  3557
                self textChanged.
a0a83ed7368c changed: #deleteFromLine:col:toLine:col:
az
parents: 4213
diff changeset
  3558
            ]
a0a83ed7368c changed: #deleteFromLine:col:toLine:col:
az
parents: 4213
diff changeset
  3559
        ]
2954
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3560
    ].
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3561
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3562
    "/ 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
  3563
    self mergeLine:startLine removeBlanks:false
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3564
4225
a0a83ed7368c changed: #deleteFromLine:col:toLine:col:
az
parents: 4213
diff changeset
  3565
    "Modified: / 10-11-1998 / 23:52:59 / cg"
a0a83ed7368c changed: #deleteFromLine:col:toLine:col:
az
parents: 4213
diff changeset
  3566
    "Modified: / 18-03-2011 / 18:25:01 / az"
2954
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3567
!
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  3568
4458
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  3569
deleteFromLine:startLineNr toLine:endLineNr
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  3570
    "delete some lines"
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  3571
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  3572
    |deleted|
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  3573
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  3574
    deleted := self textFromLine:startLineNr col:1 toLine:endLineNr+1 col:0.
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  3575
    self basicDeleteFromLine:startLineNr toLine:endLineNr.
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  3576
    self addUndo:(PasteString line:startLineNr col:1 string:deleted info:'delete').
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  3577
!
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  3578
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3579
deleteLine:lineNr
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3580
    "delete line"
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3581
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3582
    self deleteFromLine:lineNr toLine:lineNr
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3583
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3584
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3585
!
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3586
4458
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  3587
deleteLineWithoutRedraw:lineNr
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  3588
    "delete line - no redraw;
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  3589
     return true, if something was really deleted"
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  3590
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  3591
    |deleted ret|
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  3592
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  3593
    deleted := self textFromLine:lineNr col:1 toLine:lineNr+1 col:0.
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  3594
    ret := self basicDeleteLineWithoutRedraw:lineNr.
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  3595
    self addUndo:(PasteString line:lineNr col:1 string:deleted info:'delete').
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  3596
    ^ ret.
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  3597
!
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  3598
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3599
deleteLinesWithoutRedrawFrom:startLine to:endLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3600
    "delete lines - no redraw;
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3601
     return true, if something was really deleted"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3602
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3603
    |lastLine|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3604
4771
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  3605
    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
  3606
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3607
    (list isNil or:[startLine > list size]) ifTrue:[^ false].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3608
    (endLine > list size) ifTrue:[
4771
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  3609
        lastLine := list size
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3610
    ] ifFalse:[
4771
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  3611
        lastLine := endLine
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  3612
    ].
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  3613
    self basicListRemoveFromIndex:startLine toIndex:lastLine.
1717
83203096a851 dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  3614
    "/ TODO: remember old maxwidth of linerange,
83203096a851 dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  3615
    "/ only clear widthOfWidestLine, if this max
83203096a851 dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  3616
    "/ length was (one of) the longest.
83203096a851 dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  3617
    "/ avoids slow delete with huge texts.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3618
    widthOfWidestLine := nil. "/ i.e. unknown
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3619
    self textChanged.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3620
    ^ true
1717
83203096a851 dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  3621
83203096a851 dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  3622
    "Modified: / 10.11.1998 / 23:55:29 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3623
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3624
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3625
deleteSelection
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3626
    "delete the selection"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3627
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3628
    |wasOn startLine startCol endLine endCol|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3629
331
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
  3630
    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
  3631
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3632
    selectionStartLine notNil ifTrue:[
4823
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  3633
        wasOn := self hideCursor.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  3634
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  3635
        startLine := selectionStartLine.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  3636
        startCol := selectionStartCol.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  3637
        endLine := selectionEndLine.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  3638
        endCol := selectionEndCol.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  3639
        self unselectWithoutRedraw.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  3640
        self deleteFromLine:startLine col:startCol toLine:endLine col:endCol.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  3641
        self setCursorLine:startLine col:startCol.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  3642
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  3643
        self makeCursorVisibleAndShowCursor:wasOn
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3644
    ]
121
claus
parents: 118
diff changeset
  3645
!
claus
parents: 118
diff changeset
  3646
2157
ba22c3cc278b added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
  3647
deleteWordBeforeCursor
ba22c3cc278b added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
  3648
    "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
  3649
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  3650
    |wasOn beginCol beginLine endCol endLine|
2157
ba22c3cc278b added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
  3651
3799
f6cbe8d860d5 code formatting
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3652
    self checkModificationsAllowed ifFalse:[ ^ self].
5361
d39070e004c1 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5357
diff changeset
  3653
    cursorCol <= 1 ifTrue:[
d39070e004c1 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5357
diff changeset
  3654
        self deleteCharBeforeCursor.
d39070e004c1 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5357
diff changeset
  3655
        ^ self 
d39070e004c1 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5357
diff changeset
  3656
    ].
3799
f6cbe8d860d5 code formatting
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3657
2157
ba22c3cc278b added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
  3658
    wasOn := self hideCursor.
3799
f6cbe8d860d5 code formatting
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3659
    self 
f6cbe8d860d5 code formatting
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3660
        undoableDo:[
f6cbe8d860d5 code formatting
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3661
            endCol := cursorCol-1.
f6cbe8d860d5 code formatting
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3662
            endLine := cursorLine.
f6cbe8d860d5 code formatting
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3663
            self cursorToPreviousWord.
f6cbe8d860d5 code formatting
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3664
            beginCol := cursorCol.
f6cbe8d860d5 code formatting
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3665
            beginLine := cursorLine.
f6cbe8d860d5 code formatting
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3666
            self deleteFromLine:beginLine col:beginCol toLine:endLine col:endCol.
5361
d39070e004c1 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5357
diff changeset
  3667
            self cursorLine:cursorLine col:beginCol.
3799
f6cbe8d860d5 code formatting
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3668
        ] 
f6cbe8d860d5 code formatting
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3669
        info:'Delete Word'.
2157
ba22c3cc278b added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
  3670
    wasOn ifTrue:[ self showCursor ].
ba22c3cc278b added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
  3671
ba22c3cc278b added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
  3672
    "Modified: / 22.2.2000 / 23:59:04 / cg"
ba22c3cc278b added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
  3673
!
ba22c3cc278b added Shift-BackSpace function: DeleteWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
  3674
5761
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3675
indentSelectionBy1
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3676
    "indent selected line-range
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3677
     by 1 space (i.e. to the right)"
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3678
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3679
    self indentBy:1
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3680
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3681
    "Created: / 06-06-2016 / 10:58:19 / cg"
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3682
!
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  3683
4458
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  3684
insert:aCharacter atLine:lineNr col:colNr
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  3685
    "insert a single character at lineNr/colNr;
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  3686
     set emphasis to character at current position"
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  3687
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  3688
    self basicInsert:aCharacter atLine:lineNr col:colNr.
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  3689
    aCharacter ~~ Character cr ifTrue:[
4823
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  3690
        self addUndo:(DeleteCharacters line:lineNr col:colNr info:'insert').
4458
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  3691
    ]
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  3692
!
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  3693
121
claus
parents: 118
diff changeset
  3694
insertCharAtCursor:aCharacter
1566
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  3695
    "insert a single character at cursor-position - advance cursor."
121
claus
parents: 118
diff changeset
  3696
claus
parents: 118
diff changeset
  3697
    |wasOn|
claus
parents: 118
diff changeset
  3698
claus
parents: 118
diff changeset
  3699
    wasOn := self hideCursor.
1566
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  3700
    aCharacter == Character tab ifTrue:[
4820
8640fa6f128f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4818
diff changeset
  3701
        "/ needs special care to advance cursor correctly
8640fa6f128f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4818
diff changeset
  3702
        self insertTabAtCursor
121
claus
parents: 118
diff changeset
  3703
    ] ifFalse:[
4820
8640fa6f128f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4818
diff changeset
  3704
        self insert:aCharacter atLine:cursorLine col:cursorCol.
8640fa6f128f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4818
diff changeset
  3705
        aCharacter == (Character cr) ifTrue:[
8640fa6f128f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4818
diff changeset
  3706
            self basicCursorReturn
8640fa6f128f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4818
diff changeset
  3707
        ] ifFalse:[
8640fa6f128f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4818
diff changeset
  3708
            self cursorRight.
8640fa6f128f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4818
diff changeset
  3709
        ].
121
claus
parents: 118
diff changeset
  3710
    ].
claus
parents: 118
diff changeset
  3711
    self makeCursorVisibleAndShowCursor:wasOn.
1566
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  3712
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  3713
    "Modified: / 12.6.1998 / 21:50:20 / cg"
121
claus
parents: 118
diff changeset
  3714
!
claus
parents: 118
diff changeset
  3715
641
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  3716
insertLine:aString before:lineNr
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  3717
    "insert the line aString before line lineNr"
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  3718
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  3719
    ^ self insertLines:(Array with:aString) from:1 to:1  before:lineNr.
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  3720
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  3721
    "Modified: 14.5.1996 / 13:42:54 / cg"
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  3722
!
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  3723
155
claus
parents: 133
diff changeset
  3724
insertLines:aStringCollection before:lineNr
claus
parents: 133
diff changeset
  3725
    "insert a bunch before line lineNr"
claus
parents: 133
diff changeset
  3726
claus
parents: 133
diff changeset
  3727
    self insertLines:aStringCollection from:1 to:aStringCollection size before:lineNr
claus
parents: 133
diff changeset
  3728
claus
parents: 133
diff changeset
  3729
    "Modified: 6.9.1995 / 20:51:03 / claus"
claus
parents: 133
diff changeset
  3730
!
claus
parents: 133
diff changeset
  3731
4771
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  3732
insertLines:someText from:start to:end before:lineNr
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  3733
    "insert a bunch of lines before line lineNr.
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  3734
     The cursor position is left unchanged."
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  3735
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  3736
    |text indent visLine w nLines "{ Class: SmallInteger }"
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  3737
     srcY "{ Class: SmallInteger }"
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  3738
     dstY "{ Class: SmallInteger }" |
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  3739
5357
d942c4152f03 class: EditTextView
ca
parents: 5331
diff changeset
  3740
    "wrong when pasting multiple lines"
d942c4152f03 class: EditTextView
ca
parents: 5331
diff changeset
  3741
    false "autoIndent" ifTrue:[
4771
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  3742
        indent := self leftIndentForLine:lineNr.
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  3743
4812
ca6d48bf0053 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4811
diff changeset
  3744
        text := someText 
ca6d48bf0053 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4811
diff changeset
  3745
            collect:[:ln||line|
ca6d48bf0053 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4811
diff changeset
  3746
                ln notNil ifTrue:[
ca6d48bf0053 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4811
diff changeset
  3747
                    line := ln withoutLeadingSeparators.
ca6d48bf0053 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4811
diff changeset
  3748
                    (line isEmpty or:[indent == 0]) ifFalse:[
ca6d48bf0053 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4811
diff changeset
  3749
                        line := (String new:indent), line
ca6d48bf0053 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4811
diff changeset
  3750
                    ].
ca6d48bf0053 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4811
diff changeset
  3751
                    line
ca6d48bf0053 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4811
diff changeset
  3752
                ] ifFalse:[
ca6d48bf0053 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4811
diff changeset
  3753
                    nil
ca6d48bf0053 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4811
diff changeset
  3754
                ]
ca6d48bf0053 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4811
diff changeset
  3755
            ].
4771
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  3756
    ] ifFalse:[
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  3757
        text := someText
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  3758
    ].
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  3759
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  3760
    visLine := self listLineToVisibleLine:lineNr.
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  3761
    (shown not or:[visLine isNil]) ifTrue:[
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  3762
        self withoutRedrawInsertLines:text
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  3763
             from:start to:end
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  3764
             before:lineNr.
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  3765
    ] ifFalse:[
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  3766
        nLines := end - start + 1.
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  3767
        ((visLine + nLines) >= nLinesShown) ifTrue:[
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  3768
            self withoutRedrawInsertLines:text
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  3769
                 from:start to:end
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  3770
                 before:lineNr.
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  3771
            self redrawFromVisibleLine:visLine to:nLinesShown
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  3772
        ] ifFalse:[
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  3773
            w := self widthForScrollBetween:(lineNr + nLines)
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  3774
                                        and:(firstLineShown + nLines + nLinesShown).
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  3775
            srcY := topMargin + ((visLine - 1) * fontHeight).
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  3776
            dstY := srcY + (nLines * fontHeight).
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  3777
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  3778
            "/
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  3779
            "/ scroll ...
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  3780
            "/
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  3781
            "
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  3782
             stupid: must catchExpose before inserting new
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  3783
             stuff - since catchExpose may perform redraws
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  3784
            "
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  3785
            self catchExpose.
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  3786
            self withoutRedrawInsertLines:text
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  3787
                 from:start to:end
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  3788
                 before:lineNr.
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  3789
            self
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  3790
                copyFrom:self
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  3791
                x:textStartLeft y:srcY
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  3792
                toX:textStartLeft y:dstY
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  3793
                width:w
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  3794
                height:(height - dstY)
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  3795
                async:true.
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  3796
            self redrawFromVisibleLine:visLine to:(visLine + nLines - 1).
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  3797
            self waitForExpose
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  3798
        ].
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  3799
    ].
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  3800
    widthOfWidestLine notNil ifTrue:[
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  3801
        text do:[:line |
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  3802
            widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:line).
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  3803
        ]
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  3804
    ].
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  3805
    self textChanged.
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  3806
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  3807
    "Modified: 29.1.1997 / 13:02:39 / cg"
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  3808
!
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  3809
654
d621e63baaa5 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 641
diff changeset
  3810
insertLines:lines withCR:withCr
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  3811
    "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
  3812
     Cursor is moved behind insertion.
641
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  3813
     If withCr is true, append cr after last line"
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  3814
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  3815
    |start end nLines wasOn|
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  3816
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  3817
    lines notNil ifTrue:[
4649
1b1db54a3d29 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4635
diff changeset
  3818
        nLines := lines size.
1b1db54a3d29 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4635
diff changeset
  3819
        (nLines == 1) ifTrue:[
1b1db54a3d29 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4635
diff changeset
  3820
            self insertStringAtCursor:(lines at:1).
1b1db54a3d29 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4635
diff changeset
  3821
            withCr ifTrue:[
1b1db54a3d29 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4635
diff changeset
  3822
                self insertCharAtCursor:(Character cr)
1b1db54a3d29 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4635
diff changeset
  3823
            ]
1b1db54a3d29 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4635
diff changeset
  3824
        ] ifFalse:[
1b1db54a3d29 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4635
diff changeset
  3825
            (cursorCol ~~ 1) ifTrue:[
1b1db54a3d29 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4635
diff changeset
  3826
                self insertStringAtCursor:(lines at:1).
1b1db54a3d29 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4635
diff changeset
  3827
                self insertCharAtCursor:(Character cr).
1b1db54a3d29 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4635
diff changeset
  3828
                start := 2
1b1db54a3d29 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4635
diff changeset
  3829
            ] ifFalse:[
1b1db54a3d29 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4635
diff changeset
  3830
                start := 1
1b1db54a3d29 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4635
diff changeset
  3831
            ].
1b1db54a3d29 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4635
diff changeset
  3832
            withCr ifTrue:[
1b1db54a3d29 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4635
diff changeset
  3833
                end := nLines
1b1db54a3d29 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4635
diff changeset
  3834
            ] ifFalse:[
1b1db54a3d29 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4635
diff changeset
  3835
                end := nLines - 1
1b1db54a3d29 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4635
diff changeset
  3836
            ].
1b1db54a3d29 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4635
diff changeset
  3837
            (start <= nLines) ifTrue:[
1b1db54a3d29 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4635
diff changeset
  3838
                (end >= start) ifTrue:[
1b1db54a3d29 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4635
diff changeset
  3839
                    wasOn := self hideCursor.
1b1db54a3d29 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4635
diff changeset
  3840
                    self insertLines:lines from:start to:end before:cursorLine.
1b1db54a3d29 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4635
diff changeset
  3841
                    self setCursorLine:(cursorLine + (end - start + 1)).
1b1db54a3d29 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4635
diff changeset
  3842
                    wasOn ifTrue:[self showCursor].
1b1db54a3d29 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4635
diff changeset
  3843
                ]
1b1db54a3d29 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4635
diff changeset
  3844
            ].
1b1db54a3d29 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4635
diff changeset
  3845
            withCr ifFalse:[
1b1db54a3d29 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4635
diff changeset
  3846
                "last line without cr"
1b1db54a3d29 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4635
diff changeset
  3847
                self insertStringAtCursor:(lines at:nLines)
1b1db54a3d29 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4635
diff changeset
  3848
            ]
1b1db54a3d29 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4635
diff changeset
  3849
        ]
641
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  3850
    ]
654
d621e63baaa5 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 641
diff changeset
  3851
1566
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  3852
    "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
  3853
    "Modified: / 12.6.1998 / 21:51:16 / cg"
654
d621e63baaa5 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 641
diff changeset
  3854
!
d621e63baaa5 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 641
diff changeset
  3855
d621e63baaa5 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 641
diff changeset
  3856
insertLines:lines withCr:withCr
d621e63baaa5 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 641
diff changeset
  3857
    "insert a bunch of lines at cursor position. Cursor
d621e63baaa5 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 641
diff changeset
  3858
     is moved behind insertion.
d621e63baaa5 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 641
diff changeset
  3859
     If withCr is true, append cr after last line"
d621e63baaa5 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 641
diff changeset
  3860
2363
1982139b2c0b Use <resource:#obsolete>
Stefan Vogel <sv@exept.de>
parents: 2357
diff changeset
  3861
    <resource:#obsolete>
1982139b2c0b Use <resource:#obsolete>
Stefan Vogel <sv@exept.de>
parents: 2357
diff changeset
  3862
1292
ca4c9a957a32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1290
diff changeset
  3863
    self obsoleteMethodWarning:'use #insertLines:withCR:'.
ca4c9a957a32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1290
diff changeset
  3864
    self insertLines:lines withCR:withCr.
ca4c9a957a32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1290
diff changeset
  3865
ca4c9a957a32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1290
diff changeset
  3866
    "Modified: 31.7.1997 / 23:07:22 / cg"
641
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  3867
!
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  3868
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3869
insertSelectedStringAtCursor:aString
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3870
    "insert the argument, aString at cursor position and select it"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3871
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3872
    |startLine startCol|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3873
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3874
    startLine := cursorLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3875
    startCol := cursorCol.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3876
    self insertStringAtCursor:aString.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3877
    self selectFromLine:startLine col:startCol
4823
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  3878
                 toLine:cursorLine col:(cursorCol - 1).
3514
98e103cad51d insertSelectedStringAtCursor: - make selection visible afterwards;
Michael Beyl <mb@exept.de>
parents: 3510
diff changeset
  3879
    self makeSelectionVisible.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3880
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3881
1935
b59ff4681762 added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
  3882
insertString:aString atCharacterPosition:charPos
b59ff4681762 added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
  3883
    "insert the argument, aString at a character position"
b59ff4681762 added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
  3884
b59ff4681762 added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
  3885
    |line col|
b59ff4681762 added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
  3886
b59ff4681762 added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
  3887
    line := self lineOfCharacterPosition:charPos.
b59ff4681762 added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
  3888
    col := charPos - (self characterPositionOfLine:line col:1) + 1.
5060
669de456849b class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5057
diff changeset
  3889
    col == 0 ifTrue:[
669de456849b class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5057
diff changeset
  3890
        line > 1 ifTrue:[
669de456849b class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5057
diff changeset
  3891
            line := line - 1. 
5216
8d6eef5d09c3 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5194
diff changeset
  3892
            col := (self listAt:line) size + 1. 
5060
669de456849b class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5057
diff changeset
  3893
        ] ifFalse:[
669de456849b class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5057
diff changeset
  3894
            col := 1.
669de456849b class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5057
diff changeset
  3895
        ]
669de456849b class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5057
diff changeset
  3896
    ].
1935
b59ff4681762 added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
  3897
    self insertString:aString atLine:line col:col
b59ff4681762 added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
  3898
!
b59ff4681762 added #insertString:atCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
  3899
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3900
insertString:aString atLine:lineNr col:colNr
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3901
    "insert the string, aString at line/col;
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3902
     handle cr's correctly"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3903
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3904
    |start           "{ Class: SmallInteger }"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3905
     stop            "{ Class: SmallInteger }"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3906
     end             "{ Class: SmallInteger }"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3907
     subString c
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3908
     l               "{ Class: SmallInteger }" |
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3909
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3910
    aString isNil ifTrue:[^ self].
1560
43d0f7c2143f use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents: 1559
diff changeset
  3911
    (aString includes:(Character cr)) ifFalse:[
4823
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  3912
        ^ self insertStringWithoutCRs:aString atLine:lineNr col:colNr
121
claus
parents: 118
diff changeset
  3913
    ].
1560
43d0f7c2143f use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents: 1559
diff changeset
  3914
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3915
    l := lineNr.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3916
    c := colNr.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3917
    start := 1.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3918
    end := aString size.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3919
    [start <= end] whileTrue:[
4823
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  3920
        stop := aString indexOf:(Character cr) startingAt:start.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  3921
        stop == 0 ifTrue:[
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  3922
            stop := end + 1
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  3923
        ].
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  3924
        subString := aString copyFrom:start to:(stop - 1).
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  3925
        self insertStringWithoutCRs:subString atLine:l col:c.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  3926
        (stop <= end) ifTrue:[
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  3927
            c := c + subString size.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  3928
            self insert:(Character cr) atLine:l col:c.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  3929
            l := l + 1.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  3930
            c := 1
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  3931
        ].
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  3932
        start := stop + 1
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3933
    ]
1480
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  3934
1560
43d0f7c2143f use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents: 1559
diff changeset
  3935
    "Modified: / 10.6.1998 / 19:03:59 / cg"
121
claus
parents: 118
diff changeset
  3936
!
claus
parents: 118
diff changeset
  3937
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3938
insertStringAtCursor:aString
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3939
    "insert the argument, aString at cursor position
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3940
     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
  3941
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3942
    aString isNil ifTrue:[
4823
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  3943
        "new:"
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  3944
        self insertCharAtCursor:(Character cr).
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  3945
        ^ self
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  3946
    ].
1560
43d0f7c2143f use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents: 1559
diff changeset
  3947
    (aString includes:(Character cr)) ifFalse:[
4823
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  3948
        ^ self insertStringWithoutCRsAtCursor:aString
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  3949
    ].
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  3950
654
d621e63baaa5 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 641
diff changeset
  3951
    self insertLines:aString asStringCollection withCR:false.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3952
1560
43d0f7c2143f use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents: 1559
diff changeset
  3953
    "Modified: / 10.6.1998 / 19:03:21 / cg"
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  3954
!
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  3955
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3956
insertStringWithoutCRs:aString atLine:lineNr col:colNr
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3957
    "insert aString (which has no crs) at lineNr/colNr"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3958
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3959
    self withoutRedrawInsertStringWithoutCRs:aString atLine:lineNr col:colNr.
4190
d79217c1317d changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4189
diff changeset
  3960
    shown ifTrue:[
4889
3ee5b37416a1 class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 4884
diff changeset
  3961
        gc font hasOverlappingCharacters ifTrue:[
4190
d79217c1317d changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4189
diff changeset
  3962
            self invalidateLine:lineNr.
d79217c1317d changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4189
diff changeset
  3963
        ] ifFalse:[
d79217c1317d changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4189
diff changeset
  3964
            self redrawLine:lineNr from:colNr
d79217c1317d changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4189
diff changeset
  3965
        ]
d79217c1317d changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4189
diff changeset
  3966
    ]
d79217c1317d changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4189
diff changeset
  3967
4191
8ac20ced2fbf changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4190
diff changeset
  3968
    "Modified: / 09-11-2010 / 13:43:03 / cg"
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  3969
!
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  3970
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3971
insertStringWithoutCRsAtCursor:aString
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3972
    "insert a string (which has no crs) at cursor position
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3973
     - advance cursor"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3974
2422
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  3975
    |wasOn oldLen newLen deltaLen|
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  3976
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  3977
    aString size > 0 ifTrue:[
4823
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  3978
        wasOn := self hideCursor.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  3979
        (aString includes:Character tab) ifTrue:[
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  3980
            self checkForExistingLine:cursorLine.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  3981
            oldLen := (list at:cursorLine) size.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  3982
            self insertString:aString atLine:cursorLine col:cursorCol.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  3983
            newLen := (list at:cursorLine) size.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  3984
            deltaLen := newLen - oldLen.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  3985
        ] ifFalse:[
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  3986
            self insertString:aString atLine:(cursorLine ? 1) col:cursorCol.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  3987
            deltaLen := aString size.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  3988
        ].
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  3989
        self setCursorCol:(cursorCol + deltaLen).
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  3990
        wasOn ifTrue:[self showCursor]
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3991
    ]
1563
b4eb49efdfcd fixed cursor positioning if inserting a string with tabs.
Claus Gittinger <cg@exept.de>
parents: 1561
diff changeset
  3992
b4eb49efdfcd fixed cursor positioning if inserting a string with tabs.
Claus Gittinger <cg@exept.de>
parents: 1561
diff changeset
  3993
    "Modified: / 10.6.1998 / 20:43:52 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3994
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3995
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3996
insertTabAtCursor
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3997
    "insert spaces to next tab"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3998
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3999
    |wasOn nextTab|
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  4000
121
claus
parents: 118
diff changeset
  4001
    wasOn := self hideCursor.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4002
    nextTab := self nextTabAfter:cursorCol.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4003
    self insertStringAtCursor:(String new:(nextTab - cursorCol)).
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4004
    self makeCursorVisibleAndShowCursor:wasOn.
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  4005
!
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  4006
3542
30ed44ed0178 +joinLines (CTRL-j);
Claus Gittinger <cg@exept.de>
parents: 3517
diff changeset
  4007
joinLines
3890
4c5c54cf856b +wrapLines
Claus Gittinger <cg@exept.de>
parents: 3886
diff changeset
  4008
    "join lines (remove line-break)"
4c5c54cf856b +wrapLines
Claus Gittinger <cg@exept.de>
parents: 3886
diff changeset
  4009
3583
fd5a924c8681 menu enablement
Claus Gittinger <cg@exept.de>
parents: 3580
diff changeset
  4010
    self checkModificationsAllowed ifFalse:[ ^ self].
fd5a924c8681 menu enablement
Claus Gittinger <cg@exept.de>
parents: 3580
diff changeset
  4011
3683
5891af82a177 middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents: 3650
diff changeset
  4012
    self
3890
4c5c54cf856b +wrapLines
Claus Gittinger <cg@exept.de>
parents: 3886
diff changeset
  4013
        undoableDo:[
4c5c54cf856b +wrapLines
Claus Gittinger <cg@exept.de>
parents: 3886
diff changeset
  4014
            |line col lineLen|
4c5c54cf856b +wrapLines
Claus Gittinger <cg@exept.de>
parents: 3886
diff changeset
  4015
4c5c54cf856b +wrapLines
Claus Gittinger <cg@exept.de>
parents: 3886
diff changeset
  4016
            line := cursorLine.
4c5c54cf856b +wrapLines
Claus Gittinger <cg@exept.de>
parents: 3886
diff changeset
  4017
            col := cursorCol.
4c5c54cf856b +wrapLines
Claus Gittinger <cg@exept.de>
parents: 3886
diff changeset
  4018
            lineLen := (list at:line) size.
4c5c54cf856b +wrapLines
Claus Gittinger <cg@exept.de>
parents: 3886
diff changeset
  4019
            col > lineLen ifTrue:[
4c5c54cf856b +wrapLines
Claus Gittinger <cg@exept.de>
parents: 3886
diff changeset
  4020
                self insertString:(String new:col-lineLen) atLine:line col:col+1.
4c5c54cf856b +wrapLines
Claus Gittinger <cg@exept.de>
parents: 3886
diff changeset
  4021
            ] ifFalse:[
4c5c54cf856b +wrapLines
Claus Gittinger <cg@exept.de>
parents: 3886
diff changeset
  4022
                self deleteCharsAtLine:line fromCol:col toCol:lineLen.
4c5c54cf856b +wrapLines
Claus Gittinger <cg@exept.de>
parents: 3886
diff changeset
  4023
            ].
4c5c54cf856b +wrapLines
Claus Gittinger <cg@exept.de>
parents: 3886
diff changeset
  4024
            self mergeLine:line removeBlanks:true.
4c5c54cf856b +wrapLines
Claus Gittinger <cg@exept.de>
parents: 3886
diff changeset
  4025
            self cursorLine:line col:col.
4c5c54cf856b +wrapLines
Claus Gittinger <cg@exept.de>
parents: 3886
diff changeset
  4026
        ]
4c5c54cf856b +wrapLines
Claus Gittinger <cg@exept.de>
parents: 3886
diff changeset
  4027
        info:'Join'
3542
30ed44ed0178 +joinLines (CTRL-j);
Claus Gittinger <cg@exept.de>
parents: 3517
diff changeset
  4028
!
30ed44ed0178 +joinLines (CTRL-j);
Claus Gittinger <cg@exept.de>
parents: 3517
diff changeset
  4029
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4030
mergeLine:lineNr
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4031
    "merge line lineNr with line lineNr+1"
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4032
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4033
    self mergeLine:lineNr removeBlanks:true
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4034
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4035
    "Modified: 9.9.1997 / 09:28:03 / cg"
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4036
!
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4037
4458
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4038
mergeLine:lineNr removeBlanks:removeBlanks
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4039
    "merge line lineNr with line lineNr+1"
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4040
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4041
    |len|
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4042
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4043
    self checkModificationsAllowed ifFalse:[ ^ self].
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4044
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4045
    len := (self listAt:lineNr) size.
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4046
    self nonUndoableDo:[
4823
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  4047
        self basicMergeLine:lineNr removeBlanks:removeBlanks.
4458
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4048
    ].
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4049
    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
  4050
!
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4051
5761
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  4052
parenthizeSelection
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  4053
    "place parenthesis around the selected text.
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  4054
     if already parenthized, de-parenthize it"
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  4055
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  4056
    self parenthizeSelectionWith:$( and:$)
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  4057
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  4058
    "Created: / 06-06-2016 / 10:59:05 / cg"
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  4059
!
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  4060
2506
5568d67dbddd Ctrl-8 / Ctrl-9,
Claus Gittinger <cg@exept.de>
parents: 2505
diff changeset
  4061
parenthizeSelectionWith:openingCharacter and:closingCharacter
5761
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  4062
    "if already parenthized, de-parenthize it"
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  4063
5560
511e59f19726 #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 5529
diff changeset
  4064
    |newSelectionEnd startLine endLine startCol endCol|
2505
9204d5313979 Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents: 2491
diff changeset
  4065
9204d5313979 Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents: 2491
diff changeset
  4066
    self hasSelection ifFalse:[^ self].
5560
511e59f19726 #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 5529
diff changeset
  4067
    startLine := selectionStartLine.
511e59f19726 #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 5529
diff changeset
  4068
    endLine := selectionEndLine.
511e59f19726 #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 5529
diff changeset
  4069
    startCol := selectionStartCol.
511e59f19726 #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 5529
diff changeset
  4070
    endCol := selectionEndCol.
511e59f19726 #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 5529
diff changeset
  4071
    
511e59f19726 #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 5529
diff changeset
  4072
    newSelectionEnd := endCol.
511e59f19726 #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 5529
diff changeset
  4073
    
511e59f19726 #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 5529
diff changeset
  4074
    (self characterAtLine:startLine col:startCol) == openingCharacter ifTrue:[
511e59f19726 #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 5529
diff changeset
  4075
        (self characterAtLine:endLine col:endCol) == closingCharacter ifTrue:[
511e59f19726 #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 5529
diff changeset
  4076
            self deleteCharAtLine:endLine col:endCol.
4823
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  4077
            newSelectionEnd := newSelectionEnd-1.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  4078
        ].
5560
511e59f19726 #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 5529
diff changeset
  4079
        self deleteCharAtLine:startLine col:startCol.
511e59f19726 #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 5529
diff changeset
  4080
        startLine == endLine ifTrue:[
4823
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  4081
            newSelectionEnd := newSelectionEnd-1.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  4082
        ]
2505
9204d5313979 Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents: 2491
diff changeset
  4083
    ] ifFalse:[
5560
511e59f19726 #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 5529
diff changeset
  4084
        self insert:closingCharacter atLine:endLine col:endCol+1.
4823
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  4085
        newSelectionEnd := newSelectionEnd+1.
5560
511e59f19726 #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 5529
diff changeset
  4086
        self insert:openingCharacter atLine:startLine col:startCol.
511e59f19726 #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 5529
diff changeset
  4087
        startLine == endLine ifTrue:[
4823
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  4088
            newSelectionEnd := newSelectionEnd+1.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  4089
        ]
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  4090
    ].
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  4091
    self
5560
511e59f19726 #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 5529
diff changeset
  4092
        selectFromLine:startLine col:startCol
511e59f19726 #BUGFIX
Claus Gittinger <cg@exept.de>
parents: 5529
diff changeset
  4093
        toLine:endLine col:newSelectionEnd.
5761
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  4094
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  4095
    "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
  4096
!
9204d5313979 Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents: 2491
diff changeset
  4097
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4098
removeTrailingBlankLines
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4099
    "remove all blank lines at end of text"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4100
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4101
    |lastLine "{ Class: SmallInteger }"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4102
     line finished|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4103
5114
679cca16c072 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5112
diff changeset
  4104
    NoModificationError handle:[:ex |
679cca16c072 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5112
diff changeset
  4105
        ^ self
679cca16c072 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5112
diff changeset
  4106
    ] do:[
679cca16c072 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5112
diff changeset
  4107
        lastLine := list size.
679cca16c072 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5112
diff changeset
  4108
        finished := false.
679cca16c072 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5112
diff changeset
  4109
        [finished] whileFalse:[
679cca16c072 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5112
diff changeset
  4110
            (lastLine <= 1) ifTrue:[
4771
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  4111
                finished := true
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  4112
            ] ifFalse:[
5114
679cca16c072 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5112
diff changeset
  4113
                line := list at:lastLine.
679cca16c072 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5112
diff changeset
  4114
                line notNil ifTrue:[
679cca16c072 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5112
diff changeset
  4115
                    line isBlank ifTrue:[
679cca16c072 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5112
diff changeset
  4116
                        self basicListAt:lastLine put:nil.
679cca16c072 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5112
diff changeset
  4117
                        line := nil
679cca16c072 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5112
diff changeset
  4118
                    ]
679cca16c072 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5112
diff changeset
  4119
                ].
679cca16c072 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5112
diff changeset
  4120
                line notNil ifTrue:[
679cca16c072 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5112
diff changeset
  4121
                    finished := true
679cca16c072 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5112
diff changeset
  4122
                ] ifFalse:[
679cca16c072 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5112
diff changeset
  4123
                    lastLine := lastLine - 1
679cca16c072 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5112
diff changeset
  4124
                ]
4771
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  4125
            ]
5114
679cca16c072 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5112
diff changeset
  4126
        ].
679cca16c072 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5112
diff changeset
  4127
        (lastLine ~~ list size) ifTrue:[
679cca16c072 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5112
diff changeset
  4128
            list grow:lastLine.
679cca16c072 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5112
diff changeset
  4129
            "/ self textChanged
4771
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  4130
        ]
118
claus
parents: 105
diff changeset
  4131
    ].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4132
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4133
4458
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4134
replace:aCharacter atLine:lineNr col:colNr
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4135
    "replace a single character at lineNr/colNr"
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4136
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4137
    |originalChar|
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4138
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4139
    originalChar := self characterAtLine:lineNr col:colNr.
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4140
    self basicReplace:aCharacter atLine:lineNr col:colNr.
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4141
    self addUndo:(ReplaceCharacters line:lineNr col:colNr character:originalChar info:'replace').
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4142
!
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4143
4713
e8c9caf13e05 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4707
diff changeset
  4144
replace:patternArg by:replacePatternArg all:all ignoreCase:ignoreCase
3430
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  4145
    |pattern replacePattern|
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  4146
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  4147
    pattern := patternArg string.
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  4148
    replacePattern := replacePatternArg string.
4630
b043ca9e5060 class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 4623
diff changeset
  4149
    (pattern notEmpty and:[ replacePattern notEmpty ]) ifTrue:[
b043ca9e5060 class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 4623
diff changeset
  4150
        self rememberSearchPattern:pattern.
b043ca9e5060 class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 4623
diff changeset
  4151
        self rememberSearchPattern:replacePattern.
4713
e8c9caf13e05 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4707
diff changeset
  4152
        LastSearchIgnoredCase := ignoreCase.
4630
b043ca9e5060 class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 4623
diff changeset
  4153
        self
b043ca9e5060 class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 4623
diff changeset
  4154
            undoableDo:[
b043ca9e5060 class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 4623
diff changeset
  4155
                all ifTrue:[
b043ca9e5060 class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 4623
diff changeset
  4156
                    self
b043ca9e5060 class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 4623
diff changeset
  4157
                        replaceString:pattern
b043ca9e5060 class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 4623
diff changeset
  4158
                        to:replacePattern
4713
e8c9caf13e05 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4707
diff changeset
  4159
                        ignoreCase:ignoreCase
4630
b043ca9e5060 class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 4623
diff changeset
  4160
                ] ifFalse:[
b043ca9e5060 class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 4623
diff changeset
  4161
                    (self selectionAsString notNil
4713
e8c9caf13e05 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4707
diff changeset
  4162
                        and:[ self selectionAsString sameAs:pattern caseSensitive:ignoreCase not ])
4630
b043ca9e5060 class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 4623
diff changeset
  4163
                            ifTrue:[
4742
a00cb40ee392 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4738
diff changeset
  4164
                                self replaceSelectionBy:replacePattern.
4630
b043ca9e5060 class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 4623
diff changeset
  4165
                                self
b043ca9e5060 class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 4623
diff changeset
  4166
                                    search:pattern
4713
e8c9caf13e05 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4707
diff changeset
  4167
                                    ignoreCase:ignoreCase
4630
b043ca9e5060 class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 4623
diff changeset
  4168
                                    forward:(lastSearchDirection = #forward).
b043ca9e5060 class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 4623
diff changeset
  4169
                            ].
b043ca9e5060 class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 4623
diff changeset
  4170
                ]
b043ca9e5060 class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 4623
diff changeset
  4171
            ]
b043ca9e5060 class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 4623
diff changeset
  4172
            info:'Replace'
3430
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  4173
    ]
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  4174
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  4175
    "Created: / 11-07-2006 / 11:19:57 / fm"
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  4176
!
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  4177
477
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  4178
replaceCharAtCursor:aCharacter
5413
b21cbb97c038 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5404
diff changeset
  4179
    "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
  4180
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  4181
    |wasOn|
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  4182
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  4183
    wasOn := self hideCursor.
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  4184
    aCharacter == (Character cr) ifTrue:[
4823
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  4185
        self cursorReturn
477
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  4186
    ] ifFalse:[
4823
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  4187
        self replace:aCharacter atLine:cursorLine col:cursorCol.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  4188
        self cursorRight.
477
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  4189
    ].
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  4190
    self makeCursorVisibleAndShowCursor:wasOn.
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  4191
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  4192
    "Created: 6.3.1996 / 12:27:42 / cg"
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  4193
!
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  4194
4458
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4195
replaceContentsWith:newContents
5413
b21cbb97c038 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5404
diff changeset
  4196
    "undoably replace everything"
4458
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4197
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4198
    |originalContents|
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4199
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4200
    originalContents := self contents.
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4201
    self contents:newContents keepUndoHistory:true.
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4202
    self addUndo:(ReplaceContents text:originalContents info:'replace').
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4203
!
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4204
2427
43cc7ea39bac more editing stuff (xxx-characterPosition)
Claus Gittinger <cg@exept.de>
parents: 2422
diff changeset
  4205
replaceFromCharacterPosition:charPos1 to:charPos2 with:newString
5413
b21cbb97c038 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5404
diff changeset
  4206
    "undoably replace a substring at a character position"
2427
43cc7ea39bac more editing stuff (xxx-characterPosition)
Claus Gittinger <cg@exept.de>
parents: 2422
diff changeset
  4207
5216
8d6eef5d09c3 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5194
diff changeset
  4208
    "/ 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
  4209
    self insertString:newString atCharacterPosition:charPos1.
43cc7ea39bac more editing stuff (xxx-characterPosition)
Claus Gittinger <cg@exept.de>
parents: 2422
diff changeset
  4210
    self deleteFromCharacterPosition:charPos1+newString size to:charPos2+newString size.
43cc7ea39bac more editing stuff (xxx-characterPosition)
Claus Gittinger <cg@exept.de>
parents: 2422
diff changeset
  4211
!
43cc7ea39bac more editing stuff (xxx-characterPosition)
Claus Gittinger <cg@exept.de>
parents: 2422
diff changeset
  4212
4458
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4213
replaceLine:lineNr with:newText
5413
b21cbb97c038 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5404
diff changeset
  4214
    "undoably replace a line at lineNr"
4458
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4215
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4216
    |originalLine|
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4217
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4218
    originalLine := self listAt:lineNr.
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4219
    originalLine isNil ifTrue:[
4823
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  4220
        self checkForExistingLine:lineNr
4458
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4221
    ].
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4222
    self list at:lineNr put:newText.
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4223
    self addUndo:(ReplaceLine line:lineNr string:originalLine info:'replace').
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4224
    self invalidateLine:lineNr.
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4225
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4226
    "Modified: / 12-04-2007 / 09:31:33 / cg"
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4227
!
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4228
1564
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  4229
replaceLines:lines withCR:withCr
5413
b21cbb97c038 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5404
diff changeset
  4230
    "undoably a bunch of lines at cursor position. Cursor
1564
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  4231
     is moved behind replacement.
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  4232
     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
  4233
     after the last line"
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  4234
1809
111f603c0a1c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1807
diff changeset
  4235
    |line col nLines wasOn|
1564
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  4236
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  4237
    lines notNil ifTrue:[
4661
c029273f7660 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4649
diff changeset
  4238
        wasOn := self hideCursor.
c029273f7660 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4649
diff changeset
  4239
        nLines := lines size.
c029273f7660 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4649
diff changeset
  4240
        line := cursorLine.
c029273f7660 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4649
diff changeset
  4241
        col := cursorCol.
c029273f7660 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4649
diff changeset
  4242
        lines keysAndValuesDo:[:i :l |
c029273f7660 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4649
diff changeset
  4243
            self replaceString:(l ? '') atLine:line col:col.
c029273f7660 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4649
diff changeset
  4244
            (i ~~ nLines or:[withCr]) ifTrue:[
c029273f7660 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4649
diff changeset
  4245
                line := line + 1.
c029273f7660 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4649
diff changeset
  4246
                col := 1.
c029273f7660 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4649
diff changeset
  4247
            ] ifFalse:[
c029273f7660 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4649
diff changeset
  4248
                col := col + (l size).
c029273f7660 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4649
diff changeset
  4249
            ]
c029273f7660 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4649
diff changeset
  4250
        ].
c029273f7660 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4649
diff changeset
  4251
        self cursorLine:line col:col.
c029273f7660 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4649
diff changeset
  4252
        self makeCursorVisibleAndShowCursor:wasOn.
c029273f7660 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4649
diff changeset
  4253
        "/ wasOn ifTrue:[self showCursor].
1564
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  4254
    ]
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  4255
4661
c029273f7660 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4649
diff changeset
  4256
    "Created: / 18-05-1996 / 15:32:06 / cg"
c029273f7660 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4649
diff changeset
  4257
    "Modified: / 25-07-2013 / 17:00:53 / cg"
1564
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  4258
!
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  4259
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4260
replaceSelectionBy:something
5413
b21cbb97c038 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5404
diff changeset
  4261
    "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
  4262
     leave cursor after insertion"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4263
4666
81e48e442abe class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4664
diff changeset
  4264
    self replaceSelectionBy:something keepCursor:false select:false
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  4265
!
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  4266
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  4267
replaceSelectionBy:something keepCursor:keep
5413
b21cbb97c038 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5404
diff changeset
  4268
    "undoably delete the selection (if any) and insert something, a character or string;
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  4269
     leave cursor after insertion or leave it, depending on keep"
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  4270
4666
81e48e442abe class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4664
diff changeset
  4271
    self replaceSelectionBy:something keepCursor:keep select:false
81e48e442abe class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4664
diff changeset
  4272
81e48e442abe class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4664
diff changeset
  4273
    "Modified: 9.10.1996 / 16:14:35 / cg"
81e48e442abe class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4664
diff changeset
  4274
!
81e48e442abe class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4664
diff changeset
  4275
81e48e442abe class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4664
diff changeset
  4276
replaceSelectionBy:something keepCursor:keep select:selectNewText
5413
b21cbb97c038 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5404
diff changeset
  4277
    "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
  4278
     leave cursor after insertion or leave it, depending on keep.
81e48e442abe class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4664
diff changeset
  4279
     If selectNewText is true, select the new text; otherwise deselect"
81e48e442abe class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4664
diff changeset
  4280
81e48e442abe class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4664
diff changeset
  4281
    |sel l c selStartLine selStartCol|
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  4282
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  4283
    l := cursorLine.
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  4284
    c := cursorCol.
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  4285
4818
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  4286
    sel := self selectionAsString.
4666
81e48e442abe class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4664
diff changeset
  4287
    sel isNil ifTrue:[
81e48e442abe class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4664
diff changeset
  4288
        selStartLine := l.
81e48e442abe class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4664
diff changeset
  4289
        selStartCol := c.
81e48e442abe class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4664
diff changeset
  4290
    ] ifFalse:[
81e48e442abe class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4664
diff changeset
  4291
        selStartLine := selectionStartLine.
81e48e442abe class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4664
diff changeset
  4292
        selStartCol := selectionStartCol.
81e48e442abe class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4664
diff changeset
  4293
4053
31117d801975 added: #setLastStringToReplace:
fm
parents: 4051
diff changeset
  4294
        self setLastStringToReplace: sel.
31117d801975 added: #setLastStringToReplace:
fm
parents: 4051
diff changeset
  4295
4010
9c22bd531240 lastStringToReplace to use in again
fm
parents: 3996
diff changeset
  4296
        self deleteSelection.
9c22bd531240 lastStringToReplace to use in again
fm
parents: 3996
diff changeset
  4297
        replacing := true.
4818
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  4298
        lastReplacementInfo rememberReplacement.
4048
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
  4299
        lastReplacementInfo lastReplacement: ''.
4818
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  4300
        lastReplacementInfo stillCollectingInput:true.
4010
9c22bd531240 lastStringToReplace to use in again
fm
parents: 3996
diff changeset
  4301
        undoSupport actionInfo:'replace'.
3161
982c2e416728 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3160
diff changeset
  4302
    ].
982c2e416728 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3160
diff changeset
  4303
982c2e416728 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3160
diff changeset
  4304
    something isCharacter ifTrue:[
4051
4fdd00fbdc60 changed:
fm
parents: 4048
diff changeset
  4305
        lastReplacementInfo lastReplacement notNil ifTrue:[
4818
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  4306
            lastReplacementInfo stillCollectingInput ifTrue:[
4051
4fdd00fbdc60 changed:
fm
parents: 4048
diff changeset
  4307
                lastReplacementInfo lastReplacement: (lastReplacementInfo lastReplacement copyWith:something).
4818
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  4308
            ].
4010
9c22bd531240 lastStringToReplace to use in again
fm
parents: 3996
diff changeset
  4309
        ].
9c22bd531240 lastStringToReplace to use in again
fm
parents: 3996
diff changeset
  4310
        self isInInsertMode ifTrue:[
9c22bd531240 lastStringToReplace to use in again
fm
parents: 3996
diff changeset
  4311
            self insertCharAtCursor:something
9c22bd531240 lastStringToReplace to use in again
fm
parents: 3996
diff changeset
  4312
        ] ifFalse:[
9c22bd531240 lastStringToReplace to use in again
fm
parents: 3996
diff changeset
  4313
            self replaceCharAtCursor:something
9c22bd531240 lastStringToReplace to use in again
fm
parents: 3996
diff changeset
  4314
        ]
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  4315
    ] ifFalse:[
4010
9c22bd531240 lastStringToReplace to use in again
fm
parents: 3996
diff changeset
  4316
        something isString ifTrue:[
4048
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
  4317
            lastReplacementInfo lastReplacement: something.
4010
9c22bd531240 lastStringToReplace to use in again
fm
parents: 3996
diff changeset
  4318
            self isInInsertMode ifTrue:[
9c22bd531240 lastStringToReplace to use in again
fm
parents: 3996
diff changeset
  4319
                self insertStringAtCursor:something
9c22bd531240 lastStringToReplace to use in again
fm
parents: 3996
diff changeset
  4320
            ] ifFalse:[
9c22bd531240 lastStringToReplace to use in again
fm
parents: 3996
diff changeset
  4321
                self replaceStringAtCursor:something
9c22bd531240 lastStringToReplace to use in again
fm
parents: 3996
diff changeset
  4322
            ]
9c22bd531240 lastStringToReplace to use in again
fm
parents: 3996
diff changeset
  4323
        ] ifFalse:[
9c22bd531240 lastStringToReplace to use in again
fm
parents: 3996
diff changeset
  4324
            Transcript showCR:'EditTextView: non String-or-Character in replace'.
9c22bd531240 lastStringToReplace to use in again
fm
parents: 3996
diff changeset
  4325
        ].
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  4326
    ].
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  4327
    keep ifTrue:[
4010
9c22bd531240 lastStringToReplace to use in again
fm
parents: 3996
diff changeset
  4328
        self cursorLine:l col:c
4666
81e48e442abe class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4664
diff changeset
  4329
    ].
81e48e442abe class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4664
diff changeset
  4330
    selectNewText ifTrue:[
81e48e442abe class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4664
diff changeset
  4331
        self selectFromLine:selStartLine col:selStartCol toLine:cursorLine col:cursorCol-1
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  4332
    ]
477
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  4333
840
b0071cea13fd fixed Again when spaces are replaced
Claus Gittinger <cg@exept.de>
parents: 828
diff changeset
  4334
    "Modified: 9.10.1996 / 16:14:35 / cg"
1564
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  4335
!
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  4336
4458
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4337
replaceString:aString atLine:lineNr col:colNr
5413
b21cbb97c038 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5404
diff changeset
  4338
    "undoably replace multiple characters starting at lineNr/colNr.
4458
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4339
     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
  4340
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4341
    |originalString|
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4342
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4343
    self checkModificationsAllowed ifFalse:[ ^ self].
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4344
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4345
    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
  4346
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4347
    self basicReplaceString:aString atLine:lineNr col:colNr.
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4348
    self addUndo:(ReplaceCharacters line:lineNr col:colNr characters:originalString info:'replace').
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4349
!
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4350
4713
e8c9caf13e05 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4707
diff changeset
  4351
replaceString:aString to:aNewString ignoreCase:ignoreCase
3549
569d0e4ab5a3 join at cursorposition
Claus Gittinger <cg@exept.de>
parents: 3542
diff changeset
  4352
    |continue count|
569d0e4ab5a3 join at cursorposition
Claus Gittinger <cg@exept.de>
parents: 3542
diff changeset
  4353
569d0e4ab5a3 join at cursorposition
Claus Gittinger <cg@exept.de>
parents: 3542
diff changeset
  4354
    self cursorToTop.
569d0e4ab5a3 join at cursorposition
Claus Gittinger <cg@exept.de>
parents: 3542
diff changeset
  4355
    self selectFromBeginning.
569d0e4ab5a3 join at cursorposition
Claus Gittinger <cg@exept.de>
parents: 3542
diff changeset
  4356
    count := 0.
569d0e4ab5a3 join at cursorposition
Claus Gittinger <cg@exept.de>
parents: 3542
diff changeset
  4357
    continue := true.
569d0e4ab5a3 join at cursorposition
Claus Gittinger <cg@exept.de>
parents: 3542
diff changeset
  4358
    [ continue ] whileTrue:[
4713
e8c9caf13e05 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4707
diff changeset
  4359
        (self selectionAsString notNil
e8c9caf13e05 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4707
diff changeset
  4360
        and:[ self selectionAsString sameAs:aString caseSensitive:ignoreCase not ])
e8c9caf13e05 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4707
diff changeset
  4361
            ifTrue:[
4742
a00cb40ee392 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4738
diff changeset
  4362
                self replaceSelectionBy:aNewString.
4713
e8c9caf13e05 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4707
diff changeset
  4363
                count := count + 1.
e8c9caf13e05 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4707
diff changeset
  4364
            ].
e8c9caf13e05 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4707
diff changeset
  4365
        self
e8c9caf13e05 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4707
diff changeset
  4366
            searchFwd:aString
e8c9caf13e05 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4707
diff changeset
  4367
            ignoreCase:ignoreCase
e8c9caf13e05 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4707
diff changeset
  4368
            ifAbsent:[
e8c9caf13e05 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4707
diff changeset
  4369
                Dialog information:('%1 has been replaced by %2 %3 times' 
e8c9caf13e05 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4707
diff changeset
  4370
                                    bindWith:aString with:aNewString with:count).
e8c9caf13e05 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4707
diff changeset
  4371
                continue := false.
e8c9caf13e05 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4707
diff changeset
  4372
            ].
3549
569d0e4ab5a3 join at cursorposition
Claus Gittinger <cg@exept.de>
parents: 3542
diff changeset
  4373
    ].
3430
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  4374
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  4375
    "Created: / 10-07-2006 / 16:42:48 / fm"
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  4376
!
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  4377
1564
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  4378
replaceStringAtCursor:aString
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  4379
    "replace multiple characters at cursor-position - advance cursor"
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  4380
1566
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  4381
    |wasOn i1 i2|
1564
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  4382
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  4383
    wasOn := self hideCursor.
1566
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  4384
    (aString includes:Character tab) ifTrue:[
4823
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  4385
        "/ need special care for TAB (to move cursor correctly)
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  4386
        i1 := 1.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  4387
        [i1 ~~ 0] whileTrue:[
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  4388
            i2 := aString indexOf:Character tab startingAt:i1.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  4389
            i2 ~~ 0 ifTrue:[
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  4390
                i1 ~~ i2 ifTrue:[
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  4391
                    self replaceString:(aString copyFrom:i1 to:i2-1) atLine:cursorLine col:cursorCol.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  4392
                    self cursorCol:(cursorCol + (i2 - i1)).
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  4393
                ].
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  4394
                self replaceTABAtCursor.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  4395
                i2 := i2 + 1.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  4396
            ] ifFalse:[
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  4397
                self replaceString:(aString copyFrom:i1) atLine:cursorLine col:cursorCol.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  4398
                self cursorCol:(cursorCol + (aString size - i1 + 1)).
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  4399
            ].
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  4400
            i1 := i2.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  4401
        ]
1566
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  4402
    ] ifFalse:[
4823
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  4403
        self replaceString:aString atLine:cursorLine col:cursorCol.
5325
b3d62a76761c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5283
diff changeset
  4404
        self setValidatedCursorCol:(cursorCol + aString size).
b3d62a76761c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5283
diff changeset
  4405
        "/ self cursorCol:(cursorCol + aString size).
b3d62a76761c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5283
diff changeset
  4406
    ].
b3d62a76761c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5283
diff changeset
  4407
    wasOn ifTrue:[
b3d62a76761c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5283
diff changeset
  4408
        self sensor pushUserEvent:#makeCursorVisibleAndShowCursor: for:self withArguments:{ wasOn } 
b3d62a76761c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5283
diff changeset
  4409
        "/ self makeCursorVisibleAndShowCursor:wasOn.
b3d62a76761c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5283
diff changeset
  4410
    ].
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
    "Created: / 9.6.1998 / 20:33:20 / cg"
1597
5fdcfcedb91c fixed cursor positioning after replaceStringAtCursor.
Claus Gittinger <cg@exept.de>
parents: 1596
diff changeset
  4413
    "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
  4414
!
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  4415
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  4416
replaceTABAtCursor
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  4417
    "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
  4418
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  4419
    |wasOn nextTab|
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  4420
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  4421
    wasOn := self hideCursor.
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  4422
    nextTab := self nextTabAfter:cursorCol.
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  4423
    self replaceStringAtCursor:(String new:(nextTab - cursorCol)).
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  4424
    self makeCursorVisibleAndShowCursor:wasOn.
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  4425
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  4426
    "Created: / 12.6.1998 / 21:53:23 / cg"
3890
4c5c54cf856b +wrapLines
Claus Gittinger <cg@exept.de>
parents: 3886
diff changeset
  4427
!
4c5c54cf856b +wrapLines
Claus Gittinger <cg@exept.de>
parents: 3886
diff changeset
  4428
4256
1e4bdc48136c added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents: 4253
diff changeset
  4429
selectWordBeforeCursor
1e4bdc48136c added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents: 4253
diff changeset
  4430
    "select the word to the left of cursor"
1e4bdc48136c added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents: 4253
diff changeset
  4431
1e4bdc48136c added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents: 4253
diff changeset
  4432
    |savCursorLine savCursorCol  beginCol beginLine endCol endLine|
1e4bdc48136c added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents: 4253
diff changeset
  4433
1e4bdc48136c added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents: 4253
diff changeset
  4434
    savCursorLine := cursorLine.
1e4bdc48136c added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents: 4253
diff changeset
  4435
    savCursorCol := cursorCol.
1e4bdc48136c added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents: 4253
diff changeset
  4436
1e4bdc48136c added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents: 4253
diff changeset
  4437
    endCol := cursorCol-1.
1e4bdc48136c added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents: 4253
diff changeset
  4438
    endLine := cursorLine.
1e4bdc48136c added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents: 4253
diff changeset
  4439
    self cursorToPreviousWord.
1e4bdc48136c added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents: 4253
diff changeset
  4440
    beginCol := cursorCol.     
1e4bdc48136c added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents: 4253
diff changeset
  4441
    beginLine := cursorLine.
1e4bdc48136c added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents: 4253
diff changeset
  4442
    self cursorLine:savCursorLine col:savCursorCol.
1e4bdc48136c added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents: 4253
diff changeset
  4443
    self selectFromLine:beginLine col:beginCol toLine:endLine col:endCol.
1e4bdc48136c added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents: 4253
diff changeset
  4444
1e4bdc48136c added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents: 4253
diff changeset
  4445
    "Created: / 14-06-2011 / 14:46:35 / cg"
1e4bdc48136c added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents: 4253
diff changeset
  4446
!
1e4bdc48136c added: #selectWordBeforeCursor
Claus Gittinger <cg@exept.de>
parents: 4253
diff changeset
  4447
4458
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4448
splitLine:lineNr before:colNr
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4449
    "split the line linNr before colNr; the right part (from colNr)
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4450
     is cut off and inserted after lineNr; the view is redrawn"
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4451
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4452
    self basicSplitLine:lineNr before:colNr.
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4453
    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
  4454
!
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4455
5761
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  4456
toggleTabSetting
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  4457
    "toggle between 4-col
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  4458
     and 8-col tabs"
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  4459
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  4460
    (tabPositions == self class tab4Positions)
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  4461
         ifTrue:[self setTab8]
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  4462
         ifFalse:[self setTab4]
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  4463
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  4464
    "Created: / 06-06-2016 / 11:02:07 / cg"
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  4465
!
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  4466
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  4467
undentSelectionBy1
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  4468
    "undent selected line-range
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  4469
     by 1 space (i.e. to the left)"
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  4470
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  4471
    self undentBy:1
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  4472
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  4473
    "Created: / 06-06-2016 / 10:49:51 / cg"
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  4474
!
0b2929b446e9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5742
diff changeset
  4475
5146
3169904851a4 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5145
diff changeset
  4476
withAutoIndent:aBoolean do:aBlock
3169904851a4 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5145
diff changeset
  4477
    |sav|
3169904851a4 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5145
diff changeset
  4478
3169904851a4 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5145
diff changeset
  4479
    sav := autoIndent.
3169904851a4 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5145
diff changeset
  4480
    autoIndent := aBoolean.
3169904851a4 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5145
diff changeset
  4481
    aBlock ensure:[ autoIndent := sav ].
3169904851a4 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5145
diff changeset
  4482
!
3169904851a4 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5145
diff changeset
  4483
4458
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4484
withoutRedrawAt:lineNr put:aString
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4485
    "replace a line at lineNr"
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4486
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4487
    |originalLine|
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4488
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4489
    originalLine := self listAt:lineNr.
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4490
    self addUndo:(ReplaceLine line:lineNr string:originalLine info:'replace').
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4491
    super withoutRedrawAt:lineNr put:aString.
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4492
!
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4493
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4494
withoutRedrawInsertLine:aString before:lineNr
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4495
    "insert the argument, aString before line lineNr; the string
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4496
     becomes line lineNr; everything else is moved down; the view
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4497
     is not redrawn"
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4498
4771
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  4499
    self basicWithoutRedrawInsertLines:{ aString } from:1 to:1 before:lineNr.
4458
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4500
    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
  4501
!
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4502
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4503
withoutRedrawInsertLines:lines from:start to:end before:lineNr
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4504
    "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
  4505
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4506
    self basicWithoutRedrawInsertLines:lines from:start to:end before:lineNr.
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4507
    self isReadOnly ifFalse:[
4823
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  4508
        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
  4509
    ].
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4510
!
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4511
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4512
withoutRedrawInsertStringWithoutCRs:aString atLine:lineNr col:colNr
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4513
    "insert aString (which has no crs) at lineNr/colNr"
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4514
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4515
    self basicWithoutRedrawInsertStringWithoutCRs:aString atLine:lineNr col:colNr.
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4516
    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
  4517
!
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4518
3890
4c5c54cf856b +wrapLines
Claus Gittinger <cg@exept.de>
parents: 3886
diff changeset
  4519
wrapLines
4c5c54cf856b +wrapLines
Claus Gittinger <cg@exept.de>
parents: 3886
diff changeset
  4520
    "wrap lines (insert line-break)"
4c5c54cf856b +wrapLines
Claus Gittinger <cg@exept.de>
parents: 3886
diff changeset
  4521
4c5c54cf856b +wrapLines
Claus Gittinger <cg@exept.de>
parents: 3886
diff changeset
  4522
    |lineLength answerString string|
4c5c54cf856b +wrapLines
Claus Gittinger <cg@exept.de>
parents: 3886
diff changeset
  4523
4c5c54cf856b +wrapLines
Claus Gittinger <cg@exept.de>
parents: 3886
diff changeset
  4524
    self checkModificationsAllowed ifFalse:[ ^ self].
4c5c54cf856b +wrapLines
Claus Gittinger <cg@exept.de>
parents: 3886
diff changeset
  4525
4c5c54cf856b +wrapLines
Claus Gittinger <cg@exept.de>
parents: 3886
diff changeset
  4526
    self hasSelection ifFalse:[
4c5c54cf856b +wrapLines
Claus Gittinger <cg@exept.de>
parents: 3886
diff changeset
  4527
        self selectLine:cursorLine.
4c5c54cf856b +wrapLines
Claus Gittinger <cg@exept.de>
parents: 3886
diff changeset
  4528
    ].
4c5c54cf856b +wrapLines
Claus Gittinger <cg@exept.de>
parents: 3886
diff changeset
  4529
    string := self selectionAsString.
4c5c54cf856b +wrapLines
Claus Gittinger <cg@exept.de>
parents: 3886
diff changeset
  4530
    string isEmptyOrNil ifTrue:[
4c5c54cf856b +wrapLines
Claus Gittinger <cg@exept.de>
parents: 3886
diff changeset
  4531
        Dialog information:(resources string:'Nothing selected.').
4c5c54cf856b +wrapLines
Claus Gittinger <cg@exept.de>
parents: 3886
diff changeset
  4532
        ^ self.
4c5c54cf856b +wrapLines
Claus Gittinger <cg@exept.de>
parents: 3886
diff changeset
  4533
    ].
4c5c54cf856b +wrapLines
Claus Gittinger <cg@exept.de>
parents: 3886
diff changeset
  4534
4c5c54cf856b +wrapLines
Claus Gittinger <cg@exept.de>
parents: 3886
diff changeset
  4535
    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
  4536
    lineLength := Number readFrom:answerString onError:nil.
4388
558b4dbf5648 changed:
Claus Gittinger <cg@exept.de>
parents: 4373
diff changeset
  4537
    lineLength isNil ifTrue:[^ self].
3890
4c5c54cf856b +wrapLines
Claus Gittinger <cg@exept.de>
parents: 3886
diff changeset
  4538
    lineLength < 1 ifTrue:[
4c5c54cf856b +wrapLines
Claus Gittinger <cg@exept.de>
parents: 3886
diff changeset
  4539
        lineLength := 1.
4c5c54cf856b +wrapLines
Claus Gittinger <cg@exept.de>
parents: 3886
diff changeset
  4540
    ].
4c5c54cf856b +wrapLines
Claus Gittinger <cg@exept.de>
parents: 3886
diff changeset
  4541
4c5c54cf856b +wrapLines
Claus Gittinger <cg@exept.de>
parents: 3886
diff changeset
  4542
    self
4c5c54cf856b +wrapLines
Claus Gittinger <cg@exept.de>
parents: 3886
diff changeset
  4543
        undoableDo:[
4c5c54cf856b +wrapLines
Claus Gittinger <cg@exept.de>
parents: 3886
diff changeset
  4544
            |inStream line col lineLen lastGoodCol lastStartCol word|
4c5c54cf856b +wrapLines
Claus Gittinger <cg@exept.de>
parents: 3886
diff changeset
  4545
4c5c54cf856b +wrapLines
Claus Gittinger <cg@exept.de>
parents: 3886
diff changeset
  4546
            line := selectionStartLine.
4c5c54cf856b +wrapLines
Claus Gittinger <cg@exept.de>
parents: 3886
diff changeset
  4547
            col := selectionStartCol.
4c5c54cf856b +wrapLines
Claus Gittinger <cg@exept.de>
parents: 3886
diff changeset
  4548
4c5c54cf856b +wrapLines
Claus Gittinger <cg@exept.de>
parents: 3886
diff changeset
  4549
            self cutSelection.
4c5c54cf856b +wrapLines
Claus Gittinger <cg@exept.de>
parents: 3886
diff changeset
  4550
            self cursorLine:line col:col.
4c5c54cf856b +wrapLines
Claus Gittinger <cg@exept.de>
parents: 3886
diff changeset
  4551
4c5c54cf856b +wrapLines
Claus Gittinger <cg@exept.de>
parents: 3886
diff changeset
  4552
            lastGoodCol := col.
4c5c54cf856b +wrapLines
Claus Gittinger <cg@exept.de>
parents: 3886
diff changeset
  4553
4c5c54cf856b +wrapLines
Claus Gittinger <cg@exept.de>
parents: 3886
diff changeset
  4554
            inStream := string readStream.
4c5c54cf856b +wrapLines
Claus Gittinger <cg@exept.de>
parents: 3886
diff changeset
  4555
            [ inStream atEnd ] whileFalse:[
4c5c54cf856b +wrapLines
Claus Gittinger <cg@exept.de>
parents: 3886
diff changeset
  4556
                [inStream atEnd not and:[inStream peek isSeparator]] whileTrue:[ inStream next ].
4c5c54cf856b +wrapLines
Claus Gittinger <cg@exept.de>
parents: 3886
diff changeset
  4557
                word := WriteStream on:(String new:10).
4c5c54cf856b +wrapLines
Claus Gittinger <cg@exept.de>
parents: 3886
diff changeset
  4558
                [inStream atEnd not and:[inStream peek isSeparator not]] whileTrue:[ word nextPut:inStream next ].
4c5c54cf856b +wrapLines
Claus Gittinger <cg@exept.de>
parents: 3886
diff changeset
  4559
                (col + 1 + word size > lineLength) ifTrue:[
4c5c54cf856b +wrapLines
Claus Gittinger <cg@exept.de>
parents: 3886
diff changeset
  4560
                    self insertCharAtCursor:(Character cr).
4c5c54cf856b +wrapLines
Claus Gittinger <cg@exept.de>
parents: 3886
diff changeset
  4561
                    col := 1.
4c5c54cf856b +wrapLines
Claus Gittinger <cg@exept.de>
parents: 3886
diff changeset
  4562
                ] ifFalse:[
4c5c54cf856b +wrapLines
Claus Gittinger <cg@exept.de>
parents: 3886
diff changeset
  4563
                    col ~~ 1 ifTrue:[ 
4c5c54cf856b +wrapLines
Claus Gittinger <cg@exept.de>
parents: 3886
diff changeset
  4564
                        self insertStringAtCursor:' '.
4c5c54cf856b +wrapLines
Claus Gittinger <cg@exept.de>
parents: 3886
diff changeset
  4565
                        col := col + 1.
4c5c54cf856b +wrapLines
Claus Gittinger <cg@exept.de>
parents: 3886
diff changeset
  4566
                    ]    
4c5c54cf856b +wrapLines
Claus Gittinger <cg@exept.de>
parents: 3886
diff changeset
  4567
               ].
4c5c54cf856b +wrapLines
Claus Gittinger <cg@exept.de>
parents: 3886
diff changeset
  4568
               self insertStringAtCursor:word contents.
4c5c54cf856b +wrapLines
Claus Gittinger <cg@exept.de>
parents: 3886
diff changeset
  4569
               col := col + word size.
4c5c54cf856b +wrapLines
Claus Gittinger <cg@exept.de>
parents: 3886
diff changeset
  4570
            ].
4c5c54cf856b +wrapLines
Claus Gittinger <cg@exept.de>
parents: 3886
diff changeset
  4571
        ]
4c5c54cf856b +wrapLines
Claus Gittinger <cg@exept.de>
parents: 3886
diff changeset
  4572
        info:'Wrap'
4388
558b4dbf5648 changed:
Claus Gittinger <cg@exept.de>
parents: 4373
diff changeset
  4573
558b4dbf5648 changed:
Claus Gittinger <cg@exept.de>
parents: 4373
diff changeset
  4574
    "Modified: / 01-03-2012 / 19:56:22 / cg"
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4575
! !
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4576
2752
5650a9ab5935 method category rename
Claus Gittinger <cg@exept.de>
parents: 2744
diff changeset
  4577
!EditTextView methodsFor:'editing-basic'!
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4578
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4579
basicDeleteCharsAtLine:lineNr fromCol:startCol toCol:endCol
3549
569d0e4ab5a3 join at cursorposition
Claus Gittinger <cg@exept.de>
parents: 3542
diff changeset
  4580
    "delete characters from startCol to endCol in line lineNr"
569d0e4ab5a3 join at cursorposition
Claus Gittinger <cg@exept.de>
parents: 3542
diff changeset
  4581
1803
ac7cc1b99407 scroll left as required, if deleting characters of the longest line,
Claus Gittinger <cg@exept.de>
parents: 1796
diff changeset
  4582
    |line lineSize newLine start stop prevWidth newWidth|
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4583
4673
575d2d398823 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4666
diff changeset
  4584
    self unselect.
575d2d398823 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4666
diff changeset
  4585
575d2d398823 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4666
diff changeset
  4586
    cursorLine == lineNr ifTrue:[
5909
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4587
        cursorCol >= startCol ifTrue:[
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4588
            cursorCol >= endCol ifTrue:[
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4589
                cursorCol := startCol.
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4590
            ] ifFalse:[
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4591
                cursorCol := cursorCol - (endCol - startCol + 1).
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4592
                "/ self assert:(cursorCol >= 0).
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4593
                cursorCol := cursorCol max:1.
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4594
            ]
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4595
        ].
4673
575d2d398823 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4666
diff changeset
  4596
    ].
575d2d398823 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4666
diff changeset
  4597
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4598
    line := self listAt:lineNr.
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  4599
4673
575d2d398823 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4666
diff changeset
  4600
    (self checkModificationsAllowed and:[line notNil]) ifFalse:[^ self].
575d2d398823 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4666
diff changeset
  4601
575d2d398823 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4666
diff changeset
  4602
    lineSize := line size.
575d2d398823 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4666
diff changeset
  4603
575d2d398823 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4666
diff changeset
  4604
    startCol == 0 ifFalse:[ start := startCol ] ifTrue:[ start := 1 ].
575d2d398823 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4666
diff changeset
  4605
    endCol > lineSize ifFalse:[ stop  := endCol ] ifTrue:[ stop  := lineSize ].
575d2d398823 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4666
diff changeset
  4606
575d2d398823 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4666
diff changeset
  4607
    stop >= start ifTrue:[
5909
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4608
        start ~~ 1 ifTrue:[ newLine := line copyFrom:1 to:(start-1) ]
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4609
                  ifFalse:[ newLine := '' ].
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4610
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4611
        stop == lineSize ifFalse:[
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4612
            line bitsPerCharacter > newLine bitsPerCharacter ifTrue:[
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4613
                newLine := line string species fromString:newLine.
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4614
            ].
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4615
            newLine := newLine, (line copyFrom:(stop + 1) to:lineSize)
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4616
        ].
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4617
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4618
        (self trimBlankLines and:[newLine isBlank]) ifTrue:[
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4619
            newLine := nil
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4620
        ].
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4621
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4622
        prevWidth := self widthOfLine:lineNr.
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4623
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4624
        self basicListAt:lineNr put:newLine.
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4625
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4626
        (prevWidth = widthOfWidestLine) ifTrue:[
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4627
            "/ remember old width of this line,
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4628
            "/ only clear widthOfWidestLine, if this lines
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4629
            "/ length was (one of) the longest.
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4630
            "/ avoids slow delete with huge texts.
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4631
            widthOfWidestLine := nil.   "i.e. unknown"
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4632
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4633
            "/ scroll left if reqiured
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4634
            viewOrigin x > 0 ifTrue:[
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4635
                newWidth := self widthOfLine:lineNr.
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4636
                newWidth < (viewOrigin x + width) ifTrue:[
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4637
                    self scrollHorizontalTo:(newWidth
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4638
                                             - width
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4639
                                             + margin + margin
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4640
                                             + (gc font widthOf:'  '))
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4641
                ]
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4642
            ].
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4643
            self textChanged.
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4644
        ] ifFalse:[
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4645
            self textChanged "/ textChangedButNoSizeChange
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4646
        ].
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4647
        gc font hasOverlappingCharacters ifTrue:[
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4648
            self invalidateLine:lineNr.
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4649
        ] ifFalse:[
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4650
            self redrawLine:lineNr from:start.
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4651
        ].
4673
575d2d398823 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4666
diff changeset
  4652
    ].
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  4653
4191
8ac20ced2fbf changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4190
diff changeset
  4654
    "Modified: / 09-11-2010 / 13:42:45 / cg"
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4655
!
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
basicDeleteFromLine:startLineNr toLine:endLineNr
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4658
    "delete some lines"
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4659
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4660
    |wasOn nLines|
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4661
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4662
    self checkModificationsAllowed ifFalse:[ ^ self].
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4663
    list isNil ifTrue:[^ self].
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4664
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4665
    wasOn := self hideCursor.
1717
83203096a851 dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  4666
83203096a851 dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  4667
    "/ isnt this the same as:
83203096a851 dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  4668
    "/ self deleteLinesWithoutRedrawFrom:startLineNr to:endLineNr.
4226
a09775d899a6 changed: #basicDeleteFromLine:toLine:
az
parents: 4225
diff changeset
  4669
    startLineNr <= list size ifTrue:[
4771
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  4670
        self basicListRemoveFromIndex:startLineNr toIndex:(endLineNr min:list size).
4226
a09775d899a6 changed: #basicDeleteFromLine:toLine:
az
parents: 4225
diff changeset
  4671
    ].
1717
83203096a851 dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  4672
    "/ TODO: remember old maxwidth of linerange,
83203096a851 dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  4673
    "/ only clear widthOfWidestLine, if this max
83203096a851 dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  4674
    "/ length was (one of) the longest.
83203096a851 dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  4675
    "/ avoids slow delete with huge texts.
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4676
    widthOfWidestLine := nil. "/ i.e. unknown
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4677
    self textChanged.
1717
83203096a851 dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  4678
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4679
    self redrawFromLine:startLineNr.
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4680
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4681
    nLines := list size.
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4682
    (firstLineShown >= nLines) ifTrue:[
4226
a09775d899a6 changed: #basicDeleteFromLine:toLine:
az
parents: 4225
diff changeset
  4683
        self makeLineVisible:nLines
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4684
    ].
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4685
    wasOn ifTrue:[self showCursor].
1717
83203096a851 dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  4686
4226
a09775d899a6 changed: #basicDeleteFromLine:toLine:
az
parents: 4225
diff changeset
  4687
    "Modified: / 10-11-1998 / 23:55:05 / cg"
a09775d899a6 changed: #basicDeleteFromLine:toLine:
az
parents: 4225
diff changeset
  4688
    "Modified: / 18-03-2011 / 18:26:23 / az"
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4689
!
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4690
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4691
basicDeleteLineWithoutRedraw:lineNr
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4692
    "delete line - no redraw;
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4693
     return true, if something was really deleted"
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4694
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4695
    self checkModificationsAllowed ifFalse:[ ^ false].
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4696
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4697
    (list isNil or:[lineNr > list size]) ifTrue:[^ false].
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4698
    list removeIndex:lineNr.
1717
83203096a851 dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  4699
    "/ TODO: remember old maxwidth of linerange,
83203096a851 dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  4700
    "/ only clear widthOfWidestLine, if this max
83203096a851 dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  4701
    "/ length was (one of) the longest.
83203096a851 dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  4702
    "/ avoids slow delete with huge texts.
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4703
    widthOfWidestLine := nil. "/ i.e. unknown
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4704
    self textChanged.
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4705
    ^ true
1717
83203096a851 dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  4706
83203096a851 dont forget widthOfWidestLine information when deleting single
Claus Gittinger <cg@exept.de>
parents: 1688
diff changeset
  4707
    "Modified: / 10.11.1998 / 23:53:24 / cg"
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4708
!
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4709
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4710
basicInsert:aCharacter atLine:lineNr col:colNr
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  4711
    "insert a single character at lineNr/colNr;
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  4712
     set emphasis to character at current position"
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  4713
1929
8e70fb7c9701 fixed handling of italic text when inserting
Claus Gittinger <cg@exept.de>
parents: 1928
diff changeset
  4714
    |line lineSize newLine drawCharacterOnly attribute oldClip x y|
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4715
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4716
    self checkModificationsAllowed ifFalse:[ ^ self].
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4717
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4718
    aCharacter == (Character cr) ifTrue:[
5909
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4719
        self splitLine:lineNr before:colNr.
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4720
        ^ self
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4721
    ].
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  4722
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4723
    drawCharacterOnly := false.
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4724
    self checkForExistingLine:lineNr.
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4725
    line := list at:lineNr.
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4726
    lineSize := line size.
671
f3fe0d8c604d added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents: 666
diff changeset
  4727
3023
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  4728
    self st80EditMode ifFalse:[
5909
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4729
        (self trimBlankLines
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4730
        and:[colNr > lineSize
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4731
        and:[aCharacter == Character space]]) ifTrue:[
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4732
            ^ self
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4733
        ]
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4734
    ].
671
f3fe0d8c604d added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents: 666
diff changeset
  4735
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4736
    (lineSize == 0) ifTrue:[
5909
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4737
        newLine := aCharacter asString species new:colNr.
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4738
        drawCharacterOnly := true
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4739
    ] ifFalse: [
5909
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4740
        (colNr > lineSize) ifTrue: [
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4741
            colNr == (lineSize +1) ifTrue:[
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4742
                attribute := line emphasisAt:lineSize
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4743
            ].
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4744
            newLine := line species new:colNr.
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4745
            newLine replaceFrom:1 to:lineSize with:line startingAt:1.
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4746
            drawCharacterOnly := true
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4747
        ] ifFalse: [
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4748
            attribute := line emphasisAt:colNr.
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4749
            newLine   := line species new:(lineSize + 1).
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4750
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4751
            newLine replaceFrom:1 to:(colNr - 1) with:line startingAt:1.
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4752
            newLine replaceFrom:(colNr + 1) to:(lineSize + 1) with:line startingAt:colNr
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4753
        ]
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4754
    ].
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  4755
2869
48d830f0aea5 insertCharacter: care for wide chars
Claus Gittinger <cg@exept.de>
parents: 2866
diff changeset
  4756
    aCharacter asString bitsPerCharacter > newLine bitsPerCharacter ifTrue:[
5909
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4757
        newLine := aCharacter asString species fromString:newLine.
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4758
        line isText ifTrue:[
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4759
            newLine := newLine asText
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4760
        ]
2869
48d830f0aea5 insertCharacter: care for wide chars
Claus Gittinger <cg@exept.de>
parents: 2866
diff changeset
  4761
    ].
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4762
    newLine at:colNr put:aCharacter.
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  4763
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  4764
    attribute notNil ifTrue:[
5909
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4765
        newLine emphasisAt:colNr put:attribute.
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  4766
    ].
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  4767
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4768
    aCharacter == (Character tab) ifTrue:[
5909
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4769
        newLine := self withTabsExpanded:newLine.
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4770
        drawCharacterOnly := false
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4771
    ].
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  4772
4771
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  4773
    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
  4774
    widthOfWidestLine notNil ifTrue:[
5909
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4775
        widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:newLine).
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4776
    ].
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4777
    self textChanged.
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4778
    shown ifTrue:[
5909
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4779
        "/ care for italic text - in this case, we must also
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4780
        "/ redraw the character before the insertion in order
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4781
        "/ to fix the slanted piece of the character.
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4782
        "/ (but we must clip, to avoid destoying the character before)
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4783
        (newLine notNil and:[newLine isText]) ifTrue:[
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4784
            colNr > 1 ifTrue:[
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4785
                cursorVisibleLine notNil ifTrue:[
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4786
                    oldClip := self clippingRectangleOrNil.
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4787
                    x := (self xOfCol:colNr-1 inVisibleLine:cursorVisibleLine) - viewOrigin x.
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4788
                    y := self yOfVisibleLine:cursorVisibleLine.
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4789
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4790
                    gc font hasOverlappingCharacters ifTrue:[
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4791
                        self invalidateLine:lineNr.
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4792
                    ] ifFalse:[
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4793
                        drawCharacterOnly ifTrue:[
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4794
                            self clippingRectangle:(x@y extent:((gc font width * 2) @ fontHeight)).
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4795
                            self redrawLine:lineNr from:colNr-1 to:colNr
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4796
                        ] ifFalse:[
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4797
                            self clippingRectangle:(x@y extent:((width - x) @ fontHeight)).
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4798
                            self redrawLine:lineNr from:colNr-1
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4799
                        ].
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4800
                        self clippingRectangle:oldClip.
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4801
                    ].
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4802
                ].
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4803
                ^ self.
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4804
            ].
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4805
        ].
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4806
        gc font hasOverlappingCharacters ifTrue:[
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4807
            self invalidateLine:lineNr.
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4808
        ] ifFalse:[
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4809
            drawCharacterOnly ifTrue:[
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4810
                self redrawLine:lineNr col:colNr
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4811
            ] ifFalse:[
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4812
                self redrawLine:lineNr from:colNr
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4813
            ]
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
    ]
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4816
4191
8ac20ced2fbf changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4190
diff changeset
  4817
    "Modified: / 09-11-2010 / 13:43:18 / cg"
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4818
!
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4819
4771
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  4820
basicListAt:lineNr put:newLine
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  4821
    "redefinable for special subclasses (with virtual list)"
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  4822
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  4823
    list at:lineNr put:newLine.
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  4824
!
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  4825
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  4826
basicListRemoveFromIndex:startLineNr toIndex:endLineNr
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  4827
    "redefinable for special subclasses (with virtual list)"
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  4828
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  4829
    list removeFromIndex:startLineNr toIndex:(endLineNr min:list size).
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  4830
!
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  4831
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4832
basicMergeLine:lineNr removeBlanks:removeBlanks
1319
2739903e7a80 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  4833
    "merge line lineNr with line lineNr+1"
2739903e7a80 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  4834
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  4835
    |leftPart rightPart bothParts nextLineNr i|
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  4836
2356
6416beb0f23a backSpace if behond end of text.
Claus Gittinger <cg@exept.de>
parents: 2350
diff changeset
  4837
    (list notNil and:[(list size) >= lineNr]) ifFalse:[
5909
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4838
        "/ empty list or beyond end of text
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4839
        ^ self
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  4840
    ].
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  4841
    leftPart := self listAt:lineNr.
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  4842
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  4843
    leftPart isNil ifTrue:[
5909
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4844
        leftPart := ''.
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4845
        autoIndent ifTrue:[
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4846
            (i := self leftIndentForLine:cursorLine) == 0 ifFalse:[
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4847
                leftPart := String new:i
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4848
            ]
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4849
        ]
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  4850
    ].
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  4851
    self cursorLine:lineNr col:((leftPart size) + 1).
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  4852
    nextLineNr := self validateCursorLine:(lineNr + 1).
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  4853
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  4854
    nextLineNr > (list size) ifFalse:[
5909
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4855
        (rightPart := self listAt:nextLineNr) isNil ifTrue:[
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4856
            rightPart := ''
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4857
        ] ifFalse:[
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4858
            removeBlanks ifTrue:[
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4859
                rightPart := rightPart withoutLeadingSeparators.
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4860
            ]
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4861
        ].
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4862
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4863
        bothParts := leftPart , rightPart.
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4864
        (self trimBlankLines and:[bothParts isBlank]) ifTrue:[bothParts := nil].
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4865
        self basicListAt:lineNr put:bothParts.
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4866
        self redrawLine:lineNr.
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4867
        self deleteLine:nextLineNr
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4868
    ]
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4869
1319
2739903e7a80 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  4870
    "Created: 9.9.1997 / 09:27:38 / cg"
2739903e7a80 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  4871
    "Modified: 9.9.1997 / 09:28:27 / cg"
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4872
!
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4873
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4874
basicReplace:aCharacter atLine:lineNr col:colNr
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4875
    "replace a single character at lineNr/colNr"
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4876
5045
6197bf1337fe class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4988
diff changeset
  4877
    |line lineSize newLineSpecies newLine drawCharacterOnly|
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4878
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4879
    self checkModificationsAllowed ifFalse:[ ^ self].
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4880
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4881
    aCharacter == (Character cr) ifTrue:[
5909
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4882
        ^ self
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4883
    ].
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4884
1558
abf35cc39757 minimize redraw in overwrite-replace;
Claus Gittinger <cg@exept.de>
parents: 1557
diff changeset
  4885
    drawCharacterOnly := true.
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4886
    self checkForExistingLine:lineNr.
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4887
    line := list at:lineNr.
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4888
    lineSize := line size.
671
f3fe0d8c604d added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents: 666
diff changeset
  4889
5909
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4890
    (self trimBlankLines
671
f3fe0d8c604d added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents: 666
diff changeset
  4891
    and:[colNr > lineSize
f3fe0d8c604d added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents: 666
diff changeset
  4892
    and:[aCharacter == Character space]]) ifTrue:[
5909
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4893
        ^ self
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4894
    ].
671
f3fe0d8c604d added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents: 666
diff changeset
  4895
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4896
    (lineSize == 0) ifTrue:[
5909
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4897
        newLine := aCharacter asString species new:colNr.
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4898
    ] ifFalse: [
5045
6197bf1337fe class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4988
diff changeset
  4899
        (aCharacter bitsPerCharacter > line bitsPerCharacter) ifTrue:[ 
5909
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4900
            newLineSpecies := aCharacter stringSpecies
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4901
        ] ifFalse:[
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4902
            newLineSpecies := line species
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4903
        ].
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4904
        newLine := newLineSpecies new:(colNr max:lineSize).
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4905
        newLine replaceFrom:1 to:lineSize with:line startingAt:1.
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4906
    ].
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4907
    newLine at:colNr put:aCharacter.
1558
abf35cc39757 minimize redraw in overwrite-replace;
Claus Gittinger <cg@exept.de>
parents: 1557
diff changeset
  4908
    aCharacter == (Character tab) ifTrue:[
5909
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4909
        newLine := self withTabsExpanded:newLine.
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4910
        drawCharacterOnly := false
1558
abf35cc39757 minimize redraw in overwrite-replace;
Claus Gittinger <cg@exept.de>
parents: 1557
diff changeset
  4911
    ].
4771
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  4912
    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
  4913
    widthOfWidestLine notNil ifTrue:[
5909
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4914
        widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:newLine).
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4915
    ].
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4916
    self textChanged.
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4917
    shown ifTrue:[
5909
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4918
        gc font hasOverlappingCharacters ifTrue:[
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4919
            self invalidateLine:lineNr.
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4920
        ] ifFalse:[
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4921
            drawCharacterOnly ifTrue:[
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4922
                self redrawLine:lineNr col:colNr
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4923
            ] ifFalse:[
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4924
                self redrawLine:lineNr from:colNr
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4925
            ]
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4926
        ]
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4927
    ]
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  4928
4190
d79217c1317d changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4189
diff changeset
  4929
    "Created: / 06-03-1996 / 12:29:20 / cg"
4191
8ac20ced2fbf changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4190
diff changeset
  4930
    "Modified: / 09-11-2010 / 13:42:54 / cg"
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  4931
!
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  4932
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4933
basicReplaceString:aString atLine:lineNr col:colNr
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4934
    "replace multiple characters starting at lineNr/colNr.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4935
     This is not prepared to encounter special chars (except TAB)
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4936
     in the string."
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4937
5045
6197bf1337fe class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4988
diff changeset
  4938
    |line lineSize newLine newLineSpecies endCol|
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4939
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4940
    self checkModificationsAllowed ifFalse:[ ^ self].
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4941
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4942
    self checkForExistingLine:lineNr.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4943
    line := list at:lineNr.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4944
    lineSize := line size.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4945
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4946
    endCol := colNr + aString size - 1.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4947
    (lineSize == 0) ifTrue:[
4190
d79217c1317d changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4189
diff changeset
  4948
        newLine := aString species new:endCol.
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4949
    ] ifFalse: [
5571
b2ec50dc48ca #BUGFIX
Stefan Vogel <sv@exept.de>
parents: 5560
diff changeset
  4950
        (aString bitsPerCharacter > line bitsPerCharacter) ifTrue:[ 
5045
6197bf1337fe class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4988
diff changeset
  4951
            newLineSpecies := aString stringSpecies
6197bf1337fe class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4988
diff changeset
  4952
        ] ifFalse:[
6197bf1337fe class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4988
diff changeset
  4953
            newLineSpecies := line species
6197bf1337fe class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4988
diff changeset
  4954
        ].
6197bf1337fe class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4988
diff changeset
  4955
6197bf1337fe class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4988
diff changeset
  4956
        newLine := newLineSpecies new:(endCol max:lineSize).
6197bf1337fe class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4988
diff changeset
  4957
        newLine replaceFrom:1 to:lineSize with:line startingAt:1.
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4958
    ].
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4959
    newLine replaceFrom:colNr with:aString.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4960
    (aString includes:(Character tab)) ifTrue:[
4190
d79217c1317d changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4189
diff changeset
  4961
        newLine := self withTabsExpanded:newLine.
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4962
    ].
4771
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  4963
    self basicListAt:lineNr put:(newLine ifNil:[newLine] ifNotNil:[newLine asSingleByteStringIfPossible]).
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4964
    widthOfWidestLine notNil ifTrue:[
4458
f3421ef26d82 changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4451
diff changeset
  4965
        widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:newLine).
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4966
    ].
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4967
    self textChanged.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4968
    shown ifTrue:[
4889
3ee5b37416a1 class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 4884
diff changeset
  4969
        gc font hasOverlappingCharacters ifTrue:[
4190
d79217c1317d changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4189
diff changeset
  4970
            self invalidateLine:lineNr.
d79217c1317d changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4189
diff changeset
  4971
        ] ifFalse:[
d79217c1317d changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4189
diff changeset
  4972
            self redrawLine:lineNr from:colNr
d79217c1317d changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4189
diff changeset
  4973
        ]
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4974
    ]
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4975
4190
d79217c1317d changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4189
diff changeset
  4976
    "Created: / 11-06-1998 / 10:38:32 / cg"
4191
8ac20ced2fbf changed:5 methods
Claus Gittinger <cg@exept.de>
parents: 4190
diff changeset
  4977
    "Modified: / 09-11-2010 / 13:42:56 / cg"
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4978
!
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  4979
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4980
basicSplitLine:lineNr before:colNr
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4981
    "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
  4982
     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
  4983
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  4984
    |line lineSize leftRest rightRest visLine w h mustWait
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4985
     srcY    "{ Class: SmallInteger }" |
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  4986
3027
0dd9657b8033 *** empty log message ***
ca
parents: 3024
diff changeset
  4987
    list isNil ifTrue:[ ^ self ].
0dd9657b8033 *** empty log message ***
ca
parents: 3024
diff changeset
  4988
    lineNr > (list size) ifTrue:[ ^ self ].
0dd9657b8033 *** empty log message ***
ca
parents: 3024
diff changeset
  4989
0dd9657b8033 *** empty log message ***
ca
parents: 3024
diff changeset
  4990
    (colNr == 1) ifTrue:[
5909
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4991
        self nonUndoableDo:[
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4992
            self insertLine:nil before:lineNr.
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4993
        ].
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4994
        ^ self
3027
0dd9657b8033 *** empty log message ***
ca
parents: 3024
diff changeset
  4995
    ].
0dd9657b8033 *** empty log message ***
ca
parents: 3024
diff changeset
  4996
0dd9657b8033 *** empty log message ***
ca
parents: 3024
diff changeset
  4997
    line := list at:lineNr.
4199
cd7069b3bc33 comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents: 4192
diff changeset
  4998
    line notNil ifTrue:[
5909
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  4999
        lineSize := line size.
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  5000
        (colNr <= lineSize) ifTrue:[
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  5001
            rightRest := line copyFrom:colNr to:lineSize.
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  5002
            (colNr > 1) ifTrue:[
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  5003
                leftRest := line copyTo:(colNr - 1)
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  5004
            ]
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
            leftRest := line
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  5007
        ]
3027
0dd9657b8033 *** empty log message ***
ca
parents: 3024
diff changeset
  5008
    ].
0dd9657b8033 *** empty log message ***
ca
parents: 3024
diff changeset
  5009
    leftRest notNil ifTrue:[
5909
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  5010
        (self trimBlankLines and:[leftRest isBlank]) ifTrue:[leftRest := nil]
3027
0dd9657b8033 *** empty log message ***
ca
parents: 3024
diff changeset
  5011
    ].
4771
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  5012
    self basicListAt:lineNr put:leftRest.
3027
0dd9657b8033 *** empty log message ***
ca
parents: 3024
diff changeset
  5013
    self nonUndoableDo:[
5909
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  5014
        self withoutRedrawInsertLine:rightRest before:(lineNr + 1).
3027
0dd9657b8033 *** empty log message ***
ca
parents: 3024
diff changeset
  5015
    ].
0dd9657b8033 *** empty log message ***
ca
parents: 3024
diff changeset
  5016
    visLine := self listLineToVisibleLine:(lineNr).
0dd9657b8033 *** empty log message ***
ca
parents: 3024
diff changeset
  5017
    visLine notNil ifTrue:[
5909
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  5018
        w := self widthForScrollBetween:lineNr
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  5019
                                    and:(firstLineShown + nLinesShown).
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  5020
        srcY := topMargin + (visLine * fontHeight).
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  5021
        h := ((nLinesShown - visLine - 1) * fontHeight).
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  5022
        (mustWait := (w > 0 and:[h > 0])) ifTrue:[
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  5023
            self catchExpose.
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  5024
            self
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  5025
                copyFrom:self
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  5026
                x:textStartLeft y:srcY
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  5027
                toX:textStartLeft y:(srcY + fontHeight)
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  5028
                width:w
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  5029
                height:((nLinesShown - visLine - 1) * fontHeight)
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  5030
                async:true.
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  5031
        ].
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  5032
        self redrawLine:lineNr.
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  5033
        self redrawLine:(lineNr + 1).
9895cf95cd00 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5904
diff changeset
  5034
        mustWait ifTrue:[self waitForExpose]
3027
0dd9657b8033 *** empty log message ***
ca
parents: 3024
diff changeset
  5035
    ].
0dd9657b8033 *** empty log message ***
ca
parents: 3024
diff changeset
  5036
    widthOfWidestLine := nil. "/ unknown
0dd9657b8033 *** empty log message ***
ca
parents: 3024
diff changeset
  5037
    self textChanged.
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5038
4199
cd7069b3bc33 comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents: 4192
diff changeset
  5039
    "Modified: / 06-12-2010 / 13:12:55 / cg"
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5040
!
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5041
2954
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  5042
basicWithoutRedrawInsertLines:lines from:start to:end before:lineNr
4328
ea91d179b5f0 changed:
Claus Gittinger <cg@exept.de>
parents: 4289
diff changeset
  5043
    "insert a bunch of lines before line lineNr; the view is not redrawn.
ea91d179b5f0 changed:
Claus Gittinger <cg@exept.de>
parents: 4289
diff changeset
  5044
     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
  5045
     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
  5046
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  5047
    |newLine newLines nLines|
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  5048
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  5049
    nLines := end - start + 1.
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  5050
    newLines := Array new:(lines size).
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  5051
    start to:end do:[:index |
4328
ea91d179b5f0 changed:
Claus Gittinger <cg@exept.de>
parents: 4289
diff changeset
  5052
        newLine := lines at:index.
ea91d179b5f0 changed:
Claus Gittinger <cg@exept.de>
parents: 4289
diff changeset
  5053
        newLine notNil ifTrue:[
ea91d179b5f0 changed:
Claus Gittinger <cg@exept.de>
parents: 4289
diff changeset
  5054
            newLine isString ifTrue:[
ea91d179b5f0 changed:
Claus Gittinger <cg@exept.de>
parents: 4289
diff changeset
  5055
                newLine isBlank ifTrue:[
ea91d179b5f0 changed:
Claus Gittinger <cg@exept.de>
parents: 4289
diff changeset
  5056
                    newLine := nil
ea91d179b5f0 changed:
Claus Gittinger <cg@exept.de>
parents: 4289
diff changeset
  5057
                ] ifFalse:[
ea91d179b5f0 changed:
Claus Gittinger <cg@exept.de>
parents: 4289
diff changeset
  5058
                    (newLine includes:(Character tab)) ifTrue:[
ea91d179b5f0 changed:
Claus Gittinger <cg@exept.de>
parents: 4289
diff changeset
  5059
                        newLine := self withTabs:(ListView tab8Positions) expand:newLine
ea91d179b5f0 changed:
Claus Gittinger <cg@exept.de>
parents: 4289
diff changeset
  5060
                    ]
ea91d179b5f0 changed:
Claus Gittinger <cg@exept.de>
parents: 4289
diff changeset
  5061
                ]
ea91d179b5f0 changed:
Claus Gittinger <cg@exept.de>
parents: 4289
diff changeset
  5062
            ]
ea91d179b5f0 changed:
Claus Gittinger <cg@exept.de>
parents: 4289
diff changeset
  5063
        ].
ea91d179b5f0 changed:
Claus Gittinger <cg@exept.de>
parents: 4289
diff changeset
  5064
        newLines at:index put:newLine
2954
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  5065
    ].
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  5066
    list isNil ifTrue: [
4328
ea91d179b5f0 changed:
Claus Gittinger <cg@exept.de>
parents: 4289
diff changeset
  5067
        list := StringCollection new:(lineNr + nLines + 1)
2954
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  5068
    ] ifFalse: [
4328
ea91d179b5f0 changed:
Claus Gittinger <cg@exept.de>
parents: 4289
diff changeset
  5069
        list grow:((list size + nLines) max:(lineNr + nLines - 1))
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  5070
    ].
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  5071
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  5072
    "I have changed 'replaceFrom:to:with:startingAt:' to correctly handle
2954
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  5073
     overlapping copy - if it didn't, we had to use:"
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  5074
"
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  5075
    index := list size.
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  5076
    [index > lineNr] whileTrue: [
4328
ea91d179b5f0 changed:
Claus Gittinger <cg@exept.de>
parents: 4289
diff changeset
  5077
        pIndex := index - 1.
ea91d179b5f0 changed:
Claus Gittinger <cg@exept.de>
parents: 4289
diff changeset
  5078
        list at:index put:(list at:pIndex).
ea91d179b5f0 changed:
Claus Gittinger <cg@exept.de>
parents: 4289
diff changeset
  5079
        index := pIndex
2954
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  5080
    ].
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  5081
"
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  5082
    list replaceFrom:(lineNr + nLines) to:(list size) with:list startingAt:lineNr.
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  5083
    list replaceFrom:lineNr to:(lineNr + nLines - 1) with:newLines startingAt:start.
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  5084
    self contentsChanged
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  5085
4328
ea91d179b5f0 changed:
Claus Gittinger <cg@exept.de>
parents: 4289
diff changeset
  5086
    "Modified: / 07-10-2011 / 15:55:18 / cg"
2954
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  5087
!
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  5088
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  5089
basicWithoutRedrawInsertStringWithoutCRs:aString atLine:lineNr col:colNr
4328
ea91d179b5f0 changed:
Claus Gittinger <cg@exept.de>
parents: 4289
diff changeset
  5090
    "insert aString (which has no crs) at lineNr/colNr.
ea91d179b5f0 changed:
Claus Gittinger <cg@exept.de>
parents: 4289
diff changeset
  5091
     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
  5092
     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
  5093
4360
fe77e479d95a comment/format in:
Claus Gittinger <cg@exept.de>
parents: 4328
diff changeset
  5094
    |isText strLen line lineSize newLine stringType sz lineCharWidth stringCharWidth|
2954
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  5095
4623
22047f737cb0 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4609
diff changeset
  5096
    (aString isNil) ifTrue:[ ^ self].
2954
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  5097
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  5098
    strLen := aString size.
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  5099
    self checkForExistingLine:lineNr.
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  5100
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  5101
    stringType := aString string species.
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  5102
    isText     := aString isText.
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  5103
    line       := list at:lineNr.
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  5104
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  5105
    line notNil ifTrue:[
4328
ea91d179b5f0 changed:
Claus Gittinger <cg@exept.de>
parents: 4289
diff changeset
  5106
        lineSize := line size.
ea91d179b5f0 changed:
Claus Gittinger <cg@exept.de>
parents: 4289
diff changeset
  5107
        line isString ifFalse:[
ea91d179b5f0 changed:
Claus Gittinger <cg@exept.de>
parents: 4289
diff changeset
  5108
            stringType := line species
ea91d179b5f0 changed:
Claus Gittinger <cg@exept.de>
parents: 4289
diff changeset
  5109
        ] ifTrue:[
4360
fe77e479d95a comment/format in:
Claus Gittinger <cg@exept.de>
parents: 4328
diff changeset
  5110
            lineCharWidth := line bitsPerCharacter.
fe77e479d95a comment/format in:
Claus Gittinger <cg@exept.de>
parents: 4328
diff changeset
  5111
            stringCharWidth := aString bitsPerCharacter.
fe77e479d95a comment/format in:
Claus Gittinger <cg@exept.de>
parents: 4328
diff changeset
  5112
            lineCharWidth > stringCharWidth ifTrue:[
4328
ea91d179b5f0 changed:
Claus Gittinger <cg@exept.de>
parents: 4289
diff changeset
  5113
                stringType := line string species
4360
fe77e479d95a comment/format in:
Claus Gittinger <cg@exept.de>
parents: 4328
diff changeset
  5114
            ] ifFalse:[
fe77e479d95a comment/format in:
Claus Gittinger <cg@exept.de>
parents: 4328
diff changeset
  5115
                stringCharWidth > lineCharWidth ifTrue:[
fe77e479d95a comment/format in:
Claus Gittinger <cg@exept.de>
parents: 4328
diff changeset
  5116
                    stringType := aString string species
fe77e479d95a comment/format in:
Claus Gittinger <cg@exept.de>
parents: 4328
diff changeset
  5117
                ]
4328
ea91d179b5f0 changed:
Claus Gittinger <cg@exept.de>
parents: 4289
diff changeset
  5118
            ].
ea91d179b5f0 changed:
Claus Gittinger <cg@exept.de>
parents: 4289
diff changeset
  5119
            line isText ifTrue:[ isText := true ]
ea91d179b5f0 changed:
Claus Gittinger <cg@exept.de>
parents: 4289
diff changeset
  5120
        ].
2954
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  5121
    ] ifFalse:[
4328
ea91d179b5f0 changed:
Claus Gittinger <cg@exept.de>
parents: 4289
diff changeset
  5122
        lineSize := 0
2954
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  5123
    ].
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  5124
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  5125
    ((colNr == 1) and:[lineSize == 0]) ifTrue: [
4328
ea91d179b5f0 changed:
Claus Gittinger <cg@exept.de>
parents: 4289
diff changeset
  5126
        newLine := aString
2954
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  5127
    ] ifFalse:[
4328
ea91d179b5f0 changed:
Claus Gittinger <cg@exept.de>
parents: 4289
diff changeset
  5128
        (lineSize == 0 or:[colNr > lineSize]) ifTrue: [
ea91d179b5f0 changed:
Claus Gittinger <cg@exept.de>
parents: 4289
diff changeset
  5129
            sz := colNr + strLen - 1
ea91d179b5f0 changed:
Claus Gittinger <cg@exept.de>
parents: 4289
diff changeset
  5130
        ] ifFalse:[
ea91d179b5f0 changed:
Claus Gittinger <cg@exept.de>
parents: 4289
diff changeset
  5131
            sz := lineSize + strLen
ea91d179b5f0 changed:
Claus Gittinger <cg@exept.de>
parents: 4289
diff changeset
  5132
        ].
ea91d179b5f0 changed:
Claus Gittinger <cg@exept.de>
parents: 4289
diff changeset
  5133
4360
fe77e479d95a comment/format in:
Claus Gittinger <cg@exept.de>
parents: 4328
diff changeset
  5134
        newLine := stringType new:sz.
fe77e479d95a comment/format in:
Claus Gittinger <cg@exept.de>
parents: 4328
diff changeset
  5135
        isText ifTrue:[
fe77e479d95a comment/format in:
Claus Gittinger <cg@exept.de>
parents: 4328
diff changeset
  5136
            newLine := Text string:newLine
4328
ea91d179b5f0 changed:
Claus Gittinger <cg@exept.de>
parents: 4289
diff changeset
  5137
        ].
ea91d179b5f0 changed:
Claus Gittinger <cg@exept.de>
parents: 4289
diff changeset
  5138
ea91d179b5f0 changed:
Claus Gittinger <cg@exept.de>
parents: 4289
diff changeset
  5139
        (lineSize ~~ 0) ifTrue: [
ea91d179b5f0 changed:
Claus Gittinger <cg@exept.de>
parents: 4289
diff changeset
  5140
            (colNr > lineSize) ifTrue: [
ea91d179b5f0 changed:
Claus Gittinger <cg@exept.de>
parents: 4289
diff changeset
  5141
                newLine replaceFrom:1 to:lineSize with:line startingAt:1
ea91d179b5f0 changed:
Claus Gittinger <cg@exept.de>
parents: 4289
diff changeset
  5142
            ] ifFalse: [
ea91d179b5f0 changed:
Claus Gittinger <cg@exept.de>
parents: 4289
diff changeset
  5143
                newLine replaceFrom:1 to:(colNr - 1) with:line startingAt:1.
ea91d179b5f0 changed:
Claus Gittinger <cg@exept.de>
parents: 4289
diff changeset
  5144
                newLine replaceFrom:(colNr + strLen) to:(lineSize + strLen) with:line startingAt:colNr
ea91d179b5f0 changed:
Claus Gittinger <cg@exept.de>
parents: 4289
diff changeset
  5145
            ]
ea91d179b5f0 changed:
Claus Gittinger <cg@exept.de>
parents: 4289
diff changeset
  5146
        ].
ea91d179b5f0 changed:
Claus Gittinger <cg@exept.de>
parents: 4289
diff changeset
  5147
        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
  5148
    ].
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
    (aString includes:(Character tab)) ifTrue:[
4328
ea91d179b5f0 changed:
Claus Gittinger <cg@exept.de>
parents: 4289
diff changeset
  5151
        newLine := self withTabs:(ListView tab8Positions) expand:newLine
2954
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  5152
    ].
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  5153
4771
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  5154
    self basicListAt:lineNr put:(newLine ifNil:[newLine] ifNotNil:[newLine asSingleByteStringIfPossible]).
2954
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  5155
    widthOfWidestLine notNil ifTrue:[
4328
ea91d179b5f0 changed:
Claus Gittinger <cg@exept.de>
parents: 4289
diff changeset
  5156
        widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:newLine).
2954
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  5157
    ].
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  5158
    self textChanged.
65a518fe6eb6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2952
diff changeset
  5159
4360
fe77e479d95a comment/format in:
Claus Gittinger <cg@exept.de>
parents: 4328
diff changeset
  5160
    "Modified: / 25-01-2012 / 00:37:29 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5161
! !
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5162
2752
5650a9ab5935 method category rename
Claus Gittinger <cg@exept.de>
parents: 2744
diff changeset
  5163
!EditTextView methodsFor:'event handling'!
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5164
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5165
buttonPress:button x:x y:y
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5166
    "hide the cursor when button is activated"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5167
5216
8d6eef5d09c3 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5194
diff changeset
  5168
    hasKeyboardFocus := true.   "/ cg: why is this needed?
2589
62794ae04446 support drop
ca
parents: 2580
diff changeset
  5169
    dragIsActive := false.
62794ae04446 support drop
ca
parents: 2580
diff changeset
  5170
4801
69a5bff7b5cd Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4786
diff changeset
  5171
    completionSupport notNil ifTrue:[ 
4696
428c8bc44cfb refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents: 4694
diff changeset
  5172
        "/ also give that guy a chance to close its popup view
4801
69a5bff7b5cd Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4786
diff changeset
  5173
        completionSupport buttonPress:button x:x y:y
4696
428c8bc44cfb refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents: 4694
diff changeset
  5174
    ].
4609
8b3eb80d04d0 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4595
diff changeset
  5175
1817
1a9e22f755c8 show non-focus cursor when disabled or readOnly
Claus Gittinger <cg@exept.de>
parents: 1816
diff changeset
  5176
    cursorShown ifTrue: [
3915
737e276852c8 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3907
diff changeset
  5177
        self drawCursor
737e276852c8 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3907
diff changeset
  5178
    ].
737e276852c8 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3907
diff changeset
  5179
4420
8f0164295ef8 changed:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4414
diff changeset
  5180
    "On X11, be nice and paste PRIMARY when middle click. 
8f0164295ef8 changed:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4414
diff changeset
  5181
     Note, that middle button on X11 is translated to button
8f0164295ef8 changed:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4414
diff changeset
  5182
     128 in Smalltalk/X - see XWorkstation class>>initializeConstants"
5643
921578f80870 device access
Claus Gittinger <cg@exept.de>
parents: 5593
diff changeset
  5183
    (button == #paste and:[device platformName == #X11]) ifTrue:[
4420
8f0164295ef8 changed:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4414
diff changeset
  5184
        self undoableDo:[
8f0164295ef8 changed:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4414
diff changeset
  5185
            self paste: (self getClipboardText:#selection).
8f0164295ef8 changed:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4414
diff changeset
  5186
        ].
8f0164295ef8 changed:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4414
diff changeset
  5187
        ^self.
8f0164295ef8 changed:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4414
diff changeset
  5188
    ].
8f0164295ef8 changed:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4414
diff changeset
  5189
3915
737e276852c8 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3907
diff changeset
  5190
    (button == 1) ifTrue:[
737e276852c8 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3907
diff changeset
  5191
        self hideCursor
737e276852c8 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3907
diff changeset
  5192
    ].
737e276852c8 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3907
diff changeset
  5193
"/ some very old code from times, when a right-click was a paste in X11
737e276852c8 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3907
diff changeset
  5194
"/
737e276852c8 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3907
diff changeset
  5195
"/    (button == #paste) ifTrue:[
737e276852c8 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3907
diff changeset
  5196
"/        self pasteOrReplace.
737e276852c8 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3907
diff changeset
  5197
"/        ^ self
737e276852c8 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3907
diff changeset
  5198
"/    ].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5199
    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
  5200
4420
8f0164295ef8 changed:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4414
diff changeset
  5201
    "Modified: / 23-03-1999 / 13:51:40 / cg"
8f0164295ef8 changed:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4414
diff changeset
  5202
    "Modified (comment): / 17-04-2012 / 21:02:25 / Jan Vrany <jan.vrany@fit.cvut.cz>"
121
claus
parents: 118
diff changeset
  5203
!
claus
parents: 118
diff changeset
  5204
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5205
buttonRelease:button x:x y:y
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5206
    "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
  5207
3789
a9b4805e0754 when clicking on a character, position the cursor on the next
Claus Gittinger <cg@exept.de>
parents: 3788
diff changeset
  5208
    |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
  5209
3915
737e276852c8 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 3907
diff changeset
  5210
    (button == 1) ifTrue:[
5882
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5211
        typeOfSelection := nil.
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5212
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5213
        dragIsActive ifTrue:[
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5214
            self unselect
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5215
        ].
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5216
        selectionStartLine isNil ifTrue:[
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5217
            clickCol notNil ifTrue:[
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5218
                self cursorMovementAllowed ifTrue:[
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5219
                    newCursorCol := clickCol.
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5220
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5221
                    cursorType ~~ #block ifTrue:[
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5222
                        clickPos notNil ifTrue:[
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5223
                            "/ we do something special, if the text-cursor's type is not a block-cursor
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5224
                            "/ (i.e. if its an ibeam).
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5225
                            "/ adjust clickCol if the user clicked in the right third of a character.
3790
7f4d267cf342 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3789
diff changeset
  5226
                            x1 := self xOfCol:clickCol inVisibleLine:clickLine.  
5882
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5227
                            x2 := self xOfCol:clickCol+1 inVisibleLine:clickLine.
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5228
                            x2_3 := x1 + ((x2-x1) * (2/3)).
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5229
                            (clickPos x >= x2_3) ifTrue:[ newCursorCol := clickCol+1 ].
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5230
                        ].
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5231
                    ].
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5232
                    "/ the following fixes the ugly select behavior when double clicking on
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5233
                    "/ a partially visible last line (where the first click used to
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5234
                    "/ scroll the text so that the second click was handled on another
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5235
                    "/ line. An alternative (possibly better) solution would be to
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5236
                    "/ remember the last click position and adjust in the double click
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5237
                    "/ event handling (i.e. subtract the number of scrolled lines in between)
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5238
                    "/ Time will show, if this hack works.
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5239
                    clickLine >= (self lastLineShown -1 ) ifTrue:[
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5240
                        self cursorLine:clickLine col:newCursorCol makeVisible:false.
5057
990eb60b7dbe class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5056
diff changeset
  5241
                        Processor 
5882
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5242
                            addTimedBlock:[self sensor pushUserEvent:#makeCursorVisible for:self]
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5243
                            after:0.3 seconds.
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5244
                    ] ifFalse:[
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5245
                        self cursorLine:clickLine col:newCursorCol.
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5246
                    ].
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5247
                ].
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5248
                true "self hadSelectionBeforeClick not" ifTrue:[
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5249
                    list notEmptyOrNil ifTrue:[
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5250
                        UserPreferences current selectAllWhenClickingBeyondEnd ifTrue:[
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5251
                            (clickLine >= list size) ifTrue:[
4396
7820ce5cac3d changed: #buttonRelease:x:y:
Claus Gittinger <cg@exept.de>
parents: 4394
diff changeset
  5252
                                (clickLine > (self list size + 2) 
5882
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5253
                                or:[ clickCol > (list last size + 5) ]) ifTrue:[
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5254
                                    self selectAll
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5255
                                ].
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5256
                            ].
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5257
                        ]
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5258
                    ]
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5259
                ]
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5260
            ]
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5261
        ] ifFalse:[
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5262
            lastStringFromReplaceForNextSearch := nil.  "new selection invalidates remembered string"
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5263
        ].
137955a00e20 #OTHER by mawalch
mawalch
parents: 5860
diff changeset
  5264
        self showCursor
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
    super buttonRelease:button x:x y:y
1580
d30e562bea15 allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
  5267
4396
7820ce5cac3d changed: #buttonRelease:x:y:
Claus Gittinger <cg@exept.de>
parents: 4394
diff changeset
  5268
    "Modified: / 07-03-2012 / 18:48:37 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5269
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5270
2580
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  5271
cursorKeyPress:key shifted:shifted
4492
088b5fba29d0 changed: #keyPress:x:y:view:
Claus Gittinger <cg@exept.de>
parents: 4484
diff changeset
  5272
    <resource: #keyboard (#CursorRight #CursorDown #CursorUp #CursorDown)>
088b5fba29d0 changed: #keyPress:x:y:view:
Claus Gittinger <cg@exept.de>
parents: 4484
diff changeset
  5273
4844
269a12794578 Selection refactoring, part 3: support for paste-cursordown-paste
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4843
diff changeset
  5274
    | n oldTypeOfSelection |
269a12794578 Selection refactoring, part 3: support for paste-cursordown-paste
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4843
diff changeset
  5275
269a12794578 Selection refactoring, part 3: support for paste-cursordown-paste
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4843
diff changeset
  5276
    oldTypeOfSelection := typeOfSelection.
2730
61a2f1981ac6 Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents: 2725
diff changeset
  5277
2606
6a3ab90d339f redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents: 2599
diff changeset
  5278
    self changeTypeOfSelectionTo:nil.
2580
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  5279
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  5280
    (key == #CursorRight) ifTrue:[
4100
3fbb7392a6e1 changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents: 4097
diff changeset
  5281
        (shifted and:[selectionStartLine isNil]) ifTrue:[
3fbb7392a6e1 changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents: 4097
diff changeset
  5282
            selectionStartLine := selectionEndLine := clickStartLine := cursorLine.
3fbb7392a6e1 changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents: 4097
diff changeset
  5283
            selectionStartCol := selectionEndCol := clickStartCol := cursorCol.
4841
4fca96a61d42 Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4674
diff changeset
  5284
            cursorCol := cursorCol + 1.
4100
3fbb7392a6e1 changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents: 4097
diff changeset
  5285
            expandingTop := false.
3fbb7392a6e1 changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents: 4097
diff changeset
  5286
            self validateNewSelection.
4420
8f0164295ef8 changed:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4414
diff changeset
  5287
            self setPrimarySelection.
4100
3fbb7392a6e1 changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents: 4097
diff changeset
  5288
            self selectionChanged.
3fbb7392a6e1 changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents: 4097
diff changeset
  5289
            self redrawLine:selectionStartLine.
3fbb7392a6e1 changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents: 4097
diff changeset
  5290
            ^ self.
3fbb7392a6e1 changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents: 4097
diff changeset
  5291
        ].
3fbb7392a6e1 changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents: 4097
diff changeset
  5292
4841
4fca96a61d42 Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4674
diff changeset
  5293
        self cursorMovementAllowed ifTrue:[
4fca96a61d42 Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4674
diff changeset
  5294
            shifted ifTrue:[
4fca96a61d42 Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4674
diff changeset
  5295
                self addToSelectionAfter:[ self cursorRight ]
4fca96a61d42 Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4674
diff changeset
  5296
            ] ifFalse:[
4844
269a12794578 Selection refactoring, part 3: support for paste-cursordown-paste
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4843
diff changeset
  5297
                "/ Compensate for Claus paste-cursordown-paste feature.
269a12794578 Selection refactoring, part 3: support for paste-cursordown-paste
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4843
diff changeset
  5298
                "/ Right after paste the cursor is at the beginning of the
269a12794578 Selection refactoring, part 3: support for paste-cursordown-paste
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4843
diff changeset
  5299
                "/ selection. But if immediately after paste user moves cursor right
269a12794578 Selection refactoring, part 3: support for paste-cursordown-paste
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4843
diff changeset
  5300
                "/ (but without shift!!!!!!), she probably wants to move past the 
269a12794578 Selection refactoring, part 3: support for paste-cursordown-paste
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4843
diff changeset
  5301
                "/ pasted text, not into it. This is how every other editor behaves.
269a12794578 Selection refactoring, part 3: support for paste-cursordown-paste
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4843
diff changeset
  5302
                oldTypeOfSelection == #paste ifTrue:[
269a12794578 Selection refactoring, part 3: support for paste-cursordown-paste
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4843
diff changeset
  5303
                    cursorLine := selectionEndLine.
269a12794578 Selection refactoring, part 3: support for paste-cursordown-paste
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4843
diff changeset
  5304
                    cursorCol := selectionEndCol + 1.
4100
3fbb7392a6e1 changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents: 4097
diff changeset
  5305
                ].
4975
bee454945bf7 Bugfix for cursor position after non-shifter cursor key press while having selection.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4974
diff changeset
  5306
bee454945bf7 Bugfix for cursor position after non-shifter cursor key press while having selection.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4974
diff changeset
  5307
                "/ If there's selection, unselect and move cursor
bee454945bf7 Bugfix for cursor position after non-shifter cursor key press while having selection.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4974
diff changeset
  5308
                "/ to the end of selection.
bee454945bf7 Bugfix for cursor position after non-shifter cursor key press while having selection.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4974
diff changeset
  5309
                self hasSelection ifTrue:[ 
bee454945bf7 Bugfix for cursor position after non-shifter cursor key press while having selection.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4974
diff changeset
  5310
                    self setCursorLine: selectionEndLine.
bee454945bf7 Bugfix for cursor position after non-shifter cursor key press while having selection.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4974
diff changeset
  5311
                    self setCursorCol: selectionEndCol + 1.
bee454945bf7 Bugfix for cursor position after non-shifter cursor key press while having selection.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4974
diff changeset
  5312
                    self unselect; makeCursorVisible.
bee454945bf7 Bugfix for cursor position after non-shifter cursor key press while having selection.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4974
diff changeset
  5313
                    ^ self.
4100
3fbb7392a6e1 changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents: 4097
diff changeset
  5314
                ].
3fbb7392a6e1 changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents: 4097
diff changeset
  5315
                self unselect; makeCursorVisible.
4841
4fca96a61d42 Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4674
diff changeset
  5316
                self cursorRight.
4100
3fbb7392a6e1 changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents: 4097
diff changeset
  5317
            ].
3fbb7392a6e1 changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents: 4097
diff changeset
  5318
        ].
3fbb7392a6e1 changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents: 4097
diff changeset
  5319
        ^ self
2580
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  5320
    ].
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  5321
    (key == #CursorDown) ifTrue:[
4100
3fbb7392a6e1 changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents: 4097
diff changeset
  5322
        (shifted and:[selectionStartLine isNil]) ifTrue:[
3fbb7392a6e1 changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents: 4097
diff changeset
  5323
            selectionStartLine := clickStartLine := cursorLine. selectionEndLine := cursorLine + 1.
4841
4fca96a61d42 Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4674
diff changeset
  5324
            selectionStartCol := clickStartCol := cursorCol.
4fca96a61d42 Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4674
diff changeset
  5325
            selectionEndCol := cursorCol - 1.
4970
36ec8c9fde52 Fix for issue #36.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4969
diff changeset
  5326
"/            selectionEndCol == 1 ifTrue:[
36ec8c9fde52 Fix for issue #36.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4969
diff changeset
  5327
"/                selectionEndCol := 0.
36ec8c9fde52 Fix for issue #36.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4969
diff changeset
  5328
"/            ].
4841
4fca96a61d42 Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4674
diff changeset
  5329
            self setCursorLine: cursorLine + 1.
4100
3fbb7392a6e1 changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents: 4097
diff changeset
  5330
            self validateNewSelection.
3fbb7392a6e1 changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents: 4097
diff changeset
  5331
            self selectionChanged.
3fbb7392a6e1 changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents: 4097
diff changeset
  5332
            self redrawLine:selectionStartLine.
3fbb7392a6e1 changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents: 4097
diff changeset
  5333
            expandingTop := false.
3fbb7392a6e1 changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents: 4097
diff changeset
  5334
            self redrawLine:selectionEndLine.
3fbb7392a6e1 changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents: 4097
diff changeset
  5335
            ^ self
3fbb7392a6e1 changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents: 4097
diff changeset
  5336
        ].
3fbb7392a6e1 changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents: 4097
diff changeset
  5337
3fbb7392a6e1 changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents: 4097
diff changeset
  5338
        selectionStartLine notNil ifTrue:[
3fbb7392a6e1 changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents: 4097
diff changeset
  5339
            self cursorMovementAllowed ifTrue:[
3fbb7392a6e1 changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents: 4097
diff changeset
  5340
                "/
3fbb7392a6e1 changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents: 4097
diff changeset
  5341
                "/ treat the whole selection as cursor
3fbb7392a6e1 changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents: 4097
diff changeset
  5342
                "/
4841
4fca96a61d42 Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4674
diff changeset
  5343
"/                self setCursorLine:(selectionEndLine ? selectionStartLine).
4fca96a61d42 Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4674
diff changeset
  5344
"/                self setCursorCol:selectionStartCol.
4fca96a61d42 Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4674
diff changeset
  5345
"/                (cursorCol == 0 or:[selectionEndCol == 0]) ifTrue:[
4fca96a61d42 Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4674
diff changeset
  5346
"/                    self setCursorCol:1.
4fca96a61d42 Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4674
diff changeset
  5347
"/                    self setCursorLine:(cursorLine - 1).
4fca96a61d42 Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4674
diff changeset
  5348
"/                ].
4fca96a61d42 Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4674
diff changeset
  5349
"/                self makeCursorVisible.
4fca96a61d42 Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4674
diff changeset
  5350
"/
4fca96a61d42 Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4674
diff changeset
  5351
"/                shifted ifTrue:[
4fca96a61d42 Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4674
diff changeset
  5352
"/                    clickLine := cursorLine.
4fca96a61d42 Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4674
diff changeset
  5353
"/                    clickCol := cursorCol.
4fca96a61d42 Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4674
diff changeset
  5354
"/                    self setCursorLine: cursorLine + 1.
4fca96a61d42 Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4674
diff changeset
  5355
"/                    self expandSelectionDown.
4fca96a61d42 Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4674
diff changeset
  5356
"/                    ^ self
4fca96a61d42 Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4674
diff changeset
  5357
"/                ].
4fca96a61d42 Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4674
diff changeset
  5358
"/                self unselect.
4100
3fbb7392a6e1 changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents: 4097
diff changeset
  5359
            ].
3fbb7392a6e1 changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents: 4097
diff changeset
  5360
        ].
4841
4fca96a61d42 Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4674
diff changeset
  5361
        self cursorMovementAllowed ifTrue:[
4fca96a61d42 Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4674
diff changeset
  5362
            n := 1 + (self sensor compressKeyPressEventsWithKey:#CursorDown).
4fca96a61d42 Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4674
diff changeset
  5363
            shifted ifTrue:[
4fca96a61d42 Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4674
diff changeset
  5364
                self addToSelectionAfter:[ self cursorDown:n ]
4fca96a61d42 Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4674
diff changeset
  5365
            ] ifFalse:[
4975
bee454945bf7 Bugfix for cursor position after non-shifter cursor key press while having selection.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4974
diff changeset
  5366
                "/ If there's selection, unselect and move cursor
4977
d0e0234d922c Fix for select & CursorDown press (non-shift)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4976
diff changeset
  5367
                "/ one line below last selection line but at the
d0e0234d922c Fix for select & CursorDown press (non-shift)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4976
diff changeset
  5368
                "/ selectionStartCol column. This behavior is
d0e0234d922c Fix for select & CursorDown press (non-shift)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4976
diff changeset
  5369
                "/ useful when pasting...
4975
bee454945bf7 Bugfix for cursor position after non-shifter cursor key press while having selection.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4974
diff changeset
  5370
                self hasSelection ifTrue:[ 
bee454945bf7 Bugfix for cursor position after non-shifter cursor key press while having selection.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4974
diff changeset
  5371
                    self setCursorLine: selectionEndLine.
4977
d0e0234d922c Fix for select & CursorDown press (non-shift)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4976
diff changeset
  5372
                    self setCursorCol: selectionStartCol.
4975
bee454945bf7 Bugfix for cursor position after non-shifter cursor key press while having selection.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4974
diff changeset
  5373
                ].    
4841
4fca96a61d42 Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4674
diff changeset
  5374
                self unselect; makeCursorVisible.
4fca96a61d42 Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4674
diff changeset
  5375
                self cursorDown:n.
4fca96a61d42 Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4674
diff changeset
  5376
            ].  
4fca96a61d42 Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4674
diff changeset
  5377
            "/
4fca96a61d42 Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4674
diff changeset
  5378
            "/ flush keyboard to avoid runaway cursor
4fca96a61d42 Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4674
diff changeset
  5379
            "/
4fca96a61d42 Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4674
diff changeset
  5380
            self sensor flushKeyboardFor:self.
4fca96a61d42 Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4674
diff changeset
  5381
        ].
4100
3fbb7392a6e1 changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents: 4097
diff changeset
  5382
        ^ self
2580
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  5383
    ].
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  5384
    (key == #CursorLeft or:[key == #CursorUp]) ifTrue:[
4100
3fbb7392a6e1 changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents: 4097
diff changeset
  5385
        (shifted and:[selectionStartLine isNil]) ifTrue:[
3fbb7392a6e1 changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents: 4097
diff changeset
  5386
            expandingTop := true.
3fbb7392a6e1 changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents: 4097
diff changeset
  5387
            key == #CursorLeft ifTrue:[
3fbb7392a6e1 changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents: 4097
diff changeset
  5388
                cursorCol > 1 ifTrue:[
3fbb7392a6e1 changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents: 4097
diff changeset
  5389
                    selectionStartLine := selectionEndLine := clickStartLine := cursorLine.
3fbb7392a6e1 changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents: 4097
diff changeset
  5390
                    selectionEndCol := clickStartCol := cursorCol-1.
3fbb7392a6e1 changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents: 4097
diff changeset
  5391
                    selectionStartCol := cursorCol-1.
4841
4fca96a61d42 Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4674
diff changeset
  5392
                    self setCursorCol: cursorCol-1.
4100
3fbb7392a6e1 changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents: 4097
diff changeset
  5393
                    self validateNewSelection.
3fbb7392a6e1 changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents: 4097
diff changeset
  5394
                    self selectionChanged.
3fbb7392a6e1 changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents: 4097
diff changeset
  5395
                    self redrawLine:selectionStartLine.
3fbb7392a6e1 changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents: 4097
diff changeset
  5396
                    ^ self
3fbb7392a6e1 changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents: 4097
diff changeset
  5397
                ]
3fbb7392a6e1 changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents: 4097
diff changeset
  5398
            ] ifFalse:[
3fbb7392a6e1 changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents: 4097
diff changeset
  5399
                cursorLine > 1 ifTrue:[
3fbb7392a6e1 changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents: 4097
diff changeset
  5400
                    selectionEndLine := clickStartLine := cursorLine.
4841
4fca96a61d42 Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4674
diff changeset
  5401
                    selectionStartCol := clickStartCol := cursorCol.
4fca96a61d42 Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4674
diff changeset
  5402
                    selectionEndCol := cursorCol - 1.
4100
3fbb7392a6e1 changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents: 4097
diff changeset
  5403
                    selectionStartLine := cursorLine - 1.
3fbb7392a6e1 changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents: 4097
diff changeset
  5404
                    selectionEndCol == 1 ifTrue:[
3fbb7392a6e1 changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents: 4097
diff changeset
  5405
                        selectionEndCol := 0.
3fbb7392a6e1 changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents: 4097
diff changeset
  5406
                    ].
3fbb7392a6e1 changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents: 4097
diff changeset
  5407
                    self validateNewSelection.
3fbb7392a6e1 changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents: 4097
diff changeset
  5408
                    self selectionChanged.
3fbb7392a6e1 changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents: 4097
diff changeset
  5409
                    self redrawFromLine:selectionStartLine to:cursorLine.
4841
4fca96a61d42 Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4674
diff changeset
  5410
                    self setCursorLine: cursorLine - 1.  
4100
3fbb7392a6e1 changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents: 4097
diff changeset
  5411
                    ^ self
3fbb7392a6e1 changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents: 4097
diff changeset
  5412
                ]
3fbb7392a6e1 changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents: 4097
diff changeset
  5413
            ]
3fbb7392a6e1 changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents: 4097
diff changeset
  5414
        ].
3fbb7392a6e1 changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents: 4097
diff changeset
  5415
4841
4fca96a61d42 Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4674
diff changeset
  5416
        self hasSelection ifTrue:[
4100
3fbb7392a6e1 changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents: 4097
diff changeset
  5417
            self cursorMovementAllowed ifTrue:[
3fbb7392a6e1 changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents: 4097
diff changeset
  5418
                "/
3fbb7392a6e1 changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents: 4097
diff changeset
  5419
                "/ treat the whole selection as cursor
3fbb7392a6e1 changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents: 4097
diff changeset
  5420
                "/
4841
4fca96a61d42 Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4674
diff changeset
  5421
"/                self setCursorLine:selectionStartLine.
4fca96a61d42 Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4674
diff changeset
  5422
"/                self setCursorCol:selectionStartCol.
4975
bee454945bf7 Bugfix for cursor position after non-shifter cursor key press while having selection.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4974
diff changeset
  5423
"/                self makeCursorVisible.
bee454945bf7 Bugfix for cursor position after non-shifter cursor key press while having selection.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4974
diff changeset
  5424
"/
4841
4fca96a61d42 Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4674
diff changeset
  5425
"/                shifted ifFalse:[
4fca96a61d42 Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4674
diff changeset
  5426
"/                    self unselect.
4fca96a61d42 Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4674
diff changeset
  5427
"/                ]
4100
3fbb7392a6e1 changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents: 4097
diff changeset
  5428
            ].
3fbb7392a6e1 changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents: 4097
diff changeset
  5429
        ].
3fbb7392a6e1 changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents: 4097
diff changeset
  5430
        (key == #CursorLeft) ifTrue:[
4841
4fca96a61d42 Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4674
diff changeset
  5431
            shifted ifTrue:[
4fca96a61d42 Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4674
diff changeset
  5432
                self addToSelectionAfter:[self cursorLeft].
4fca96a61d42 Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4674
diff changeset
  5433
            ] ifFalse:[
4975
bee454945bf7 Bugfix for cursor position after non-shifter cursor key press while having selection.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4974
diff changeset
  5434
                "/ If there's selection, unselect and move cursor
bee454945bf7 Bugfix for cursor position after non-shifter cursor key press while having selection.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4974
diff changeset
  5435
                "/ to the end of selection.   
bee454945bf7 Bugfix for cursor position after non-shifter cursor key press while having selection.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4974
diff changeset
  5436
                self hasSelection ifTrue:[ 
bee454945bf7 Bugfix for cursor position after non-shifter cursor key press while having selection.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4974
diff changeset
  5437
                    self setCursorLine:selectionStartLine.
bee454945bf7 Bugfix for cursor position after non-shifter cursor key press while having selection.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4974
diff changeset
  5438
                    self setCursorCol:selectionStartCol.
bee454945bf7 Bugfix for cursor position after non-shifter cursor key press while having selection.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4974
diff changeset
  5439
                    self unselect; makeCursorVisible.                    
bee454945bf7 Bugfix for cursor position after non-shifter cursor key press while having selection.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4974
diff changeset
  5440
                    ^ self.
bee454945bf7 Bugfix for cursor position after non-shifter cursor key press while having selection.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4974
diff changeset
  5441
                ].
4841
4fca96a61d42 Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4674
diff changeset
  5442
                self unselect; makeCursorVisible.
4fca96a61d42 Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4674
diff changeset
  5443
                self cursorLeft. 
4fca96a61d42 Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4674
diff changeset
  5444
            ].
4fca96a61d42 Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4674
diff changeset
  5445
            ^self
4100
3fbb7392a6e1 changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents: 4097
diff changeset
  5446
        ].
3fbb7392a6e1 changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents: 4097
diff changeset
  5447
        (key == #CursorUp)        ifTrue:[
3fbb7392a6e1 changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents: 4097
diff changeset
  5448
            n := 1 + (self sensor compressKeyPressEventsWithKey:#CursorUp).
4841
4fca96a61d42 Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4674
diff changeset
  5449
            shifted ifTrue:[
4fca96a61d42 Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4674
diff changeset
  5450
                self addToSelectionAfter: [ self cursorUp:n ]
4fca96a61d42 Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4674
diff changeset
  5451
            ] ifFalse:[
4975
bee454945bf7 Bugfix for cursor position after non-shifter cursor key press while having selection.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4974
diff changeset
  5452
                "/ If there's selection, unselect and move cursor
bee454945bf7 Bugfix for cursor position after non-shifter cursor key press while having selection.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4974
diff changeset
  5453
                "/ to the beggining of selection.   
bee454945bf7 Bugfix for cursor position after non-shifter cursor key press while having selection.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4974
diff changeset
  5454
                self hasSelection ifTrue:[ 
bee454945bf7 Bugfix for cursor position after non-shifter cursor key press while having selection.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4974
diff changeset
  5455
                    self setCursorLine:selectionStartLine.
bee454945bf7 Bugfix for cursor position after non-shifter cursor key press while having selection.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4974
diff changeset
  5456
                    self setCursorCol:selectionStartCol.
bee454945bf7 Bugfix for cursor position after non-shifter cursor key press while having selection.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4974
diff changeset
  5457
                ].    
4841
4fca96a61d42 Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4674
diff changeset
  5458
                self unselect; makeCursorVisible.
4fca96a61d42 Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4674
diff changeset
  5459
                self cursorUp:n.
4fca96a61d42 Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4674
diff changeset
  5460
            ].
4100
3fbb7392a6e1 changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents: 4097
diff changeset
  5461
            "/
3fbb7392a6e1 changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents: 4097
diff changeset
  5462
            "/ flush keyboard to avoid runaway cursor
3fbb7392a6e1 changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents: 4097
diff changeset
  5463
            "/
3fbb7392a6e1 changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents: 4097
diff changeset
  5464
            self sensor flushKeyboardFor:self.
3fbb7392a6e1 changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents: 4097
diff changeset
  5465
            ^ self
3fbb7392a6e1 changed: #cursorKeyPress:shifted:
Claus Gittinger <cg@exept.de>
parents: 4097
diff changeset
  5466
        ].
2580
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  5467
    ].
4420
8f0164295ef8 changed:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4414
diff changeset
  5468
4977
d0e0234d922c Fix for select & CursorDown press (non-shift)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4976
diff changeset
  5469
    "Modified: / 28-03-2014 / 12:32:07 / Jan Vrany <jan.vrany@fit.cvut.cz>"
2580
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  5470
!
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  5471
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5472
doKeyPress:key x:x y:y
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5473
    "handle keyboard input"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5474
4521
0b6740e2d1a7 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4494
diff changeset
  5475
    <resource: #keyboard (#Paste #Insert #PasteFromHistory #Cut #Again #AgainForAll
3781
36268d8303d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3780
diff changeset
  5476
                          #Replace #Undo #Redo #Accept
3780
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5477
                          #Delete #BasicDelete #BackSpace #BasicBackspace
4707
f6ac835a1cf6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4701
diff changeset
  5478
                          #DeleteSpaces #Join
3780
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5479
                          #SearchMatchingParent #SelectMatchingParents
4707
f6ac835a1cf6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4701
diff changeset
  5480
                          #SelectWord #ExpandSelectionByWord
3780
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5481
                          #SelectToEnd #SelectFromBeginning
4707
f6ac835a1cf6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4701
diff changeset
  5482
                          #SelectLine #ExpandSelectionByLine
3780
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5483
                          #BeginOfLine #EndOfLine #NextWord #PreviousWord
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5484
                          #CursorRight #CursorDown #CursorLeft #CursorUp
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5485
                          #Return #Tab #BackTab #NonInsertingTab #Escape
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5486
                          #GotoLine #BeginOfText #EndOfText
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5487
                          #InsertLine #DeleteLine
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5488
                          #SelectLineFromBeginning
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5489
                          #LearnKeyboardMacro #ExecuteKeyboardMacro #ToggleInsertMode
5134
f801128ce11d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5133
diff changeset
  5490
                          #OpenSpecialCharacterWindow #InsertUUID
3780
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5491
                          #'F*' #'f*')>
2017
5d4bf15e09f5 simple (naive) undo
Claus Gittinger <cg@exept.de>
parents: 2010
diff changeset
  5492
4730
1f84a8cfec4e class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4728
diff changeset
  5493
    |fKeyMacros shiftPressed ctrlPressed i event macroName
5119
1ba5fb52a0e3 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5114
diff changeset
  5494
     immediateCompletion currentUserPrefs rawKey|
4818
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  5495
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  5496
    currentUserPrefs := UserPreferences current.
2184
fb634dc3e606 learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents: 2157
diff changeset
  5497
4701
fc3e667bcc01 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4700
diff changeset
  5498
    "/ experimental
4818
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  5499
    immediateCompletion := currentUserPrefs immediateCodeCompletion.
4738
f59a81d925c9 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4731
diff changeset
  5500
    (immediateCompletion 
4818
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  5501
    or:[currentUserPrefs codeCompletionOnControlKey
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  5502
    or:[currentUserPrefs codeCompletionOnTabKey]]) ifTrue:[
4801
69a5bff7b5cd Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4786
diff changeset
  5503
        completionSupport isNil ifTrue:[
69a5bff7b5cd Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4786
diff changeset
  5504
            self initializeCompletionSupport.
4609
8b3eb80d04d0 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4595
diff changeset
  5505
        ].
4801
69a5bff7b5cd Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4786
diff changeset
  5506
    ].
5394
bd2329beafbc class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5393
diff changeset
  5507
    
4801
69a5bff7b5cd Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4786
diff changeset
  5508
    "/ JV: why setting it to nil here?
69a5bff7b5cd Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4786
diff changeset
  5509
"/    ifFalse:[
69a5bff7b5cd Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4786
diff changeset
  5510
"/        completionService := nil
69a5bff7b5cd Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4786
diff changeset
  5511
"/    ].
69a5bff7b5cd Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4786
diff changeset
  5512
    completionSupport notNil ifTrue:[
5394
bd2329beafbc class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5393
diff changeset
  5513
        completionSupport stopCompletionProcess.
4801
69a5bff7b5cd Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4786
diff changeset
  5514
        (completionSupport handleKeyPress:key x:x y:y) ifTrue:["eaten" ^ self].
4696
428c8bc44cfb refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents: 4694
diff changeset
  5515
    ].
428c8bc44cfb refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents: 4694
diff changeset
  5516
4818
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  5517
    key isSymbol ifTrue:[
5643
921578f80870 device access
Claus Gittinger <cg@exept.de>
parents: 5593
diff changeset
  5518
        (device modifierKeys includes:key) ifFalse:[
4818
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  5519
            lastReplacementInfo stillCollectingInput:false.
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  5520
        ]
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  5521
    ].
3793
5a6074a257c1 learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents: 3790
diff changeset
  5522
    (key == #LearnKeyboardMacro) ifTrue:[
4818
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  5523
        lastReplacementInfo stillCollectingInput:false.
3793
5a6074a257c1 learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents: 3790
diff changeset
  5524
        self toggleLearnMode.
5a6074a257c1 learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents: 3790
diff changeset
  5525
        ^ self
5a6074a257c1 learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents: 3790
diff changeset
  5526
    ].
5a6074a257c1 learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents: 3790
diff changeset
  5527
    (key == #ExecuteKeyboardMacro) ifTrue:[
4818
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  5528
        lastReplacementInfo stillCollectingInput:false.
3793
5a6074a257c1 learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents: 3790
diff changeset
  5529
        self executeLearnedKeyboardMacro.
5a6074a257c1 learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents: 3790
diff changeset
  5530
        ^ self.
5a6074a257c1 learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents: 3790
diff changeset
  5531
    ].
3799
f6cbe8d860d5 code formatting
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  5532
    (key == #Undo) ifTrue:[self undo. ^self].
f6cbe8d860d5 code formatting
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  5533
    (key == #Redo) ifTrue:[self redo. ^self].
f6cbe8d860d5 code formatting
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  5534
3793
5a6074a257c1 learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents: 3790
diff changeset
  5535
    self learnMode ifTrue:[
4482
0530a2d95b4b class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 4481
diff changeset
  5536
        event := WindowGroup lastEventQuerySignal query.
3793
5a6074a257c1 learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents: 3790
diff changeset
  5537
        learnedMacro add:event.
5a6074a257c1 learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents: 3790
diff changeset
  5538
    ].
5a6074a257c1 learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents: 3790
diff changeset
  5539
4238
5f7125996b44 changed:
Stefan Vogel <sv@exept.de>
parents: 4237
diff changeset
  5540
    (self executekeyboardMacroNamed:key) ifTrue:[
5f7125996b44 changed:
Stefan Vogel <sv@exept.de>
parents: 4237
diff changeset
  5541
        "the macro named key exists"
3780
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5542
        ^ self
2416
56acdd9e31b5 lifted mkeyboardMacro handling from Workspace to EditTextView
Claus Gittinger <cg@exept.de>
parents: 2406
diff changeset
  5543
    ].
56acdd9e31b5 lifted mkeyboardMacro handling from Workspace to EditTextView
Claus Gittinger <cg@exept.de>
parents: 2406
diff changeset
  5544
4482
0530a2d95b4b class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 4481
diff changeset
  5545
    key isSymbol ifFalse:[
0530a2d95b4b class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 4481
diff changeset
  5546
        "the usual case: key is a character, but maybe a string also (in X11)"
0530a2d95b4b class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 4481
diff changeset
  5547
        self handleNonCommandKey:key.
0530a2d95b4b class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 4481
diff changeset
  5548
        ^ self
0530a2d95b4b class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 4481
diff changeset
  5549
    ].
0530a2d95b4b class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 4481
diff changeset
  5550
0530a2d95b4b class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 4481
diff changeset
  5551
    event isNil ifTrue:[
0530a2d95b4b class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 4481
diff changeset
  5552
        event := WindowGroup lastEventQuerySignal query.
0530a2d95b4b class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 4481
diff changeset
  5553
    ].
0530a2d95b4b class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 4481
diff changeset
  5554
    shiftPressed := event hasShift.
0530a2d95b4b class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 4481
diff changeset
  5555
    ctrlPressed := event hasCtrl and:[(event rawKey asString startsWith:'Ctrl') not].
5119
1ba5fb52a0e3 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5114
diff changeset
  5556
    rawKey := event rawKey.
4482
0530a2d95b4b class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 4481
diff changeset
  5557
5133
9d9d9845258f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5119
diff changeset
  5558
    key == #InsertUUID ifTrue:[
9d9d9845258f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5119
diff changeset
  5559
        self insertUUID.
9d9d9845258f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5119
diff changeset
  5560
        ^ self.
9d9d9845258f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5119
diff changeset
  5561
    ].
9d9d9845258f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5119
diff changeset
  5562
4253
adea55ecdb57 changed: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents: 4249
diff changeset
  5563
    (key == #DeleteWordBeforeCursor) ifTrue:[
adea55ecdb57 changed: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents: 4249
diff changeset
  5564
        self deleteWordBeforeCursor.
adea55ecdb57 changed: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents: 4249
diff changeset
  5565
        ^ self.
adea55ecdb57 changed: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents: 4249
diff changeset
  5566
    ].
adea55ecdb57 changed: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents: 4249
diff changeset
  5567
5119
1ba5fb52a0e3 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5114
diff changeset
  5568
    (rawKey == #BackSpace or:[key == #BasicBackspace]) ifTrue:[
3780
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5569
        selectionStartLine notNil ifTrue:[
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5570
            ((key == #BasicBackspace)
4818
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  5571
            or:[ currentUserPrefs deleteSetsClipboardText not ])
3780
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5572
            ifTrue:[
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5573
                self deleteSelection.
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5574
            ] ifFalse: [
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5575
                self copyAndDeleteSelection.
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5576
            ].
4609
8b3eb80d04d0 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4595
diff changeset
  5577
        ] ifFalse:[
8b3eb80d04d0 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4595
diff changeset
  5578
            self makeCursorVisible.
8b3eb80d04d0 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4595
diff changeset
  5579
"/          (shiftPressed and:[ ctrlPressed ]) ifTrue:[
8b3eb80d04d0 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4595
diff changeset
  5580
"/            self deleteWordBeforeCursor.
8b3eb80d04d0 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4595
diff changeset
  5581
"/          ] ifFalse:[
8b3eb80d04d0 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4595
diff changeset
  5582
            self deleteCharBeforeCursor.
8b3eb80d04d0 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4595
diff changeset
  5583
"/          ].
3780
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5584
        ].
4738
f59a81d925c9 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4731
diff changeset
  5585
        true "immediateCompletion" ifTrue:[ 
5394
bd2329beafbc class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5393
diff changeset
  5586
            completionSupport notNil ifTrue:[ 
bd2329beafbc class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5393
diff changeset
  5587
                completionSupport postKeyPress:key
bd2329beafbc class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5393
diff changeset
  5588
            ].
4731
e3da3340744b class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4730
diff changeset
  5589
        ].
3780
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5590
        ^ self
2205
230cf9cef6c3 searchPatter, if from selection (escape meta characters)
Claus Gittinger <cg@exept.de>
parents: 2196
diff changeset
  5591
    ].
2184
fb634dc3e606 learn (Cmd-l)and executeMacro (Cmd-M)
Claus Gittinger <cg@exept.de>
parents: 2157
diff changeset
  5592
3782
79ae5dad28d4 Ctrl-Insert to toggle insert mode.
Claus Gittinger <cg@exept.de>
parents: 3781
diff changeset
  5593
    (key == #ToggleAutoIndent) ifTrue:[
79ae5dad28d4 Ctrl-Insert to toggle insert mode.
Claus Gittinger <cg@exept.de>
parents: 3781
diff changeset
  5594
        self autoIndent:(autoIndent not).
79ae5dad28d4 Ctrl-Insert to toggle insert mode.
Claus Gittinger <cg@exept.de>
parents: 3781
diff changeset
  5595
        ^ self.
79ae5dad28d4 Ctrl-Insert to toggle insert mode.
Claus Gittinger <cg@exept.de>
parents: 3781
diff changeset
  5596
    ].
79ae5dad28d4 Ctrl-Insert to toggle insert mode.
Claus Gittinger <cg@exept.de>
parents: 3781
diff changeset
  5597
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  5598
    key == #ToggleInsertMode ifTrue:[
3782
79ae5dad28d4 Ctrl-Insert to toggle insert mode.
Claus Gittinger <cg@exept.de>
parents: 3781
diff changeset
  5599
        self insertMode:(editMode value == EditMode insertMode) not.
3780
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5600
        ^ self.
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  5601
    ].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5602
4162
9c80c8f4ba45 changed:
Claus Gittinger <cg@exept.de>
parents: 4143
diff changeset
  5603
    key == #OpenSpecialCharacterWindow ifTrue:[
9c80c8f4ba45 changed:
Claus Gittinger <cg@exept.de>
parents: 4143
diff changeset
  5604
        CharacterSetView notNil ifTrue:[
9c80c8f4ba45 changed:
Claus Gittinger <cg@exept.de>
parents: 4143
diff changeset
  5605
            self specialCharacters.
9c80c8f4ba45 changed:
Claus Gittinger <cg@exept.de>
parents: 4143
diff changeset
  5606
            ^ self.
9c80c8f4ba45 changed:
Claus Gittinger <cg@exept.de>
parents: 4143
diff changeset
  5607
        ]        
9c80c8f4ba45 changed:
Claus Gittinger <cg@exept.de>
parents: 4143
diff changeset
  5608
    ].
9c80c8f4ba45 changed:
Claus Gittinger <cg@exept.de>
parents: 4143
diff changeset
  5609
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5610
    replacing := false.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5611
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5612
    "
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5613
     Fn      pastes a key-sequence (but only if not overlayed with
3780
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5614
             another function in the keyboard map)
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5615
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5616
     see TextView>>:x:y
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5617
    "
1177
9d23e1241404 avoid match: if possible (to not clobber the previous matchString)
Claus Gittinger <cg@exept.de>
parents: 1108
diff changeset
  5618
    (key at:1) asLowercase == $f ifTrue:[
3780
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5619
        (('[fF][0-9]' match:key)
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5620
        or:['[fF][0-9][0-9]' match:key]) ifTrue:[
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5621
            shiftPressed ifFalse:[
4818
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  5622
                fKeyMacros := currentUserPrefs functionKeySequences.
3780
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5623
                fKeyMacros notNil ifTrue:[
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5624
                    (fKeyMacros includesKey:key) ifTrue:[
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5625
                        self pasteOrReplace:(fKeyMacros at:key) asStringCollection.
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5626
                        ^ self
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5627
                    ]
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5628
                ]
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5629
            ]
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5630
        ].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5631
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5632
2506
5568d67dbddd Ctrl-8 / Ctrl-9,
Claus Gittinger <cg@exept.de>
parents: 2505
diff changeset
  5633
    (key == #'Ctrl8' or:[key == #'Ctrl9']) ifTrue:[
3780
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5634
        self parenthizeSelectionWith:$( and:$).
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5635
        ^ self.
2506
5568d67dbddd Ctrl-8 / Ctrl-9,
Claus Gittinger <cg@exept.de>
parents: 2505
diff changeset
  5636
    ].
5568d67dbddd Ctrl-8 / Ctrl-9,
Claus Gittinger <cg@exept.de>
parents: 2505
diff changeset
  5637
    (key == #'Ctrl2') ifTrue:[
3780
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5638
        self parenthizeSelectionWith:$" and:$".
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5639
        ^ self.
2506
5568d67dbddd Ctrl-8 / Ctrl-9,
Claus Gittinger <cg@exept.de>
parents: 2505
diff changeset
  5640
    ].
5568d67dbddd Ctrl-8 / Ctrl-9,
Claus Gittinger <cg@exept.de>
parents: 2505
diff changeset
  5641
    (key == #'Ctrl#') ifTrue:[
3780
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5642
        self parenthizeSelectionWith:$' and:$'.
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5643
        ^ self.
2505
9204d5313979 Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents: 2491
diff changeset
  5644
    ].
4286
83ef1d9faf6d added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents: 4285
diff changeset
  5645
    (key == #'ConvertSelectionToLowercaseOrUppercaseOrUppercaseFirst') ifTrue:[
83ef1d9faf6d added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents: 4285
diff changeset
  5646
        self convertSelectionToLowercaseOrUppercaseOrUppercaseFirst.
83ef1d9faf6d added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents: 4285
diff changeset
  5647
        ^ self.
83ef1d9faf6d added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents: 4285
diff changeset
  5648
    ].
2505
9204d5313979 Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents: 2491
diff changeset
  5649
274
6df4bb990f04 handle accept where acceptAction is define (this was a historic leftover)
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
  5650
    (key == #Accept)  ifTrue:[^ self accept].
5387
b94d35da3ad6 class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 5371
diff changeset
  5651
    (key == #PasteFromHistory) ifTrue:[self pasteOrReplaceFromHistory. ^self].
b94d35da3ad6 class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 5371
diff changeset
  5652
    (key == #Paste or:[key == #Insert]) ifTrue:[self pasteOrReplaceByKeyPress. ^self].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5653
    (key == #Cut) ifTrue:[self cut. ^self].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5654
    (key == #Again) ifTrue:[self again. ^self].
3781
36268d8303d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3780
diff changeset
  5655
    (key == #AgainForAll) ifTrue:[self multipleAgain. ^self].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5656
3542
30ed44ed0178 +joinLines (CTRL-j);
Claus Gittinger <cg@exept.de>
parents: 3517
diff changeset
  5657
    (key == #Join) ifTrue:[self joinLines. ^self].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5658
    (key == #Replace) ifTrue:[self replace. ^self].
4707
f6ac835a1cf6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4701
diff changeset
  5659
    (key == #ExpandSelectionByWord) ifTrue:[
f6ac835a1cf6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4701
diff changeset
  5660
        self makeCursorVisible.
f6ac835a1cf6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4701
diff changeset
  5661
        self findNextWordAfterSelectionAndAddToSelection.
f6ac835a1cf6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4701
diff changeset
  5662
        ^ self
f6ac835a1cf6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4701
diff changeset
  5663
    ].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5664
    (key == #SelectWord) ifTrue:[
3780
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5665
        self makeCursorVisible.
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5666
        self selectWordUnderCursor.
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5667
        ^ self
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5668
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5669
2505
9204d5313979 Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents: 2491
diff changeset
  5670
    (key == #SearchMatchingParent) ifTrue:[self searchForMatchingParenthesis. ^ self].
9204d5313979 Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents: 2491
diff changeset
  5671
    (key == #SelectMatchingParents) ifTrue:[self searchForAndSelectMatchingParenthesis. ^ self].
9204d5313979 Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents: 2491
diff changeset
  5672
    (key == #SelectToEnd) ifTrue:[self selectUpToEnd. ^ self].
9204d5313979 Ctrl-8 / Ctrl-9 to parenthize/unparenthize
Claus Gittinger <cg@exept.de>
parents: 2491
diff changeset
  5673
    (key == #SelectFromBeginning) ifTrue:[self selectFromBeginning. ^ self].
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
" disabled - nobody liked it ...
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5676
  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
  5677
1304
173d00c195f9 flush pending keyboard events in cursor-up/down
Claus Gittinger <cg@exept.de>
parents: 1300
diff changeset
  5678
    (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
  5679
    (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
  5680
    (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
  5681
    (key == #Ctrlp) ifTrue:[self unselect. self cursorUp. ^ self].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5682
"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5683
1675
b1cba2341f95 EndOfLine / BeginOfLine unselect first.
Claus Gittinger <cg@exept.de>
parents: 1601
diff changeset
  5684
    (key == #BeginOfLine) ifTrue:[
3780
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5685
        shiftPressed ifTrue: [
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5686
            "/ "Original St/X code - now use Ctrl modifier"
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5687
            "/ self unselect.
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5688
            "/ self cursorHome.
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5689
            "Jan's modification"
4841
4fca96a61d42 Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4674
diff changeset
  5690
            self addToSelectionAfter:[ self cursorToBeginOfLine ].
4257
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  5691
            "/ Jan's modification modified by his own request ;-))
4841
4fca96a61d42 Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4674
diff changeset
  5692
            "/ JV: Well, does not work correctly. Better to fix addToSelectionAfter: 
4fca96a61d42 Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4674
diff changeset
  5693
            "/ self selectFromBeginOfLine.
3780
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5694
        ] ifFalse: [
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5695
            self unselect.
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5696
            ctrlPressed ifTrue:[
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5697
                self cursorHome.
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5698
            ] ifFalse:[
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5699
                self cursorToBeginOfLine.
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5700
            ]
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5701
        ].
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5702
        ^ self
1675
b1cba2341f95 EndOfLine / BeginOfLine unselect first.
Claus Gittinger <cg@exept.de>
parents: 1601
diff changeset
  5703
    ].
b1cba2341f95 EndOfLine / BeginOfLine unselect first.
Claus Gittinger <cg@exept.de>
parents: 1601
diff changeset
  5704
    (key == #EndOfLine) ifTrue:[
3780
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5705
        shiftPressed ifTrue:[
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5706
            "/ "Original St/X code - now use Ctrl modifier"
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5707
            "/ self unselect.
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5708
            "/ self cursorToBottom
4257
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  5709
            " Jan's modification"
4841
4fca96a61d42 Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4674
diff changeset
  5710
            self addToSelectionAfter:[ self cursorToEndOfLine ] .
4257
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  5711
            "/ Jan's modification modified by his own request ;-))
4841
4fca96a61d42 Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4674
diff changeset
  5712
            "/ JV: Well, does not work correctly. Better to fix addToSelectionAfter:
4fca96a61d42 Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4674
diff changeset
  5713
            "/  self selectToEndOfLine.
3780
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5714
        ] ifFalse:[
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5715
            self unselect.
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5716
            ctrlPressed ifTrue:[
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5717
                self cursorToBottom
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5718
            ] ifFalse:[
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5719
                self cursorToEndOfLine.
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5720
            ]
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5721
        ].
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5722
        ^ self
1675
b1cba2341f95 EndOfLine / BeginOfLine unselect first.
Claus Gittinger <cg@exept.de>
parents: 1601
diff changeset
  5723
    ].
4978
0eb26aed1456 Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4977
diff changeset
  5724
    (key == #NextWord) ifTrue:[
0eb26aed1456 Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4977
diff changeset
  5725
        shiftPressed ifTrue:[
0eb26aed1456 Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4977
diff changeset
  5726
            self addToSelectionAfter:[  
0eb26aed1456 Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4977
diff changeset
  5727
                self cursorToNextWord. 
0eb26aed1456 Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4977
diff changeset
  5728
            ]
0eb26aed1456 Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4977
diff changeset
  5729
        ] ifFalse:[ 
0eb26aed1456 Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4977
diff changeset
  5730
            self cursorToNextWord
0eb26aed1456 Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4977
diff changeset
  5731
        ].
0eb26aed1456 Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4977
diff changeset
  5732
        ^self
0eb26aed1456 Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4977
diff changeset
  5733
    ].
3310
83368f9014a1 word check
Claus Gittinger <cg@exept.de>
parents: 3303
diff changeset
  5734
    (key == #EndOfWord) ifTrue:[self cursorToEndOfWord. ^self].
4978
0eb26aed1456 Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4977
diff changeset
  5735
    (key == #PreviousWord) ifTrue:[
0eb26aed1456 Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4977
diff changeset
  5736
        shiftPressed ifTrue:[
0eb26aed1456 Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4977
diff changeset
  5737
            self addToSelectionAfter:[      
0eb26aed1456 Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4977
diff changeset
  5738
                self cursorToPreviousWord. 
0eb26aed1456 Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4977
diff changeset
  5739
            ]
0eb26aed1456 Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4977
diff changeset
  5740
        ] ifFalse:[ 
0eb26aed1456 Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4977
diff changeset
  5741
            self cursorToPreviousWord.                                
0eb26aed1456 Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4977
diff changeset
  5742
        ].
0eb26aed1456 Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4977
diff changeset
  5743
        ^self
0eb26aed1456 Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4977
diff changeset
  5744
    ].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5745
    (key == #GotoLine) ifTrue:[self gotoLine. ^self].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5746
5119
1ba5fb52a0e3 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5114
diff changeset
  5747
    (rawKey == #CursorRight
1ba5fb52a0e3 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5114
diff changeset
  5748
    or:[rawKey == #CursorDown
1ba5fb52a0e3 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5114
diff changeset
  5749
    or:[rawKey == #CursorLeft
1ba5fb52a0e3 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5114
diff changeset
  5750
    or:[rawKey == #CursorUp]]]) ifTrue:[
1ba5fb52a0e3 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5114
diff changeset
  5751
        self cursorKeyPress:rawKey shifted:shiftPressed.
3780
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5752
        ^ self.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5753
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5754
5119
1ba5fb52a0e3 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5114
diff changeset
  5755
    (key == #ShiftReturn or:[key == #NonInsertingReturn]) ifTrue:[
3780
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5756
        self unselect. self cursorReturn.
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5757
        ^ self
3257
628e1e05814d shift-Tab fix.
Claus Gittinger <cg@exept.de>
parents: 3252
diff changeset
  5758
    ].
628e1e05814d shift-Tab fix.
Claus Gittinger <cg@exept.de>
parents: 3252
diff changeset
  5759
628e1e05814d shift-Tab fix.
Claus Gittinger <cg@exept.de>
parents: 3252
diff changeset
  5760
    (key == #Return) ifTrue:[
3780
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5761
        shiftPressed ifTrue:[
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5762
            self unselect. self cursorReturn.
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5763
            ^ self
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5764
        ].
4199
cd7069b3bc33 comment/format in: #doKeyPress:x:y:
Claus Gittinger <cg@exept.de>
parents: 4192
diff changeset
  5765
3780
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5766
        self isReadOnly ifTrue:[
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5767
            self unselect; makeCursorVisible.
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5768
            self cursorReturn
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5769
        ] ifFalse:[
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5770
            self isInInsertMode ifFalse:[
5529
0b33c7ac879d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 5525
diff changeset
  5771
                self cursorReturn:true.
3780
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5772
                autoIndent == true ifTrue:[
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5773
                    i := self leftIndentForLine:(cursorLine + 1).
4820
8640fa6f128f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4818
diff changeset
  5774
                    (self listAt:cursorLine) isEmptyOrNil ifTrue:[
4811
e868808b229e class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4803
diff changeset
  5775
                        self cursorCol:(i+1 max:1)
e868808b229e class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4803
diff changeset
  5776
                    ]
3780
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5777
                ]
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5778
            ] ifTrue:[
4826
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
  5779
                |left right oldIndent|
4812
ca6d48bf0053 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4811
diff changeset
  5780
3780
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5781
                "/ old version just unselected ...
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5782
                "/ self unselect; makeCursorVisible.
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5783
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5784
                "/ new version deletes ...
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5785
                typeOfSelection == #paste ifTrue:[
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5786
                    self unselect; makeCursorVisible.
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5787
                ] ifFalse:[
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5788
                    self copyAndDeleteSelection.
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5789
                ].
4816
6020db6f57f6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4814
diff changeset
  5790
                left := (self listAt:cursorLine to:cursorCol-1) ? ''.
6020db6f57f6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4814
diff changeset
  5791
                right := (self listAt:cursorLine from:cursorCol) ? ''.
3780
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5792
                self insertCharAtCursor:(Character cr).
5112
a1aa277baf30 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5107
diff changeset
  5793
3780
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5794
                autoIndent == true ifTrue:[
4816
6020db6f57f6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4814
diff changeset
  5795
                    (right isEmpty and:[cursorCol ~~ 1]) ifTrue:[
6020db6f57f6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4814
diff changeset
  5796
                        "/ nothing to do.
4812
ca6d48bf0053 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4811
diff changeset
  5797
                    ] ifFalse:[
ca6d48bf0053 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4811
diff changeset
  5798
                        ((self listAt:cursorLine) isEmptyOrNil 
5112
a1aa277baf30 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5107
diff changeset
  5799
                        or:[ false "cursorCol == 1" ]) ifTrue:[
4812
ca6d48bf0053 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4811
diff changeset
  5800
                            i := (self leftIndentForLine:cursorLine).
4823
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  5801
                            left := left withoutSeparators.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  5802
                            right := right withoutSeparators.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  5803
                            (left endsWith:'[') ifTrue:[
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  5804
"/                                i := i + 4.
4816
6020db6f57f6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4814
diff changeset
  5805
                            ] ifFalse:[
4823
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  5806
                                (false "(left endsWith:']')" or:[(right startsWith:']')]) ifTrue:[
4816
6020db6f57f6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4814
diff changeset
  5807
                                    i := i - 4.
6020db6f57f6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4814
diff changeset
  5808
                                ].
4812
ca6d48bf0053 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4811
diff changeset
  5809
                            ].
4826
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
  5810
                            oldIndent := self leftIndentOfLine:cursorLine.
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
  5811
                            self indentFromLine:cursorLine toLine:cursorLine by:(i-oldIndent).
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
  5812
                            self st80EditMode ifTrue:[
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
  5813
                                (self listAt:cursorLine) size < i ifTrue:[
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
  5814
                                    self insertStringAtCursor:(String new:((i-oldIndent) max:0)).
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
  5815
                                ].
ee17c37a8012 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4823
diff changeset
  5816
                            ].
4812
ca6d48bf0053 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4811
diff changeset
  5817
                            self cursorCol:(i+1 max:1)
ca6d48bf0053 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4811
diff changeset
  5818
                        ].
ca6d48bf0053 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4811
diff changeset
  5819
                    ]
3780
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5820
                ].
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5821
            ].
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5822
        ].
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5823
        ^ self
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5824
    ].
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
  5825
2819
a7a41dfb9df7 BackTab / NonInsertingTab modifiers now defined in keyboard.rc
ca
parents: 2817
diff changeset
  5826
    (key == #NonInsertingTab) ifTrue:[
3780
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5827
        self unselect. self cursorTab.
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5828
        ^ self
2819
a7a41dfb9df7 BackTab / NonInsertingTab modifiers now defined in keyboard.rc
ca
parents: 2817
diff changeset
  5829
    ].
3422
a0c68e8bd56e tab with line selection means: indent/undent
Claus Gittinger <cg@exept.de>
parents: 3416
diff changeset
  5830
    ((key == #BackTab) or:[(key == #Tab)]) ifTrue:[
3780
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5831
        self tabMeansNextField ifTrue:[^ super keyPress:key x:x y:y].
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5832
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5833
        self hasSelection ifTrue:[
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5834
            selectStyle == #line ifTrue:[
4238
5f7125996b44 changed:
Stefan Vogel <sv@exept.de>
parents: 4237
diff changeset
  5835
                ((key == #Tab) and:[shiftPressed not]) ifTrue:[
5f7125996b44 changed:
Stefan Vogel <sv@exept.de>
parents: 4237
diff changeset
  5836
                    macroName := #IndentBy4.
5f7125996b44 changed:
Stefan Vogel <sv@exept.de>
parents: 4237
diff changeset
  5837
                ] ifFalse:[
5f7125996b44 changed:
Stefan Vogel <sv@exept.de>
parents: 4237
diff changeset
  5838
                    macroName := #UndentBy4.
5f7125996b44 changed:
Stefan Vogel <sv@exept.de>
parents: 4237
diff changeset
  5839
                ].
5f7125996b44 changed:
Stefan Vogel <sv@exept.de>
parents: 4237
diff changeset
  5840
                macroName notNil ifTrue:[
5f7125996b44 changed:
Stefan Vogel <sv@exept.de>
parents: 4237
diff changeset
  5841
                    self executekeyboardMacroNamed:macroName.
3780
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5842
                ].
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5843
            ]
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5844
        ].
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5845
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5846
        self unselect.
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5847
        (key == #Tab) ifTrue:[
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5848
            (shiftPressed or:[self isInInsertMode not]) ifTrue:[
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5849
                self cursorTab.
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5850
                ^ self
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5851
            ].
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5852
            self insertTabAtCursor.
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5853
            ^ self
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5854
        ].
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5855
        self cursorBacktab.
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5856
        ^ self
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5857
    ].
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
  5858
2883
6cdb4a5a7b5e shift-delete - delete whiteSpace
Claus Gittinger <cg@exept.de>
parents: 2880
diff changeset
  5859
    "/ key == #DeleteSpaces ifTrue:[
5119
1ba5fb52a0e3 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5114
diff changeset
  5860
    (rawKey == #Delete) ifTrue:[
3780
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5861
        shiftPressed ifTrue:[
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5862
            [(cursorCol <= (self listAt:cursorLine) size)
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5863
             and:[self characterUnderCursor isSeparator]] whileTrue:[
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5864
             self makeCursorVisible.
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5865
                self deleteCharAtCursor.
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5866
            ].
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5867
            ^ self
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5868
        ]
2883
6cdb4a5a7b5e shift-delete - delete whiteSpace
Claus Gittinger <cg@exept.de>
parents: 2880
diff changeset
  5869
    ].
6cdb4a5a7b5e shift-delete - delete whiteSpace
Claus Gittinger <cg@exept.de>
parents: 2880
diff changeset
  5870
5119
1ba5fb52a0e3 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5114
diff changeset
  5871
    (rawKey == #Delete
870
c606f29db5d7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 865
diff changeset
  5872
     or:[key == #BasicDelete]) ifTrue:[
4129
34908a157d21 changed: #deleteCopyToClipboard:
fm
parents: 4126
diff changeset
  5873
        selectionStartLine notNil ifTrue:[  
4130
87d51f65430e changed: #doKeyPress:x:y:
fm
parents: 4129
diff changeset
  5874
"/          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
  5875
"/          To remove text repetetively, use Cut instead.
87d51f65430e changed: #doKeyPress:x:y:
fm
parents: 4129
diff changeset
  5876
"/            self setLastStringToReplace: self selection asStringWithoutFinalCR.
87d51f65430e changed: #doKeyPress:x:y:
fm
parents: 4129
diff changeset
  5877
"/            lastReplacementInfo lastReplacement: nil.
3780
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5878
            ((key == #BasicDelete)
4818
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  5879
            or:[currentUserPrefs deleteSetsClipboardText not]) ifTrue:[
3780
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5880
                self deleteSelection.
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5881
            ] ifFalse:[
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5882
                self copyAndDeleteSelection.
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5883
            ].
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5884
            ^ self
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5885
        ].
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5886
        self makeCursorVisible.
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5887
        self deleteCharAtCursor.
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5888
        ^ self
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5889
    ].
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
  5890
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5891
    (key == #BeginOfText) ifTrue:[     "i.e. HOME"
3780
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5892
        self unselect.
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5893
        cursorVisibleLine == 1 ifTrue:[
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5894
            self cursorHome.
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5895
        ] ifFalse:[
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5896
            self cursorToFirstVisibleLine
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5897
        ].
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5898
        ^ self
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5899
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5900
    (key == #EndOfText) ifTrue:[       "i.e. END"
3780
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5901
        self unselect.
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5902
        cursorVisibleLine == nFullLinesShown ifTrue:[
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5903
            self cursorToBottom.
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5904
        ] ifFalse:[
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5905
            self cursorToLastVisibleLine
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5906
        ].
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
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 == #Escape)
3257
628e1e05814d shift-Tab fix.
Claus Gittinger <cg@exept.de>
parents: 3252
diff changeset
  5910
    or:[key == #SelectLineFromBeginning]) ifTrue:[
3780
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5911
        self makeCursorVisible.
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5912
        self unselect. self selectCursorLineFromBeginning.
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5913
        ^ self
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5914
    ].
3257
628e1e05814d shift-Tab fix.
Claus Gittinger <cg@exept.de>
parents: 3252
diff changeset
  5915
    (key == #SelectLine) ifTrue:[
3780
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5916
        self makeCursorVisible.
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5917
        self unselect. self selectCursorLine.
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5918
        ^ self
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5919
    ].
3257
628e1e05814d shift-Tab fix.
Claus Gittinger <cg@exept.de>
parents: 3252
diff changeset
  5920
    (key == #ExpandSelectionByLine) ifTrue:[
4707
f6ac835a1cf6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4701
diff changeset
  5921
        "/ self makeCursorVisible.
3780
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5922
        self selectExpandCursorLine.
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5923
        ^ self
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5924
    ].
3257
628e1e05814d shift-Tab fix.
Claus Gittinger <cg@exept.de>
parents: 3252
diff changeset
  5925
    (key == #DeleteLine) ifTrue:[
3780
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5926
        self makeCursorVisible.
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5927
        self unselect. self deleteCursorLine.
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5928
        ^ self
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5929
    ].
3257
628e1e05814d shift-Tab fix.
Claus Gittinger <cg@exept.de>
parents: 3252
diff changeset
  5930
    (key == #InsertLine) ifTrue:[
3780
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5931
        self makeCursorVisible.
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5932
        self unselect. self insertLine:nil before:cursorLine.
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  5933
        ^ self
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5934
    ].
3781
36268d8303d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3780
diff changeset
  5935
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5936
    super keyPress:key x:x y:y
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  5937
3310
83368f9014a1 word check
Claus Gittinger <cg@exept.de>
parents: 3303
diff changeset
  5938
    "Modified: / 06-02-1998 / 11:59:59 / stefan"
4286
83ef1d9faf6d added: #convertSelectionToLowercaseOrUppercaseOrUppercaseFirst
Claus Gittinger <cg@exept.de>
parents: 4285
diff changeset
  5939
    "Modified: / 14-07-2011 / 12:08:28 / cg"
4978
0eb26aed1456 Fix for Ctrl-Shift-Left/Right (Shift-NextWord / PreviousWord)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4977
diff changeset
  5940
    "Modified: / 31-03-2014 / 16:27:08 / Jan Vrany <jan.vrany@fit.cvut.cz>"
121
claus
parents: 118
diff changeset
  5941
!
claus
parents: 118
diff changeset
  5942
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5943
executeKeyboardMacro:cmdMacro
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5944
    Error handle:[:ex |
4823
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  5945
        self warn:'Error in keyboard macro: ' , ex description.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  5946
        ex return.
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5947
    ] do:[
4823
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  5948
        AbortOperationRequest handle:[:ex |
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  5949
            self warn:'Keyboard macro aborted'.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  5950
            ex return.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  5951
        ] do:[
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  5952
            Parser
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  5953
                evaluate:cmdMacro asString
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  5954
                receiver:self
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  5955
                notifying:nil
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  5956
                compile:false.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  5957
        ].
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5958
    ].
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5959
!
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  5960
5340
fcba05443013 Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 5333
diff changeset
  5961
extendSelectionToX:x y:y setPrimarySelection:aBoolean
fcba05443013 Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 5333
diff changeset
  5962
    | movedVisibleLine movedLine movedCol movedUp |
fcba05443013 Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 5333
diff changeset
  5963
fcba05443013 Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 5333
diff changeset
  5964
    movedVisibleLine := self visibleLineOfY:y.
fcba05443013 Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 5333
diff changeset
  5965
    movedLine := self visibleLineToAbsoluteLine:movedVisibleLine.
fcba05443013 Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 5333
diff changeset
  5966
fcba05443013 Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 5333
diff changeset
  5967
    (x < leftMargin) ifTrue:[
fcba05443013 Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 5333
diff changeset
  5968
        movedCol := 0
fcba05443013 Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 5333
diff changeset
  5969
    ] ifFalse:[
fcba05443013 Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 5333
diff changeset
  5970
        movedCol := self colOfX:x inVisibleLine:movedVisibleLine
fcba05443013 Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 5333
diff changeset
  5971
    ].
fcba05443013 Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 5333
diff changeset
  5972
fcba05443013 Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 5333
diff changeset
  5973
    "find out if we are before or after initial click"
fcba05443013 Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 5333
diff changeset
  5974
    movedUp := false.
fcba05443013 Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 5333
diff changeset
  5975
    (movedLine < (clickStartLine ? movedLine)) ifTrue:[
fcba05443013 Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 5333
diff changeset
  5976
        movedUp := true
fcba05443013 Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 5333
diff changeset
  5977
    ] ifFalse:[
fcba05443013 Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 5333
diff changeset
  5978
        (movedLine == (clickStartLine ? movedLine)) ifTrue:[
fcba05443013 Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 5333
diff changeset
  5979
            (movedCol < (clickStartCol ? movedCol)) ifTrue:[
fcba05443013 Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 5333
diff changeset
  5980
                movedUp := true
fcba05443013 Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 5333
diff changeset
  5981
            ]
fcba05443013 Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 5333
diff changeset
  5982
        ]
fcba05443013 Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 5333
diff changeset
  5983
    ].
fcba05443013 Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 5333
diff changeset
  5984
fcba05443013 Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 5333
diff changeset
  5985
    self hasSelection ifTrue:[ 
fcba05443013 Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 5333
diff changeset
  5986
        movedUp ifTrue:[
fcba05443013 Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 5333
diff changeset
  5987
            "/ Set cursor to selection start
fcba05443013 Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 5333
diff changeset
  5988
            self setCursorLine: selectionStartLine col: selectionStartCol
fcba05443013 Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 5333
diff changeset
  5989
        ] ifFalse:[ 
fcba05443013 Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 5333
diff changeset
  5990
            "/ Set cursor to selection end
fcba05443013 Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 5333
diff changeset
  5991
            self setCursorLine: selectionEndLine col: selectionEndCol + 1
fcba05443013 Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 5333
diff changeset
  5992
        ].
fcba05443013 Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 5333
diff changeset
  5993
    ].
fcba05443013 Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 5333
diff changeset
  5994
fcba05443013 Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 5333
diff changeset
  5995
fcba05443013 Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 5333
diff changeset
  5996
fcba05443013 Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 5333
diff changeset
  5997
    super extendSelectionToX:x y:y setPrimarySelection:aBoolean.
fcba05443013 Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 5333
diff changeset
  5998
fcba05443013 Fixed cursor handling when selection is done by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 5333
diff changeset
  5999
    "Created: / 02-05-2015 / 07:33:06 / Jan Vrany <jan.vrany@fit.cvut.cz>"
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  6000
!
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  6001
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  6002
handleNonCommandKey:keyArg
4700
150468a2ea5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4697
diff changeset
  6003
    |selStartLineBefore selStartColBefore selEndLineBefore selEndColBefore key|
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
    self isReadOnly ifTrue:[
4988
9f6f620a1f06 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4967
diff changeset
  6006
        self flashReadOnly.
3813
8d719ca5812d dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3811
diff changeset
  6007
        ^ self.
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  6008
    ].
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  6009
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  6010
    key := keyArg.
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  6011
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  6012
    typeOfSelection == #paste ifTrue:[
4846
cd2e0b754655 Fix for paster-keystroke: should insert character at the end of the just pasted selection,
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4845
diff changeset
  6013
        "Pasted selection will NOT be replaced by keystroke (non-standard, St/X feature)"
cd2e0b754655 Fix for paster-keystroke: should insert character at the end of the just pasted selection,
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4845
diff changeset
  6014
cd2e0b754655 Fix for paster-keystroke: should insert character at the end of the just pasted selection,
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4845
diff changeset
  6015
        "/ After paste, the cursor is at the beginning to support
cd2e0b754655 Fix for paster-keystroke: should insert character at the end of the just pasted selection,
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4845
diff changeset
  6016
        "/ paste-cursordown-paste. Compensate for this here - we want
cd2e0b754655 Fix for paster-keystroke: should insert character at the end of the just pasted selection,
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4845
diff changeset
  6017
        "/ to continue editing after the end of the selection.
cd2e0b754655 Fix for paster-keystroke: should insert character at the end of the just pasted selection,
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4845
diff changeset
  6018
        "/ This is
cd2e0b754655 Fix for paster-keystroke: should insert character at the end of the just pasted selection,
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4845
diff changeset
  6019
        cursorLine := selectionEndLine.
cd2e0b754655 Fix for paster-keystroke: should insert character at the end of the just pasted selection,
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4845
diff changeset
  6020
        cursorCol := selectionEndCol + 1.
cd2e0b754655 Fix for paster-keystroke: should insert character at the end of the just pasted selection,
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4845
diff changeset
  6021
cd2e0b754655 Fix for paster-keystroke: should insert character at the end of the just pasted selection,
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4845
diff changeset
  6022
        "/ Cursor position set, we can unselect.
cd2e0b754655 Fix for paster-keystroke: should insert character at the end of the just pasted selection,
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4845
diff changeset
  6023
        self unselect.
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  6024
    ].
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  6025
4700
150468a2ea5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4697
diff changeset
  6026
    selStartLineBefore := selectionStartLine.
150468a2ea5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4697
diff changeset
  6027
    selStartColBefore := self selectionStartCol.
150468a2ea5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4697
diff changeset
  6028
    selEndLineBefore := selectionEndLine.
150468a2ea5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4697
diff changeset
  6029
    selEndColBefore := self selectionEndCol.
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  6030
4940
73e7031a4a85 class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 4889
diff changeset
  6031
    (gc characterEncoding ? #'iso10646-1') ~~ #'iso10646-1' ifTrue:[
4481
76c592c0ae9c class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 4475
diff changeset
  6032
        key isCharacter ifTrue:[
4940
73e7031a4a85 class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 4889
diff changeset
  6033
            key := CharacterEncoder encode:key from:#'iso10646-1' into:gc characterEncoding.
4481
76c592c0ae9c class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 4475
diff changeset
  6034
        ] ifFalse:[
4940
73e7031a4a85 class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 4889
diff changeset
  6035
            key := CharacterEncoder encodeString:key from:#'iso10646-1' into:gc characterEncoding.
4481
76c592c0ae9c class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 4475
diff changeset
  6036
        ].
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  6037
    ].
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  6038
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  6039
    "replace selection by what is typed in -
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  6040
     if word was selected with a space, keep it.
4700
150468a2ea5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4697
diff changeset
  6041
     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
  6042
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  6043
    editMode value isInsertAndSelectMode ifTrue:[
3813
8d719ca5812d dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3811
diff changeset
  6044
        selectionStartLine := selectionStartCol := selectionEndLine := selectionEndCol := nil.
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  6045
    ].
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  6046
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  6047
    (selectStyle == #wordLeft) ifTrue:[
3813
8d719ca5812d dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3811
diff changeset
  6048
        self replaceSelectionBy:(' ' , key asString)
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  6049
    ] ifFalse:[
3813
8d719ca5812d dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3811
diff changeset
  6050
        (selectStyle == #wordRight) ifTrue:[
8d719ca5812d dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3811
diff changeset
  6051
            self replaceSelectionBy:(key asString , ' ').
8d719ca5812d dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3811
diff changeset
  6052
            self cursorLeft
8d719ca5812d dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3811
diff changeset
  6053
        ] ifFalse:[
8d719ca5812d dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3811
diff changeset
  6054
            self replaceSelectionBy:key
8d719ca5812d dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3811
diff changeset
  6055
        ]
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6056
    ].
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  6057
    selectStyle := nil.
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  6058
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  6059
    editMode value isInsertAndSelectMode ifTrue:[
4700
150468a2ea5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4697
diff changeset
  6060
        selectionStartLine := selStartLineBefore.
150468a2ea5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4697
diff changeset
  6061
        selectionStartCol := selStartColBefore.
150468a2ea5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4697
diff changeset
  6062
        selectionEndLine := selEndLineBefore.
150468a2ea5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4697
diff changeset
  6063
        selectionEndCol := selEndColBefore.
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  6064
    ].
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  6065
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  6066
    showMatchingParenthesis ifTrue:[
3813
8d719ca5812d dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3811
diff changeset
  6067
        "emacs style parenthesis shower"
8d719ca5812d dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3811
diff changeset
  6068
      (ExecutingMacroQuery query ? false) ifFalse:[
8d719ca5812d dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3811
diff changeset
  6069
        "claus: only do it for closing parenthesis -
8d719ca5812d dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3811
diff changeset
  6070
                otherwise its too anoying.
8d719ca5812d dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3811
diff changeset
  6071
        "
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  6072
"
4481
76c592c0ae9c class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 4475
diff changeset
  6073
        ('()[]{}' includes:key) ifTrue:[
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  6074
"
4481
76c592c0ae9c class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 4475
diff changeset
  6075
        (')]}' includes:key) ifTrue:[
3813
8d719ca5812d dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3811
diff changeset
  6076
        self
8d719ca5812d dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3811
diff changeset
  6077
            searchForMatchingParenthesisFromLine:cursorLine col:(cursorCol - 1)
8d719ca5812d dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3811
diff changeset
  6078
            ifFound:[:line :col |
8d719ca5812d dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3811
diff changeset
  6079
                         |savLine savCol sensor|
8d719ca5812d dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3811
diff changeset
  6080
8d719ca5812d dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3811
diff changeset
  6081
                         self withCursor:Cursor eye do:[
8d719ca5812d dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3811
diff changeset
  6082
                             savLine := cursorLine.
8d719ca5812d dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3811
diff changeset
  6083
                             savCol := cursorCol.
8d719ca5812d dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3811
diff changeset
  6084
                             self cursorLine:line col:col.
4940
73e7031a4a85 class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 4889
diff changeset
  6085
                             self flush.
3813
8d719ca5812d dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3811
diff changeset
  6086
8d719ca5812d dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3811
diff changeset
  6087
                             "/ want to wait 200ms, but not if another keyPress
8d719ca5812d dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3811
diff changeset
  6088
                             "/ arrives in the meantime ...
8d719ca5812d dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3811
diff changeset
  6089
8d719ca5812d dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3811
diff changeset
  6090
                             sensor := self sensor.
8d719ca5812d dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3811
diff changeset
  6091
                             5 timesRepeat:[
8d719ca5812d dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3811
diff changeset
  6092
                                 (sensor hasKeyPressEventFor:self) ifFalse:[
8d719ca5812d dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3811
diff changeset
  6093
                                     Processor activeProcess millisecondDelay:40.
8d719ca5812d dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3811
diff changeset
  6094
                                 ]
8d719ca5812d dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3811
diff changeset
  6095
                             ].
8d719ca5812d dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3811
diff changeset
  6096
                             self cursorLine:savLine col:savCol
8d719ca5812d dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3811
diff changeset
  6097
                         ]
8d719ca5812d dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3811
diff changeset
  6098
                    ]
8d719ca5812d dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3811
diff changeset
  6099
            ifNotFound:[self showNotFound]
8d719ca5812d dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3811
diff changeset
  6100
            onError:[self beep]
8d719ca5812d dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3811
diff changeset
  6101
        ].
8d719ca5812d dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3811
diff changeset
  6102
      ]
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  6103
    ].
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  6104
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  6105
"/    true "autoExpandWhileTyping" ifTrue:[
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  6106
"/        self wordAtLine:cursorLine col:cursorCol-1 do:[
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  6107
"/            :beginLine :beginCol :endLine :endCol :style |
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  6108
"/
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  6109
"/            self selectFromLine:beginLine col:beginCol toLine:endLine col:endCol.
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  6110
"/            self selection.
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  6111
"/            typeOfSelection := #paste.
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6112
"/        ].
3683
5891af82a177 middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents: 3650
diff changeset
  6113
"/    ].
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  6114
    editMode value isInsertAndSelectMode ifTrue:[
3813
8d719ca5812d dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3811
diff changeset
  6115
        selectionStartLine isNil ifTrue:[
8d719ca5812d dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3811
diff changeset
  6116
            self selectFromLine:cursorLine col:cursorCol-1 toLine:cursorLine col:cursorCol-1.
8d719ca5812d dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3811
diff changeset
  6117
        ] ifFalse:[
8d719ca5812d dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3811
diff changeset
  6118
            self selectFromLine:selectionStartLine col:selectionStartCol toLine:cursorLine col:cursorCol-1.
8d719ca5812d dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3811
diff changeset
  6119
        ].
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  6120
    ].
4801
69a5bff7b5cd Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4786
diff changeset
  6121
    completionSupport notNil ifTrue:[ completionSupport postKeyPress:keyArg ].
4360
fe77e479d95a comment/format in:
Claus Gittinger <cg@exept.de>
parents: 4328
diff changeset
  6122
fe77e479d95a comment/format in:
Claus Gittinger <cg@exept.de>
parents: 4328
diff changeset
  6123
    "Modified (comment): / 25-01-2012 / 00:30:11 / cg"
4846
cd2e0b754655 Fix for paster-keystroke: should insert character at the end of the just pasted selection,
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4845
diff changeset
  6124
    "Modified: / 30-08-2013 / 20:10:01 / Jan Vrany <jan.vrany@fit.cvut.cz>"
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  6125
!
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  6126
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  6127
keyPress:key x:x y:y
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  6128
    "handle keyboard input"
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  6129
4771
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  6130
    |wasOn|
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  6131
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  6132
    wasOn := cursorShown.
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  6133
5689
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  6134
    NoModificationError 
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  6135
        handle:[:ex |
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  6136
            self flashReadOnly.
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  6137
            (cursorShown not and:[wasOn]) ifTrue:[
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  6138
                self makeCursorVisibleAndShowCursor:wasOn.
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  6139
            ].
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  6140
        ] 
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  6141
        do:[
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  6142
            self undoableDo:[
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  6143
                self doKeyPress:key x:x y:y
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  6144
            ].
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  6145
        ].
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  6146
4242
93363c9c43cd changed: #keyPress:x:y:
Claus Gittinger <cg@exept.de>
parents: 4238
diff changeset
  6147
    self repairDamage
93363c9c43cd changed: #keyPress:x:y:
Claus Gittinger <cg@exept.de>
parents: 4238
diff changeset
  6148
93363c9c43cd changed: #keyPress:x:y:
Claus Gittinger <cg@exept.de>
parents: 4238
diff changeset
  6149
    "Modified: / 18-04-2011 / 21:35:27 / cg"
5689
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  6150
    "Modified (format): / 30-04-2016 / 20:45:52 / cg"
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  6151
!
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  6152
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6153
mapped
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6154
    "view was made visible"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6155
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6156
    super mapped.
2422
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  6157
    self updateCursorVisibleLine.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6158
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6159
3268
d30df22739ca move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents: 3257
diff changeset
  6160
requestAutoAccept
5068
3ad3eb432172 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5067
diff changeset
  6161
    "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
  6162
     This forces my value to be accepted into my model.
3ad3eb432172 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5067
diff changeset
  6163
     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
  6164
d30df22739ca move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents: 3257
diff changeset
  6165
    acceptEnabled == false ifTrue:[
4823
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  6166
        "/ nope -
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  6167
        ^ false
3268
d30df22739ca move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents: 3257
diff changeset
  6168
    ].
5404
50b74416cbd4 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5400
diff changeset
  6169
    "/ cg: only do this if modified.
50b74416cbd4 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5400
diff changeset
  6170
    "/ otherwise, users would have to make sure that the contents is
50b74416cbd4 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5400
diff changeset
  6171
    "/ always correct (which they don't). If you change this back,
50b74416cbd4 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5400
diff changeset
  6172
    "/ please check the expecco file-save or file-reimport dialog,
50b74416cbd4 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5400
diff changeset
  6173
    "/ which has a problem with that behavior.
50b74416cbd4 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5400
diff changeset
  6174
    self modified ifTrue:[
50b74416cbd4 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5400
diff changeset
  6175
        self accept.
50b74416cbd4 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5400
diff changeset
  6176
    ].
3268
d30df22739ca move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents: 3257
diff changeset
  6177
    ^ true.
d30df22739ca move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents: 3257
diff changeset
  6178
!
d30df22739ca move #requestAutoAccept from EditField to superclass EditTextView
Stefan Vogel <sv@exept.de>
parents: 3257
diff changeset
  6179
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6180
sizeChanged:how
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6181
    "make certain, cursor is visible after the sizechange"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6182
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6183
    |cv|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6184
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6185
    cv := cursorVisibleLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6186
    super sizeChanged:how.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6187
    cv notNil ifTrue:[
4823
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  6188
        self makeLineVisible:cursorLine
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6189
    ]
4967
5af7718d4f2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4966
diff changeset
  6190
!
5af7718d4f2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4966
diff changeset
  6191
5af7718d4f2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4966
diff changeset
  6192
unmapped
5af7718d4f2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4966
diff changeset
  6193
    super unmapped.
5af7718d4f2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4966
diff changeset
  6194
5af7718d4f2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4966
diff changeset
  6195
    completionSupport notNil ifTrue:[
5af7718d4f2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4966
diff changeset
  6196
        completionSupport release.
5af7718d4f2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4966
diff changeset
  6197
    ].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6198
! !
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6199
1807
30526cb1acfc category and comment
Claus Gittinger <cg@exept.de>
parents: 1804
diff changeset
  6200
!EditTextView methodsFor:'focus handling'!
30526cb1acfc category and comment
Claus Gittinger <cg@exept.de>
parents: 1804
diff changeset
  6201
4818
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  6202
focusOut
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  6203
    super focusOut.
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  6204
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  6205
    completionSupport notNil ifTrue:[
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  6206
        completionSupport release.
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  6207
    ].
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  6208
!
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  6209
1807
30526cb1acfc category and comment
Claus Gittinger <cg@exept.de>
parents: 1804
diff changeset
  6210
hasKeyboardFocus:aBoolean
30526cb1acfc category and comment
Claus Gittinger <cg@exept.de>
parents: 1804
diff changeset
  6211
    "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
  6212
     (otherwise, I would not know about this)"
30526cb1acfc category and comment
Claus Gittinger <cg@exept.de>
parents: 1804
diff changeset
  6213
30526cb1acfc category and comment
Claus Gittinger <cg@exept.de>
parents: 1804
diff changeset
  6214
    hasKeyboardFocus := aBoolean.
4609
8b3eb80d04d0 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4595
diff changeset
  6215
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6216
    (cursorShown
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6217
    and:[self enabled
3296
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
  6218
    and:[self isReadOnly not]]) ifTrue:[
5890
5dc30fda9ebf #OTHER by mawalch
mawalch
parents: 5887
diff changeset
  6219
        self drawCursor
4609
8b3eb80d04d0 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4595
diff changeset
  6220
    ].
8b3eb80d04d0 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4595
diff changeset
  6221
8b3eb80d04d0 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4595
diff changeset
  6222
    hasKeyboardFocus ifFalse:[
5890
5dc30fda9ebf #OTHER by mawalch
mawalch
parents: 5887
diff changeset
  6223
        completionSupport notNil ifTrue:[
5dc30fda9ebf #OTHER by mawalch
mawalch
parents: 5887
diff changeset
  6224
            "/ this is a hack for Windows:
5dc30fda9ebf #OTHER by mawalch
mawalch
parents: 5887
diff changeset
  6225
            "/ on windows, an activate:false event is first sent to my textView,
5dc30fda9ebf #OTHER by mawalch
mawalch
parents: 5887
diff changeset
  6226
            "/ then an activate is sent to the completion popup.
5dc30fda9ebf #OTHER by mawalch
mawalch
parents: 5887
diff changeset
  6227
            "/ this is done BEFORE the buttonPress event is delivered.
5dc30fda9ebf #OTHER by mawalch
mawalch
parents: 5887
diff changeset
  6228
            "/ therefore, allow for the activate of the completionMenu and its button event to be processed.
5dc30fda9ebf #OTHER by mawalch
mawalch
parents: 5887
diff changeset
  6229
            "/ before forcing it to be closed...
5dc30fda9ebf #OTHER by mawalch
mawalch
parents: 5887
diff changeset
  6230
            completionSupport startTimeoutForEditViewLostFocus.
5dc30fda9ebf #OTHER by mawalch
mawalch
parents: 5887
diff changeset
  6231
        ].
1816
0b9380a0cc7e only take keyboardFocus (and show cursor)
Claus Gittinger <cg@exept.de>
parents: 1811
diff changeset
  6232
    ].
0b9380a0cc7e only take keyboardFocus (and show cursor)
Claus Gittinger <cg@exept.de>
parents: 1811
diff changeset
  6233
4821
b108cc2ff7e9 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4820
diff changeset
  6234
    "Modified (format): / 06-11-2013 / 15:37:31 / cg"
1807
30526cb1acfc category and comment
Claus Gittinger <cg@exept.de>
parents: 1804
diff changeset
  6235
!
30526cb1acfc category and comment
Claus Gittinger <cg@exept.de>
parents: 1804
diff changeset
  6236
30526cb1acfc category and comment
Claus Gittinger <cg@exept.de>
parents: 1804
diff changeset
  6237
showFocus:explicit
30526cb1acfc category and comment
Claus Gittinger <cg@exept.de>
parents: 1804
diff changeset
  6238
    "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
  6239
     displayed, show the cursor when I got the focus"
30526cb1acfc category and comment
Claus Gittinger <cg@exept.de>
parents: 1804
diff changeset
  6240
5239
0312ca8fd55e class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5226
diff changeset
  6241
    self hasKeyboardFocus:true.
1807
30526cb1acfc category and comment
Claus Gittinger <cg@exept.de>
parents: 1804
diff changeset
  6242
    self showCursor.
30526cb1acfc category and comment
Claus Gittinger <cg@exept.de>
parents: 1804
diff changeset
  6243
    super showFocus:explicit
30526cb1acfc category and comment
Claus Gittinger <cg@exept.de>
parents: 1804
diff changeset
  6244
30526cb1acfc category and comment
Claus Gittinger <cg@exept.de>
parents: 1804
diff changeset
  6245
    "Modified: 11.12.1996 / 16:56:54 / cg"
1918
3ac07b97b4f7 use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents: 1902
diff changeset
  6246
!
3ac07b97b4f7 use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents: 1902
diff changeset
  6247
4967
5af7718d4f2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4966
diff changeset
  6248
showNoFocus:explicit
5af7718d4f2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4966
diff changeset
  6249
    "the view lost the keyboard focus 
5af7718d4f2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4966
diff changeset
  6250
     (either explicit, via tabbing; or implicit, by pointer movement)
5af7718d4f2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4966
diff changeset
  6251
      - change any display attributes as req'd."
5af7718d4f2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4966
diff changeset
  6252
5af7718d4f2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4966
diff changeset
  6253
    super showNoFocus:explicit.
5149
cc14f4e4157d class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5146
diff changeset
  6254
cc14f4e4157d class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5146
diff changeset
  6255
    "/ cg: only do this for an explicit change (i.e. by tabbing),
cc14f4e4157d class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5146
diff changeset
  6256
    "/ not when the focus is lost normally (because this also happens when
cc14f4e4157d class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5146
diff changeset
  6257
    "/ 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
  6258
    "/ completer. Otherwise, completion does not work when clocking into the list.
cc14f4e4157d class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5146
diff changeset
  6259
    explicit ifTrue:[
cc14f4e4157d class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5146
diff changeset
  6260
        completionSupport notNil ifTrue:[
cc14f4e4157d class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5146
diff changeset
  6261
            completionSupport release.
cc14f4e4157d class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5146
diff changeset
  6262
        ].
4818
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  6263
    ].
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  6264
!
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  6265
1918
3ac07b97b4f7 use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents: 1902
diff changeset
  6266
wantsFocusWithPointerEnter
3ac07b97b4f7 use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents: 1902
diff changeset
  6267
    "return true, if I want the focus when
3ac07b97b4f7 use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents: 1902
diff changeset
  6268
     the mouse pointer enters"
3ac07b97b4f7 use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents: 1902
diff changeset
  6269
3296
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
  6270
    (UserPreferences current focusFollowsMouse ~~ false
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
  6271
     and:[(styleSheet at:#'editText.requestFocusOnPointerEnter' default:true)
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
  6272
     and:[self enabled
4781
11d53632e47e class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4775
diff changeset
  6273
     and:[true "self isReadOnly not"]]]
4097
233d27a2b0a0 comment/format in: #wantsFocusWithPointerEnter
Claus Gittinger <cg@exept.de>
parents: 4089
diff changeset
  6274
    ) ifTrue:[
233d27a2b0a0 comment/format in: #wantsFocusWithPointerEnter
Claus Gittinger <cg@exept.de>
parents: 4089
diff changeset
  6275
        ^ true
1918
3ac07b97b4f7 use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents: 1902
diff changeset
  6276
    ].
3ac07b97b4f7 use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents: 1902
diff changeset
  6277
3ac07b97b4f7 use extra query: #wantsFocusWithPointerEnter;
Claus Gittinger <cg@exept.de>
parents: 1902
diff changeset
  6278
    ^ false
1807
30526cb1acfc category and comment
Claus Gittinger <cg@exept.de>
parents: 1804
diff changeset
  6279
! !
30526cb1acfc category and comment
Claus Gittinger <cg@exept.de>
parents: 1804
diff changeset
  6280
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6281
!EditTextView methodsFor:'formatting'!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6282
4237
Claus Gittinger <cg@exept.de>
parents: 4226
diff changeset
  6283
executekeyboardMacroNamed:macroName
4371
a631db2025af changed: #executekeyboardMacroNamed:
Claus Gittinger <cg@exept.de>
parents: 4360
diff changeset
  6284
    "try to execute the keyboard macro; 
a631db2025af changed: #executekeyboardMacroNamed:
Claus Gittinger <cg@exept.de>
parents: 4360
diff changeset
  6285
     return true if that worked, false otherwise"
a631db2025af changed: #executekeyboardMacroNamed:
Claus Gittinger <cg@exept.de>
parents: 4360
diff changeset
  6286
4482
0530a2d95b4b class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 4481
diff changeset
  6287
    |cmdMacro|
0530a2d95b4b class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 4481
diff changeset
  6288
0530a2d95b4b class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 4481
diff changeset
  6289
    cmdMacro := UserPreferences current functionKeySequences at:macroName ifAbsent:[^ false].
4371
a631db2025af changed: #executekeyboardMacroNamed:
Claus Gittinger <cg@exept.de>
parents: 4360
diff changeset
  6290
    self
a631db2025af changed: #executekeyboardMacroNamed:
Claus Gittinger <cg@exept.de>
parents: 4360
diff changeset
  6291
        undoableDo:[ self executeKeyboardMacro:cmdMacro ]
a631db2025af changed: #executekeyboardMacroNamed:
Claus Gittinger <cg@exept.de>
parents: 4360
diff changeset
  6292
        info: macroName.
a631db2025af changed: #executekeyboardMacroNamed:
Claus Gittinger <cg@exept.de>
parents: 4360
diff changeset
  6293
    ^ true
4238
5f7125996b44 changed:
Stefan Vogel <sv@exept.de>
parents: 4237
diff changeset
  6294
5f7125996b44 changed:
Stefan Vogel <sv@exept.de>
parents: 4237
diff changeset
  6295
    "
4483
5b71475eddbc class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 4482
diff changeset
  6296
      EditTextView open
4238
5f7125996b44 changed:
Stefan Vogel <sv@exept.de>
parents: 4237
diff changeset
  6297
                contents:'bla';
5f7125996b44 changed:
Stefan Vogel <sv@exept.de>
parents: 4237
diff changeset
  6298
                selectAll;
5f7125996b44 changed:
Stefan Vogel <sv@exept.de>
parents: 4237
diff changeset
  6299
                executekeyboardMacroNamed:#IndentBy4.
4483
5b71475eddbc class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 4482
diff changeset
  6300
      EditTextView open
4238
5f7125996b44 changed:
Stefan Vogel <sv@exept.de>
parents: 4237
diff changeset
  6301
                contents:'bla';
5f7125996b44 changed:
Stefan Vogel <sv@exept.de>
parents: 4237
diff changeset
  6302
                selectAll;
5f7125996b44 changed:
Stefan Vogel <sv@exept.de>
parents: 4237
diff changeset
  6303
                executekeyboardMacroNamed:#blabla.
5f7125996b44 changed:
Stefan Vogel <sv@exept.de>
parents: 4237
diff changeset
  6304
    "
4371
a631db2025af changed: #executekeyboardMacroNamed:
Claus Gittinger <cg@exept.de>
parents: 4360
diff changeset
  6305
a631db2025af changed: #executekeyboardMacroNamed:
Claus Gittinger <cg@exept.de>
parents: 4360
diff changeset
  6306
    "Modified: / 14-02-2012 / 11:17:27 / cg"
4237
Claus Gittinger <cg@exept.de>
parents: 4226
diff changeset
  6307
!
Claus Gittinger <cg@exept.de>
parents: 4226
diff changeset
  6308
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6309
indent
3221
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  6310
    "indent a line-range - this is done by searching for the
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  6311
     last non-empty line before the selection, and changing the indent
4742
a00cb40ee392 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4738
diff changeset
  6312
     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
  6313
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6314
    |start end|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6315
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6316
    selectionStartLine isNil ifTrue:[^ self].
3221
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  6317
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6318
    start := selectionStartLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6319
    end := selectionEndLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6320
    (selectionEndCol == 0) ifTrue:[
3786
11145773de65 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3782
diff changeset
  6321
        end := end - 1
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6322
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6323
    self unselect.
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  6324
    self
3786
11145773de65 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3782
diff changeset
  6325
        undoableDo:[self indentFromLine:start toLine:end]
11145773de65 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3782
diff changeset
  6326
        info:'Indent'
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6327
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6328
4237
Claus Gittinger <cg@exept.de>
parents: 4226
diff changeset
  6329
indentBy4
5050
a1157f4a40ce class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5045
diff changeset
  6330
    self indentBy:4. "/ self executekeyboardMacroNamed:#IndentBy4.
a1157f4a40ce class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5045
diff changeset
  6331
a1157f4a40ce class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5045
diff changeset
  6332
    "Modified: / 06-04-2011 / 18:52:40 / cg"
a1157f4a40ce class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5045
diff changeset
  6333
!
a1157f4a40ce class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5045
diff changeset
  6334
a1157f4a40ce class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5045
diff changeset
  6335
indentBy8
a1157f4a40ce class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5045
diff changeset
  6336
    self indentBy:8. "/ self executekeyboardMacroNamed:#IndentBy4.
4237
Claus Gittinger <cg@exept.de>
parents: 4226
diff changeset
  6337
Claus Gittinger <cg@exept.de>
parents: 4226
diff changeset
  6338
    "Modified: / 06-04-2011 / 18:52:40 / cg"
Claus Gittinger <cg@exept.de>
parents: 4226
diff changeset
  6339
!
Claus Gittinger <cg@exept.de>
parents: 4226
diff changeset
  6340
5050
a1157f4a40ce class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5045
diff changeset
  6341
indentBy:n
a1157f4a40ce class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5045
diff changeset
  6342
    |line1 line2|
a1157f4a40ce class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5045
diff changeset
  6343
a1157f4a40ce class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5045
diff changeset
  6344
    line1 := self selectionStartLine.
a1157f4a40ce class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5045
diff changeset
  6345
    line2 := self selectionEndLine.
a1157f4a40ce class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5045
diff changeset
  6346
    line1 isNil ifTrue:[
5833
584a6e4d283a #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 5826
diff changeset
  6347
        line1 := self cursorLine.
584a6e4d283a #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 5826
diff changeset
  6348
        line1 notNil ifTrue:[
584a6e4d283a #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 5826
diff changeset
  6349
            line2 := line1
584a6e4d283a #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 5826
diff changeset
  6350
        ]
5769
32db0c4a851c #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 5761
diff changeset
  6351
    ] ifFalse:[
5833
584a6e4d283a #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 5826
diff changeset
  6352
        line2 notNil ifTrue:[
584a6e4d283a #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 5826
diff changeset
  6353
            self selectionEndCol == 0 ifTrue:[ line2 := line2 - 1 ].
5769
32db0c4a851c #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 5761
diff changeset
  6354
        ].                
32db0c4a851c #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 5761
diff changeset
  6355
    ].                
5050
a1157f4a40ce class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5045
diff changeset
  6356
    line1 notNil ifTrue:[
5833
584a6e4d283a #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 5826
diff changeset
  6357
        self indentFromLine:line1 toLine:line2 by:n.
5050
a1157f4a40ce class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5045
diff changeset
  6358
    ]
a1157f4a40ce class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5045
diff changeset
  6359
!
a1157f4a40ce class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5045
diff changeset
  6360
a1157f4a40ce class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5045
diff changeset
  6361
indentByTab
a1157f4a40ce class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5045
diff changeset
  6362
    self indentBy:((tabPositions == self class tab4Positions) ifTrue:4 ifFalse:8)
a1157f4a40ce class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5045
diff changeset
  6363
!
a1157f4a40ce class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5045
diff changeset
  6364
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6365
indentFromLine:start toLine:end
3221
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  6366
    "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
  6367
     last non-empty line before start, and change the indent
4742
a00cb40ee392 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4738
diff changeset
  6368
     of the selected line-range based on that line's indent."
a00cb40ee392 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4738
diff changeset
  6369
4811
e868808b229e class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4803
diff changeset
  6370
    |leftStart delta|
474
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  6371
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  6372
    leftStart := self leftIndentForLine:start.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6373
    (leftStart == 0) ifTrue:[^ self].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6374
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6375
    delta := leftStart - (self leftIndentOfLine:start).
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6376
    (delta == 0) ifTrue:[^ self].
4811
e868808b229e class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4803
diff changeset
  6377
    self indentFromLine:start toLine:end by:delta
e868808b229e class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4803
diff changeset
  6378
!
e868808b229e class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4803
diff changeset
  6379
e868808b229e class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4803
diff changeset
  6380
indentFromLine:start toLine:end by:delta
e868808b229e class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4803
diff changeset
  6381
    "indent a line-range - this is done by searching for the
e868808b229e class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4803
diff changeset
  6382
     last non-empty line before start, and change the indent
e868808b229e class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4803
diff changeset
  6383
     of the selected line-range based on that line's indent."
e868808b229e class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4803
diff changeset
  6384
e868808b229e class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4803
diff changeset
  6385
    |d line spaces anyChange|
e868808b229e class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4803
diff changeset
  6386
e868808b229e class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4803
diff changeset
  6387
    (delta == 0) ifTrue:[^ self].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6388
    (delta > 0) ifTrue:[
4742
a00cb40ee392 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4738
diff changeset
  6389
        spaces := String new:delta
a00cb40ee392 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4738
diff changeset
  6390
    ].
a00cb40ee392 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4738
diff changeset
  6391
a00cb40ee392 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4738
diff changeset
  6392
    anyChange := false.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6393
    start to:end do:[:lineNr |
4742
a00cb40ee392 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4738
diff changeset
  6394
        line := self listAt:lineNr.
a00cb40ee392 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4738
diff changeset
  6395
        line notNil ifTrue:[
a00cb40ee392 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4738
diff changeset
  6396
            line isBlank ifTrue:[
4771
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  6397
                self basicListAt:lineNr put:nil
4742
a00cb40ee392 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4738
diff changeset
  6398
            ] ifFalse:[
a00cb40ee392 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4738
diff changeset
  6399
                (delta > 0) ifTrue:[
a00cb40ee392 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4738
diff changeset
  6400
                    line := spaces , line.
a00cb40ee392 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4738
diff changeset
  6401
                    widthOfWidestLine notNil ifTrue:[
a00cb40ee392 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4738
diff changeset
  6402
                        widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:line).
a00cb40ee392 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4738
diff changeset
  6403
                    ]
a00cb40ee392 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4738
diff changeset
  6404
                ] ifFalse:[
a00cb40ee392 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4738
diff changeset
  6405
                    "check if deletion is ok"
a00cb40ee392 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4738
diff changeset
  6406
                    d := delta negated + 1.
a00cb40ee392 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4738
diff changeset
  6407
a00cb40ee392 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4738
diff changeset
  6408
                    line size > d ifTrue:[
a00cb40ee392 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4738
diff changeset
  6409
                        (line copyTo:(d - 1)) withoutSeparators isEmpty ifTrue:[
a00cb40ee392 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4738
diff changeset
  6410
                            line := line copyFrom:d
a00cb40ee392 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4738
diff changeset
  6411
                        ]
a00cb40ee392 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4738
diff changeset
  6412
                    ].
a00cb40ee392 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4738
diff changeset
  6413
                    widthOfWidestLine := nil
a00cb40ee392 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4738
diff changeset
  6414
                ].
a00cb40ee392 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4738
diff changeset
  6415
                self replaceLine:lineNr with:line.
a00cb40ee392 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4738
diff changeset
  6416
                anyChange := true.
a00cb40ee392 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4738
diff changeset
  6417
            ]
a00cb40ee392 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4738
diff changeset
  6418
        ]
a00cb40ee392 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4738
diff changeset
  6419
    ].
a00cb40ee392 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4738
diff changeset
  6420
a00cb40ee392 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4738
diff changeset
  6421
    anyChange ifTrue:[ self textChanged ].
a00cb40ee392 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4738
diff changeset
  6422
3221
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  6423
    "/ self redrawFromLine:start to:end
474
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  6424
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  6425
    "Modified: 5.3.1996 / 14:59:18 / cg"
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  6426
!
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  6427
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  6428
leftIndentForLine:lineNr
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  6429
    "find an appropriate indent for a line.
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  6430
     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
  6431
     and returning its indent.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  6432
     cg: changed: only look for the single previous line."
474
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  6433
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  6434
    "SHOULD GO TO ListView"
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  6435
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  6436
    |line lnr indent|
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  6437
474
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  6438
    lnr := lineNr.
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  6439
4823
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  6440
    "/ [lnr ~~ 1] whileTrue:[
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  6441
    (lnr ~~ 1) ifTrue:[
4814
6f9c85f3fbfb class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4812
diff changeset
  6442
        lnr  := lnr - 1.
6f9c85f3fbfb class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4812
diff changeset
  6443
        line := self listAt:lnr.
6f9c85f3fbfb class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4812
diff changeset
  6444
6f9c85f3fbfb class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4812
diff changeset
  6445
        line notNil ifTrue:[
6f9c85f3fbfb class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4812
diff changeset
  6446
            indent := line indexOfNonSeparatorStartingAt:1.
6f9c85f3fbfb class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4812
diff changeset
  6447
            indent ~~ 0 ifTrue:[
6f9c85f3fbfb class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4812
diff changeset
  6448
                (line endsWith:$[) ifTrue:[
6f9c85f3fbfb class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4812
diff changeset
  6449
                    ^ indent + 4 - 1
6f9c85f3fbfb class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4812
diff changeset
  6450
                ].
6f9c85f3fbfb class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4812
diff changeset
  6451
                ^ indent - 1
6f9c85f3fbfb class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4812
diff changeset
  6452
            ]
6f9c85f3fbfb class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4812
diff changeset
  6453
        ]
474
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  6454
    ].
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  6455
    ^ 0
474
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  6456
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  6457
    "Created: 5.3.1996 / 14:58:53 / cg"
4237
Claus Gittinger <cg@exept.de>
parents: 4226
diff changeset
  6458
!
Claus Gittinger <cg@exept.de>
parents: 4226
diff changeset
  6459
Claus Gittinger <cg@exept.de>
parents: 4226
diff changeset
  6460
undentBy4
5050
a1157f4a40ce class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5045
diff changeset
  6461
    self undentBy:4. "/ self executekeyboardMacroNamed:#UndentBy4.
a1157f4a40ce class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5045
diff changeset
  6462
a1157f4a40ce class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5045
diff changeset
  6463
    "Modified: / 06-04-2011 / 18:52:49 / cg"
a1157f4a40ce class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5045
diff changeset
  6464
!
a1157f4a40ce class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5045
diff changeset
  6465
a1157f4a40ce class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5045
diff changeset
  6466
undentBy8
a1157f4a40ce class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5045
diff changeset
  6467
    self undentBy:8. "/ self executekeyboardMacroNamed:#UndentBy4.
4237
Claus Gittinger <cg@exept.de>
parents: 4226
diff changeset
  6468
Claus Gittinger <cg@exept.de>
parents: 4226
diff changeset
  6469
    "Modified: / 06-04-2011 / 18:52:49 / cg"
5050
a1157f4a40ce class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5045
diff changeset
  6470
!
a1157f4a40ce class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5045
diff changeset
  6471
a1157f4a40ce class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5045
diff changeset
  6472
undentBy:n
a1157f4a40ce class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5045
diff changeset
  6473
    self indentBy:(n negated)
a1157f4a40ce class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5045
diff changeset
  6474
!
a1157f4a40ce class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5045
diff changeset
  6475
a1157f4a40ce class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5045
diff changeset
  6476
undentByTab
a1157f4a40ce class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5045
diff changeset
  6477
    self undentBy:((tabPositions == self class tab4Positions) ifTrue:4 ifFalse:8).
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  6478
! !
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  6479
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  6480
!EditTextView methodsFor:'initialization'!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  6481
941
f06fa4d47f26 fetch device resources early
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  6482
fetchDeviceResources
f06fa4d47f26 fetch device resources early
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  6483
    "fetch device colors, to avoid reallocation at redraw time"
f06fa4d47f26 fetch device resources early
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  6484
f06fa4d47f26 fetch device resources early
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  6485
    super fetchDeviceResources.
f06fa4d47f26 fetch device resources early
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  6486
5643
921578f80870 device access
Claus Gittinger <cg@exept.de>
parents: 5593
diff changeset
  6487
    cursorFgColor notNil ifTrue:[cursorFgColor := cursorFgColor onDevice:device].
921578f80870 device access
Claus Gittinger <cg@exept.de>
parents: 5593
diff changeset
  6488
    cursorBgColor notNil ifTrue:[cursorBgColor := cursorBgColor onDevice:device].
921578f80870 device access
Claus Gittinger <cg@exept.de>
parents: 5593
diff changeset
  6489
    cursorNoFocusFgColor notNil ifTrue:[cursorNoFocusFgColor := cursorNoFocusFgColor onDevice:device].
941
f06fa4d47f26 fetch device resources early
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  6490
f06fa4d47f26 fetch device resources early
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  6491
    "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
  6492
    "Modified: 18.2.1997 / 15:02:46 / cg"
941
f06fa4d47f26 fetch device resources early
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  6493
!
f06fa4d47f26 fetch device resources early
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  6494
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6495
initEvents
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6496
    "enable enter/leave events in addition"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6497
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6498
    super initEvents.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6499
    self enableEnterLeaveEvents
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6500
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6501
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6502
initStyle
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6503
    "initialize style specific stuff"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6504
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6505
    super initStyle.
4576
c9d937d20173 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4566
diff changeset
  6506
    "/ lineSpacing := 2.       "/ for underwave - also looks better
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6507
    lockUpdates := false.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6508
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6509
    cursorFgColor := DefaultCursorForegroundColor.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6510
    cursorFgColor isNil ifTrue:[cursorFgColor := bgColor].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6511
    cursorBgColor := DefaultCursorBackgroundColor.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6512
    cursorBgColor isNil ifTrue:[cursorBgColor := fgColor].
4721
59fc420ce5b0 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4715
diff changeset
  6513
    cursorType isNil ifTrue:[cursorType := DefaultCursorType].
59fc420ce5b0 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4715
diff changeset
  6514
    cursorTypeNoFocus isNil ifTrue:[
59fc420ce5b0 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4715
diff changeset
  6515
        cursorTypeNoFocus := cursorType.
59fc420ce5b0 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4715
diff changeset
  6516
        DefaultCursorTypeNoFocus notNil ifTrue:[
59fc420ce5b0 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4715
diff changeset
  6517
            cursorTypeNoFocus := DefaultCursorTypeNoFocus.
59fc420ce5b0 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4715
diff changeset
  6518
        ]
1534
bcb211e1b41a read noFocus cursorStyle from styleSheet
Claus Gittinger <cg@exept.de>
parents: 1533
diff changeset
  6519
    ].
1022
4362861fe15e allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents: 1018
diff changeset
  6520
    cursorNoFocusFgColor := DefaultCursorNoFocusForegroundColor.
4362861fe15e allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents: 1018
diff changeset
  6521
    cursorNoFocusFgColor isNil ifTrue:[
4576
c9d937d20173 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4566
diff changeset
  6522
        cursorType ~~ #block ifTrue:[
c9d937d20173 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4566
diff changeset
  6523
            cursorNoFocusFgColor := cursorBgColor
c9d937d20173 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4566
diff changeset
  6524
        ] ifFalse:[
c9d937d20173 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4566
diff changeset
  6525
            cursorNoFocusFgColor := cursorFgColor
c9d937d20173 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4566
diff changeset
  6526
        ]
1022
4362861fe15e allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents: 1018
diff changeset
  6527
    ].
4362861fe15e allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents: 1018
diff changeset
  6528
2088
b2beb67b1a98 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2085
diff changeset
  6529
    "Modified: / 15.12.1999 / 22:27:45 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6530
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6531
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6532
initialize
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6533
    "initialize a new EditTextView;
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6534
     setup some instance variables"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6535
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6536
    super initialize.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6537
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6538
    self level:-1.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6539
    readOnly := false.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6540
    fixedSize := false.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6541
    exceptionBlock := [:errorText | ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6542
    cursorShown := prevCursorState := true.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6543
    cursorLine := 1.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6544
    cursorVisibleLine := 1.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6545
    cursorCol := 1.
5251
259d72b38bd7 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5244
diff changeset
  6546
    cursorLineHolder := ValueHolder with:1.
259d72b38bd7 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5244
diff changeset
  6547
    cursorColHolder := ValueHolder with:1.
2119
2aa585fc62a3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2117
diff changeset
  6548
    modifiedChannel := ValueHolder with:false.
2aa585fc62a3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2117
diff changeset
  6549
    acceptChannel := ValueHolder with:false.
1437
ab84b08a9f9c allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
  6550
    acceptChannel addDependent:self.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6551
    showMatchingParenthesis := false.
3296
7322b2e5222c Allow for readOnly TextCollectors
Stefan Vogel <sv@exept.de>
parents: 3269
diff changeset
  6552
    hasKeyboardFocus := false.
323
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
  6553
    tabMeansNextField := false.
5106
7376f2c47d5f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5104
diff changeset
  6554
    "/ autoIndent := UserPreferences current autoIndentInCodeView.
7376f2c47d5f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5104
diff changeset
  6555
    autoIndent := false.
5251
259d72b38bd7 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5244
diff changeset
  6556
    editMode := ValueHolder with:EditMode insertMode.
259d72b38bd7 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5244
diff changeset
  6557
    learnMode := ValueHolder with:false.
2131
858209ba8509 cursor movement default
Claus Gittinger <cg@exept.de>
parents: 2129
diff changeset
  6558
    cursorMovementWhenUpdating := #beginOfText.
4048
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
  6559
    lastReplacementInfo := LastReplacementInfo new.
1596
0bbdb4e9fc43 made st80Mode also an inst-flag;
Claus Gittinger <cg@exept.de>
parents: 1591
diff changeset
  6560
3683
5891af82a177 middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents: 3650
diff changeset
  6561
    "/ enable drop by default
2589
62794ae04446 support drop
ca
parents: 2580
diff changeset
  6562
    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
  6563
5dcc2912bcb6 undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents: 2984
diff changeset
  6564
    undoSupport := UndoSupport for:self.
5251
259d72b38bd7 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5244
diff changeset
  6565
    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
  6566
87d60a4b098b Added codeAspect to EditTextView to signify what's being edited.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4801
diff changeset
  6567
    "Modified: / 27-09-2013 / 09:41:32 / Jan Vrany <jan.vrany@fit.cvut.cz>"
4696
428c8bc44cfb refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents: 4694
diff changeset
  6568
!
428c8bc44cfb refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents: 4694
diff changeset
  6569
4801
69a5bff7b5cd Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4786
diff changeset
  6570
initializeCompletionSupport
69a5bff7b5cd Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4786
diff changeset
  6571
    |supportClass|
69a5bff7b5cd Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4786
diff changeset
  6572
69a5bff7b5cd Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4786
diff changeset
  6573
    completionSupport isNil ifTrue:[
69a5bff7b5cd Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4786
diff changeset
  6574
        (supportClass := self completionSupportClass) notNil ifTrue:[
69a5bff7b5cd Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4786
diff changeset
  6575
            completionSupport := supportClass for:self.            
4696
428c8bc44cfb refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents: 4694
diff changeset
  6576
        ].
428c8bc44cfb refactored codeCompletionService
Claus Gittinger <cg@exept.de>
parents: 4694
diff changeset
  6577
    ].
4801
69a5bff7b5cd Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4786
diff changeset
  6578
69a5bff7b5cd Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4786
diff changeset
  6579
    "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
  6580
!
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  6581
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  6582
release
4801
69a5bff7b5cd Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4786
diff changeset
  6583
    completionSupport notNil ifTrue:[
69a5bff7b5cd Completion support refactored:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4786
diff changeset
  6584
        completionSupport release
4771
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  6585
    ].
109861cbb78c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4764
diff changeset
  6586
    super release
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  6587
! !
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  6588
2580
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  6589
!EditTextView methodsFor:'macros'!
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  6590
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  6591
executeLearnedKeyboardMacro
4673
575d2d398823 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4666
diff changeset
  6592
    "replay the characters as learned previously"
575d2d398823 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4666
diff changeset
  6593
2795
1f7b5f242eee learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents: 2792
diff changeset
  6594
    (self learnMode not and:[learnedMacro size > 0]) ifTrue:[
3813
8d719ca5812d dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3811
diff changeset
  6595
        ExecutingMacroQuery 
8d719ca5812d dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3811
diff changeset
  6596
            answer:true
8d719ca5812d dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3811
diff changeset
  6597
            do:[
8d719ca5812d dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3811
diff changeset
  6598
                learnedMacro do:[:event |
8d719ca5812d dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3811
diff changeset
  6599
                            WindowGroup lastEventQuerySignal answer:event
8d719ca5812d dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3811
diff changeset
  6600
                            do:[
8d719ca5812d dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3811
diff changeset
  6601
                                self
8d719ca5812d dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3811
diff changeset
  6602
                                    dispatchEvent:event
8d719ca5812d dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3811
diff changeset
  6603
                                    withFocusOn:nil
8d719ca5812d dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3811
diff changeset
  6604
                                    delegate:false
8d719ca5812d dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3811
diff changeset
  6605
                            ]
8d719ca5812d dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3811
diff changeset
  6606
                ]
8d719ca5812d dont show matching parents when executing a keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3811
diff changeset
  6607
            ].
2580
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  6608
    ] ifFalse:[
5153
7dfd1a447284 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5149
diff changeset
  6609
        self flash:'no macro'.
2580
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  6610
    ].
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  6611
!
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  6612
2795
1f7b5f242eee learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents: 2792
diff changeset
  6613
learnMode
3793
5a6074a257c1 learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents: 3790
diff changeset
  6614
    "true if currently learning"
5a6074a257c1 learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents: 3790
diff changeset
  6615
2795
1f7b5f242eee learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents: 2792
diff changeset
  6616
    ^ (learnMode value ? false).
1f7b5f242eee learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents: 2792
diff changeset
  6617
!
1f7b5f242eee learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents: 2792
diff changeset
  6618
2580
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  6619
learnMode:aBoolean
3793
5a6074a257c1 learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents: 3790
diff changeset
  6620
    "toggle the learn-mode"
5a6074a257c1 learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents: 3790
diff changeset
  6621
2580
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  6622
    |fg bg|
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  6623
2795
1f7b5f242eee learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents: 2792
diff changeset
  6624
    self learnModeHolder value:aBoolean.
1f7b5f242eee learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents: 2792
diff changeset
  6625
1f7b5f242eee learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents: 2792
diff changeset
  6626
    aBoolean ifTrue:[
5795
ee8125645546 #OTHER by stefan
Stefan Vogel <sv@exept.de>
parents: 5787
diff changeset
  6627
        learnedMacro := OrderedCollection new.
ee8125645546 #OTHER by stefan
Stefan Vogel <sv@exept.de>
parents: 5787
diff changeset
  6628
        fg := self whiteColor.
ee8125645546 #OTHER by stefan
Stefan Vogel <sv@exept.de>
parents: 5787
diff changeset
  6629
        bg := self blackColor.
2580
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  6630
    ] ifFalse:[
5795
ee8125645546 #OTHER by stefan
Stefan Vogel <sv@exept.de>
parents: 5787
diff changeset
  6631
        cursorFgColor := fg := (DefaultCursorForegroundColor ? bgColor).
ee8125645546 #OTHER by stefan
Stefan Vogel <sv@exept.de>
parents: 5787
diff changeset
  6632
        cursorBgColor := bg := (DefaultCursorBackgroundColor ? fgColor).
2580
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  6633
    ].
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  6634
    self cursorForegroundColor:fg backgroundColor:bg.
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  6635
!
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  6636
2795
1f7b5f242eee learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents: 2792
diff changeset
  6637
learnModeHolder
4673
575d2d398823 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4666
diff changeset
  6638
    "a holder returning true, if in learn mode"
575d2d398823 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4666
diff changeset
  6639
2795
1f7b5f242eee learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents: 2792
diff changeset
  6640
    learnMode isNil ifTrue:[
5251
259d72b38bd7 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5244
diff changeset
  6641
        learnMode := ValueHolder with:false
2795
1f7b5f242eee learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents: 2792
diff changeset
  6642
    ].
1f7b5f242eee learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents: 2792
diff changeset
  6643
    ^ learnMode
1f7b5f242eee learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents: 2792
diff changeset
  6644
!
1f7b5f242eee learnMode and insertMode as valueHolders
Claus Gittinger <cg@exept.de>
parents: 2792
diff changeset
  6645
4673
575d2d398823 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4666
diff changeset
  6646
rememberLearnedMacroAs: nameString
575d2d398823 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4666
diff changeset
  6647
    Macros isNil ifTrue:[
575d2d398823 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4666
diff changeset
  6648
        Macros := Dictionary new.
575d2d398823 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4666
diff changeset
  6649
    ].
575d2d398823 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4666
diff changeset
  6650
    Macros at:nameString put:learnedMacro
575d2d398823 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4666
diff changeset
  6651
!
575d2d398823 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4666
diff changeset
  6652
2580
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  6653
toggleLearnMode
3793
5a6074a257c1 learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents: 3790
diff changeset
  6654
    "toggle the learn-mode"
5a6074a257c1 learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents: 3790
diff changeset
  6655
5a6074a257c1 learnmode: also learn backspace !
Claus Gittinger <cg@exept.de>
parents: 3790
diff changeset
  6656
    self learnMode:(self learnMode not).
2580
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  6657
! !
12fea7ffcf8e learn/execute on menu
Claus Gittinger <cg@exept.de>
parents: 2579
diff changeset
  6658
4449
59fe55c937ea changed: #openFileBrowserOnIt
Claus Gittinger <cg@exept.de>
parents: 4430
diff changeset
  6659
!EditTextView methodsFor:'menu & menu actions'!
121
claus
parents: 118
diff changeset
  6660
2680
208d99c47d7c babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents: 2677
diff changeset
  6661
babelFishTranslate:fromToModeString
5962
0636ffb5a147 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5937
diff changeset
  6662
    "translate the selected text and paste it after the selection.
0636ffb5a147 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5937
diff changeset
  6663
     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
  6664
208d99c47d7c babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents: 2677
diff changeset
  6665
    |original translated|
208d99c47d7c babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents: 2677
diff changeset
  6666
208d99c47d7c babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents: 2677
diff changeset
  6667
    original := self selectionAsString.
208d99c47d7c babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents: 2677
diff changeset
  6668
    original size == 0 ifTrue:[^ self].
208d99c47d7c babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents: 2677
diff changeset
  6669
208d99c47d7c babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents: 2677
diff changeset
  6670
    self withWaitCursorDo:[
5962
0636ffb5a147 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5937
diff changeset
  6671
        (HostNameLookupError , SOAP::SoapImplError) handle:[:ex |
0636ffb5a147 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5937
diff changeset
  6672
            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
  6673
        ] do:[
0636ffb5a147 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5937
diff changeset
  6674
            translated := SOAP::BabelFishClient new 
0636ffb5a147 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5937
diff changeset
  6675
                            translate:original mode:fromToModeString.
0636ffb5a147 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5937
diff changeset
  6676
        ]
2680
208d99c47d7c babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents: 2677
diff changeset
  6677
    ].
208d99c47d7c babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents: 2677
diff changeset
  6678
208d99c47d7c babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents: 2677
diff changeset
  6679
    "/ v pasteOrReplace:translated
208d99c47d7c babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents: 2677
diff changeset
  6680
    self cursorLine:(self selectionEndLine) col:(self selectionEndCol + 1).
208d99c47d7c babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents: 2677
diff changeset
  6681
    self unselect.
3799
f6cbe8d860d5 code formatting
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  6682
    self 
f6cbe8d860d5 code formatting
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  6683
        undoablePaste:translated 
5962
0636ffb5a147 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5937
diff changeset
  6684
        info:'Translate'
3495
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  6685
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  6686
    "Modified: / 28-07-2007 / 13:27:21 / cg"
2680
208d99c47d7c babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents: 2677
diff changeset
  6687
!
208d99c47d7c babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents: 2677
diff changeset
  6688
3517
0a2f117c2fb8 +compare menu item
Claus Gittinger <cg@exept.de>
parents: 3514
diff changeset
  6689
compareWithClipboard
0a2f117c2fb8 +compare menu item
Claus Gittinger <cg@exept.de>
parents: 3514
diff changeset
  6690
    "compare the selection against the clipboard contents"
0a2f117c2fb8 +compare menu item
Claus Gittinger <cg@exept.de>
parents: 3514
diff changeset
  6691
0a2f117c2fb8 +compare menu item
Claus Gittinger <cg@exept.de>
parents: 3514
diff changeset
  6692
    |t1 t2|
0a2f117c2fb8 +compare menu item
Claus Gittinger <cg@exept.de>
parents: 3514
diff changeset
  6693
0a2f117c2fb8 +compare menu item
Claus Gittinger <cg@exept.de>
parents: 3514
diff changeset
  6694
    t2 := self getClipboardText.
3683
5891af82a177 middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents: 3650
diff changeset
  6695
    t2 isEmptyOrNil ifTrue:[
4823
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  6696
        Dialog information:'Clipboard is empty.'.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  6697
        ^ self.
3517
0a2f117c2fb8 +compare menu item
Claus Gittinger <cg@exept.de>
parents: 3514
diff changeset
  6698
    ].
0a2f117c2fb8 +compare menu item
Claus Gittinger <cg@exept.de>
parents: 3514
diff changeset
  6699
0a2f117c2fb8 +compare menu item
Claus Gittinger <cg@exept.de>
parents: 3514
diff changeset
  6700
    self hasSelection ifTrue:[
4823
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  6701
        t1 := self selectionAsString.
3517
0a2f117c2fb8 +compare menu item
Claus Gittinger <cg@exept.de>
parents: 3514
diff changeset
  6702
    ] ifFalse:[
4823
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  6703
        t1 := self contents asString
3517
0a2f117c2fb8 +compare menu item
Claus Gittinger <cg@exept.de>
parents: 3514
diff changeset
  6704
    ].
0a2f117c2fb8 +compare menu item
Claus Gittinger <cg@exept.de>
parents: 3514
diff changeset
  6705
    t1 := t1 string.
0a2f117c2fb8 +compare menu item
Claus Gittinger <cg@exept.de>
parents: 3514
diff changeset
  6706
0a2f117c2fb8 +compare menu item
Claus Gittinger <cg@exept.de>
parents: 3514
diff changeset
  6707
    t1 = t2 ifTrue:[
4823
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  6708
        Dialog information:'Strings are equal.'.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  6709
        ^ self.
3517
0a2f117c2fb8 +compare menu item
Claus Gittinger <cg@exept.de>
parents: 3514
diff changeset
  6710
    ].
0a2f117c2fb8 +compare menu item
Claus Gittinger <cg@exept.de>
parents: 3514
diff changeset
  6711
    DiffTextView
4823
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  6712
        openOn:t1 label:'Editor'
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  6713
        and:t2 label:'Clipboard'
3517
0a2f117c2fb8 +compare menu item
Claus Gittinger <cg@exept.de>
parents: 3514
diff changeset
  6714
!
0a2f117c2fb8 +compare menu item
Claus Gittinger <cg@exept.de>
parents: 3514
diff changeset
  6715
5826
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6716
compareWithFile
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6717
    "compare the selection or the whole text against the contents of a file"
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6718
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6719
    |fn t1 t2|
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6720
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6721
    fn := Dialog requestFileName:'Compare against file:' default:defaultFileNameForFileDialog.
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6722
    fn isEmptyOrNil ifTrue:[^ self].
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6723
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6724
    t2 := fn asFilename contentsOfEntireFile.
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6725
    t2 isEmptyOrNil ifTrue:[
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6726
        Dialog information:'File is empty.'.
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6727
        ^ self.
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6728
    ].
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6729
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6730
    self hasSelection ifTrue:[
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6731
        t1 := self selectionAsString.
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6732
    ] ifFalse:[
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6733
        t1 := self contents asString
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6734
    ].
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6735
    t1 := t1 string.
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6736
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6737
    t1 = t2 ifTrue:[
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6738
        Dialog information:'Same contents.'.
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6739
        ^ self.
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6740
    ].
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6741
    DiffTextView
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6742
        openOn:t1 label:'Editor'
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6743
        and:t2 label:'File'
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6744
!
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6745
5689
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  6746
copySelection
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  6747
    "copy contents into smalltalk copybuffer.
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  6748
     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
  6749
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  6750
    self hasSelection ifTrue:[
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  6751
        self setCursorLine:selectionEndLine col:selectionEndCol+1
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  6752
    ].
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  6753
    super copySelection.
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  6754
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  6755
    "Created: / 30-04-2016 / 21:07:10 / cg"
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  6756
!
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  6757
121
claus
parents: 118
diff changeset
  6758
cut
claus
parents: 118
diff changeset
  6759
    "cut selection into copybuffer"
claus
parents: 118
diff changeset
  6760
3324
1297aecf6699 delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents: 3313
diff changeset
  6761
    self deleteCopyToClipboard:true
121
claus
parents: 118
diff changeset
  6762
!
claus
parents: 118
diff changeset
  6763
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6764
defaultForGotoLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6765
    "return a default value to show in the gotoLine box"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6766
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6767
    cursorLine notNil ifTrue:[
4823
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  6768
        ^ cursorLine
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6769
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6770
    ^ super defaultForGotoLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6771
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  6772
3324
1297aecf6699 delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents: 3313
diff changeset
  6773
deleteCopyToClipboard:toClipboard
1297aecf6699 delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents: 3313
diff changeset
  6774
    "cut selection into copybuffer"
1297aecf6699 delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents: 3313
diff changeset
  6775
4129
34908a157d21 changed: #deleteCopyToClipboard:
fm
parents: 4126
diff changeset
  6776
    |line col history sel |
3324
1297aecf6699 delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents: 3313
diff changeset
  6777
1297aecf6699 delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents: 3313
diff changeset
  6778
    (self checkModificationsAllowed) ifFalse:[
4988
9f6f620a1f06 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4967
diff changeset
  6779
        self flashReadOnly.
3786
11145773de65 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3782
diff changeset
  6780
        ^ self
3324
1297aecf6699 delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents: 3313
diff changeset
  6781
    ].
1297aecf6699 delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents: 3313
diff changeset
  6782
1297aecf6699 delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents: 3313
diff changeset
  6783
    sel := self selection.
1297aecf6699 delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents: 3313
diff changeset
  6784
    sel notNil ifTrue:[
4129
34908a157d21 changed: #deleteCopyToClipboard:
fm
parents: 4126
diff changeset
  6785
        self setLastStringToReplace: sel.
4053
31117d801975 added: #setLastStringToReplace:
fm
parents: 4051
diff changeset
  6786
3786
11145773de65 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3782
diff changeset
  6787
        line := selectionStartLine.
11145773de65 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3782
diff changeset
  6788
        col := selectionStartCol.
11145773de65 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3782
diff changeset
  6789
11145773de65 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3782
diff changeset
  6790
        toClipboard ifTrue:[
11145773de65 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3782
diff changeset
  6791
            "
11145773de65 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3782
diff changeset
  6792
             remember in CopyBuffer
11145773de65 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3782
diff changeset
  6793
            "
11145773de65 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3782
diff changeset
  6794
            self setClipboardText:sel. "/ lastString.
11145773de65 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3782
diff changeset
  6795
        ].
11145773de65 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3782
diff changeset
  6796
11145773de65 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3782
diff changeset
  6797
        "
11145773de65 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3782
diff changeset
  6798
         append to DeleteHistory (if there is one)
11145773de65 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3782
diff changeset
  6799
        "
11145773de65 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3782
diff changeset
  6800
        history := Smalltalk at:#DeleteHistory.
11145773de65 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3782
diff changeset
  6801
        history notNil ifTrue:[
11145773de65 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3782
diff changeset
  6802
            history addAll:(sel asStringCollection).
11145773de65 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3782
diff changeset
  6803
            history size > 1000 ifTrue:[
11145773de65 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3782
diff changeset
  6804
                history := history copyFrom:(history size - 1000)
11145773de65 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3782
diff changeset
  6805
            ].
11145773de65 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3782
diff changeset
  6806
        ].
11145773de65 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3782
diff changeset
  6807
11145773de65 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3782
diff changeset
  6808
        "
11145773de65 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3782
diff changeset
  6809
         now, delete it
11145773de65 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3782
diff changeset
  6810
        "
11145773de65 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3782
diff changeset
  6811
        self 
11145773de65 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3782
diff changeset
  6812
            undoableDo:[self deleteSelection] 
11145773de65 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3782
diff changeset
  6813
            info:'Delete'.
4048
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
  6814
        lastReplacementInfo lastReplacement: nil
3324
1297aecf6699 delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents: 3313
diff changeset
  6815
    ] ifFalse:[
3786
11145773de65 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3782
diff changeset
  6816
        "
11145773de65 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3782
diff changeset
  6817
         a cut without selection will search&cut again
11145773de65 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3782
diff changeset
  6818
        "
11145773de65 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3782
diff changeset
  6819
        self undoableDo:[
11145773de65 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3782
diff changeset
  6820
            self again
11145773de65 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3782
diff changeset
  6821
        ]
3324
1297aecf6699 delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents: 3313
diff changeset
  6822
    ]
1297aecf6699 delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents: 3313
diff changeset
  6823
1297aecf6699 delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents: 3313
diff changeset
  6824
    "Modified: / 5.4.1998 / 16:51:53 / cg"
1297aecf6699 delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents: 3313
diff changeset
  6825
!
1297aecf6699 delete does not (by default) update the clipboard
Claus Gittinger <cg@exept.de>
parents: 3313
diff changeset
  6826
428
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  6827
editMenu
5977
a1ac33c0e445 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5972
diff changeset
  6828
    "return the view's middleButtonMenu"
428
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  6829
3781
36268d8303d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3780
diff changeset
  6830
    <resource: #keyboard (#Again #AgainForAll #Copy #Cut #Paste #Accept 
5826
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6831
                          #Find #GotoLine #SaveAs #Print
3890
4c5c54cf856b +wrapLines
Claus Gittinger <cg@exept.de>
parents: 3886
diff changeset
  6832
                          #PasteFromHistory #Join #Wrap #Undo #Redo 
3781
36268d8303d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3780
diff changeset
  6833
                          #ToggleAutoIndent #ToggleInsertMode 
5826
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6834
                          #LearnKeyboardMacro #ExecuteKeyboardMacro )>
1261
bdb18f73205c resource flag: #menu -> #programMenu
Claus Gittinger <cg@exept.de>
parents: 1198
diff changeset
  6835
    <resource: #programMenu>
1054
d699ecd13e60 menu resource
Claus Gittinger <cg@exept.de>
parents: 1049
diff changeset
  6836
3683
5891af82a177 middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents: 3650
diff changeset
  6837
    |items m sub translateItems sortItems miscItems toolItems subSub toolSub
3569
d3eec21d0ece also show \"what-would-be-done\" in redo item
Claus Gittinger <cg@exept.de>
parents: 3566
diff changeset
  6838
     transSub sortSub what undoIdx redoIdx sensor main mainItems|
1515
9e9b65bd6efb care for nil sensor
Claus Gittinger <cg@exept.de>
parents: 1495
diff changeset
  6839
2460
Claus Gittinger <cg@exept.de>
parents: 2438
diff changeset
  6840
    items := #(
5826
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6841
                    ('Redo'             redo           Redo        )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6842
                    ('Again (for All)'  multipleAgain  AgainForAll )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6843
                    ('-'                                        )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6844
                    ('Search...'        search         Find     )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6845
                    ('Goto Line...'     gotoLine       GotoLine )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6846
                    ('-'                                        )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6847
                    ('Tools'            tools                   )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6848
                    ('Font...'           changeFont             )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6849
                    ('Insert Unicode...' insertUnicode )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6850
            ).
4213
6045bffe7299 changed: #editMenu
Claus Gittinger <cg@exept.de>
parents: 4199
diff changeset
  6851
    CharacterSetView notNil ifTrue:[
5826
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6852
        items := items ,
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6853
                    #(
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6854
                        ('Special Characters...'    specialCharacters  OpenSpecialCharacterWindow )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6855
                    ).
4213
6045bffe7299 changed: #editMenu
Claus Gittinger <cg@exept.de>
parents: 4199
diff changeset
  6856
    ].
6045bffe7299 changed: #editMenu
Claus Gittinger <cg@exept.de>
parents: 4199
diff changeset
  6857
    items := items , #(
5826
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6858
                    ('-'                                        )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6859
                    ('Save As...'       save           SaveAs   )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6860
                    ('Print'            doPrint        Print    )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6861
                    ('='                                        )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6862
                    ('Misc'             misc           ShiftCtrl) ).
2460
Claus Gittinger <cg@exept.de>
parents: 2438
diff changeset
  6863
2866
9dd71df46f73 specialCharacters menu item
Claus Gittinger <cg@exept.de>
parents: 2857
diff changeset
  6864
    miscItems := #(
5826
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6865
                    ('AutoIndent \c'    autoIndent:                  ToggleAutoIndent )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6866
                    ('InsertMode \c'    insertMode:                  ToggleInsertMode )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6867
                    ('-'                                        )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6868
                    ('Paste Previous...'   pasteOrReplaceFromHistory PasteFromHistory )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6869
                    ('Join Lines'       joinLines                    Join )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6870
                    ('Wrap Lines...'    wrapLines                    Wrap )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6871
                    ('-'                                        )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6872
                    ('Learn Macro'      learnMode:                   LearnKeyboardMacro)
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6873
                    ('Execute Macro'    executeLearnedKeyboardMacro  ExecuteKeyboardMacro )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6874
                    ('-'                                        )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6875
                    ('Insert File...'           insertFile          )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6876
                    ('Insert URL Contents...'   insertURL           )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6877
                    ('Insert new UUID'      insertUUID          )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6878
                    ('Insert Date && Time'  insertDateAndTime   )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6879
                    ('-'                                        )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6880
                    ('Insert File as String Literal...' insertFileAsStringLiteral  )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6881
                    ('Paste as String Literal'          pasteAsStringLiteral       )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6882
                ).
4213
6045bffe7299 changed: #editMenu
Claus Gittinger <cg@exept.de>
parents: 4199
diff changeset
  6883
"/    CharacterSetView notNil ifTrue:[
6045bffe7299 changed: #editMenu
Claus Gittinger <cg@exept.de>
parents: 4199
diff changeset
  6884
"/        miscItems := miscItems ,
6045bffe7299 changed: #editMenu
Claus Gittinger <cg@exept.de>
parents: 4199
diff changeset
  6885
"/                    #(
5529
0b33c7ac879d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 5525
diff changeset
  6886
"/                        ('-'                                        )
4213
6045bffe7299 changed: #editMenu
Claus Gittinger <cg@exept.de>
parents: 4199
diff changeset
  6887
"/                        ('Special Characters...'    specialCharacters  OpenSpecialCharacterWindow )
5529
0b33c7ac879d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 5525
diff changeset
  6888
"/                        ('Font...'                  changeFont              )
4213
6045bffe7299 changed: #editMenu
Claus Gittinger <cg@exept.de>
parents: 4199
diff changeset
  6889
"/                    ).
5529
0b33c7ac879d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 5525
diff changeset
  6890
"/    ] ifFalse:[
0b33c7ac879d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 5525
diff changeset
  6891
"/        miscItems := miscItems ,
0b33c7ac879d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 5525
diff changeset
  6892
"/                #(
0b33c7ac879d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 5525
diff changeset
  6893
"/                    ('Font...'                  changeFont              )
0b33c7ac879d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 5525
diff changeset
  6894
"/"/                    ('Encoding...'      changeEncoding          )
0b33c7ac879d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 5525
diff changeset
  6895
"/                ).
0b33c7ac879d #FEATURE
Claus Gittinger <cg@exept.de>
parents: 5525
diff changeset
  6896
"/    ]. 
2866
9dd71df46f73 specialCharacters menu item
Claus Gittinger <cg@exept.de>
parents: 2857
diff changeset
  6897
2680
208d99c47d7c babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents: 2677
diff changeset
  6898
    translateItems := #(
5826
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6899
                    ('English -> German'      (babelFishTranslate: 'en_de')   )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6900
                    ('English -> French'      (babelFishTranslate: 'en_fr')   )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6901
                    ('English -> Italian'     (babelFishTranslate: 'en_it')   )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6902
                    ('English -> Spanish'     (babelFishTranslate: 'en_es')   )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6903
                    ('English -> Portuguese'  (babelFishTranslate: 'en_pt')   )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6904
                    ('-'                                        )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6905
                    ('German -> English'      (babelFishTranslate: 'de_en')   )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6906
                    ('French -> English'      (babelFishTranslate: 'fr_en')   )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6907
                    ('Italian -> English'     (babelFishTranslate: 'it_en')   )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6908
                    ('Spanish -> English'     (babelFishTranslate: 'es_en')   )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6909
                    ('Portuguese -> English'  (babelFishTranslate: 'pt_en')   )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6910
              ).
3221
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  6911
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  6912
    sortItems := #(
5826
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6913
                    ('Lines'                            (sortSelection:ignoreCase: #lines false)        )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6914
                    ('Lines by First Word'              (sortSelection:ignoreCase: #linesByFirstWord false)     )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6915
                    ('Lines by n''th Word'              (sortSelection:ignoreCase: #linesByNthWord false)       )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6916
                    ('Lines by n''th Number'            (sortSelection:ignoreCase: #linesByNthNumber false)     )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6917
                    ('Lines by n''th Hex Number'        (sortSelection:ignoreCase: #linesByNthHexNumber false)     )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6918
                    ('Words'                            (sortSelection:ignoreCase: #words false)        )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6919
                    ('-'                                                      )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6920
                    ('Lines (ignore case)'               (sortSelection:ignoreCase: #lines true)         )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6921
                    ('Lines by First Word (ignore case)' (sortSelection:ignoreCase: #linesByFirstWord true)      )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6922
                    ('Lines by n''th Word (ignore case)' (sortSelection:ignoreCase: #linesByNthWord true)        )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6923
                    ('Words (ignore case)'               (sortSelection:ignoreCase: #words true)         )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6924
                    ('-'                                                      )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6925
                    ('By Line Length'                    (sortSelection:ignoreCase: #linesByLength nil)         )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6926
                    ('Reverse'                           (sortSelection:ignoreCase: #reverse       nil)         )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6927
              ).
2680
208d99c47d7c babelFish service moved to editor
Claus Gittinger <cg@exept.de>
parents: 2677
diff changeset
  6928
2762
e29673db4ddb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2757
diff changeset
  6929
    toolItems := #(
5826
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6930
                    ('Indent'                      indent                     )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6931
                    ('Toggle Case'      convertSelectionToLowercaseOrUppercaseOrUppercaseFirst   ConvertSelectionToLowercaseOrUppercaseOrUppercaseFirst)
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6932
                    ('Sort'                        sort                       )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6933
                    ('Split...'                    splitLinesAtCharacterOrString )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6934
                    ('-'                                                      )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6935
                    ('Google Spell Check'          googleSpellingSuggestion   )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6936
                    ('Builtin Spell Check'         internalSpellingSuggestion   )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6937
                    ('Translate'                   babelFishTranslate         )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6938
                    ('Compare with Clipboard...'   compareWithClipboard       )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6939
                    ('Compare with File...'        compareWithFile            )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6940
              ).
2762
e29673db4ddb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2757
diff changeset
  6941
3623
f99c70d99425 close door to fileBrowser and workspace
Claus Gittinger <cg@exept.de>
parents: 3595
diff changeset
  6942
    Smalltalk isStandAloneApp ifFalse:[
5826
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6943
        toolItems := toolItems , #(
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6944
                        ('-'                                                      )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6945
                        ('Open FileBrowser on It'      openFileBrowserOnIt        )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6946
                        ('Open Workspace with It'      openWorkspaceWithIt        )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6947
                        ('Inspect Selected String'     inspectSelectedString      )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6948
                  ).
3623
f99c70d99425 close door to fileBrowser and workspace
Claus Gittinger <cg@exept.de>
parents: 3595
diff changeset
  6949
    ].
f99c70d99425 close door to fileBrowser and workspace
Claus Gittinger <cg@exept.de>
parents: 3595
diff changeset
  6950
2460
Claus Gittinger <cg@exept.de>
parents: 2438
diff changeset
  6951
    sub := PopUpMenu itemList:items resources:resources performer:model.
2461
54d220735048 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2460
diff changeset
  6952
    sub receiver:self.
2460
Claus Gittinger <cg@exept.de>
parents: 2438
diff changeset
  6953
2919
Claus Gittinger <cg@exept.de>
parents: 2916
diff changeset
  6954
    toolSub := PopUpMenu itemList:toolItems resources:resources performer:model.
Claus Gittinger <cg@exept.de>
parents: 2916
diff changeset
  6955
    toolSub receiver:self.
Claus Gittinger <cg@exept.de>
parents: 2916
diff changeset
  6956
    sub subMenuAt:#tools put:toolSub.
Claus Gittinger <cg@exept.de>
parents: 2916
diff changeset
  6957
3495
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  6958
    transSub := PopUpMenu itemList:translateItems resources:resources performer:model.
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  6959
    transSub receiver:self.
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  6960
    toolSub subMenuAt:#babelFishTranslate put:transSub.
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  6961
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  6962
    sortSub := PopUpMenu itemList:sortItems resources:resources performer:model.
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  6963
    sortSub receiver:self.
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  6964
    toolSub subMenuAt:#sort put:sortSub.
3221
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  6965
2866
9dd71df46f73 specialCharacters menu item
Claus Gittinger <cg@exept.de>
parents: 2857
diff changeset
  6966
    subSub := PopUpMenu itemList:miscItems resources:resources performer:model.
9dd71df46f73 specialCharacters menu item
Claus Gittinger <cg@exept.de>
parents: 2857
diff changeset
  6967
    subSub receiver:self.
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  6968
    subSub checkToggleAt:#autoIndent: put:autoIndent.
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  6969
    subSub checkToggleAt:#insertMode: put:(self isInInsertMode).
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  6970
    subSub checkToggleAt:#learnMode: put:(self learnModeHolder value).
3907
e4be6bf71a98 Always Paste the Contents when Dropping a File
Claus Gittinger <cg@exept.de>
parents: 3890
diff changeset
  6971
2866
9dd71df46f73 specialCharacters menu item
Claus Gittinger <cg@exept.de>
parents: 2857
diff changeset
  6972
    sub subMenuAt:#misc put:subSub.
9dd71df46f73 specialCharacters menu item
Claus Gittinger <cg@exept.de>
parents: 2857
diff changeset
  6973
3495
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  6974
    mainItems := #(
5826
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6975
                    ('Undo'    undo             Undo   )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6976
                    ('Again'   again            Again  )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6977
                    ('-'                               )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6978
                    ('Cut'     cut              Cut    )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6979
                    ('Copy'    copySelection    Copy   )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6980
                    ('Paste'   pasteOrReplace   Paste  )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6981
                    ('-'                               )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6982
                    ('Accept'  accept           Accept )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6983
                    ('='                               )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6984
                    ('More'    others           Ctrl   )
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6985
              ).
3495
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  6986
    main := PopUpMenu itemList:mainItems resources:resources.
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  6987
    main subMenuAt:#others put:sub.
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  6988
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  6989
    sensor := self sensor.
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  6990
    (sensor notNil and:[sensor ctrlDown]) ifTrue:[
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  6991
       sensor shiftDown ifTrue:[
5826
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6992
            m := subSub
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6993
        ] ifFalse:[
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6994
            m := sub
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6995
        ]
428
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  6996
    ] ifFalse:[
5826
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  6997
        m := main
428
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  6998
    ].
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  6999
4742
a00cb40ee392 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4738
diff changeset
  7000
    "/ the 'Smalltalk at:' code is here to
a00cb40ee392 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4738
diff changeset
  7001
    "/ avoid making the SOAP package a prerequisite for this package (libwidg)
4373
22fb03e6d08a class definition
Claus Gittinger <cg@exept.de>
parents: 4371
diff changeset
  7002
    (Smalltalk at:#'SOAP::GoogleClient') isNil ifTrue:[
5826
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  7003
        "/ GoogleClient new spellingSuggestionOf: 'Smmalltlaak and Soaap'.
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  7004
        m disable:#googleSpellingSuggestion
2676
cc61fa88a3fb google spelling;
Claus Gittinger <cg@exept.de>
parents: 2660
diff changeset
  7005
    ].
4742
a00cb40ee392 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4738
diff changeset
  7006
    (Smalltalk at:#'RBSpellChecker') isNil ifTrue:[
5826
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  7007
        m disable:#internalSpellingSuggestion
4742
a00cb40ee392 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4738
diff changeset
  7008
    ].
2676
cc61fa88a3fb google spelling;
Claus Gittinger <cg@exept.de>
parents: 2660
diff changeset
  7009
3811
a56e6f74ee4d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3801
diff changeset
  7010
    HTTPInterface isNil ifTrue:[
5826
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  7011
        m disableAll:#(insertURL)
3811
a56e6f74ee4d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3801
diff changeset
  7012
    ].
a56e6f74ee4d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3801
diff changeset
  7013
1733
c5139b7402f0 use self isReadonly; readOnly may now be a valueHolder.
Claus Gittinger <cg@exept.de>
parents: 1732
diff changeset
  7014
    self isReadOnly ifTrue:[
5826
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  7015
        m disableAll:#(accept undo again multipleAgain redo
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  7016
                       paste pasteOrReplace pasteOrReplaceFromHistory
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  7017
                       cut indent autoIndent: insertMode:
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  7018
                       insertFile insertFileAsStringLiteral insertURL
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  7019
                       babelFishTranslate googleSpellingSuggestion sort
4475
ca13f24cb1f3 class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 4464
diff changeset
  7020
                       convertSelectionToLowercaseOrUppercaseOrUppercaseFirst 
5826
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  7021
                       joinLines wrapLines insertUUID insertDateAndTime pasteAsStringLiteral
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  7022
                       insertUnicode specialCharacters)
428
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  7023
    ].
2817
7c82a9535b96 not ifTrue -> ifFalse
Claus Gittinger <cg@exept.de>
parents: 2815
diff changeset
  7024
    self hasSelectionForCopy ifFalse:[
5826
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  7025
        m disable:#copySelection.
428
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  7026
    ].
2416
56acdd9e31b5 lifted mkeyboardMacro handling from Workspace to EditTextView
Claus Gittinger <cg@exept.de>
parents: 2406
diff changeset
  7027
    self hasSelection ifFalse:[
5371
663c7bdd9fa8 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5370
diff changeset
  7028
        m disableAll:#(cut googleSpellingSuggestion babelFishTranslate openFileBrowserOnIt 
5826
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  7029
                       openWorkspaceWithIt sort indent splitLinesAtCharacterOrString inspectSelectedString).
2762
e29673db4ddb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2757
diff changeset
  7030
    ] ifTrue:[
5826
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  7031
        (Error handle:[:ex |
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  7032
            ex return:false
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  7033
        ] do:[
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  7034
            |fn|
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  7035
            fn := self selectionAsString.
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  7036
            fn asFilename exists or:[ fn withoutSeparators withoutQuotes asFilename exists ]
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  7037
        ]) ifFalse:[
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  7038
            m disableAll:#(openFileBrowserOnIt).
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  7039
        ]
428
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  7040
    ].
2569
b499c81c58ae added hasUndoAction query.
Claus Gittinger <cg@exept.de>
parents: 2560
diff changeset
  7041
    self hasUndoAction ifFalse:[
5826
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  7042
        m disable:#undo.
3115
b75128334006 info string in undo
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
  7043
    ] ifTrue:[
5826
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  7044
        what := undoSupport undoActionInfo.
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  7045
        what notNil ifTrue:[
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  7046
            undoIdx := m indexOf:#undo.
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  7047
            m labelAt:undoIdx put:(resources string:'Undo (%1)' with:what).
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  7048
        ]
1818
aa16d9b96e40 fixed cut to not compress multiple blanks.
Claus Gittinger <cg@exept.de>
parents: 1817
diff changeset
  7049
    ].
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  7050
    self hasRedoAction ifFalse:[
5826
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  7051
        sub disable:#redo.
3569
d3eec21d0ece also show \"what-would-be-done\" in redo item
Claus Gittinger <cg@exept.de>
parents: 3566
diff changeset
  7052
    ] ifTrue:[
5826
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  7053
        what := undoSupport redoActionInfo.
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  7054
        what notNil ifTrue:[
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  7055
            redoIdx := sub indexOf:#redo.
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  7056
            sub labelAt:redoIdx put:(resources string:'Redo (%1)' with:what).
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  7057
        ]
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  7058
    ].
5216
8d6eef5d09c3 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5194
diff changeset
  7059
    self canAccept ifFalse:[
5826
28864f883d37 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5795
diff changeset
  7060
        m disable:#accept
1108
3d14bb6bceb7 added disableAccept
Claus Gittinger <cg@exept.de>
parents: 1082
diff changeset
  7061
    ].
428
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  7062
    ^ m.
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  7063
4388
558b4dbf5648 changed:
Claus Gittinger <cg@exept.de>
parents: 4373
diff changeset
  7064
    "Modified: / 01-03-2012 / 19:56:58 / cg"
428
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  7065
!
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  7066
2544
48ab4ed67816 shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  7067
getTextSelectionFromHistory
48ab4ed67816 shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  7068
    |sel list box history|
48ab4ed67816 shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  7069
5643
921578f80870 device access
Claus Gittinger <cg@exept.de>
parents: 5593
diff changeset
  7070
    history := device getCopyBufferHistory copy.
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  7071
    list := history collect:[:entry |
4165
869b207a6964 changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents: 4162
diff changeset
  7072
                |text shown|
869b207a6964 changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents: 4162
diff changeset
  7073
869b207a6964 changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents: 4162
diff changeset
  7074
                text := entry asString string asCollectionOfLines.
869b207a6964 changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents: 4162
diff changeset
  7075
                shown := text detect:[:line| line notEmptyOrNil] ifNone:['      '].
869b207a6964 changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents: 4162
diff changeset
  7076
                text size > 1 ifTrue:[
869b207a6964 changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents: 4162
diff changeset
  7077
                    shown := shown,(resources string:' ... [%1 lines]' with:text size).
869b207a6964 changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents: 4162
diff changeset
  7078
                ].
869b207a6964 changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents: 4162
diff changeset
  7079
                shown
869b207a6964 changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents: 4162
diff changeset
  7080
            ].
869b207a6964 changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents: 4162
diff changeset
  7081
2544
48ab4ed67816 shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  7082
    box := ListSelectionBox
4165
869b207a6964 changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents: 4162
diff changeset
  7083
                title:(resources string:'Clipboard History')
869b207a6964 changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents: 4162
diff changeset
  7084
                okText:(resources string:'Paste')
869b207a6964 changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents: 4162
diff changeset
  7085
                abortText:(resources string:'Cancel')
869b207a6964 changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents: 4162
diff changeset
  7086
                list:list
869b207a6964 changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents: 4162
diff changeset
  7087
                action:[:idx | idx notNil ifTrue:[sel := history at:idx]].
869b207a6964 changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents: 4162
diff changeset
  7088
    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
  7089
    box useIndex:true.
48ab4ed67816 shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  7090
    box show.
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  7091
    ^ sel.
4165
869b207a6964 changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents: 4162
diff changeset
  7092
869b207a6964 changed: #getTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents: 4162
diff changeset
  7093
    "Modified: / 25-08-2010 / 22:02:14 / cg"
2544
48ab4ed67816 shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  7094
!
48ab4ed67816 shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  7095
48ab4ed67816 shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  7096
getTextSelectionOrTextSelectionFromHistory
2730
61a2f1981ac6 Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents: 2725
diff changeset
  7097
61a2f1981ac6 Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents: 2725
diff changeset
  7098
    self sensor shiftDown ifTrue:[
3855
8607bb2b8b6c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3825
diff changeset
  7099
        ^ self getTextSelectionFromHistory
2544
48ab4ed67816 shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  7100
    ].
2724
23f4e16dc4f4 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2720
diff changeset
  7101
4285
8487c7a8fab0 changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents: 4275
diff changeset
  7102
    "/ return either the (xterm-) selection or the clipBoard depending on
8487c7a8fab0 changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents: 4275
diff changeset
  7103
    "/ the Ctrl-Key state.
8487c7a8fab0 changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents: 4275
diff changeset
  7104
8487c7a8fab0 changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents: 4275
diff changeset
  7105
    "/ ouch - this used to be ok for ALT-c / ALT-v,
8487c7a8fab0 changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents: 4275
diff changeset
  7106
    "/ but no longer works with CTRL-c / CTRL-v.
8487c7a8fab0 changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents: 4275
diff changeset
  7107
    ^ self getClipboardText:#clipboard
8487c7a8fab0 changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents: 4275
diff changeset
  7108
8487c7a8fab0 changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents: 4275
diff changeset
  7109
"/    ^ self
8487c7a8fab0 changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents: 4275
diff changeset
  7110
"/        getClipboardText:(self sensor ctrlDown
8487c7a8fab0 changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents: 4275
diff changeset
  7111
"/                            ifTrue:[#selection]
8487c7a8fab0 changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents: 4275
diff changeset
  7112
"/                            ifFalse:[#clipboard])
8487c7a8fab0 changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents: 4275
diff changeset
  7113
8487c7a8fab0 changed: #getTextSelectionOrTextSelectionFromHistory
Claus Gittinger <cg@exept.de>
parents: 4275
diff changeset
  7114
    "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
  7115
!
48ab4ed67816 shift-paste: select pasted string from copyBuffer history
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  7116
2676
cc61fa88a3fb google spelling;
Claus Gittinger <cg@exept.de>
parents: 2660
diff changeset
  7117
googleSpellingSuggestion
cc61fa88a3fb google spelling;
Claus Gittinger <cg@exept.de>
parents: 2660
diff changeset
  7118
    "insert the google-spelling suggestion for the selected text.
cc61fa88a3fb google spelling;
Claus Gittinger <cg@exept.de>
parents: 2660
diff changeset
  7119
     Requires that the SOAP stuff is loaded and working."
cc61fa88a3fb google spelling;
Claus Gittinger <cg@exept.de>
parents: 2660
diff changeset
  7120
2677
afb234f8b822 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2676
diff changeset
  7121
    |text suggestion|
2676
cc61fa88a3fb google spelling;
Claus Gittinger <cg@exept.de>
parents: 2660
diff changeset
  7122
cc61fa88a3fb google spelling;
Claus Gittinger <cg@exept.de>
parents: 2660
diff changeset
  7123
    self withWaitCursorDo:[
3799
f6cbe8d860d5 code formatting
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  7124
        text := self selection asString string withoutSeparators.
f6cbe8d860d5 code formatting
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  7125
        text size == 0 ifTrue:[^ self].
f6cbe8d860d5 code formatting
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  7126
4742
a00cb40ee392 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4738
diff changeset
  7127
        "/ the 'Smalltalk at:' code is here to
a00cb40ee392 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4738
diff changeset
  7128
        "/ avoid making the SOAP package a prerequisite for this package (libwidg)
a00cb40ee392 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4738
diff changeset
  7129
        (Smalltalk at:#'SOAP::SoapImplError') handle:[:ex |
3799
f6cbe8d860d5 code formatting
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  7130
            Dialog warn:('Spelling correction failed - WEB Service error:\\%1.' bindWith:ex description allBold) withCRs.
f6cbe8d860d5 code formatting
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  7131
            ^ self.
f6cbe8d860d5 code formatting
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  7132
        ] do:[
4742
a00cb40ee392 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4738
diff changeset
  7133
            suggestion := (Smalltalk at:#'SOAP::GoogleClient') new spellingSuggestionOf:text.
3799
f6cbe8d860d5 code formatting
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  7134
        ].
f6cbe8d860d5 code formatting
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  7135
        suggestion size == 0 ifTrue:[
4742
a00cb40ee392 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4738
diff changeset
  7136
            self information:('No spelling suggestion from Google for: ' , text).
a00cb40ee392 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4738
diff changeset
  7137
            Transcript showCR:('No spelling suggestion from Google for: ' , text).
3799
f6cbe8d860d5 code formatting
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  7138
            ^ self.
f6cbe8d860d5 code formatting
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  7139
        ].
f6cbe8d860d5 code formatting
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  7140
    ].
f6cbe8d860d5 code formatting
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  7141
    self 
f6cbe8d860d5 code formatting
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  7142
        undoablePaste:suggestion 
f6cbe8d860d5 code formatting
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  7143
        info:'Spelling Suggestion'.
3495
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  7144
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  7145
    "Modified: / 28-07-2007 / 13:25:10 / cg"
2676
cc61fa88a3fb google spelling;
Claus Gittinger <cg@exept.de>
parents: 2660
diff changeset
  7146
!
cc61fa88a3fb google spelling;
Claus Gittinger <cg@exept.de>
parents: 2660
diff changeset
  7147
3595
9277e3a4d2e9 paste date and time added
Claus Gittinger <cg@exept.de>
parents: 3583
diff changeset
  7148
insertDateAndTime
9277e3a4d2e9 paste date and time added
Claus Gittinger <cg@exept.de>
parents: 3583
diff changeset
  7149
    "insert the curent date and time string"
9277e3a4d2e9 paste date and time added
Claus Gittinger <cg@exept.de>
parents: 3583
diff changeset
  7150
9277e3a4d2e9 paste date and time added
Claus Gittinger <cg@exept.de>
parents: 3583
diff changeset
  7151
    typeOfSelection := nil.
3683
5891af82a177 middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents: 3650
diff changeset
  7152
    self
3786
11145773de65 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3782
diff changeset
  7153
        undoableDo:[ self pasteOrReplace:(Timestamp now printStringRFC1123Format)]
3799
f6cbe8d860d5 code formatting
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  7154
        info:'Paste Date and Time'
3595
9277e3a4d2e9 paste date and time added
Claus Gittinger <cg@exept.de>
parents: 3583
diff changeset
  7155
!
9277e3a4d2e9 paste date and time added
Claus Gittinger <cg@exept.de>
parents: 3583
diff changeset
  7156
2676
cc61fa88a3fb google spelling;
Claus Gittinger <cg@exept.de>
parents: 2660
diff changeset
  7157
insertFile
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  7158
    "insert contents of a file
2676
cc61fa88a3fb google spelling;
Claus Gittinger <cg@exept.de>
parents: 2660
diff changeset
  7159
     - ask user for filename using a fileSelectionBox."
cc61fa88a3fb google spelling;
Claus Gittinger <cg@exept.de>
parents: 2660
diff changeset
  7160
3731
041b0c7ad557 +insert as literal
Claus Gittinger <cg@exept.de>
parents: 3725
diff changeset
  7161
    self insertFileAsStringLiteral:false
041b0c7ad557 +insert as literal
Claus Gittinger <cg@exept.de>
parents: 3725
diff changeset
  7162
!
041b0c7ad557 +insert as literal
Claus Gittinger <cg@exept.de>
parents: 3725
diff changeset
  7163
041b0c7ad557 +insert as literal
Claus Gittinger <cg@exept.de>
parents: 3725
diff changeset
  7164
insertFileAsStringLiteral
041b0c7ad557 +insert as literal
Claus Gittinger <cg@exept.de>
parents: 3725
diff changeset
  7165
    "insert a file's contents as a string literal.
041b0c7ad557 +insert as literal
Claus Gittinger <cg@exept.de>
parents: 3725
diff changeset
  7166
     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
  7167
     to make it a legal string literal"
041b0c7ad557 +insert as literal
Claus Gittinger <cg@exept.de>
parents: 3725
diff changeset
  7168
041b0c7ad557 +insert as literal
Claus Gittinger <cg@exept.de>
parents: 3725
diff changeset
  7169
    self insertFileAsStringLiteral:true
041b0c7ad557 +insert as literal
Claus Gittinger <cg@exept.de>
parents: 3725
diff changeset
  7170
!
041b0c7ad557 +insert as literal
Claus Gittinger <cg@exept.de>
parents: 3725
diff changeset
  7171
041b0c7ad557 +insert as literal
Claus Gittinger <cg@exept.de>
parents: 3725
diff changeset
  7172
insertFileAsStringLiteral:asStringLiteral
041b0c7ad557 +insert as literal
Claus Gittinger <cg@exept.de>
parents: 3725
diff changeset
  7173
    "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
  7174
     - ask user for filename using a fileSelectionBox."
041b0c7ad557 +insert as literal
Claus Gittinger <cg@exept.de>
parents: 3725
diff changeset
  7175
3409
d650e3ae9085 insert-file menu item cares for current selection being a filename
Claus Gittinger <cg@exept.de>
parents: 3406
diff changeset
  7176
    |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
  7177
d650e3ae9085 insert-file menu item cares for current selection being a filename
Claus Gittinger <cg@exept.de>
parents: 3406
diff changeset
  7178
    ((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
  7179
    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
  7180
    and:[ selFn isRegularFile ]])
d650e3ae9085 insert-file menu item cares for current selection being a filename
Claus Gittinger <cg@exept.de>
parents: 3406
diff changeset
  7181
    ifTrue:[
3731
041b0c7ad557 +insert as literal
Claus Gittinger <cg@exept.de>
parents: 3725
diff changeset
  7182
        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
  7183
    ].
2757
b98097eaf8dc Stc cannot handle thisContext restart in true-Block.
Stefan Vogel <sv@exept.de>
parents: 2756
diff changeset
  7184
b98097eaf8dc Stc cannot handle thisContext restart in true-Block.
Stefan Vogel <sv@exept.de>
parents: 2756
diff changeset
  7185
    [
3731
041b0c7ad557 +insert as literal
Claus Gittinger <cg@exept.de>
parents: 3725
diff changeset
  7186
        |why|
041b0c7ad557 +insert as literal
Claus Gittinger <cg@exept.de>
parents: 3725
diff changeset
  7187
041b0c7ad557 +insert as literal
Claus Gittinger <cg@exept.de>
parents: 3725
diff changeset
  7188
        file := Dialog
041b0c7ad557 +insert as literal
Claus Gittinger <cg@exept.de>
parents: 3725
diff changeset
  7189
            requestFileName:(resources string:'Insert Contents Of:')
041b0c7ad557 +insert as literal
Claus Gittinger <cg@exept.de>
parents: 3725
diff changeset
  7190
            default:initial
041b0c7ad557 +insert as literal
Claus Gittinger <cg@exept.de>
parents: 3725
diff changeset
  7191
            ok:(resources string:'Insert')
041b0c7ad557 +insert as literal
Claus Gittinger <cg@exept.de>
parents: 3725
diff changeset
  7192
            abort:(resources string:'Cancel')
041b0c7ad557 +insert as literal
Claus Gittinger <cg@exept.de>
parents: 3725
diff changeset
  7193
            pattern:nil
041b0c7ad557 +insert as literal
Claus Gittinger <cg@exept.de>
parents: 3725
diff changeset
  7194
            fromDirectory:directoryForFileDialog.
041b0c7ad557 +insert as literal
Claus Gittinger <cg@exept.de>
parents: 3725
diff changeset
  7195
        file isNil ifTrue:[
041b0c7ad557 +insert as literal
Claus Gittinger <cg@exept.de>
parents: 3725
diff changeset
  7196
            "cancel"
041b0c7ad557 +insert as literal
Claus Gittinger <cg@exept.de>
parents: 3725
diff changeset
  7197
            ^ self.
041b0c7ad557 +insert as literal
Claus Gittinger <cg@exept.de>
parents: 3725
diff changeset
  7198
        ].
041b0c7ad557 +insert as literal
Claus Gittinger <cg@exept.de>
parents: 3725
diff changeset
  7199
        file := file asFilename.
041b0c7ad557 +insert as literal
Claus Gittinger <cg@exept.de>
parents: 3725
diff changeset
  7200
        directoryForFileDialog := file.
041b0c7ad557 +insert as literal
Claus Gittinger <cg@exept.de>
parents: 3725
diff changeset
  7201
041b0c7ad557 +insert as literal
Claus Gittinger <cg@exept.de>
parents: 3725
diff changeset
  7202
        ok := file isReadable and:[file isDirectory not].
041b0c7ad557 +insert as literal
Claus Gittinger <cg@exept.de>
parents: 3725
diff changeset
  7203
        ok ifFalse:[
041b0c7ad557 +insert as literal
Claus Gittinger <cg@exept.de>
parents: 3725
diff changeset
  7204
            file isReadable ifFalse:[
041b0c7ad557 +insert as literal
Claus Gittinger <cg@exept.de>
parents: 3725
diff changeset
  7205
                why := '%1 is unreadable.\\Please try again.'
041b0c7ad557 +insert as literal
Claus Gittinger <cg@exept.de>
parents: 3725
diff changeset
  7206
            ] ifTrue:[
041b0c7ad557 +insert as literal
Claus Gittinger <cg@exept.de>
parents: 3725
diff changeset
  7207
                why := '%1 is a directory.\\Please try again.'
041b0c7ad557 +insert as literal
Claus Gittinger <cg@exept.de>
parents: 3725
diff changeset
  7208
            ].
041b0c7ad557 +insert as literal
Claus Gittinger <cg@exept.de>
parents: 3725
diff changeset
  7209
            Dialog warn:(resources stringWithCRs:why with:file pathName).
041b0c7ad557 +insert as literal
Claus Gittinger <cg@exept.de>
parents: 3725
diff changeset
  7210
        ].
2909
a43e1343718f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2901
diff changeset
  7211
    ] doUntil:[ok].
2757
b98097eaf8dc Stc cannot handle thisContext restart in true-Block.
Stefan Vogel <sv@exept.de>
parents: 2756
diff changeset
  7212
5063
103ce513648a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5060
diff changeset
  7213
    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
  7214
    self
3786
11145773de65 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3782
diff changeset
  7215
        undoableDo:[ self paste:(asStringLiteral ifTrue:[text storeString] ifFalse:[text]) ]
3799
f6cbe8d860d5 code formatting
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  7216
        info:'Paste File'
3495
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  7217
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  7218
    "Modified: / 28-07-2007 / 13:23:32 / cg"
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  7219
!
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  7220
3811
a56e6f74ee4d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3801
diff changeset
  7221
insertURL
a56e6f74ee4d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3801
diff changeset
  7222
    "insert contents of a URL
a56e6f74ee4d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3801
diff changeset
  7223
     - ask user for URL using a dialog."
a56e6f74ee4d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3801
diff changeset
  7224
a56e6f74ee4d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3801
diff changeset
  7225
    self insertURLAsStringLiteral:false
a56e6f74ee4d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3801
diff changeset
  7226
!
a56e6f74ee4d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3801
diff changeset
  7227
a56e6f74ee4d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3801
diff changeset
  7228
insertURLAsStringLiteral:asStringLiteral
a56e6f74ee4d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3801
diff changeset
  7229
    "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
  7230
     - ask user for filename using a fileSelectionBox."
a56e6f74ee4d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3801
diff changeset
  7231
a56e6f74ee4d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3801
diff changeset
  7232
    |sel url text response initial|
a56e6f74ee4d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3801
diff changeset
  7233
a56e6f74ee4d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3801
diff changeset
  7234
    (sel := self selectionAsString) notEmptyOrNil
a56e6f74ee4d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3801
diff changeset
  7235
    ifTrue:[
a56e6f74ee4d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3801
diff changeset
  7236
        initial := sel.
a56e6f74ee4d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3801
diff changeset
  7237
    ].
a56e6f74ee4d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3801
diff changeset
  7238
a56e6f74ee4d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3801
diff changeset
  7239
    url := Dialog
a56e6f74ee4d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3801
diff changeset
  7240
        request:(resources string:'Insert Contents of URL:')
a56e6f74ee4d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3801
diff changeset
  7241
        initialAnswer:initial
a56e6f74ee4d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3801
diff changeset
  7242
        okLabel:(resources string:'Insert')
a56e6f74ee4d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3801
diff changeset
  7243
        title:(resources string:'URL').
a56e6f74ee4d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3801
diff changeset
  7244
    url isNil ifTrue:[
a56e6f74ee4d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3801
diff changeset
  7245
        "cancel"
a56e6f74ee4d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3801
diff changeset
  7246
        ^ self.
a56e6f74ee4d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3801
diff changeset
  7247
    ].
a56e6f74ee4d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3801
diff changeset
  7248
    response := HTTPInterface get:url.
a56e6f74ee4d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3801
diff changeset
  7249
    response isErrorResponse ifTrue:[
a56e6f74ee4d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3801
diff changeset
  7250
        Dialog warn:(resources string:'Could not fetch the document: %1' with:url).
a56e6f74ee4d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3801
diff changeset
  7251
        ^ self.
a56e6f74ee4d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3801
diff changeset
  7252
    ].
a56e6f74ee4d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3801
diff changeset
  7253
    text := response data asString.
a56e6f74ee4d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3801
diff changeset
  7254
a56e6f74ee4d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3801
diff changeset
  7255
    self
a56e6f74ee4d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3801
diff changeset
  7256
        undoableDo:[ 
a56e6f74ee4d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3801
diff changeset
  7257
            self paste:(asStringLiteral ifTrue:[text storeString] ifFalse:[text]) 
a56e6f74ee4d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3801
diff changeset
  7258
        ]
a56e6f74ee4d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3801
diff changeset
  7259
        info:'Insert Contents of URL'
a56e6f74ee4d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3801
diff changeset
  7260
!
a56e6f74ee4d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3801
diff changeset
  7261
3495
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  7262
insertUUID
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  7263
    "insert a new UUID's string"
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  7264
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  7265
    typeOfSelection := nil.
3683
5891af82a177 middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents: 3650
diff changeset
  7266
    self
3786
11145773de65 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3782
diff changeset
  7267
        undoableDo:[ self pasteOrReplace:(UUID genUUID printString)]
3799
f6cbe8d860d5 code formatting
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  7268
        info:'Paste New UUID'
3495
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  7269
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  7270
    "Created: / 28-07-2007 / 13:01:16 / cg"
2676
cc61fa88a3fb google spelling;
Claus Gittinger <cg@exept.de>
parents: 2660
diff changeset
  7271
!
cc61fa88a3fb google spelling;
Claus Gittinger <cg@exept.de>
parents: 2660
diff changeset
  7272
4940
73e7031a4a85 class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 4889
diff changeset
  7273
insertUnicode
73e7031a4a85 class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 4889
diff changeset
  7274
    "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
  7275
73e7031a4a85 class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 4889
diff changeset
  7276
    |unicodePoint unicodeChar unicodeString|
73e7031a4a85 class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 4889
diff changeset
  7277
5904
76febd97d52d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5890
diff changeset
  7278
    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
  7279
    unicodeString size < 2 ifTrue:[
5904
76febd97d52d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5890
diff changeset
  7280
        ^ self.
4940
73e7031a4a85 class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 4889
diff changeset
  7281
    ].
73e7031a4a85 class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 4889
diff changeset
  7282
    (unicodeString second = $+ and:['Uu' includes:unicodeString first]) ifTrue:[
5904
76febd97d52d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5890
diff changeset
  7283
        unicodePoint := Integer readFrom:(unicodeString copyFrom:3) radix:16 onError:[^ self].
4940
73e7031a4a85 class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 4889
diff changeset
  7284
    ] ifFalse:[
5904
76febd97d52d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5890
diff changeset
  7285
        unicodePoint := Integer readFrom:unicodeString onError:[^ self].
5787
6afec9827d1c #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 5774
diff changeset
  7286
    ].
4940
73e7031a4a85 class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 4889
diff changeset
  7287
        
73e7031a4a85 class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 4889
diff changeset
  7288
    unicodeChar := Character value:unicodePoint.
73e7031a4a85 class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 4889
diff changeset
  7289
    self keyPress:unicodeChar x:0 y:0.
73e7031a4a85 class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 4889
diff changeset
  7290
    self keyRelease:unicodeChar x:0 y:0.
73e7031a4a85 class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 4889
diff changeset
  7291
!
73e7031a4a85 class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 4889
diff changeset
  7292
5331
1d78ee0cb88b class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5325
diff changeset
  7293
inspectSelectedString
1d78ee0cb88b class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5325
diff changeset
  7294
    "inspect the selected text"
1d78ee0cb88b class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5325
diff changeset
  7295
1d78ee0cb88b class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5325
diff changeset
  7296
    self selectionAsString inspect.
1d78ee0cb88b class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5325
diff changeset
  7297
!
1d78ee0cb88b class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5325
diff changeset
  7298
4742
a00cb40ee392 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4738
diff changeset
  7299
internalSpellingSuggestion
a00cb40ee392 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4738
diff changeset
  7300
    "insert the internal-spelling suggestion for the selected text.
a00cb40ee392 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4738
diff changeset
  7301
     Requires that the RefactoryBrowser/line/spelCheck stuff is loaded."
a00cb40ee392 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4738
diff changeset
  7302
a00cb40ee392 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4738
diff changeset
  7303
    |text suggestions best|
a00cb40ee392 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4738
diff changeset
  7304
a00cb40ee392 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4738
diff changeset
  7305
    self withWaitCursorDo:[
a00cb40ee392 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4738
diff changeset
  7306
        text := self selection asString string withoutSeparators.
a00cb40ee392 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4738
diff changeset
  7307
        text size == 0 ifTrue:[^ self].
a00cb40ee392 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4738
diff changeset
  7308
a00cb40ee392 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4738
diff changeset
  7309
        suggestions := RBSpellChecker default bestMatchesFor:text.
a00cb40ee392 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4738
diff changeset
  7310
        suggestions size == 0 ifTrue:[
a00cb40ee392 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4738
diff changeset
  7311
            self information:('No spelling suggestion from builtin checker for: ' , text).
a00cb40ee392 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4738
diff changeset
  7312
            Transcript showCR:('No spelling suggestion from builtin checker for: ' , text).
a00cb40ee392 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4738
diff changeset
  7313
            ^ self.
a00cb40ee392 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4738
diff changeset
  7314
        ].
a00cb40ee392 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4738
diff changeset
  7315
        Transcript showCR:suggestions.
a00cb40ee392 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4738
diff changeset
  7316
        best := suggestions first.
a00cb40ee392 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4738
diff changeset
  7317
    ].
a00cb40ee392 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4738
diff changeset
  7318
    self 
a00cb40ee392 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4738
diff changeset
  7319
        undoablePaste:best 
a00cb40ee392 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4738
diff changeset
  7320
        info:'Spelling Suggestion'.
a00cb40ee392 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4738
diff changeset
  7321
!
a00cb40ee392 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4738
diff changeset
  7322
4884
9b12ee7ca951 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4829
diff changeset
  7323
openFileBrowserOnFileNamed:fileNameString
9b12ee7ca951 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4829
diff changeset
  7324
    "open a fileBrowser on the given fileNameString"
2762
e29673db4ddb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2757
diff changeset
  7325
4630
b043ca9e5060 class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 4623
diff changeset
  7326
    |fn|
2762
e29673db4ddb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2757
diff changeset
  7327
4884
9b12ee7ca951 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4829
diff changeset
  7328
    fn := fileNameString asFilename.
2762
e29673db4ddb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2757
diff changeset
  7329
    fn exists ifFalse:[
4884
9b12ee7ca951 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4829
diff changeset
  7330
        fn := fileNameString withoutSeparators withoutQuotes asFilename.
4042
2dac2f89e877 changed:
Claus Gittinger <cg@exept.de>
parents: 4041
diff changeset
  7331
        fn exists ifFalse:[
5082
57b4941c5788 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5068
diff changeset
  7332
            ^ self warn:(resources 
57b4941c5788 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5068
diff changeset
  7333
                            string:'Sorry - file "%1" was not found in directory "%2"' 
57b4941c5788 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5068
diff changeset
  7334
                            with:fn baseName allBold
57b4941c5788 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5068
diff changeset
  7335
                            with:fn directory baseName allBold).
4042
2dac2f89e877 changed:
Claus Gittinger <cg@exept.de>
parents: 4041
diff changeset
  7336
        ].
2762
e29673db4ddb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2757
diff changeset
  7337
    ].
4449
59fe55c937ea changed: #openFileBrowserOnIt
Claus Gittinger <cg@exept.de>
parents: 4430
diff changeset
  7338
    UserPreferences fileBrowserClass openOn:fn
59fe55c937ea changed: #openFileBrowserOnIt
Claus Gittinger <cg@exept.de>
parents: 4430
diff changeset
  7339
59fe55c937ea changed: #openFileBrowserOnIt
Claus Gittinger <cg@exept.de>
parents: 4430
diff changeset
  7340
    "Modified: / 06-09-2012 / 14:47:22 / cg"
2762
e29673db4ddb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2757
diff changeset
  7341
!
e29673db4ddb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2757
diff changeset
  7342
4884
9b12ee7ca951 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4829
diff changeset
  7343
openFileBrowserOnIt
9b12ee7ca951 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4829
diff changeset
  7344
    "open a fileBrowser on the selected fileName"
9b12ee7ca951 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4829
diff changeset
  7345
9b12ee7ca951 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4829
diff changeset
  7346
    |fileNameString|
9b12ee7ca951 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4829
diff changeset
  7347
9b12ee7ca951 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4829
diff changeset
  7348
    fileNameString := self selectionAsString.
9b12ee7ca951 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4829
diff changeset
  7349
    self openFileBrowserOnFileNamed:fileNameString
9b12ee7ca951 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4829
diff changeset
  7350
9b12ee7ca951 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4829
diff changeset
  7351
    "Modified: / 06-09-2012 / 14:47:22 / cg"
9b12ee7ca951 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4829
diff changeset
  7352
!
9b12ee7ca951 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4829
diff changeset
  7353
3483
8ef0f9a0737f +openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents: 3482
diff changeset
  7354
openWorkspaceWithIt
8ef0f9a0737f +openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents: 3482
diff changeset
  7355
    "open a workspace containing the selected text"
8ef0f9a0737f +openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents: 3482
diff changeset
  7356
8ef0f9a0737f +openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents: 3482
diff changeset
  7357
    |text|
8ef0f9a0737f +openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents: 3482
diff changeset
  7358
8ef0f9a0737f +openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents: 3482
diff changeset
  7359
    text := self selectionAsString.
8ef0f9a0737f +openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents: 3482
diff changeset
  7360
    WorkspaceApplication openWith:text selected:true
8ef0f9a0737f +openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents: 3482
diff changeset
  7361
8ef0f9a0737f +openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents: 3482
diff changeset
  7362
    "Created: / 26-05-2007 / 06:05:22 / cg"
8ef0f9a0737f +openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents: 3482
diff changeset
  7363
!
8ef0f9a0737f +openWorkspaceWithSelection menu function
Claus Gittinger <cg@exept.de>
parents: 3482
diff changeset
  7364
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  7365
paste
1289
e2dcc5fe612c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1287
diff changeset
  7366
    "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
  7367
     Then paste at cursor position."
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  7368
2989
5dcc2912bcb6 undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents: 2984
diff changeset
  7369
    self checkModificationsAllowed ifTrue:[
4823
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  7370
        self withSelfAndTextForPasteDo:[:me :text |
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  7371
            me unselect.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  7372
            me undoablePaste:text
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  7373
        ]
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  7374
    ]
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  7375
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  7376
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  7377
paste:someText
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  7378
    "paste someText at cursor"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  7379
3825
184c9b081973 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3816
diff changeset
  7380
    self paste:someText withCR:false
184c9b081973 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3816
diff changeset
  7381
!
184c9b081973 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3816
diff changeset
  7382
184c9b081973 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3816
diff changeset
  7383
paste:someText withCR:withCR
184c9b081973 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3816
diff changeset
  7384
    "paste someText at cursor"
184c9b081973 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3816
diff changeset
  7385
2856
bc6bb86d4d2e character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents: 2854
diff changeset
  7386
    |s nLines startLine startCol l1 l2 c1 c2 codingErrorReported|
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  7387
1480
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  7388
    self checkModificationsAllowed ifFalse:[^ self].
2853
f8c1d3963b49 preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents: 2846
diff changeset
  7389
    someText isNil ifTrue:[^ self].
f8c1d3963b49 preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents: 2846
diff changeset
  7390
f8c1d3963b49 preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents: 2846
diff changeset
  7391
    s := someText.
2856
bc6bb86d4d2e character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents: 2854
diff changeset
  7392
    codingErrorReported := false.
bc6bb86d4d2e character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents: 2854
diff changeset
  7393
    CharacterEncoderError handle:[:ex |
3825
184c9b081973 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3816
diff changeset
  7394
        |code msg|
184c9b081973 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3816
diff changeset
  7395
184c9b081973 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3816
diff changeset
  7396
        code := ex parameter.
184c9b081973 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3816
diff changeset
  7397
        codingErrorReported ifFalse:[
4940
73e7031a4a85 class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 4889
diff changeset
  7398
            msg := 'Cannot represent pasted string in this Views encoding (',gc characterEncoding,').'.
3825
184c9b081973 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3816
diff changeset
  7399
            code notNil ifTrue:[
184c9b081973 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3816
diff changeset
  7400
                msg := msg , '\\Reason: No representation for ' , (code radixPrintStringRadix:16).
184c9b081973 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3816
diff changeset
  7401
            ].
184c9b081973 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3816
diff changeset
  7402
            Dialog warn:(resources stringWithCRs:msg).
184c9b081973 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3816
diff changeset
  7403
            codingErrorReported := true.
184c9b081973 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3816
diff changeset
  7404
        ].
184c9b081973 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3816
diff changeset
  7405
        ex proceedWith:ex defaultValue
2856
bc6bb86d4d2e character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents: 2854
diff changeset
  7406
    ] do:[
3825
184c9b081973 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3816
diff changeset
  7407
        s isString ifTrue:[
4940
73e7031a4a85 class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 4889
diff changeset
  7408
            s encoding ~~ gc characterEncoding ifTrue:[
73e7031a4a85 class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 4889
diff changeset
  7409
                s := s encodeFrom:(s encoding) into:gc characterEncoding.
3825
184c9b081973 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3816
diff changeset
  7410
            ].
184c9b081973 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3816
diff changeset
  7411
184c9b081973 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3816
diff changeset
  7412
            s := s asStringCollection.
184c9b081973 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3816
diff changeset
  7413
            (someText endsWith:Character cr) ifTrue:[
184c9b081973 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3816
diff changeset
  7414
                "/ s := s copyWith:nil.
184c9b081973 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3816
diff changeset
  7415
                s := s copyWith:'' "/ an empty line at the end
184c9b081973 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3816
diff changeset
  7416
184c9b081973 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3816
diff changeset
  7417
            ]
184c9b081973 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3816
diff changeset
  7418
        ] ifFalse:[
184c9b081973 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3816
diff changeset
  7419
            s isStringCollection ifTrue:[
4940
73e7031a4a85 class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 4889
diff changeset
  7420
                s := s encodeFrom:(s encoding) into:gc characterEncoding.
3825
184c9b081973 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3816
diff changeset
  7421
            ] ifFalse:[
184c9b081973 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3816
diff changeset
  7422
                (self
184c9b081973 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3816
diff changeset
  7423
                    confirm:(resources
184c9b081973 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3816
diff changeset
  7424
                        stringWithCRs:'Selection (%1) is not convertable to Text.\\Paste storeString ?'
184c9b081973 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3816
diff changeset
  7425
                        with:s class name)) ifFalse:[^ self].
184c9b081973 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3816
diff changeset
  7426
                s := StringCollection with:s storeString .
184c9b081973 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3816
diff changeset
  7427
                "/ ^ self
184c9b081973 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3816
diff changeset
  7428
            ].
184c9b081973 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3816
diff changeset
  7429
        ].
2856
bc6bb86d4d2e character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents: 2854
diff changeset
  7430
    ].
bc6bb86d4d2e character encodings - first attempt
Claus Gittinger <cg@exept.de>
parents: 2854
diff changeset
  7431
2853
f8c1d3963b49 preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents: 2846
diff changeset
  7432
    (nLines := s size) == 0 ifTrue:[^ self].
f8c1d3963b49 preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents: 2846
diff changeset
  7433
    (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
  7434
f8c1d3963b49 preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents: 2846
diff changeset
  7435
    typeOfSelection := #paste.
f8c1d3963b49 preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents: 2846
diff changeset
  7436
f8c1d3963b49 preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents: 2846
diff changeset
  7437
    startLine := l1 := cursorLine.
f8c1d3963b49 preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents: 2846
diff changeset
  7438
    startCol := c1 := cursorCol.
3180
609f340fd96c paste - do not expand tabs!
Michael Beyl <mb@exept.de>
parents: 3161
diff changeset
  7439
5194
24c790b5d279 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5153
diff changeset
  7440
    "do not autoindent here. 
24c790b5d279 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5153
diff changeset
  7441
     It does make things very ugly, in the inspector 
24c790b5d279 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5153
diff changeset
  7442
     (try inspecting a multiline string)..."
24c790b5d279 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5153
diff changeset
  7443
    self withAutoIndent:false do:[
24c790b5d279 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5153
diff changeset
  7444
        "do not expand tabs into spaces here -
24c790b5d279 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5153
diff changeset
  7445
         they get expanded in basicWithoutRedrawInsertStringWithoutCRs:aString atLine:lineNr col:colNr.
24c790b5d279 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5153
diff changeset
  7446
         Some Subviews want to paste with unexpanded tabs!!"
24c790b5d279 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5153
diff changeset
  7447
24c790b5d279 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5153
diff changeset
  7448
        self insertLines:s withCR:withCR.
24c790b5d279 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5153
diff changeset
  7449
    ].
2853
f8c1d3963b49 preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents: 2846
diff changeset
  7450
    l2 := cursorLine.
f8c1d3963b49 preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents: 2846
diff changeset
  7451
    c2 := (cursorCol - 1).
f8c1d3963b49 preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents: 2846
diff changeset
  7452
    self selectFromLine:l1 col:c1 toLine:l2 col:c2.
f8c1d3963b49 preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents: 2846
diff changeset
  7453
    typeOfSelection := #paste. "/ sigh - cleared by #selectFromLine:
4844
269a12794578 Selection refactoring, part 3: support for paste-cursordown-paste
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4843
diff changeset
  7454
    "/ For Claus to support paste-cursordown-paste :-)
269a12794578 Selection refactoring, part 3: support for paste-cursordown-paste
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4843
diff changeset
  7455
    "/ Move cursor the the beggining of the selection so subsequent
269a12794578 Selection refactoring, part 3: support for paste-cursordown-paste
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4843
diff changeset
  7456
    "/ cursor move will start there.
269a12794578 Selection refactoring, part 3: support for paste-cursordown-paste
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4843
diff changeset
  7457
    self setCursorLine: l1.
269a12794578 Selection refactoring, part 3: support for paste-cursordown-paste
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4843
diff changeset
  7458
    self setCursorCol: c1.
2853
f8c1d3963b49 preps for character conversions (paste)
Claus Gittinger <cg@exept.de>
parents: 2846
diff changeset
  7459
4328
ea91d179b5f0 changed:
Claus Gittinger <cg@exept.de>
parents: 4289
diff changeset
  7460
    "Modified: / 14-02-1996 / 11:14:14 / stefan"
4360
fe77e479d95a comment/format in:
Claus Gittinger <cg@exept.de>
parents: 4328
diff changeset
  7461
    "Modified: / 25-01-2012 / 00:31:30 / cg"
4844
269a12794578 Selection refactoring, part 3: support for paste-cursordown-paste
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4843
diff changeset
  7462
    "Modified: / 30-08-2013 / 00:09:11 / Jan Vrany <jan.vrany@fit.cvut.cz>"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  7463
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  7464
3731
041b0c7ad557 +insert as literal
Claus Gittinger <cg@exept.de>
parents: 3725
diff changeset
  7465
pasteAsStringLiteral
041b0c7ad557 +insert as literal
Claus Gittinger <cg@exept.de>
parents: 3725
diff changeset
  7466
    "insert clipboard string as a string literal.
041b0c7ad557 +insert as literal
Claus Gittinger <cg@exept.de>
parents: 3725
diff changeset
  7467
     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
  7468
     to make it a legal string literal"
041b0c7ad557 +insert as literal
Claus Gittinger <cg@exept.de>
parents: 3725
diff changeset
  7469
041b0c7ad557 +insert as literal
Claus Gittinger <cg@exept.de>
parents: 3725
diff changeset
  7470
    typeOfSelection := nil.
041b0c7ad557 +insert as literal
Claus Gittinger <cg@exept.de>
parents: 3725
diff changeset
  7471
    self
5107
0653fd82a0f4 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5106
diff changeset
  7472
        undoableDo:[ self pasteOrReplace:(self getClipboardText asString string storeString) ]
3786
11145773de65 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3782
diff changeset
  7473
        info:'Paste as String Literal'
3731
041b0c7ad557 +insert as literal
Claus Gittinger <cg@exept.de>
parents: 3725
diff changeset
  7474
!
041b0c7ad557 +insert as literal
Claus Gittinger <cg@exept.de>
parents: 3725
diff changeset
  7475
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  7476
pasteOrReplace
1289
e2dcc5fe612c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1287
diff changeset
  7477
    "paste the copybuffer; if there is a selection, replace it.
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  7478
     otherwise paste at cursor position.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  7479
     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
  7480
     to allow multiple paste operations in a row."
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  7481
2724
23f4e16dc4f4 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2720
diff changeset
  7482
    self withSelfAndTextForPasteDo:[:me :text | me pasteOrReplace:text]
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  7483
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  7484
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  7485
pasteOrReplace:someText
1289
e2dcc5fe612c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1287
diff changeset
  7486
    "paste someText; if there is a selection, replace it.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  7487
     otherwise paste at cursor position. Replace is not done
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  7488
     for originating by a paste, to allow multiple
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  7489
     paste."
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  7490
1480
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  7491
    self checkModificationsAllowed ifFalse:[^ self].
2989
5dcc2912bcb6 undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents: 2984
diff changeset
  7492
5dcc2912bcb6 undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents: 2984
diff changeset
  7493
    self undoableDo:[
4823
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  7494
        ((self hasSelection == true) and:[typeOfSelection ~~ #paste]) ifTrue:[
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  7495
            self replace:someText
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  7496
        ] ifFalse:[
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  7497
            self paste:someText.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  7498
        ]
3542
30ed44ed0178 +joinLines (CTRL-j);
Claus Gittinger <cg@exept.de>
parents: 3517
diff changeset
  7499
    ] info:'Paste/Replace'.
1289
e2dcc5fe612c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1287
diff changeset
  7500
2107
9d44232af0a0 textSelection fixes (added newLine) for MSDOS;
Claus Gittinger <cg@exept.de>
parents: 2101
diff changeset
  7501
    "Modified: / 30.1.2000 / 02:33:00 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  7502
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  7503
5387
b94d35da3ad6 class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 5371
diff changeset
  7504
pasteOrReplaceByKeyPress
b94d35da3ad6 class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 5371
diff changeset
  7505
    "paste a previous item from the copybuffer history.
b94d35da3ad6 class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 5371
diff changeset
  7506
     (i.e. repaste some previously deleted or copied text)"
b94d35da3ad6 class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 5371
diff changeset
  7507
b94d35da3ad6 class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 5371
diff changeset
  7508
    |text|
b94d35da3ad6 class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 5371
diff changeset
  7509
b94d35da3ad6 class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 5371
diff changeset
  7510
    self checkModificationsAllowed ifFalse:[
b94d35da3ad6 class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 5371
diff changeset
  7511
        self flashReadOnly.
b94d35da3ad6 class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 5371
diff changeset
  7512
        ^ self
b94d35da3ad6 class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 5371
diff changeset
  7513
    ].
b94d35da3ad6 class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 5371
diff changeset
  7514
    text := self getClipboardText:#clipboard.
b94d35da3ad6 class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 5371
diff changeset
  7515
    text notNil ifTrue:[
b94d35da3ad6 class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 5371
diff changeset
  7516
        self pasteOrReplace:text
b94d35da3ad6 class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 5371
diff changeset
  7517
    ]
b94d35da3ad6 class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 5371
diff changeset
  7518
!
b94d35da3ad6 class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 5371
diff changeset
  7519
3474
357e16440725 slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents: 3473
diff changeset
  7520
pasteOrReplaceFromHistory
357e16440725 slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents: 3473
diff changeset
  7521
    "paste a previous item from the copybuffer history.
357e16440725 slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents: 3473
diff changeset
  7522
     (i.e. repaste some previously deleted or copied text)"
357e16440725 slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents: 3473
diff changeset
  7523
357e16440725 slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents: 3473
diff changeset
  7524
    |text|
357e16440725 slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents: 3473
diff changeset
  7525
357e16440725 slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents: 3473
diff changeset
  7526
    self checkModificationsAllowed ifFalse:[
4988
9f6f620a1f06 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4967
diff changeset
  7527
        self flashReadOnly.
4823
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  7528
        ^ self
3474
357e16440725 slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents: 3473
diff changeset
  7529
    ].
357e16440725 slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents: 3473
diff changeset
  7530
    text := self getTextSelectionFromHistory.
357e16440725 slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents: 3473
diff changeset
  7531
    text notNil ifTrue:[
4823
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  7532
        self pasteOrReplace:text
3474
357e16440725 slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents: 3473
diff changeset
  7533
    ]
357e16440725 slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents: 3473
diff changeset
  7534
!
357e16440725 slight popupmenu reorganization
Claus Gittinger <cg@exept.de>
parents: 3473
diff changeset
  7535
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  7536
replace
1289
e2dcc5fe612c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1287
diff changeset
  7537
    "replace the selection by the contents of the copybuffer"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  7538
3269
03d04670a5d2 replace is a no op, if there is no selection
Claus Gittinger <cg@exept.de>
parents: 3268
diff changeset
  7539
    self hasSelection ifFalse:[^ self].
03d04670a5d2 replace is a no op, if there is no selection
Claus Gittinger <cg@exept.de>
parents: 3268
diff changeset
  7540
    self checkModificationsAllowed ifFalse:[^ self].
03d04670a5d2 replace is a no op, if there is no selection
Claus Gittinger <cg@exept.de>
parents: 3268
diff changeset
  7541
03d04670a5d2 replace is a no op, if there is no selection
Claus Gittinger <cg@exept.de>
parents: 3268
diff changeset
  7542
    self withSelfAndTextForPasteDo:[:me :text |
3786
11145773de65 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3782
diff changeset
  7543
        me undoableDo:[ me replace:text ]
11145773de65 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3782
diff changeset
  7544
        info:'Replace'
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  7545
    ]
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  7546
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  7547
121
claus
parents: 118
diff changeset
  7548
replace:someText
1289
e2dcc5fe612c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1287
diff changeset
  7549
    "replace the selection by someText"
121
claus
parents: 118
diff changeset
  7550
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  7551
    |selected selectedString
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  7552
     selStartLine selStartCol selEndLine selEndCol|
121
claus
parents: 118
diff changeset
  7553
1480
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  7554
    self checkModificationsAllowed ifFalse:[^ self].
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  7555
3130
c0f39f9f28d6 undoable keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3127
diff changeset
  7556
    self undoableDo:[
4010
9c22bd531240 lastStringToReplace to use in again
fm
parents: 3996
diff changeset
  7557
        selected := self selection.
9c22bd531240 lastStringToReplace to use in again
fm
parents: 3996
diff changeset
  7558
        selected isNil ifTrue:[
9c22bd531240 lastStringToReplace to use in again
fm
parents: 3996
diff changeset
  7559
            ^ self paste:someText
9c22bd531240 lastStringToReplace to use in again
fm
parents: 3996
diff changeset
  7560
        ].
9c22bd531240 lastStringToReplace to use in again
fm
parents: 3996
diff changeset
  7561
9c22bd531240 lastStringToReplace to use in again
fm
parents: 3996
diff changeset
  7562
        self deleteSelection.
9c22bd531240 lastStringToReplace to use in again
fm
parents: 3996
diff changeset
  7563
9c22bd531240 lastStringToReplace to use in again
fm
parents: 3996
diff changeset
  7564
        "take care, if we replace a selection without space by a word selected
9c22bd531240 lastStringToReplace to use in again
fm
parents: 3996
diff changeset
  7565
         with one - in this case we usually do not want the space.
9c22bd531240 lastStringToReplace to use in again
fm
parents: 3996
diff changeset
  7566
         But, if we replace a word-selected selection by something without a
9c22bd531240 lastStringToReplace to use in again
fm
parents: 3996
diff changeset
  7567
         space, we DO want the space added."
9c22bd531240 lastStringToReplace to use in again
fm
parents: 3996
diff changeset
  7568
9c22bd531240 lastStringToReplace to use in again
fm
parents: 3996
diff changeset
  7569
        selected size == 1 ifTrue:[
9c22bd531240 lastStringToReplace to use in again
fm
parents: 3996
diff changeset
  7570
            selectedString := selected at:1.
9c22bd531240 lastStringToReplace to use in again
fm
parents: 3996
diff changeset
  7571
        ].
9c22bd531240 lastStringToReplace to use in again
fm
parents: 3996
diff changeset
  7572
9c22bd531240 lastStringToReplace to use in again
fm
parents: 3996
diff changeset
  7573
        someText size == 1 ifTrue:[
9c22bd531240 lastStringToReplace to use in again
fm
parents: 3996
diff changeset
  7574
            |cutOffSpace addSpace replacement replacementString|
9c22bd531240 lastStringToReplace to use in again
fm
parents: 3996
diff changeset
  7575
9c22bd531240 lastStringToReplace to use in again
fm
parents: 3996
diff changeset
  7576
            cutOffSpace := false.
9c22bd531240 lastStringToReplace to use in again
fm
parents: 3996
diff changeset
  7577
            addSpace := false.
9c22bd531240 lastStringToReplace to use in again
fm
parents: 3996
diff changeset
  7578
            replacement := someText copyFrom:1.
9c22bd531240 lastStringToReplace to use in again
fm
parents: 3996
diff changeset
  7579
9c22bd531240 lastStringToReplace to use in again
fm
parents: 3996
diff changeset
  7580
            selectedString notNil ifTrue:[
9c22bd531240 lastStringToReplace to use in again
fm
parents: 3996
diff changeset
  7581
                ((selectedString startsWith:' ') or:[selectedString endsWith:' ']) ifFalse:[
9c22bd531240 lastStringToReplace to use in again
fm
parents: 3996
diff changeset
  7582
                   "selection has no space"
9c22bd531240 lastStringToReplace to use in again
fm
parents: 3996
diff changeset
  7583
9c22bd531240 lastStringToReplace to use in again
fm
parents: 3996
diff changeset
  7584
                    ((selectStyle == #wordleft) or:[selectStyle == #wordRight]) ifTrue:[
9c22bd531240 lastStringToReplace to use in again
fm
parents: 3996
diff changeset
  7585
                        cutOffSpace := true
9c22bd531240 lastStringToReplace to use in again
fm
parents: 3996
diff changeset
  7586
                    ]
9c22bd531240 lastStringToReplace to use in again
fm
parents: 3996
diff changeset
  7587
                ] ifTrue:[
9c22bd531240 lastStringToReplace to use in again
fm
parents: 3996
diff changeset
  7588
                    addSpace := true
9c22bd531240 lastStringToReplace to use in again
fm
parents: 3996
diff changeset
  7589
                ]
9c22bd531240 lastStringToReplace to use in again
fm
parents: 3996
diff changeset
  7590
            ].
9c22bd531240 lastStringToReplace to use in again
fm
parents: 3996
diff changeset
  7591
            replacementString := replacement at:1.
9c22bd531240 lastStringToReplace to use in again
fm
parents: 3996
diff changeset
  7592
            cutOffSpace ifTrue:[
9c22bd531240 lastStringToReplace to use in again
fm
parents: 3996
diff changeset
  7593
                (replacementString startsWith:' ') ifTrue:[
9c22bd531240 lastStringToReplace to use in again
fm
parents: 3996
diff changeset
  7594
                    replacementString := replacementString withoutSpaces
9c22bd531240 lastStringToReplace to use in again
fm
parents: 3996
diff changeset
  7595
                ].
9c22bd531240 lastStringToReplace to use in again
fm
parents: 3996
diff changeset
  7596
            ] ifFalse:[
9c22bd531240 lastStringToReplace to use in again
fm
parents: 3996
diff changeset
  7597
                selectStyle == #wordLeft ifTrue:[
9c22bd531240 lastStringToReplace to use in again
fm
parents: 3996
diff changeset
  7598
                    "want a space at left"
9c22bd531240 lastStringToReplace to use in again
fm
parents: 3996
diff changeset
  7599
                    (replacementString startsWith:' ') ifFalse:[
9c22bd531240 lastStringToReplace to use in again
fm
parents: 3996
diff changeset
  7600
                        replacementString := replacementString withoutSpaces.
9c22bd531240 lastStringToReplace to use in again
fm
parents: 3996
diff changeset
  7601
                        replacementString := ' ' , replacementString
9c22bd531240 lastStringToReplace to use in again
fm
parents: 3996
diff changeset
  7602
                    ]
9c22bd531240 lastStringToReplace to use in again
fm
parents: 3996
diff changeset
  7603
                ].
9c22bd531240 lastStringToReplace to use in again
fm
parents: 3996
diff changeset
  7604
                selectStyle == #wordRight ifTrue:[
9c22bd531240 lastStringToReplace to use in again
fm
parents: 3996
diff changeset
  7605
                    "want a space at right"
9c22bd531240 lastStringToReplace to use in again
fm
parents: 3996
diff changeset
  7606
9c22bd531240 lastStringToReplace to use in again
fm
parents: 3996
diff changeset
  7607
                    (replacementString endsWith:' ') ifFalse:[
9c22bd531240 lastStringToReplace to use in again
fm
parents: 3996
diff changeset
  7608
                        replacementString := replacementString withoutSpaces.
9c22bd531240 lastStringToReplace to use in again
fm
parents: 3996
diff changeset
  7609
                        replacementString := replacementString , ' '
9c22bd531240 lastStringToReplace to use in again
fm
parents: 3996
diff changeset
  7610
                    ]
9c22bd531240 lastStringToReplace to use in again
fm
parents: 3996
diff changeset
  7611
                ].
9c22bd531240 lastStringToReplace to use in again
fm
parents: 3996
diff changeset
  7612
            ].
9c22bd531240 lastStringToReplace to use in again
fm
parents: 3996
diff changeset
  7613
            replacement at:1 put: replacementString.
9c22bd531240 lastStringToReplace to use in again
fm
parents: 3996
diff changeset
  7614
            self paste:replacement.
9c22bd531240 lastStringToReplace to use in again
fm
parents: 3996
diff changeset
  7615
        ] ifFalse:[
9c22bd531240 lastStringToReplace to use in again
fm
parents: 3996
diff changeset
  7616
            self paste:someText
9c22bd531240 lastStringToReplace to use in again
fm
parents: 3996
diff changeset
  7617
        ].
4053
31117d801975 added: #setLastStringToReplace:
fm
parents: 4051
diff changeset
  7618
        self setLastStringToReplace: selectedString.
31117d801975 added: #setLastStringToReplace:
fm
parents: 4051
diff changeset
  7619
4048
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
  7620
        lastReplacementInfo lastReplacement: someText.
4010
9c22bd531240 lastStringToReplace to use in again
fm
parents: 3996
diff changeset
  7621
9c22bd531240 lastStringToReplace to use in again
fm
parents: 3996
diff changeset
  7622
        selStartLine := selectionStartLine.
9c22bd531240 lastStringToReplace to use in again
fm
parents: 3996
diff changeset
  7623
        selStartCol := self selectionStartCol.
9c22bd531240 lastStringToReplace to use in again
fm
parents: 3996
diff changeset
  7624
        selEndLine := selectionEndLine.
9c22bd531240 lastStringToReplace to use in again
fm
parents: 3996
diff changeset
  7625
        selEndCol := self selectionEndCol.
3130
c0f39f9f28d6 undoable keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3127
diff changeset
  7626
    ]
3542
30ed44ed0178 +joinLines (CTRL-j);
Claus Gittinger <cg@exept.de>
parents: 3517
diff changeset
  7627
    info:'Replace'
362
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  7628
1480
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  7629
    "Modified: / 14.2.1996 / 10:37:02 / stefan"
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  7630
    "Modified: / 5.4.1998 / 16:55:28 / cg"
121
claus
parents: 118
diff changeset
  7631
!
claus
parents: 118
diff changeset
  7632
3430
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  7633
searchReplace
3683
5891af82a177 middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents: 3650
diff changeset
  7634
    "search for a string - show a box to enter searchpattern
3430
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  7635
     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
  7636
     - 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
  7637
3430
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  7638
    |searchBox patternHolder replacePatternHolder caseHolder flag ign initialString bindings bldr search modal replace action|
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  7639
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  7640
    modal := false "(UserPreferences current searchDialogIsModal)".
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  7641
    lastSearchDirection := #forward.
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  7642
    ign := lastSearchIgnoredCase ? LastSearchIgnoredCase ? true.
5251
259d72b38bd7 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5244
diff changeset
  7643
    caseHolder := ValueHolder with:ign.
259d72b38bd7 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5244
diff changeset
  7644
    patternHolder := ValueHolder with:''.
259d72b38bd7 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5244
diff changeset
  7645
    replacePatternHolder := ValueHolder with:''.
3430
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  7646
    lastSearchPattern notNil ifTrue:[
4823
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  7647
        initialString := lastSearchPattern
3430
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  7648
    ].
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  7649
    self hasSelectionWithinSingleLine ifTrue:[
4823
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  7650
        initialString := self selectionAsString
3430
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  7651
    ].
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  7652
    initialString isNil ifTrue:[
4823
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  7653
        LastSearchPatterns size > 0 ifTrue:[
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  7654
            initialString := LastSearchPatterns first
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  7655
        ]
3430
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  7656
    ].
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  7657
    initialString notNil ifTrue:[
4823
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  7658
        patternHolder value:initialString.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  7659
        replacePatternHolder value:initialString.
3430
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  7660
    ].
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  7661
    flag := true.
3683
5891af82a177 middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents: 3650
diff changeset
  7662
    search := [:fwd |
4823
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  7663
            self
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  7664
                search:patternHolder value
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  7665
                ignoreCase:caseHolder value
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  7666
                forward:fwd.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  7667
        ].
3683
5891af82a177 middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents: 3650
diff changeset
  7668
    replace := [:all |
4823
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  7669
            self
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  7670
                replace:patternHolder value
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  7671
                by:replacePatternHolder value
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  7672
                all:all
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  7673
                ignoreCase:caseHolder value
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  7674
        ].
3430
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  7675
    bindings := IdentityDictionary new.
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  7676
    bindings at:#searchPattern put:patternHolder.
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  7677
    bindings at:#replacePattern put:replacePatternHolder.
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  7678
    modal ifTrue:[
4823
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  7679
        bindings at:#nextAction
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  7680
            put:[
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  7681
                flag := true.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  7682
                action := search.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  7683
                searchBox doAccept.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  7684
            ].
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  7685
        bindings at:#prevAction
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  7686
            put:[
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  7687
                flag := false.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  7688
                action := search.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  7689
                searchBox doAccept.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  7690
            ].
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  7691
        bindings at:#replaceAction
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  7692
            put:[
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  7693
                flag := false.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  7694
                action := replace.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  7695
                searchBox doAccept.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  7696
            ].
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  7697
        bindings at:#replaceAllAction
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  7698
            put:[
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  7699
                flag := true.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  7700
                action := replace.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  7701
                searchBox doAccept.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  7702
            ].
3430
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  7703
    ] ifFalse:[
4823
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  7704
        bindings at:#nextAction put:[ search value:true. ].
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  7705
        bindings at:#prevAction put:[ search value:false. ].
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  7706
        bindings at:#replaceAction put:[ replace value:false. ].
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  7707
        bindings at:#replaceAllAction put:[ replace value:true. ].
3430
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  7708
    ].
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  7709
    bindings at:#ignoreCase put:caseHolder.
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  7710
    bindings at:#patternList put:LastSearchPatterns.
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  7711
    modal ifTrue:[
4823
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  7712
        searchBox := SimpleDialog new.
3430
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  7713
    ] ifFalse:[
4823
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  7714
        searchBox := ApplicationModel new.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  7715
        searchBox createBuilder.
3430
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  7716
    ].
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  7717
    searchBox resources:(self resources).
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  7718
    bldr := searchBox builder.
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  7719
    bldr addBindings:bindings.
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  7720
    searchBox allButOpenFrom:(self class searchReplaceDialogSpec).
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  7721
    (bldr componentAt:#nextButton) cursor:(Cursor thumbsUp).
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  7722
    (bldr componentAt:#prevButton) cursor:(Cursor thumbsUp).
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  7723
    (bldr componentAt:#cancelButton) cursor:(Cursor thumbsDown).
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  7724
    modal ifTrue:[
4823
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  7725
        searchBox openDialog.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  7726
        searchBox accepted ifTrue:[
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  7727
            action value:flag
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  7728
        ].
3430
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  7729
    ] ifFalse:[
4823
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  7730
        (bldr componentAt:#nextButton) isReturnButton:false.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  7731
        (bldr componentAt:#cancelButton)
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  7732
            label:(resources string:'Close');
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  7733
            action:[ searchBox closeRequest ].
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  7734
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  7735
        "/ searchBox masterApplication:self application.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  7736
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  7737
        self topView beMaster.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  7738
        (searchBox window)
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  7739
            beSlave;
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  7740
            openInGroup:(self windowGroup).
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  7741
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  7742
        "/ searchBox window open.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  7743
5283
9c75aed7c274 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5260
diff changeset
  7744
        searchBox window assignKeyboardFocusToFirstKeyboardConsumer.
3430
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  7745
    ]
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  7746
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  7747
    "Modified: / 11-07-2006 / 11:20:06 / fm"
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  7748
!
1b0bc1af37e4 searchReplace
fm
parents: 3422
diff changeset
  7749
121
claus
parents: 118
diff changeset
  7750
showDeleted
claus
parents: 118
diff changeset
  7751
    "open a readonly editor on all deleted text"
claus
parents: 118
diff changeset
  7752
claus
parents: 118
diff changeset
  7753
    |v|
claus
parents: 118
diff changeset
  7754
claus
parents: 118
diff changeset
  7755
    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
  7756
    v readOnly:true.
121
claus
parents: 118
diff changeset
  7757
    v topView label:'deleted text'.
2624
22d352e56c27 preps for special characters
Claus Gittinger <cg@exept.de>
parents: 2617
diff changeset
  7758
!
22d352e56c27 preps for special characters
Claus Gittinger <cg@exept.de>
parents: 2617
diff changeset
  7759
3221
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  7760
sort:how ignoreCase:ignoreCase fromLine:start toLine:end
4763
89bf20c2e8f5 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4753
diff changeset
  7761
    "sort/reorder the selected lines.
89bf20c2e8f5 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4753
diff changeset
  7762
     how:
89bf20c2e8f5 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4753
diff changeset
  7763
        #lines
89bf20c2e8f5 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4753
diff changeset
  7764
        #linesByFirstWord
89bf20c2e8f5 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4753
diff changeset
  7765
        #linesByNthWord
89bf20c2e8f5 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4753
diff changeset
  7766
        #linesByNthNumber
89bf20c2e8f5 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4753
diff changeset
  7767
        #linesByNthHexNumber
89bf20c2e8f5 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4753
diff changeset
  7768
        #words
89bf20c2e8f5 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4753
diff changeset
  7769
        #linesByLength
89bf20c2e8f5 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4753
diff changeset
  7770
        #reverse
89bf20c2e8f5 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4753
diff changeset
  7771
    "
89bf20c2e8f5 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4753
diff changeset
  7772
89bf20c2e8f5 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4753
diff changeset
  7773
    |lines extractor innerExtractor fetcher operation lineWise nStr n s words|
3221
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  7774
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  7775
    lineWise := true.
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  7776
4763
89bf20c2e8f5 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4753
diff changeset
  7777
    how == #reverse ifTrue:[
89bf20c2e8f5 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4753
diff changeset
  7778
        operation := [:lines | lines reverse].
89bf20c2e8f5 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4753
diff changeset
  7779
    ] ifFalse:[
89bf20c2e8f5 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4753
diff changeset
  7780
        operation := [:linesOrWords |
89bf20c2e8f5 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4753
diff changeset
  7781
                        linesOrWords sort:[:item1 :item2 | (fetcher value:item1) < (fetcher value:item2)]
89bf20c2e8f5 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4753
diff changeset
  7782
                     ].
89bf20c2e8f5 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4753
diff changeset
  7783
89bf20c2e8f5 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4753
diff changeset
  7784
        how == #linesByLength ifTrue:[
89bf20c2e8f5 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4753
diff changeset
  7785
            fetcher := [:l | l size].
89bf20c2e8f5 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4753
diff changeset
  7786
        ] ifFalse:[
89bf20c2e8f5 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4753
diff changeset
  7787
            how == #lines ifTrue:[
89bf20c2e8f5 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4753
diff changeset
  7788
                extractor := [:l | l withoutLeadingSeparators].
89bf20c2e8f5 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4753
diff changeset
  7789
            ] ifFalse:[ 
89bf20c2e8f5 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4753
diff changeset
  7790
                how == #linesByFirstWord ifTrue:[
89bf20c2e8f5 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4753
diff changeset
  7791
                    extractor := [:l | ((l asCollectionOfWords select:[:w | w isEmpty or:[w first isLetterOrDigit]]) at:1 ifAbsent:'')].
89bf20c2e8f5 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4753
diff changeset
  7792
                ] ifFalse:[ 
89bf20c2e8f5 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4753
diff changeset
  7793
                    ((how == #linesByNthWord) or:[ how == #linesByNthNumber  or:[ how == #linesByNthHexNumber]]) ifTrue:[
89bf20c2e8f5 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4753
diff changeset
  7794
                        nStr := Dialog request:'Word/Column (1..)' initialAnswer:(LastColumnNumberForSort ? 2).
89bf20c2e8f5 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4753
diff changeset
  7795
                        nStr isEmptyOrNil ifTrue:[^ self].
89bf20c2e8f5 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4753
diff changeset
  7796
                        n := Integer readFrom:nStr onError:[^ self].
89bf20c2e8f5 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4753
diff changeset
  7797
                        LastColumnNumberForSort := n.
89bf20c2e8f5 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4753
diff changeset
  7798
                        extractor := [:l | ((l string asCollectionOfWords) at:n ifAbsent:'')].
89bf20c2e8f5 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4753
diff changeset
  7799
                        how == #linesByNthNumber ifTrue:[
89bf20c2e8f5 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4753
diff changeset
  7800
                            innerExtractor := extractor.
89bf20c2e8f5 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4753
diff changeset
  7801
                            extractor := [:l | Integer readFrom:(innerExtractor value:l) onError:0]
89bf20c2e8f5 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4753
diff changeset
  7802
                        ] ifFalse:[
89bf20c2e8f5 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4753
diff changeset
  7803
                            how == #linesByNthHexNumber ifTrue:[
89bf20c2e8f5 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4753
diff changeset
  7804
                                innerExtractor := extractor.
89bf20c2e8f5 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4753
diff changeset
  7805
                                extractor := [:l | 
89bf20c2e8f5 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4753
diff changeset
  7806
                                    |s|                                 
89bf20c2e8f5 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4753
diff changeset
  7807
                                    s := innerExtractor value:l.
89bf20c2e8f5 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4753
diff changeset
  7808
                                    (s startsWith:'16r') ifTrue:[
89bf20c2e8f5 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4753
diff changeset
  7809
                                        (Integer readSmalltalkSyntaxFrom:s) ? 0
89bf20c2e8f5 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4753
diff changeset
  7810
                                    ] ifFalse:[
89bf20c2e8f5 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4753
diff changeset
  7811
                                        Integer readFrom:s radix:16 onError:[ 0 ]
89bf20c2e8f5 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4753
diff changeset
  7812
                                    ]
89bf20c2e8f5 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4753
diff changeset
  7813
                                ]
4753
4e4aeb12d41f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4746
diff changeset
  7814
                            ]
4763
89bf20c2e8f5 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4753
diff changeset
  7815
                        ].
89bf20c2e8f5 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4753
diff changeset
  7816
                    ] ifFalse:[ 
89bf20c2e8f5 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4753
diff changeset
  7817
                        how == #words ifTrue:[
89bf20c2e8f5 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4753
diff changeset
  7818
                            lineWise := false.
89bf20c2e8f5 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4753
diff changeset
  7819
                            extractor := [:w | w].
89bf20c2e8f5 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4753
diff changeset
  7820
                        ] ifFalse:[
89bf20c2e8f5 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4753
diff changeset
  7821
                            self error:'unknown sort criteria: ', how printString.
4753
4e4aeb12d41f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4746
diff changeset
  7822
                        ]
4373
22fb03e6d08a class definition
Claus Gittinger <cg@exept.de>
parents: 4371
diff changeset
  7823
                    ]
22fb03e6d08a class definition
Claus Gittinger <cg@exept.de>
parents: 4371
diff changeset
  7824
                ]
4763
89bf20c2e8f5 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4753
diff changeset
  7825
            ].
89bf20c2e8f5 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4753
diff changeset
  7826
            ignoreCase ifTrue:[
89bf20c2e8f5 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4753
diff changeset
  7827
                fetcher := [:l | (extractor value:l) asLowercase].
89bf20c2e8f5 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4753
diff changeset
  7828
            ] ifFalse:[
89bf20c2e8f5 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4753
diff changeset
  7829
                fetcher := extractor.
89bf20c2e8f5 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4753
diff changeset
  7830
            ].
89bf20c2e8f5 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4753
diff changeset
  7831
        ].
3221
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  7832
    ].
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  7833
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  7834
    lineWise ifTrue:[
4763
89bf20c2e8f5 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4753
diff changeset
  7835
        "process the lines of the selection (aka a collection of lines)"
4373
22fb03e6d08a class definition
Claus Gittinger <cg@exept.de>
parents: 4371
diff changeset
  7836
        start == end ifTrue:[^ self ].
22fb03e6d08a class definition
Claus Gittinger <cg@exept.de>
parents: 4371
diff changeset
  7837
        lines := (start to:end) collect:[:lineNr | (self listAt:lineNr) ? ''].
4763
89bf20c2e8f5 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4753
diff changeset
  7838
        lines := operation value:lines.
4373
22fb03e6d08a class definition
Claus Gittinger <cg@exept.de>
parents: 4371
diff changeset
  7839
        (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
  7840
    ] ifFalse:[
89bf20c2e8f5 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4753
diff changeset
  7841
        "process the whole selection as a string"
89bf20c2e8f5 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4753
diff changeset
  7842
        s := self selectionAsString.
89bf20c2e8f5 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4753
diff changeset
  7843
        words := s asCollectionOfWords.
89bf20c2e8f5 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4753
diff changeset
  7844
        words := operation value:words.
89bf20c2e8f5 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4753
diff changeset
  7845
        s := words asStringCollection asStringWith:Character space.
89bf20c2e8f5 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4753
diff changeset
  7846
        self replace:s.
89bf20c2e8f5 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4753
diff changeset
  7847
    ].
3221
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  7848
    self textChanged.
4373
22fb03e6d08a class definition
Claus Gittinger <cg@exept.de>
parents: 4371
diff changeset
  7849
4414
308d40ee857b changed: #sort:ignoreCase:fromLine:toLine:
Claus Gittinger <cg@exept.de>
parents: 4396
diff changeset
  7850
    "Modified: / 31-03-2012 / 10:59:28 / cg"
3221
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  7851
!
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  7852
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  7853
sortSelection:how ignoreCase:ignoreCase
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  7854
    "sort the selected lines"
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  7855
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  7856
    |start end|
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  7857
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  7858
    selectionStartLine isNil ifTrue:[^ self].
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  7859
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  7860
    start := selectionStartLine.
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  7861
    end := selectionEndLine.
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  7862
    (selectionEndCol == 0) ifTrue:[
3786
11145773de65 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3782
diff changeset
  7863
        end := end - 1
3221
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  7864
    ].
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  7865
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  7866
    self
4373
22fb03e6d08a class definition
Claus Gittinger <cg@exept.de>
parents: 4371
diff changeset
  7867
        undoableDo:[ 
22fb03e6d08a class definition
Claus Gittinger <cg@exept.de>
parents: 4371
diff changeset
  7868
            self sort:how ignoreCase:ignoreCase fromLine:start toLine:end 
22fb03e6d08a class definition
Claus Gittinger <cg@exept.de>
parents: 4371
diff changeset
  7869
        ]
3786
11145773de65 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3782
diff changeset
  7870
        info:'Sort'
4373
22fb03e6d08a class definition
Claus Gittinger <cg@exept.de>
parents: 4371
diff changeset
  7871
22fb03e6d08a class definition
Claus Gittinger <cg@exept.de>
parents: 4371
diff changeset
  7872
    "Modified (format): / 15-02-2012 / 16:52:53 / cg"
3221
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  7873
!
12028ba1582d sort functions
Claus Gittinger <cg@exept.de>
parents: 3190
diff changeset
  7874
2624
22d352e56c27 preps for special characters
Claus Gittinger <cg@exept.de>
parents: 2617
diff changeset
  7875
specialCharacters
2915
8db67a5d1ccb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2912
diff changeset
  7876
    CharacterSetView
4823
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  7877
        openAsInputFor:self
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  7878
        label:'Special Character Input'
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  7879
        clickLabel:'Click to Insert Character'.
2866
9dd71df46f73 specialCharacters menu item
Claus Gittinger <cg@exept.de>
parents: 2857
diff changeset
  7880
!
9dd71df46f73 specialCharacters menu item
Claus Gittinger <cg@exept.de>
parents: 2857
diff changeset
  7881
5370
9b04537dc868 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5367
diff changeset
  7882
splitLinesAtCharacterOrString
9b04537dc868 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5367
diff changeset
  7883
    "ask user for the character and split after it"
9b04537dc868 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5367
diff changeset
  7884
9b04537dc868 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5367
diff changeset
  7885
    |sel in out separator record|
9b04537dc868 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5367
diff changeset
  7886
9b04537dc868 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5367
diff changeset
  7887
    selectionStartLine isNil ifTrue:[^ self].
9b04537dc868 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5367
diff changeset
  7888
9b04537dc868 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5367
diff changeset
  7889
    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
  7890
    separator isEmptyOrNil ifTrue:[^ self].
9b04537dc868 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5367
diff changeset
  7891
9b04537dc868 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5367
diff changeset
  7892
    sel := self selectionAsString.
9b04537dc868 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5367
diff changeset
  7893
    in := sel readStream.
5887
46f1b58748aa #OTHER by stefan
Stefan Vogel <sv@exept.de>
parents: 5882
diff changeset
  7894
    out := CharacterWriteStream on:''.
5370
9b04537dc868 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5367
diff changeset
  7895
    [in atEnd] whileFalse:[
5887
46f1b58748aa #OTHER by stefan
Stefan Vogel <sv@exept.de>
parents: 5882
diff changeset
  7896
        record := in throughAll:separator.
46f1b58748aa #OTHER by stefan
Stefan Vogel <sv@exept.de>
parents: 5882
diff changeset
  7897
        out nextPutLine:record.
5370
9b04537dc868 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5367
diff changeset
  7898
    ].
9b04537dc868 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5367
diff changeset
  7899
    self
9b04537dc868 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5367
diff changeset
  7900
        undoableDo:[ 
5887
46f1b58748aa #OTHER by stefan
Stefan Vogel <sv@exept.de>
parents: 5882
diff changeset
  7901
            self replaceSelectionBy:(out contents).
46f1b58748aa #OTHER by stefan
Stefan Vogel <sv@exept.de>
parents: 5882
diff changeset
  7902
        ]
46f1b58748aa #OTHER by stefan
Stefan Vogel <sv@exept.de>
parents: 5882
diff changeset
  7903
        info:'Split Selection'
5370
9b04537dc868 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5367
diff changeset
  7904
!
9b04537dc868 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5367
diff changeset
  7905
2989
5dcc2912bcb6 undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents: 2984
diff changeset
  7906
undoablePaste:someText
3495
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  7907
    self undoablePaste:someText info:nil.
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  7908
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  7909
    "Modified: / 28-07-2007 / 13:25:46 / cg"
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  7910
!
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  7911
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  7912
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
  7913
    self
4823
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  7914
        undoableDo:[
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  7915
            self paste:someText.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  7916
        ]
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  7917
        info:infoOrNil
3495
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  7918
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  7919
    "Created: / 28-07-2007 / 13:25:30 / cg"
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  7920
!
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  7921
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  7922
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
  7923
    self
4823
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  7924
        undoableDo:[
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  7925
            self pasteOrReplace:someText.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  7926
        ]
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  7927
        info:infoOrNil
3495
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  7928
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  7929
    "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
  7930
!
5dcc2912bcb6 undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents: 2984
diff changeset
  7931
4114
321416257cc5 added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents: 4110
diff changeset
  7932
undoablePasteReplacingAll:someText info:infoOrNil
321416257cc5 added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents: 4110
diff changeset
  7933
    self
321416257cc5 added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents: 4110
diff changeset
  7934
        undoableDo:[
321416257cc5 added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents: 4110
diff changeset
  7935
            self selectAll.
321416257cc5 added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents: 4110
diff changeset
  7936
            self pasteOrReplace:someText.
321416257cc5 added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents: 4110
diff changeset
  7937
        ]
321416257cc5 added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents: 4110
diff changeset
  7938
        info:infoOrNil
321416257cc5 added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents: 4110
diff changeset
  7939
321416257cc5 added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents: 4110
diff changeset
  7940
    "Created: / 28-07-2007 / 13:25:30 / cg"
321416257cc5 added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents: 4110
diff changeset
  7941
!
321416257cc5 added: #undoablePasteReplacingAll:info:
Claus Gittinger <cg@exept.de>
parents: 4110
diff changeset
  7942
2724
23f4e16dc4f4 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2720
diff changeset
  7943
withSelfAndTextForPasteDo:aBlock
23f4e16dc4f4 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2720
diff changeset
  7944
    "common code for paste/replace of the copybuffer"
23f4e16dc4f4 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2720
diff changeset
  7945
23f4e16dc4f4 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2720
diff changeset
  7946
    |sel|
23f4e16dc4f4 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2720
diff changeset
  7947
23f4e16dc4f4 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2720
diff changeset
  7948
    self checkModificationsAllowed ifFalse:[
4988
9f6f620a1f06 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4967
diff changeset
  7949
        self flashReadOnly.
4823
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  7950
        ^ self
2724
23f4e16dc4f4 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2720
diff changeset
  7951
    ].
23f4e16dc4f4 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2720
diff changeset
  7952
23f4e16dc4f4 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2720
diff changeset
  7953
    sel := self getTextSelectionOrTextSelectionFromHistory.
23f4e16dc4f4 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2720
diff changeset
  7954
    sel notNil ifTrue:[
4823
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  7955
        aBlock value:self value:sel.
2724
23f4e16dc4f4 code cleanup
Claus Gittinger <cg@exept.de>
parents: 2720
diff changeset
  7956
    ]
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  7957
! !
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  7958
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  7959
!EditTextView methodsFor:'private'!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  7960
3880
d8882158de6b beepInEditor flag
Claus Gittinger <cg@exept.de>
parents: 3868
diff changeset
  7961
beep
5244
261cf00fc93b class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5239
diff changeset
  7962
    "output an audible beep or bell on my screen device"
261cf00fc93b class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5239
diff changeset
  7963
3880
d8882158de6b beepInEditor flag
Claus Gittinger <cg@exept.de>
parents: 3868
diff changeset
  7964
    UserPreferences current beepInEditor ifTrue:[                
d8882158de6b beepInEditor flag
Claus Gittinger <cg@exept.de>
parents: 3868
diff changeset
  7965
        super beep
d8882158de6b beepInEditor flag
Claus Gittinger <cg@exept.de>
parents: 3868
diff changeset
  7966
    ]
d8882158de6b beepInEditor flag
Claus Gittinger <cg@exept.de>
parents: 3868
diff changeset
  7967
!
d8882158de6b beepInEditor flag
Claus Gittinger <cg@exept.de>
parents: 3868
diff changeset
  7968
331
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
  7969
checkModificationsAllowed
1300
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  7970
    "check if the text can be modified (i.e. is not readOnly).
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  7971
     evaluate the exceptionBlock if not.
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  7972
     This block should be provided by the application or user of the textView,
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  7973
     and may show a warnBox or whatever."
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  7974
1733
c5139b7402f0 use self isReadonly; readOnly may now be a valueHolder.
Claus Gittinger <cg@exept.de>
parents: 1732
diff changeset
  7975
    self isReadOnly ifTrue: [
4823
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  7976
        exceptionBlock isNil ifTrue:[
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  7977
            ^ false
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  7978
        ].
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  7979
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  7980
        (exceptionBlock value:'Text may not be modified') ~~ true ifTrue:[
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  7981
            ^ false
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  7982
        ]
331
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
  7983
    ].
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
  7984
    ^ true
1300
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  7985
1577
4e487247ad33 dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents: 1568
diff changeset
  7986
    "Modified: / 17.6.1998 / 15:51:10 / cg"
331
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
  7987
!
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
  7988
2596
933689d5bd9c alternative selection color
Claus Gittinger <cg@exept.de>
parents: 2589
diff changeset
  7989
currentSelectionBgColor
933689d5bd9c alternative selection color
Claus Gittinger <cg@exept.de>
parents: 2589
diff changeset
  7990
    typeOfSelection == #paste ifTrue:[
4823
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  7991
        ^ DefaultAlternativeSelectionBackgroundColor ? selectionBgColor
2596
933689d5bd9c alternative selection color
Claus Gittinger <cg@exept.de>
parents: 2589
diff changeset
  7992
    ].
5216
8d6eef5d09c3 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5194
diff changeset
  7993
    "/ hasKeyboardFocus ifFalse:[^ Color lightGrey]. 
2596
933689d5bd9c alternative selection color
Claus Gittinger <cg@exept.de>
parents: 2589
diff changeset
  7994
    ^ super currentSelectionBgColor
933689d5bd9c alternative selection color
Claus Gittinger <cg@exept.de>
parents: 2589
diff changeset
  7995
933689d5bd9c alternative selection color
Claus Gittinger <cg@exept.de>
parents: 2589
diff changeset
  7996
    "
933689d5bd9c alternative selection color
Claus Gittinger <cg@exept.de>
parents: 2589
diff changeset
  7997
     DefaultAlternativeSelectionBackgroundColor := Color yellow blendWith:Color green
933689d5bd9c alternative selection color
Claus Gittinger <cg@exept.de>
parents: 2589
diff changeset
  7998
    "
933689d5bd9c alternative selection color
Claus Gittinger <cg@exept.de>
parents: 2589
diff changeset
  7999
!
933689d5bd9c alternative selection color
Claus Gittinger <cg@exept.de>
parents: 2589
diff changeset
  8000
933689d5bd9c alternative selection color
Claus Gittinger <cg@exept.de>
parents: 2589
diff changeset
  8001
currentSelectionFgColor
933689d5bd9c alternative selection color
Claus Gittinger <cg@exept.de>
parents: 2589
diff changeset
  8002
    typeOfSelection == #paste ifTrue:[
4823
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  8003
        ^ DefaultAlternativeSelectionForegroundColor ? selectionFgColor
2596
933689d5bd9c alternative selection color
Claus Gittinger <cg@exept.de>
parents: 2589
diff changeset
  8004
    ].
933689d5bd9c alternative selection color
Claus Gittinger <cg@exept.de>
parents: 2589
diff changeset
  8005
    ^ super currentSelectionFgColor
933689d5bd9c alternative selection color
Claus Gittinger <cg@exept.de>
parents: 2589
diff changeset
  8006
!
933689d5bd9c alternative selection color
Claus Gittinger <cg@exept.de>
parents: 2589
diff changeset
  8007
3996
d0b0d69334ed added: #resetVariablesBeforeNewSearch
fm
parents: 3982
diff changeset
  8008
resetVariablesBeforeNewSearch
4451
71e8b21c63ce comment in: #resetVariablesBeforeNewSearch
Claus Gittinger <cg@exept.de>
parents: 4449
diff changeset
  8009
    "clear the autosearch action, when the first pattern is searched for"
3996
d0b0d69334ed added: #resetVariablesBeforeNewSearch
fm
parents: 3982
diff changeset
  8010
d0b0d69334ed added: #resetVariablesBeforeNewSearch
fm
parents: 3982
diff changeset
  8011
    super resetVariablesBeforeNewSearch.
d0b0d69334ed added: #resetVariablesBeforeNewSearch
fm
parents: 3982
diff changeset
  8012
d0b0d69334ed added: #resetVariablesBeforeNewSearch
fm
parents: 3982
diff changeset
  8013
    "/ new search invalidates remembered string
4048
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
  8014
    lastStringFromReplaceForNextSearch := nil.
4451
71e8b21c63ce comment in: #resetVariablesBeforeNewSearch
Claus Gittinger <cg@exept.de>
parents: 4449
diff changeset
  8015
71e8b21c63ce comment in: #resetVariablesBeforeNewSearch
Claus Gittinger <cg@exept.de>
parents: 4449
diff changeset
  8016
    "Modified (comment): / 07-03-2012 / 23:21:06 / cg"
3996
d0b0d69334ed added: #resetVariablesBeforeNewSearch
fm
parents: 3982
diff changeset
  8017
!
d0b0d69334ed added: #resetVariablesBeforeNewSearch
fm
parents: 3982
diff changeset
  8018
4053
31117d801975 added: #setLastStringToReplace:
fm
parents: 4051
diff changeset
  8019
setLastStringToReplace: aString
31117d801975 added: #setLastStringToReplace:
fm
parents: 4051
diff changeset
  8020
31117d801975 added: #setLastStringToReplace:
fm
parents: 4051
diff changeset
  8021
    "This method will set the information coming from the last replace into the replacementInfo"
31117d801975 added: #setLastStringToReplace:
fm
parents: 4051
diff changeset
  8022
31117d801975 added: #setLastStringToReplace:
fm
parents: 4051
diff changeset
  8023
    |lastReplaceIgnoredCase|
31117d801975 added: #setLastStringToReplace:
fm
parents: 4051
diff changeset
  8024
4064
140eda842f20 added: #hasSearchActionSelection
fm
parents: 4053
diff changeset
  8025
    "/ 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
  8026
    self clearSearchAction.
140eda842f20 added: #hasSearchActionSelection
fm
parents: 4053
diff changeset
  8027
4053
31117d801975 added: #setLastStringToReplace:
fm
parents: 4051
diff changeset
  8028
    lastReplacementInfo lastStringToReplace: aString.
31117d801975 added: #setLastStringToReplace:
fm
parents: 4051
diff changeset
  8029
    lastStringFromReplaceForNextSearch := aString.
31117d801975 added: #setLastStringToReplace:
fm
parents: 4051
diff changeset
  8030
31117d801975 added: #setLastStringToReplace:
fm
parents: 4051
diff changeset
  8031
    "If the replace came after a search, the next replace will have the ignored case from that search action"
4107
3881490b98f0 comment/format in:
Claus Gittinger <cg@exept.de>
parents: 4100
diff changeset
  8032
    lastReplaceIgnoredCase := (typeOfSelection == #search) 
3881490b98f0 comment/format in:
Claus Gittinger <cg@exept.de>
parents: 4100
diff changeset
  8033
                                ifTrue: [lastSearchIgnoredCase] 
3881490b98f0 comment/format in:
Claus Gittinger <cg@exept.de>
parents: 4100
diff changeset
  8034
                                ifFalse: [nil].
4053
31117d801975 added: #setLastStringToReplace:
fm
parents: 4051
diff changeset
  8035
    lastReplacementInfo lastReplaceIgnoredCase: lastReplaceIgnoredCase.
31117d801975 added: #setLastStringToReplace:
fm
parents: 4051
diff changeset
  8036
!
31117d801975 added: #setLastStringToReplace:
fm
parents: 4051
diff changeset
  8037
2225
65ac7cbffc60 added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents: 2213
diff changeset
  8038
suppressEmphasisInSelection
65ac7cbffc60 added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents: 2213
diff changeset
  8039
    "selection is shown without emphasis"
65ac7cbffc60 added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents: 2213
diff changeset
  8040
65ac7cbffc60 added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents: 2213
diff changeset
  8041
    ^ true
65ac7cbffc60 added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents: 2213
diff changeset
  8042
!
65ac7cbffc60 added suppressEmphasisInSelection handling
Claus Gittinger <cg@exept.de>
parents: 2213
diff changeset
  8043
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8044
textChanged
522
aa9458e4643e indent/undent did not trigger a modify
ca
parents: 503
diff changeset
  8045
    "my text was modified (internally).
aa9458e4643e indent/undent did not trigger a modify
ca
parents: 503
diff changeset
  8046
     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
  8047
     contentsChanged, which is triggered when the size has changed, and
4635
6218b92cce91 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4630
diff changeset
  8048
     is used to notify scrollers, other views etc.).
6218b92cce91 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4630
diff changeset
  8049
5979
faad087b3207 #DOCUMENTATION by stefan
Stefan Vogel <sv@exept.de>
parents: 5977
diff changeset
  8050
     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
  8051
     (not sending contentsChanged, but textChanged),
6218b92cce91 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4630
diff changeset
  8052
     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
  8053
641
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  8054
    self contentsChanged.
1015
caf7265128b9 clear modified on accept.
Claus Gittinger <cg@exept.de>
parents: 1013
diff changeset
  8055
    self modified:true.
5774
3a1531b4c933 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 5773
diff changeset
  8056
    dependents notNil ifTrue:[ self changed:#textChanged ].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8057
    contentsWasSaved := false
641
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  8058
1015
caf7265128b9 clear modified on accept.
Claus Gittinger <cg@exept.de>
parents: 1013
diff changeset
  8059
    "Modified: 14.2.1997 / 16:58:38 / cg"
2207
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  8060
!
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  8061
2617
a9b1af787406 typo on method name
Claus Gittinger <cg@exept.de>
parents: 2606
diff changeset
  8062
textChangedButNoSizeChange
2207
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  8063
    "my text was modified (internally).
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  8064
     Sent whenever text has been edited (not to confuse with
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  8065
     contentsChanged, which is triggered when the size has changed, and
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  8066
     is used to notify scrollers, other views etc.)"
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  8067
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  8068
    self modified:true.
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  8069
    contentsWasSaved := false
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  8070
80ca02ca0111 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
  8071
    "Modified: 14.2.1997 / 16:58:38 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8072
! !
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8073
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8074
!EditTextView methodsFor:'queries'!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8075
5216
8d6eef5d09c3 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5194
diff changeset
  8076
canAccept
8d6eef5d09c3 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5194
diff changeset
  8077
    "true if text can be accepts.
8d6eef5d09c3 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5194
diff changeset
  8078
     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
  8079
8d6eef5d09c3 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5194
diff changeset
  8080
    ^ acceptEnabled ~~ false
8d6eef5d09c3 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5194
diff changeset
  8081
!
8d6eef5d09c3 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5194
diff changeset
  8082
8d6eef5d09c3 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5194
diff changeset
  8083
canCut
8d6eef5d09c3 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5194
diff changeset
  8084
    "true if there is a selection possibly to be cut.
8d6eef5d09c3 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5194
diff changeset
  8085
     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
  8086
8d6eef5d09c3 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5194
diff changeset
  8087
    self isReadOnly ifTrue:[ ^ false ].
8d6eef5d09c3 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5194
diff changeset
  8088
    ^ self hasSelection
8d6eef5d09c3 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5194
diff changeset
  8089
!
8d6eef5d09c3 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5194
diff changeset
  8090
8d6eef5d09c3 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5194
diff changeset
  8091
canDoAgain
8d6eef5d09c3 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5194
diff changeset
  8092
    "true if there is a possible repeat last edit operation.
8d6eef5d09c3 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5194
diff changeset
  8093
     Used to disable the menu if there is nothing"
8d6eef5d09c3 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5194
diff changeset
  8094
8d6eef5d09c3 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5194
diff changeset
  8095
    self isReadOnly ifTrue:[ ^ false ].
5972
957ca3b2afb0 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5962
diff changeset
  8096
    ^ lastReplacementInfo lastStringToReplace notNil
957ca3b2afb0 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5962
diff changeset
  8097
957ca3b2afb0 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5962
diff changeset
  8098
    "Modified: / 19-11-2016 / 20:19:02 / cg"
5216
8d6eef5d09c3 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5194
diff changeset
  8099
!
8d6eef5d09c3 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5194
diff changeset
  8100
1526
7676f301bb8f added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents: 1515
diff changeset
  8101
currentLine
7676f301bb8f added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents: 1515
diff changeset
  8102
    "the current line (for relative gotos)"
7676f301bb8f added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents: 1515
diff changeset
  8103
7676f301bb8f added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents: 1515
diff changeset
  8104
    ^ cursorLine
7676f301bb8f added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents: 1515
diff changeset
  8105
7676f301bb8f added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents: 1515
diff changeset
  8106
    "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
  8107
!
7676f301bb8f added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents: 1515
diff changeset
  8108
4064
140eda842f20 added: #hasSearchActionSelection
fm
parents: 4053
diff changeset
  8109
hasSearchActionSelection
140eda842f20 added: #hasSearchActionSelection
fm
parents: 4053
diff changeset
  8110
140eda842f20 added: #hasSearchActionSelection
fm
parents: 4053
diff changeset
  8111
    ^ typeOfSelection == #searchAction
140eda842f20 added: #hasSearchActionSelection
fm
parents: 4053
diff changeset
  8112
!
140eda842f20 added: #hasSearchActionSelection
fm
parents: 4053
diff changeset
  8113
1878
d93809bda6c8 added #isKeyboardConsumer
Claus Gittinger <cg@exept.de>
parents: 1850
diff changeset
  8114
isKeyboardConsumer
d93809bda6c8 added #isKeyboardConsumer
Claus Gittinger <cg@exept.de>
parents: 1850
diff changeset
  8115
    "return true, if the receiver is a keyboard consumer;
5283
9c75aed7c274 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5260
diff changeset
  8116
     Return true here if not readOnly, redefined from SimpleView."
1878
d93809bda6c8 added #isKeyboardConsumer
Claus Gittinger <cg@exept.de>
parents: 1850
diff changeset
  8117
3476
41dde91ae706 isKeyboardConsumer: returns false if readOnly
ca
parents: 3474
diff changeset
  8118
    ^ self isReadOnly not
1878
d93809bda6c8 added #isKeyboardConsumer
Claus Gittinger <cg@exept.de>
parents: 1850
diff changeset
  8119
!
d93809bda6c8 added #isKeyboardConsumer
Claus Gittinger <cg@exept.de>
parents: 1850
diff changeset
  8120
997
615a5a19c5bf specClass
ca
parents: 991
diff changeset
  8121
specClass
1390
99674e1d9c85 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
  8122
    "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
  8123
997
615a5a19c5bf specClass
ca
parents: 991
diff changeset
  8124
    self class == EditTextView ifTrue:[^ TextEditorSpec].
1049
24360c8891d6 specClass query
Claus Gittinger <cg@exept.de>
parents: 1037
diff changeset
  8125
    ^ super specClass
24360c8891d6 specClass query
Claus Gittinger <cg@exept.de>
parents: 1037
diff changeset
  8126
1390
99674e1d9c85 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
  8127
    "Modified: / 31.10.1997 / 19:48:19 / cg"
997
615a5a19c5bf specClass
ca
parents: 991
diff changeset
  8128
!
615a5a19c5bf specClass
ca
parents: 991
diff changeset
  8129
324
9eec6d69e155 better Tab key handling
Claus Gittinger <cg@exept.de>
parents: 323
diff changeset
  8130
tabMeansNextField
323
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
  8131
    "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
  8132
313
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  8133
    "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
  8134
1733
c5139b7402f0 use self isReadonly; readOnly may now be a valueHolder.
Claus Gittinger <cg@exept.de>
parents: 1732
diff changeset
  8135
    ^ self isReadOnly or:[tabMeansNextField]
324
9eec6d69e155 better Tab key handling
Claus Gittinger <cg@exept.de>
parents: 323
diff changeset
  8136
9eec6d69e155 better Tab key handling
Claus Gittinger <cg@exept.de>
parents: 323
diff changeset
  8137
    "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
  8138
!
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  8139
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8140
widthOfContents
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8141
    "return the width of the contents in pixels
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8142
     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
  8143
     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
  8144
     line (and possibly see the cursor behind the line)"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8145
697
0f258f02e8ea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 693
diff changeset
  8146
    |w dev|
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8147
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8148
    w := super widthOfContents.
5643
921578f80870 device access
Claus Gittinger <cg@exept.de>
parents: 5593
diff changeset
  8149
    (dev := device ) isNil ifTrue:[
4889
3ee5b37416a1 class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 4884
diff changeset
  8150
        "/ really don't know ...
4823
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  8151
        dev := Screen current
606
682579fa3b62 fixed #widthOfContents if no device is known
Claus Gittinger <cg@exept.de>
parents: 597
diff changeset
  8152
    ].
4889
3ee5b37416a1 class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 4884
diff changeset
  8153
    ^ w + (gc font widthOn:dev)
697
0f258f02e8ea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 693
diff changeset
  8154
0f258f02e8ea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 693
diff changeset
  8155
    "Modified: 28.5.1996 / 19:32:25 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8156
! !
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8157
1588
e2e4ceeed3da category change
Claus Gittinger <cg@exept.de>
parents: 1585
diff changeset
  8158
!EditTextView methodsFor:'realization'!
e2e4ceeed3da category change
Claus Gittinger <cg@exept.de>
parents: 1585
diff changeset
  8159
e2e4ceeed3da category change
Claus Gittinger <cg@exept.de>
parents: 1585
diff changeset
  8160
realize
e2e4ceeed3da category change
Claus Gittinger <cg@exept.de>
parents: 1585
diff changeset
  8161
    "make the view visible - scroll to make the cursor visible."
e2e4ceeed3da category change
Claus Gittinger <cg@exept.de>
parents: 1585
diff changeset
  8162
e2e4ceeed3da category change
Claus Gittinger <cg@exept.de>
parents: 1585
diff changeset
  8163
    super realize.
e2e4ceeed3da category change
Claus Gittinger <cg@exept.de>
parents: 1585
diff changeset
  8164
e2e4ceeed3da category change
Claus Gittinger <cg@exept.de>
parents: 1585
diff changeset
  8165
    self makeCursorVisible.
5643
921578f80870 device access
Claus Gittinger <cg@exept.de>
parents: 5593
diff changeset
  8166
    cursorFgColor := cursorFgColor onDevice:device.
921578f80870 device access
Claus Gittinger <cg@exept.de>
parents: 5593
diff changeset
  8167
    cursorBgColor := cursorBgColor onDevice:device.
1588
e2e4ceeed3da category change
Claus Gittinger <cg@exept.de>
parents: 1585
diff changeset
  8168
e2e4ceeed3da category change
Claus Gittinger <cg@exept.de>
parents: 1585
diff changeset
  8169
    "Modified: 20.12.1996 / 14:16:05 / cg"
e2e4ceeed3da category change
Claus Gittinger <cg@exept.de>
parents: 1585
diff changeset
  8170
    "Created: 24.7.1997 / 18:24:12 / cg"
e2e4ceeed3da category change
Claus Gittinger <cg@exept.de>
parents: 1585
diff changeset
  8171
! !
e2e4ceeed3da category change
Claus Gittinger <cg@exept.de>
parents: 1585
diff changeset
  8172
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8173
!EditTextView methodsFor:'redrawing'!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8174
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8175
redrawCursorIfBetweenVisibleLine:startVisLine and:endVisLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8176
    "redraw the cursor, if it sits in a line range"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8177
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8178
    cursorShown ifTrue:[
4823
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  8179
        cursorVisibleLine notNil ifTrue:[
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  8180
            (cursorVisibleLine between:startVisLine and:endVisLine) ifTrue:[
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  8181
                self drawCursorCharacter
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  8182
            ]
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  8183
        ]
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8184
    ]
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  8185
!
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  8186
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8187
redrawCursorIfInVisibleLine:visLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8188
    "redraw the cursor, if it sits in visible line"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8189
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8190
    cursorShown ifTrue:[
4823
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  8191
        (visLine == cursorVisibleLine) ifTrue:[
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  8192
            self drawCursorCharacter
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  8193
        ]
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8194
    ]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8195
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8196
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8197
redrawFromVisibleLine:startVisLine to:endVisLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8198
    "redraw a visible line range"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8199
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8200
    super redrawFromVisibleLine:startVisLine to:endVisLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8201
    self redrawCursorIfBetweenVisibleLine:startVisLine and:endVisLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8202
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8203
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8204
redrawVisibleLine:visLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8205
    "redraw a visible line"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8206
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8207
    super redrawVisibleLine:visLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8208
    self redrawCursorIfInVisibleLine:visLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8209
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8210
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8211
redrawVisibleLine:visLine col:colNr
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8212
    "redraw the single character in visibleline at colNr"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8213
3510
4bd0b20bd05d cursor-only redrawing, with vertical-insertion cursor
Claus Gittinger <cg@exept.de>
parents: 3495
diff changeset
  8214
    super redrawVisibleLine:visLine col:colNr.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8215
    cursorShown ifTrue:[
4823
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  8216
        (visLine == cursorVisibleLine) ifTrue:[
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  8217
            (colNr == cursorCol) ifTrue:[
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  8218
                self drawCursorCharacter.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  8219
                ^ self
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  8220
            ]
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  8221
        ]
3510
4bd0b20bd05d cursor-only redrawing, with vertical-insertion cursor
Claus Gittinger <cg@exept.de>
parents: 3495
diff changeset
  8222
    ].
4bd0b20bd05d cursor-only redrawing, with vertical-insertion cursor
Claus Gittinger <cg@exept.de>
parents: 3495
diff changeset
  8223
4bd0b20bd05d cursor-only redrawing, with vertical-insertion cursor
Claus Gittinger <cg@exept.de>
parents: 3495
diff changeset
  8224
    "Modified: / 05-11-2007 / 17:35:53 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8225
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8226
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8227
redrawVisibleLine:visLine from:startCol
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8228
    "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
  8229
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8230
    super redrawVisibleLine:visLine from:startCol.
4494
dfe81ebdd5d6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
  8231
    cursorShown ifTrue:[
dfe81ebdd5d6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
  8232
        self redrawCursorIfInVisibleLine:visLine
dfe81ebdd5d6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4492
diff changeset
  8233
    ]
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8234
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8235
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8236
redrawVisibleLine:visLine from:startCol to:endCol
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8237
    "redraw a visible line from startCol to endCol"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8238
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8239
    super redrawVisibleLine:visLine from:startCol to:endCol.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8240
    self redrawCursorIfInVisibleLine:visLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8241
! !
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8242
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8243
!EditTextView methodsFor:'scrolling'!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8244
2331
218a017dc1f3 additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents: 2323
diff changeset
  8245
additionalMarginForHorizontalScroll
218a017dc1f3 additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents: 2323
diff changeset
  8246
    "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
  8247
     width of the document would allow.
218a017dc1f3 additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents: 2323
diff changeset
  8248
     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
  8249
     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
  8250
     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
  8251
4889
3ee5b37416a1 class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 4884
diff changeset
  8252
    ^ 10 max:gc font width
2331
218a017dc1f3 additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents: 2323
diff changeset
  8253
!
218a017dc1f3 additional scroll-margin can be redefined
Claus Gittinger <cg@exept.de>
parents: 2323
diff changeset
  8254
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8255
halfPageDown
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8256
    "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
  8257
     within the real text  "
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8258
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8259
    |prevCursorLine|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8260
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8261
    prevCursorLine := cursorVisibleLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8262
    super halfPageDown.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8263
    self cursorVisibleLine:prevCursorLine col:cursorCol
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8264
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8265
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8266
halfPageUp
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8267
    "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
  8268
     within the real text  "
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8269
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8270
    |prevCursorLine|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8271
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8272
    prevCursorLine := cursorVisibleLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8273
    super halfPageUp.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8274
    self cursorVisibleLine:prevCursorLine col:cursorCol
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8275
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8276
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8277
originChanged:delta
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8278
    "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
  8279
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8280
    super originChanged:delta.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8281
    "
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8282
     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
  8283
    "
2422
aaef7f02402c added cursorLine/Col holders;
Claus Gittinger <cg@exept.de>
parents: 2417
diff changeset
  8284
    self updateCursorVisibleLine.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8285
    prevCursorState ifTrue:[
4823
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  8286
        self showCursor
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8287
    ]
1577
4e487247ad33 dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents: 1568
diff changeset
  8288
4e487247ad33 dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents: 1568
diff changeset
  8289
    "Modified: / 17.6.1998 / 16:13:24 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8290
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8291
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8292
originWillChange
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8293
    "sent before scrolling - have to hide the cursor"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8294
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8295
    prevCursorState := cursorShown.
1601
57dde4dfee7e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  8296
    "/ cursorShown := false.
1591
d84c117e71cc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1590
diff changeset
  8297
    cursorShown ifTrue:[
4823
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  8298
        self hideCursor
1591
d84c117e71cc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1590
diff changeset
  8299
    ]
d84c117e71cc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1590
diff changeset
  8300
1601
57dde4dfee7e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1599
diff changeset
  8301
    "Modified: / 6.7.1998 / 13:07:23 / 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
pageDown
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8305
    "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
  8306
     within the real text  "
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8307
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8308
    |prevCursorLine|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8309
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8310
    prevCursorLine := cursorVisibleLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8311
    super pageDown.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8312
    self cursorVisibleLine:prevCursorLine col:cursorCol
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8313
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8314
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8315
pageUp
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8316
    "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
  8317
     within the real text  "
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8318
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8319
    |prevCursorLine|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8320
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8321
    prevCursorLine := cursorVisibleLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8322
    super pageUp.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8323
    self cursorVisibleLine:prevCursorLine col:cursorCol
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8324
! !
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8325
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8326
!EditTextView methodsFor:'searching'!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8327
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8328
searchBwd:pattern ifAbsent:aBlock
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8329
    "do a backward search"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8330
2822
08ceab3fc237 search refactored;
Claus Gittinger <cg@exept.de>
parents: 2819
diff changeset
  8331
    self searchBwd:pattern ignoreCase:false ifAbsent:aBlock
1339
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  8332
!
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  8333
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  8334
searchBwd:pattern ignoreCase:ign ifAbsent:aBlock
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  8335
    "do a backward search"
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  8336
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  8337
    cursorLine isNil ifTrue:[^ self].
4464
bbdc850e9d93 search protocol changed to pass down a searchSpec instead
Claus Gittinger <cg@exept.de>
parents: 4458
diff changeset
  8338
    super searchBwd:pattern ignoreCase:ign ifAbsent:aBlock
3580
c9d10df2b8bc StringSearchTool
fm
parents: 3578
diff changeset
  8339
!
c9d10df2b8bc StringSearchTool
fm
parents: 3578
diff changeset
  8340
c9d10df2b8bc StringSearchTool
fm
parents: 3578
diff changeset
  8341
searchBwd:pattern ignoreCase:ign startingAtLine:startLine col:startCol ifAbsent:aBlock
c9d10df2b8bc StringSearchTool
fm
parents: 3578
diff changeset
  8342
    "do a backward search"
c9d10df2b8bc StringSearchTool
fm
parents: 3578
diff changeset
  8343
c9d10df2b8bc StringSearchTool
fm
parents: 3578
diff changeset
  8344
    cursorLine isNil ifTrue:[^ self].
c9d10df2b8bc StringSearchTool
fm
parents: 3578
diff changeset
  8345
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  8346
    self
4119
90acc0c0d5f4 comment/format in: #again
fm
parents: 4117
diff changeset
  8347
        searchBackwardFor:pattern
90acc0c0d5f4 comment/format in: #again
fm
parents: 4117
diff changeset
  8348
        ignoreCase:ign
90acc0c0d5f4 comment/format in: #again
fm
parents: 4117
diff changeset
  8349
        startingAtLine:startLine col:startCol
5717
94a8cc3be8ec #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 5710
diff changeset
  8350
        ifFound:[:line :col :endColOrNil |
4119
90acc0c0d5f4 comment/format in: #again
fm
parents: 4117
diff changeset
  8351
            self cursorMovementAllowed ifTrue:[
90acc0c0d5f4 comment/format in: #again
fm
parents: 4117
diff changeset
  8352
                self cursorLine:line col:col.
90acc0c0d5f4 comment/format in: #again
fm
parents: 4117
diff changeset
  8353
            ].
5717
94a8cc3be8ec #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 5710
diff changeset
  8354
            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
  8355
"/            self makeLineVisible:cursorLine
4119
90acc0c0d5f4 comment/format in: #again
fm
parents: 4117
diff changeset
  8356
            typeOfSelection := #search]
90acc0c0d5f4 comment/format in: #again
fm
parents: 4117
diff changeset
  8357
        ifAbsent:aBlock
1339
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  8358
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  8359
    "Modified: 9.10.1997 / 13:02:13 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8360
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8361
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8362
searchForAndSelectMatchingParenthesis
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8363
    "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
  8364
2554
ec6aca20825f refactored
Claus Gittinger <cg@exept.de>
parents: 2544
diff changeset
  8365
    self searchForAndSelectMatchingParenthesisFromLine:cursorLine col:cursorCol
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8366
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8367
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8368
searchForMatchingParenthesis
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  8369
    "search for a matching parenthesis starting at cursor position.
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  8370
     Search for the corresponding character is done forward if its an opening,
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8371
     backwards if its a closing parenthesis.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8372
     Positions the cursor if found, peeps if not"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8373
2822
08ceab3fc237 search refactored;
Claus Gittinger <cg@exept.de>
parents: 2819
diff changeset
  8374
    self cursorMovementAllowed ifFalse:[^ self].
08ceab3fc237 search refactored;
Claus Gittinger <cg@exept.de>
parents: 2819
diff changeset
  8375
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  8376
    self
4823
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  8377
        searchForMatchingParenthesisFromLine:cursorLine col:cursorCol
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  8378
        ifFound:[:line :col | self cursorLine:line col:col]
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  8379
        ifNotFound:[self showNotFound]
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  8380
        onError:[self beep]
1339
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  8381
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  8382
    "Modified: 9.10.1997 / 12:56:30 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8383
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8384
3967
64bc48cd8e8b do not take search string from selection
fm
parents: 3963
diff changeset
  8385
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
  8386
    "do a forward search"
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  8387
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  8388
    cursorLine isNil ifTrue:[^ self].
3967
64bc48cd8e8b do not take search string from selection
fm
parents: 3963
diff changeset
  8389
    self 
64bc48cd8e8b do not take search string from selection
fm
parents: 3963
diff changeset
  8390
        searchForwardFor:pattern 
64bc48cd8e8b do not take search string from selection
fm
parents: 3963
diff changeset
  8391
        ignoreCase:ign
64bc48cd8e8b do not take search string from selection
fm
parents: 3963
diff changeset
  8392
        match: match
64bc48cd8e8b do not take search string from selection
fm
parents: 3963
diff changeset
  8393
        startingAtLine:startLine col:startCol
5717
94a8cc3be8ec #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 5710
diff changeset
  8394
        ifFound:[:line :col :endColOrNil|
3967
64bc48cd8e8b do not take search string from selection
fm
parents: 3963
diff changeset
  8395
            self cursorMovementAllowed ifTrue:[
64bc48cd8e8b do not take search string from selection
fm
parents: 3963
diff changeset
  8396
                self cursorLine:line col:col.
64bc48cd8e8b do not take search string from selection
fm
parents: 3963
diff changeset
  8397
            ].
5717
94a8cc3be8ec #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 5710
diff changeset
  8398
            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
  8399
"/            self makeLineVisible:cursorLine
3967
64bc48cd8e8b do not take search string from selection
fm
parents: 3963
diff changeset
  8400
            typeOfSelection := #search
64bc48cd8e8b do not take search string from selection
fm
parents: 3963
diff changeset
  8401
        ]
64bc48cd8e8b do not take search string from selection
fm
parents: 3963
diff changeset
  8402
        ifAbsent:aBlock
1339
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  8403
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  8404
    "Modified: 9.10.1997 / 12:57:47 / cg"
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  8405
    "Created: 9.10.1997 / 13:01:12 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8406
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8407
3967
64bc48cd8e8b do not take search string from selection
fm
parents: 3963
diff changeset
  8408
searchFwd:pattern ignoreCase:ign startingAtLine:startLine col:startCol ifAbsent:aBlock
64bc48cd8e8b do not take search string from selection
fm
parents: 3963
diff changeset
  8409
    "do a forward search"
64bc48cd8e8b do not take search string from selection
fm
parents: 3963
diff changeset
  8410
64bc48cd8e8b do not take search string from selection
fm
parents: 3963
diff changeset
  8411
    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
  8412
!
64bc48cd8e8b do not take search string from selection
fm
parents: 3963
diff changeset
  8413
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8414
searchFwd:pattern startingAtLine:startLine col:startCol ifAbsent:aBlock
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8415
    "do a forward search"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8416
2822
08ceab3fc237 search refactored;
Claus Gittinger <cg@exept.de>
parents: 2819
diff changeset
  8417
    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
  8418
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8419
3982
79e6af2d27b1 fixes in searchBar
fm
parents: 3976
diff changeset
  8420
searchPatternForSearchBar
79e6af2d27b1 fixes in searchBar
fm
parents: 3976
diff changeset
  8421
79e6af2d27b1 fixes in searchBar
fm
parents: 3976
diff changeset
  8422
    "Returns the next searchPattern from the user selection or from the autoSearch"
79e6af2d27b1 fixes in searchBar
fm
parents: 3976
diff changeset
  8423
79e6af2d27b1 fixes in searchBar
fm
parents: 3976
diff changeset
  8424
    |searchPattern|
79e6af2d27b1 fixes in searchBar
fm
parents: 3976
diff changeset
  8425
4138
fm
parents: 4136
diff changeset
  8426
    searchPattern := self searchPatternFromUserSelectionOrReplace.
3982
79e6af2d27b1 fixes in searchBar
fm
parents: 3976
diff changeset
  8427
    searchPattern isNil 
79e6af2d27b1 fixes in searchBar
fm
parents: 3976
diff changeset
  8428
        ifTrue: [searchPattern := lastSearchPattern]
79e6af2d27b1 fixes in searchBar
fm
parents: 3976
diff changeset
  8429
        ifFalse: [lastSearchPattern := searchPattern].
79e6af2d27b1 fixes in searchBar
fm
parents: 3976
diff changeset
  8430
    ^ searchPattern
79e6af2d27b1 fixes in searchBar
fm
parents: 3976
diff changeset
  8431
!
79e6af2d27b1 fixes in searchBar
fm
parents: 3976
diff changeset
  8432
3578
9d43beca1e85 searchForward with match argument
fm
parents: 3572
diff changeset
  8433
setSearchPatternWithMatchEscapes: match
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8434
    "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
  8435
     cursor to start of pattern"
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
    |sel|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8438
559
3ff87e9447c6 keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents: 522
diff changeset
  8439
    "/
3967
64bc48cd8e8b do not take search string from selection
fm
parents: 3963
diff changeset
  8440
    "/ 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
  8441
    "/ original string (for search after again)
4121
9232089c04c2 comment/format in: #setSearchPatternWithMatchEscapes:
fm
parents: 4119
diff changeset
  8442
    "/ 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
  8443
    "/
4249
44daffb1b034 comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents: 4248
diff changeset
  8444
"/    (lastStringFromReplaceForNextSearch notNil
44daffb1b034 comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents: 4248
diff changeset
  8445
"/     and:[typeOfSelection ~~ #search]) ifTrue:[
44daffb1b034 comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents: 4248
diff changeset
  8446
"/        lastStringFromReplaceForNextSearch isString ifTrue:[
44daffb1b034 comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents: 4248
diff changeset
  8447
"/            lastSearchPattern := lastStringFromReplaceForNextSearch.
44daffb1b034 comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents: 4248
diff changeset
  8448
"/        ] ifFalse:[
44daffb1b034 comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents: 4248
diff changeset
  8449
"/            lastSearchPattern := lastStringFromReplaceForNextSearch asStringWithoutFinalCR.
44daffb1b034 comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents: 4248
diff changeset
  8450
"/        ].
44daffb1b034 comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents: 4248
diff changeset
  8451
"/        ^ self
44daffb1b034 comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents: 4248
diff changeset
  8452
"/    ].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8453
559
3ff87e9447c6 keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents: 522
diff changeset
  8454
    "/
3ff87e9447c6 keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents: 522
diff changeset
  8455
    "/ if there is a selection:
3ff87e9447c6 keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents: 522
diff changeset
  8456
    "/    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
  8457
    "/    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
  8458
    "/    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
  8459
    "/    (to allow search-paste to be repeated)
3ff87e9447c6 keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents: 522
diff changeset
  8460
    "/
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8461
    sel := self selection.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8462
    sel notNil ifTrue:[
3967
64bc48cd8e8b do not take search string from selection
fm
parents: 3963
diff changeset
  8463
        (lastSearchPattern isNil
4484
38f88010834c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4483
diff changeset
  8464
        or:[typeOfSelection ~~ #paste and:[typeOfSelection ~~ #search]]
38f88010834c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4483
diff changeset
  8465
        ) ifTrue:[
3967
64bc48cd8e8b do not take search string from selection
fm
parents: 3963
diff changeset
  8466
            self cursorLine:selectionStartLine col:selectionStartCol.
64bc48cd8e8b do not take search string from selection
fm
parents: 3963
diff changeset
  8467
            lastSearchPattern := sel asStringWithoutFinalCR.
64bc48cd8e8b do not take search string from selection
fm
parents: 3963
diff changeset
  8468
            match ifTrue:[lastSearchPattern := lastSearchPattern withMatchEscapes].
64bc48cd8e8b do not take search string from selection
fm
parents: 3963
diff changeset
  8469
        ]
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8470
    ]
559
3ff87e9447c6 keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents: 522
diff changeset
  8471
4249
44daffb1b034 comment/format in: #deleteCopyToClipboard:
Claus Gittinger <cg@exept.de>
parents: 4248
diff changeset
  8472
    "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
  8473
!
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
  8474
5717
94a8cc3be8ec #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 5710
diff changeset
  8475
showMatch:pattern isMatch:isMatch atLine:line col:col endCol:encColOrNil
94a8cc3be8ec #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 5710
diff changeset
  8476
    super showMatch:pattern isMatch:isMatch atLine:line col:col endCol:encColOrNil.
4484
38f88010834c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4483
diff changeset
  8477
    typeOfSelection := #search.
38f88010834c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4483
diff changeset
  8478
!
38f88010834c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4483
diff changeset
  8479
2756
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
  8480
startPositionForSearchBackward
2822
08ceab3fc237 search refactored;
Claus Gittinger <cg@exept.de>
parents: 2819
diff changeset
  8481
    ^ self startPositionForSearchBackwardBasedOnCursorOrSelection
08ceab3fc237 search refactored;
Claus Gittinger <cg@exept.de>
parents: 2819
diff changeset
  8482
!
08ceab3fc237 search refactored;
Claus Gittinger <cg@exept.de>
parents: 2819
diff changeset
  8483
08ceab3fc237 search refactored;
Claus Gittinger <cg@exept.de>
parents: 2819
diff changeset
  8484
startPositionForSearchBackwardBasedOnCursorOrSelection
2756
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
  8485
    |startLine startCol|
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
  8486
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
  8487
    selectionStartLine notNil ifTrue:[
4823
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  8488
        startLine := selectionStartLine.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  8489
        startCol := selectionStartCol
2756
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
  8490
    ] ifFalse:[
4823
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  8491
        cursorLine isNil ifTrue:[
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  8492
            startLine := list size.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  8493
            startCol := self listAt:startLine size.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  8494
        ] ifFalse:[
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  8495
            startLine := cursorLine min:list size.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  8496
            startCol := cursorCol
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  8497
        ]
2756
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
  8498
    ].
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
  8499
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
  8500
    ^ startCol @ cursorLine
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
  8501
!
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
  8502
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
  8503
startPositionForSearchForward
2822
08ceab3fc237 search refactored;
Claus Gittinger <cg@exept.de>
parents: 2819
diff changeset
  8504
    ^ self startPositionForSearchForwardBasedOnCursorOrSelection
08ceab3fc237 search refactored;
Claus Gittinger <cg@exept.de>
parents: 2819
diff changeset
  8505
!
08ceab3fc237 search refactored;
Claus Gittinger <cg@exept.de>
parents: 2819
diff changeset
  8506
08ceab3fc237 search refactored;
Claus Gittinger <cg@exept.de>
parents: 2819
diff changeset
  8507
startPositionForSearchForwardBasedOnCursorOrSelection
2756
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
  8508
    |startCol|
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
  8509
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  8510
    "/ 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
  8511
    "/ 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
  8512
    startCol := cursorCol.
4424
b38e9e3b483b changed: #startPositionForSearchForwardBasedOnCursorOrSelection
Claus Gittinger <cg@exept.de>
parents: 4421
diff changeset
  8513
    self hasSelection ifTrue:[
b38e9e3b483b changed: #startPositionForSearchForwardBasedOnCursorOrSelection
Claus Gittinger <cg@exept.de>
parents: 4421
diff changeset
  8514
        ^ selectionEndCol @ selectionEndLine.
b38e9e3b483b changed: #startPositionForSearchForwardBasedOnCursorOrSelection
Claus Gittinger <cg@exept.de>
parents: 4421
diff changeset
  8515
    ] ifFalse:[
4064
140eda842f20 added: #hasSearchActionSelection
fm
parents: 4053
diff changeset
  8516
        (cursorLine == 1 and:[cursorCol == 1]) ifTrue:[
140eda842f20 added: #hasSearchActionSelection
fm
parents: 4053
diff changeset
  8517
            startCol := 0
140eda842f20 added: #hasSearchActionSelection
fm
parents: 4053
diff changeset
  8518
        ].
140eda842f20 added: #hasSearchActionSelection
fm
parents: 4053
diff changeset
  8519
        startCol := startCol min:(self at:cursorLine) size
2756
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
  8520
    ].
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
  8521
2bdd7ceaf05c initial searchPosition extracted into separate method
Claus Gittinger <cg@exept.de>
parents: 2755
diff changeset
  8522
    ^ startCol @ cursorLine
4424
b38e9e3b483b changed: #startPositionForSearchForwardBasedOnCursorOrSelection
Claus Gittinger <cg@exept.de>
parents: 4421
diff changeset
  8523
b38e9e3b483b changed: #startPositionForSearchForwardBasedOnCursorOrSelection
Claus Gittinger <cg@exept.de>
parents: 4421
diff changeset
  8524
    "Modified (format): / 24-05-2012 / 13:58:37 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8525
! !
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8526
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8527
!EditTextView methodsFor:'selections'!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8528
4973
e78f1243d4ef Implemented #traditional and #standard selection extension modes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4970
diff changeset
  8529
addToSelectionAfter:aBlock 
4841
4fca96a61d42 Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4674
diff changeset
  8530
    "Extends the selection accroding to cursor position
4fca96a61d42 Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4674
diff changeset
  8531
     after evaluation of `aBlock`. Used to implement
4973
e78f1243d4ef Implemented #traditional and #standard selection extension modes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4970
diff changeset
  8532
     Shift-Up/Down/Left/Right, Shift-Home & Shift-End."
4841
4fca96a61d42 Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4674
diff changeset
  8533
4fca96a61d42 Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4674
diff changeset
  8534
    "/ Following comment is in czech and thus now very useful.
4970
36ec8c9fde52 Fix for issue #36.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4969
diff changeset
  8535
    "/ However I (JV) kept it here as this is one of the very
4841
4fca96a61d42 Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4674
diff changeset
  8536
    "/ first fix/hack we made to Smalltalk/X ages ago, if not
4fca96a61d42 Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4674
diff changeset
  8537
    "/ the very first one. Actually, this method and comment was 
4fca96a61d42 Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4674
diff changeset
  8538
    "/ written by Martin Dvorak. Yeah, being bit nostalgic...
4fca96a61d42 Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4674
diff changeset
  8539
3023
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  8540
    "Pokud existuje selekce, upravi ji
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  8541
     podle aktualni pozice kurzoru a pozice
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  8542
     po provedeni blocku.
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  8543
     Urceno k implementaci Shift-Home a Shift-End
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  8544
     Nejak nevim, jak to presneji popsat :-)"
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  8545
4973
e78f1243d4ef Implemented #traditional and #standard selection extension modes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4970
diff changeset
  8546
    | startLine startCol endLine endCol curLine curCol cursorAtTheBeginning cursorAtTheEnd cursorWasShown flip extModeStandard |
4841
4fca96a61d42 Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4674
diff changeset
  8547
4fca96a61d42 Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4674
diff changeset
  8548
    curLine := cursorLine.
4fca96a61d42 Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4674
diff changeset
  8549
    curCol := cursorCol.
3023
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  8550
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  8551
    self hasSelection ifTrue: [
4970
36ec8c9fde52 Fix for issue #36.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4969
diff changeset
  8552
        startLine := selectionStartLine.
36ec8c9fde52 Fix for issue #36.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4969
diff changeset
  8553
        startCol := selectionStartCol.
36ec8c9fde52 Fix for issue #36.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4969
diff changeset
  8554
        endLine := selectionEndLine.
36ec8c9fde52 Fix for issue #36.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4969
diff changeset
  8555
        endCol := selectionEndCol.
4841
4fca96a61d42 Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4674
diff changeset
  8556
    ] ifFalse:[
4fca96a61d42 Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4674
diff changeset
  8557
        startLine := endLine := curLine.
4fca96a61d42 Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4674
diff changeset
  8558
        startCol := curCol.
4fca96a61d42 Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4674
diff changeset
  8559
        endCol := curCol - 1.
4fca96a61d42 Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4674
diff changeset
  8560
    ].
4fca96a61d42 Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4674
diff changeset
  8561
4fca96a61d42 Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4674
diff changeset
  8562
    cursorAtTheBeginning := (startLine == curLine) and:[startCol == curCol].
4fca96a61d42 Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4674
diff changeset
  8563
    cursorAtTheEnd := (endLine == curLine) and:[endCol == (curCol - 1)]. 
4fca96a61d42 Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4674
diff changeset
  8564
    self assert: cursorAtTheBeginning | cursorAtTheEnd.
4fca96a61d42 Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4674
diff changeset
  8565
4fca96a61d42 Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4674
diff changeset
  8566
4fca96a61d42 Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4674
diff changeset
  8567
    cursorWasShown := self hideCursor.
4fca96a61d42 Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4674
diff changeset
  8568
    aBlock value.
4fca96a61d42 Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4674
diff changeset
  8569
4fca96a61d42 Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4674
diff changeset
  8570
    cursorAtTheBeginning ifTrue:[
4fca96a61d42 Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4674
diff changeset
  8571
        (cursorCol == (endCol + 1) and:[cursorLine == endLine]) ifTrue:[
4fca96a61d42 Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4674
diff changeset
  8572
                self unselect; showCursor.
4fca96a61d42 Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4674
diff changeset
  8573
                ^self
4fca96a61d42 Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4674
diff changeset
  8574
        ].
4fca96a61d42 Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4674
diff changeset
  8575
4973
e78f1243d4ef Implemented #traditional and #standard selection extension modes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4970
diff changeset
  8576
        flip := cursorLine == endLine and:[cursorCol > endCol].
e78f1243d4ef Implemented #traditional and #standard selection extension modes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4970
diff changeset
  8577
        flip ifTrue:[ 
e78f1243d4ef Implemented #traditional and #standard selection extension modes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4970
diff changeset
  8578
            extModeStandard := UserPreferences current selectionExtensionMode == #standard.
e78f1243d4ef Implemented #traditional and #standard selection extension modes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4970
diff changeset
  8579
        ].
e78f1243d4ef Implemented #traditional and #standard selection extension modes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4970
diff changeset
  8580
        (cursorLine > endLine or:[flip]) ifTrue:[
e78f1243d4ef Implemented #traditional and #standard selection extension modes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4970
diff changeset
  8581
            (flip and:[ extModeStandard ]) ifTrue:[
e78f1243d4ef Implemented #traditional and #standard selection extension modes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4970
diff changeset
  8582
                startLine := endLine.
e78f1243d4ef Implemented #traditional and #standard selection extension modes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4970
diff changeset
  8583
                startCol := endCol + 1.
e78f1243d4ef Implemented #traditional and #standard selection extension modes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4970
diff changeset
  8584
            ].
4841
4fca96a61d42 Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4674
diff changeset
  8585
            endLine := cursorLine.
4fca96a61d42 Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4674
diff changeset
  8586
            endCol := cursorCol - 1
4fca96a61d42 Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4674
diff changeset
  8587
        ] ifFalse:[
4fca96a61d42 Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4674
diff changeset
  8588
            startLine := cursorLine.
4823
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  8589
            startCol := cursorCol.
4841
4fca96a61d42 Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4674
diff changeset
  8590
        ]
4fca96a61d42 Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4674
diff changeset
  8591
    ] ifFalse:[
4fca96a61d42 Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4674
diff changeset
  8592
        cursorAtTheEnd ifTrue:[
4fca96a61d42 Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4674
diff changeset
  8593
            (cursorCol == startCol and:[cursorLine == startLine]) ifTrue:[
4fca96a61d42 Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4674
diff changeset
  8594
                self unselect; showCursor.
4fca96a61d42 Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4674
diff changeset
  8595
                ^self
4fca96a61d42 Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4674
diff changeset
  8596
            ].
4973
e78f1243d4ef Implemented #traditional and #standard selection extension modes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4970
diff changeset
  8597
            flip := cursorLine == startLine and:[cursorCol < startCol].
e78f1243d4ef Implemented #traditional and #standard selection extension modes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4970
diff changeset
  8598
            flip ifTrue:[ 
e78f1243d4ef Implemented #traditional and #standard selection extension modes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4970
diff changeset
  8599
                extModeStandard := UserPreferences current selectionExtensionMode == #standard.
e78f1243d4ef Implemented #traditional and #standard selection extension modes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4970
diff changeset
  8600
            ].  
e78f1243d4ef Implemented #traditional and #standard selection extension modes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4970
diff changeset
  8601
            (cursorLine < startLine or:[flip]) ifTrue:[
e78f1243d4ef Implemented #traditional and #standard selection extension modes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4970
diff changeset
  8602
                (flip and:[ extModeStandard ]) ifTrue:[
e78f1243d4ef Implemented #traditional and #standard selection extension modes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4970
diff changeset
  8603
                    endLine := startLine.
e78f1243d4ef Implemented #traditional and #standard selection extension modes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4970
diff changeset
  8604
                    endCol := startCol - 1.
e78f1243d4ef Implemented #traditional and #standard selection extension modes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4970
diff changeset
  8605
                ].
4841
4fca96a61d42 Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4674
diff changeset
  8606
                startLine := cursorLine.
4fca96a61d42 Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4674
diff changeset
  8607
                startCol := cursorCol
4fca96a61d42 Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4674
diff changeset
  8608
            ] ifFalse:[
4fca96a61d42 Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4674
diff changeset
  8609
                endLine := cursorLine.
4973
e78f1243d4ef Implemented #traditional and #standard selection extension modes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4970
diff changeset
  8610
                endCol := cursorCol - 1.
4841
4fca96a61d42 Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4674
diff changeset
  8611
            ]
4823
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  8612
        ].
4841
4fca96a61d42 Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4674
diff changeset
  8613
    ].
3023
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  8614
    self selectFromLine:startLine col:startCol toLine: endLine col:endCol .
4841
4fca96a61d42 Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4674
diff changeset
  8615
    cursorWasShown ifTrue:[self showCursor].
4fca96a61d42 Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4674
diff changeset
  8616
4973
e78f1243d4ef Implemented #traditional and #standard selection extension modes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4970
diff changeset
  8617
    "Modified: / 27-03-2014 / 10:05:07 / Jan Vrany <jan.vrany@fit.cvut.cz>"
4970
36ec8c9fde52 Fix for issue #36.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4969
diff changeset
  8618
    "Modified (comment): / 25-03-2014 / 17:18:56 / Jan Vrany <jan.vrany@fit.cvut.cz>"
3023
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  8619
!
9a6809da7351 shift BOL/shift EOL now selects;
Claus Gittinger <cg@exept.de>
parents: 3020
diff changeset
  8620
1850
82516928e791 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1849
diff changeset
  8621
autoMoveCursorToEndOfSelection
82516928e791 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1849
diff changeset
  8622
    "return true, if the cursor should be automatically moved to the
82516928e791 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1849
diff changeset
  8623
     end of a selection.
3963
c315f087d655 comment in: #autoMoveCursorToEndOfSelection
Claus Gittinger <cg@exept.de>
parents: 3945
diff changeset
  8624
     Redefined to return false in terminalViews, where the cursor should
1850
82516928e791 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1849
diff changeset
  8625
     not be affected by selecting"
82516928e791 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1849
diff changeset
  8626
82516928e791 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1849
diff changeset
  8627
    ^ true
82516928e791 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1849
diff changeset
  8628
!
82516928e791 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1849
diff changeset
  8629
2606
6a3ab90d339f redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents: 2599
diff changeset
  8630
changeTypeOfSelectionTo:newType
6a3ab90d339f redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents: 2599
diff changeset
  8631
    typeOfSelection ~~ newType ifTrue:[
4823
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  8632
        typeOfSelection := newType.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  8633
        selectionStartLine notNil ifTrue:[
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  8634
            self
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  8635
                redrawFromLine:selectionStartLine col:selectionStartCol
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  8636
                toLine:selectionEndLine col:selectionEndCol
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  8637
        ].
2606
6a3ab90d339f redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents: 2599
diff changeset
  8638
    ].
6a3ab90d339f redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents: 2599
diff changeset
  8639
!
6a3ab90d339f redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents: 2599
diff changeset
  8640
4707
f6ac835a1cf6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4701
diff changeset
  8641
findNextWordAfterSelectionAndAddToSelection
f6ac835a1cf6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4701
diff changeset
  8642
    |selStartCol selStartLine selEndCol selEndLine|
f6ac835a1cf6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4701
diff changeset
  8643
f6ac835a1cf6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4701
diff changeset
  8644
    selectionStartCol isNil ifTrue:[
f6ac835a1cf6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4701
diff changeset
  8645
        self selectWordUnderCursor.
f6ac835a1cf6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4701
diff changeset
  8646
        ^ self
f6ac835a1cf6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4701
diff changeset
  8647
    ].
f6ac835a1cf6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4701
diff changeset
  8648
f6ac835a1cf6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4701
diff changeset
  8649
    selStartCol := selectionStartCol.
f6ac835a1cf6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4701
diff changeset
  8650
    selEndCol := selectionEndCol.
f6ac835a1cf6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4701
diff changeset
  8651
    selStartLine := selectionStartLine.
f6ac835a1cf6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4701
diff changeset
  8652
    selEndLine := selectionEndLine.
f6ac835a1cf6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4701
diff changeset
  8653
f6ac835a1cf6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4701
diff changeset
  8654
    self cursorToNextWord.
f6ac835a1cf6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4701
diff changeset
  8655
    self selectWordUnderCursor.
f6ac835a1cf6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4701
diff changeset
  8656
f6ac835a1cf6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4701
diff changeset
  8657
    self selectFromLine:selStartLine col:selStartCol toLine:selectionEndLine col:selectionEndCol.
f6ac835a1cf6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4701
diff changeset
  8658
!
f6ac835a1cf6 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4701
diff changeset
  8659
4138
fm
parents: 4136
diff changeset
  8660
searchPatternFromUserSelectionOrReplace
fm
parents: 4136
diff changeset
  8661
fm
parents: 4136
diff changeset
  8662
    |sel searchPattern|
fm
parents: 4136
diff changeset
  8663
fm
parents: 4136
diff changeset
  8664
    "/
fm
parents: 4136
diff changeset
  8665
    "/ if the last operation was a replace, set pattern to last
fm
parents: 4136
diff changeset
  8666
    "/ original string (for search after again)
fm
parents: 4136
diff changeset
  8667
    "/
fm
parents: 4136
diff changeset
  8668
    (lastStringFromReplaceForNextSearch notNil
fm
parents: 4136
diff changeset
  8669
     and:[typeOfSelection ~~ #search]) ifTrue:[
fm
parents: 4136
diff changeset
  8670
        lastStringFromReplaceForNextSearch isString ifTrue:[
fm
parents: 4136
diff changeset
  8671
            searchPattern := lastStringFromReplaceForNextSearch.
fm
parents: 4136
diff changeset
  8672
        ] ifFalse:[
fm
parents: 4136
diff changeset
  8673
            searchPattern := lastStringFromReplaceForNextSearch asStringWithoutFinalCR.
fm
parents: 4136
diff changeset
  8674
        ].
fm
parents: 4136
diff changeset
  8675
        ^ searchPattern
fm
parents: 4136
diff changeset
  8676
    ].
fm
parents: 4136
diff changeset
  8677
fm
parents: 4136
diff changeset
  8678
    "/
fm
parents: 4136
diff changeset
  8679
    "/ if there is a selection:
fm
parents: 4136
diff changeset
  8680
    "/    if there was no previous search, take it as search pattern.
fm
parents: 4136
diff changeset
  8681
    "/    if there was a previous search, only take the selection if
fm
parents: 4136
diff changeset
  8682
    "/    it did not result from a paste.
fm
parents: 4136
diff changeset
  8683
    "/    (to allow search-paste to be repeated)
fm
parents: 4136
diff changeset
  8684
    "/
fm
parents: 4136
diff changeset
  8685
    sel := self selection.
fm
parents: 4136
diff changeset
  8686
    sel notNil ifTrue:[
fm
parents: 4136
diff changeset
  8687
        typeOfSelection ~~ #search ifTrue:[
fm
parents: 4136
diff changeset
  8688
            typeOfSelection ~~ #paste ifTrue:[
fm
parents: 4136
diff changeset
  8689
                self cursorLine:selectionStartLine col:selectionStartCol.
fm
parents: 4136
diff changeset
  8690
                searchPattern := sel asStringWithoutFinalCR.
fm
parents: 4136
diff changeset
  8691
            ]
fm
parents: 4136
diff changeset
  8692
        ].
fm
parents: 4136
diff changeset
  8693
    ].
fm
parents: 4136
diff changeset
  8694
fm
parents: 4136
diff changeset
  8695
    ^ searchPattern
fm
parents: 4136
diff changeset
  8696
!
fm
parents: 4136
diff changeset
  8697
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8698
selectAll
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8699
    "select the whole text.
5593
ad41e448d7a8 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 5581
diff changeset
  8700
     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
  8701
     cursor to be moved in this case."
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8702
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8703
    list isNil ifTrue:[
4823
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  8704
        self unselect
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8705
    ] ifFalse:[
4823
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  8706
        super selectFromLine:1 col:1 toLine:(list size + 1) col:0.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  8707
        typeOfSelection := nil
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8708
    ]
1082
ccc3aa4268c1 better #selectAll
Claus Gittinger <cg@exept.de>
parents: 1054
diff changeset
  8709
ccc3aa4268c1 better #selectAll
Claus Gittinger <cg@exept.de>
parents: 1054
diff changeset
  8710
    "Modified: 28.2.1997 / 19:14:54 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8711
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8712
4117
470a3086aaa9 added: #selectAllInitially
sr
parents: 4114
diff changeset
  8713
selectAllInitially
470a3086aaa9 added: #selectAllInitially
sr
parents: 4114
diff changeset
  8714
    "select the whole text. This is called only once during the initialization
470a3086aaa9 added: #selectAllInitially
sr
parents: 4114
diff changeset
  8715
     for editFields which are shown in a table or tree.
470a3086aaa9 added: #selectAllInitially
sr
parents: 4114
diff changeset
  8716
     The selectAll is called via this method to allow for easier redefinition and
470a3086aaa9 added: #selectAllInitially
sr
parents: 4114
diff changeset
  8717
     to distinguish auto-select from user-initiated selects."
470a3086aaa9 added: #selectAllInitially
sr
parents: 4114
diff changeset
  8718
470a3086aaa9 added: #selectAllInitially
sr
parents: 4114
diff changeset
  8719
    self selectAll
470a3086aaa9 added: #selectAllInitially
sr
parents: 4114
diff changeset
  8720
!
470a3086aaa9 added: #selectAllInitially
sr
parents: 4114
diff changeset
  8721
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8722
selectCursorLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8723
    "select cursorline"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8724
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  8725
    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
  8726
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8727
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8728
selectCursorLineFromBeginning
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8729
    "select cursorline up to cursor position"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8730
823
fc61564f7832 escape selects up to previous character
Claus Gittinger <cg@exept.de>
parents: 785
diff changeset
  8731
    cursorCol > 1 ifTrue:[
4823
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  8732
        self selectFromLine:cursorLine col:1
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  8733
                     toLine:cursorLine col:(cursorCol-1)
823
fc61564f7832 escape selects up to previous character
Claus Gittinger <cg@exept.de>
parents: 785
diff changeset
  8734
    ]
fc61564f7832 escape selects up to previous character
Claus Gittinger <cg@exept.de>
parents: 785
diff changeset
  8735
fc61564f7832 escape selects up to previous character
Claus Gittinger <cg@exept.de>
parents: 785
diff changeset
  8736
    "Modified: 16.8.1996 / 19:14:14 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8737
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8738
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8739
selectExpandCursorLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8740
    "expand selection by one line or select cursorline"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8741
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8742
    selectionStartLine isNil ifTrue:[
4823
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  8743
        self selectCursorLine
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8744
    ] ifFalse:[
4823
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  8745
        self selectFromLine:selectionStartLine col:selectionStartCol
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  8746
                     toLine:cursorLine+1 col:0.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  8747
        self makeLineVisible:selectionEndLine
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8748
    ]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8749
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8750
4257
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  8751
selectFromBeginOfLine
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  8752
    "select the text from the beginning of the current line to the current cursor position."
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  8753
4430
61c074a935cf fixed: #selectFromBeginOfLine
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4424
diff changeset
  8754
    | newCursorCol ln |
4271
3ce604308987 changed:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4258
diff changeset
  8755
4257
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  8756
    list isNil ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  8757
        self unselect
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  8758
    ] ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  8759
        cursorCol > 1 ifTrue:[
4430
61c074a935cf fixed: #selectFromBeginOfLine
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4424
diff changeset
  8760
            ln := list at: cursorLine.
61c074a935cf fixed: #selectFromBeginOfLine
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4424
diff changeset
  8761
            newCursorCol := ln notEmptyOrNil ifTrue:[ln indexOfNonSeparator] ifFalse:[1].
4271
3ce604308987 changed:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4258
diff changeset
  8762
            self selectFromLine:cursorLine col:newCursorCol toLine:cursorLine col:cursorCol-1.
3ce604308987 changed:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4258
diff changeset
  8763
            cursorCol := newCursorCol.
4257
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  8764
            typeOfSelection := nil
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  8765
        ]
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  8766
    ]
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  8767
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  8768
    "Created: / 28-06-2011 / 22:47:04 / cg"
4430
61c074a935cf fixed: #selectFromBeginOfLine
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4424
diff changeset
  8769
    "Modified: / 18-07-2012 / 17:00:26 / Jan Vrany <jan.vrany@fit.cvut.cz>"
4257
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  8770
!
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  8771
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8772
selectFromBeginning
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8773
    "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
  8774
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8775
    |col|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8776
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8777
    list isNil ifTrue:[
4823
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  8778
        self unselect
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8779
    ] ifFalse:[
4823
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  8780
        cursorCol == 0 ifTrue:[
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  8781
            col := 0
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  8782
        ] ifFalse:[
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  8783
            col := cursorCol - 1
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  8784
        ].
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  8785
        super selectFromLine:1 col:1 toLine:cursorLine col:col.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  8786
        typeOfSelection := nil
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8787
    ]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8788
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8789
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8790
selectFromLine:startLine col:startCol toLine:endLine col:endCol
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8791
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8792
    super selectFromLine:startLine col:startCol toLine:endLine col:endCol.
5293
bb7a5aa59ddb Merged 5251ecf0c9bb and 9d85f8e1e20c (branch default)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 5220 5226
diff changeset
  8793
    "JV: That's actually rubbish as then you loose the original positon
4976
83f3df06495f Added documentation of what was changed (meant to change)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4975
diff changeset
  8794
     and if user wants to extend/shring the selection further, you don't know
83f3df06495f Added documentation of what was changed (meant to change)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4975
diff changeset
  8795
     from which end to do it!!"
83f3df06495f Added documentation of what was changed (meant to change)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4975
diff changeset
  8796
"/    (selectionEndLine notNil and:[self autoMoveCursorToEndOfSelection]) ifTrue:[
83f3df06495f Added documentation of what was changed (meant to change)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4975
diff changeset
  8797
"/        self cursorLine:selectionEndLine col:(selectionEndCol + 1).
83f3df06495f Added documentation of what was changed (meant to change)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4975
diff changeset
  8798
"/    ].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8799
    typeOfSelection := nil
4841
4fca96a61d42 Selection refactoring (part 1).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4674
diff changeset
  8800
4976
83f3df06495f Added documentation of what was changed (meant to change)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4975
diff changeset
  8801
    "Modified: / 27-08-2013 / 13:28:12 / Jan Vrany <jan.vrany@fit.cvut.cz>"
83f3df06495f Added documentation of what was changed (meant to change)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4975
diff changeset
  8802
    "Modified (comment): / 27-08-2013 / 15:58:19 / Jan Vrany <jan.vrany@fit.cvut.cz>"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8803
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8804
4257
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  8805
selectToEndOfLine
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  8806
    "select the text from the current cursor position to the end of the current line"
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  8807
4271
3ce604308987 changed:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4258
diff changeset
  8808
    | newCursorCol line |
3ce604308987 changed:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4258
diff changeset
  8809
4257
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  8810
    list isNil ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  8811
        self unselect
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  8812
    ] ifFalse:[
4275
16c80f32c06c bug fix in #selectToEndOfLine
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4271
diff changeset
  8813
        cursorCol >= 1 ifTrue:[
4271
3ce604308987 changed:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4258
diff changeset
  8814
            line := list at: cursorLine.
3ce604308987 changed:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4258
diff changeset
  8815
            newCursorCol := line size.
3ce604308987 changed:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4258
diff changeset
  8816
            [ newCursorCol > 1 and:[(line at:newCursorCol) isSeparator] ]      
3ce604308987 changed:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4258
diff changeset
  8817
                whileTrue:[newCursorCol := newCursorCol - 1].
3ce604308987 changed:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4258
diff changeset
  8818
3ce604308987 changed:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4258
diff changeset
  8819
            self selectFromLine:cursorLine col:cursorCol toLine:cursorLine col: newCursorCol.
3ce604308987 changed:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4258
diff changeset
  8820
            cursorCol := newCursorCol.
4257
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  8821
            typeOfSelection := nil
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  8822
        ]
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  8823
    ]
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  8824
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  8825
    "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
  8826
    "Modified: / 30-06-2011 / 19:51:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
4257
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  8827
!
Claus Gittinger <cg@exept.de>
parents: 4256
diff changeset
  8828
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8829
selectUpToEnd
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8830
    "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
  8831
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8832
    list isNil ifTrue:[
4823
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  8833
        self unselect
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8834
    ] ifFalse:[
4823
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  8835
        super selectFromLine:cursorLine col:cursorCol toLine:(list size + 1) col:0.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  8836
        typeOfSelection := nil
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8837
    ]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8838
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8839
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8840
selectWordUnderCursor
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8841
    "select the word under the cursor"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8842
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8843
    self selectWordAtLine:cursorLine col:cursorCol
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8844
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8845
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8846
unselect
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8847
    "forget and unhilight selection - must take care of cursor here"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8848
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8849
    |wasOn|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8850
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8851
    wasOn := self hideCursor.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8852
    super unselect.
2606
6a3ab90d339f redraw selectionm, when its seelctionType changes
Claus Gittinger <cg@exept.de>
parents: 2599
diff changeset
  8853
    typeOfSelection := nil.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8854
    wasOn ifTrue:[self showCursor]
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  8855
! !
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  8856
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  8857
!EditTextView methodsFor:'undo & again'!
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  8858
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  8859
addUndo:action
2989
5dcc2912bcb6 undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents: 2984
diff changeset
  8860
    ^ undoSupport addUndo:action.
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  8861
!
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  8862
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  8863
again
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  8864
    "repeat the last action (which was a cut or replace).
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  8865
     If current selection is not last string, search forward to
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  8866
     next occurrence of it before repeating the last operation."
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  8867
4048
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
  8868
    |s l c sel savedSelectStyle startColForSearch 
4051
4fdd00fbdc60 changed:
fm
parents: 4048
diff changeset
  8869
     lastStringToReplace lastReplaceIgnoredCase lastReplaceWasMatch|
4048
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
  8870
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
  8871
    lastStringToReplace := lastReplacementInfo lastStringToReplace.
4010
9c22bd531240 lastStringToReplace to use in again
fm
parents: 3996
diff changeset
  8872
    lastStringToReplace isNil ifTrue:[
3816
3915f7b67262 again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents: 3813
diff changeset
  8873
        ^ false
2579
74d3798f4200 do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents: 2574
diff changeset
  8874
    ].
4048
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
  8875
    lastReplaceIgnoredCase := lastReplacementInfo lastReplaceIgnoredCase.
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
  8876
    lastReplaceWasMatch := lastReplacementInfo lastReplaceWasMatch.
2579
74d3798f4200 do not remove separators from replacement string
Claus Gittinger <cg@exept.de>
parents: 2574
diff changeset
  8877
3127
29767bf8a215 better info of replace action (compound-undo-action has info, too)
Claus Gittinger <cg@exept.de>
parents: 3115
diff changeset
  8878
    self undoableDo:[
4010
9c22bd531240 lastStringToReplace to use in again
fm
parents: 3996
diff changeset
  8879
        s := lastStringToReplace asString.
3816
3915f7b67262 again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents: 3813
diff changeset
  8880
        "remove final cr"
4566
21922c626af2 Changed usage of deprecated #copyWithoutLast: to #copyButLast:
Stefan Vogel <sv@exept.de>
parents: 4555
diff changeset
  8881
        (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
  8882
    "/        s := s withoutSpaces.        "XXX - replacing text with spaces ..."
4010
9c22bd531240 lastStringToReplace to use in again
fm
parents: 3996
diff changeset
  8883
4053
31117d801975 added: #setLastStringToReplace:
fm
parents: 4051
diff changeset
  8884
        "set lastStringToReplace as the next search string 
31117d801975 added: #setLastStringToReplace:
fm
parents: 4051
diff changeset
  8885
         and set lastReplaceIgnoredCase as the next search ignored case flag"
4048
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
  8886
        lastStringFromReplaceForNextSearch := s.
4053
31117d801975 added: #setLastStringToReplace:
fm
parents: 4051
diff changeset
  8887
        lastSearchIgnoredCase := lastReplaceIgnoredCase.
4010
9c22bd531240 lastStringToReplace to use in again
fm
parents: 3996
diff changeset
  8888
3816
3915f7b67262 again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents: 3813
diff changeset
  8889
        savedSelectStyle := selectStyle.
3915f7b67262 again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents: 3813
diff changeset
  8890
        selectStyle := nil.
3915f7b67262 again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents: 3813
diff changeset
  8891
3915f7b67262 again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents: 3813
diff changeset
  8892
        sel := self selection.
3915f7b67262 again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents: 3813
diff changeset
  8893
3915f7b67262 again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents: 3813
diff changeset
  8894
        "if we are already there (after a find), ommit search"
3915f7b67262 again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents: 3813
diff changeset
  8895
3915f7b67262 again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents: 3813
diff changeset
  8896
        (sel notNil and:[sel asString withoutSeparators = s]) ifTrue:[
3915f7b67262 again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents: 3813
diff changeset
  8897
            l := selectionStartLine "cursorLine".
3915f7b67262 again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents: 3813
diff changeset
  8898
            c := selectionStartCol "cursorCol".
3915f7b67262 again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents: 3813
diff changeset
  8899
            self deleteSelection.
4051
4fdd00fbdc60 changed:
fm
parents: 4048
diff changeset
  8900
            lastReplacementInfo lastReplacement notNil ifTrue:[
4fdd00fbdc60 changed:
fm
parents: 4048
diff changeset
  8901
                self insertLines:lastReplacementInfo lastReplacement asStringCollection withCR:false.
3816
3915f7b67262 again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents: 3813
diff changeset
  8902
                self selectFromLine:l col:c toLine:cursorLine col:(cursorCol - 1).
4484
38f88010834c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4483
diff changeset
  8903
                typeOfSelection := #paste
3816
3915f7b67262 again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents: 3813
diff changeset
  8904
            ].
3915f7b67262 again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents: 3813
diff changeset
  8905
            selectStyle := savedSelectStyle.
3915f7b67262 again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents: 3813
diff changeset
  8906
            ^ true
3915f7b67262 again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents: 3813
diff changeset
  8907
        ].
3915f7b67262 again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents: 3813
diff changeset
  8908
3915f7b67262 again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents: 3813
diff changeset
  8909
        sel isEmptyOrNil ifTrue:[
3915f7b67262 again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents: 3813
diff changeset
  8910
            startColForSearch := cursorCol - 1
3915f7b67262 again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents: 3813
diff changeset
  8911
        ] ifFalse:[
3915f7b67262 again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents: 3813
diff changeset
  8912
            startColForSearch := selectionEndCol ? (cursorCol - 1)
3915f7b67262 again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents: 3813
diff changeset
  8913
        ].
4048
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
  8914
        self 
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
  8915
            searchForwardFor:s
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
  8916
            ignoreCase: lastReplaceIgnoredCase 
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
  8917
            match: lastReplaceWasMatch 
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
  8918
            startingAtLine:cursorLine col:startColForSearch
3816
3915f7b67262 again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents: 3813
diff changeset
  8919
            ifFound:
3915f7b67262 again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents: 3813
diff changeset
  8920
                [
3915f7b67262 again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents: 3813
diff changeset
  8921
                    :line :col |
3915f7b67262 again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents: 3813
diff changeset
  8922
3915f7b67262 again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents: 3813
diff changeset
  8923
                    |repl|
3915f7b67262 again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents: 3813
diff changeset
  8924
3915f7b67262 again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents: 3813
diff changeset
  8925
                    self selectFromLine:line col:col
3915f7b67262 again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents: 3813
diff changeset
  8926
                                 toLine:line col:(col + s size - 1).
3915f7b67262 again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents: 3813
diff changeset
  8927
                    self makeLineVisible:line.
3915f7b67262 again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents: 3813
diff changeset
  8928
3915f7b67262 again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents: 3813
diff changeset
  8929
                    self deleteSelection.
4051
4fdd00fbdc60 changed:
fm
parents: 4048
diff changeset
  8930
                    lastReplacementInfo lastReplacement notNil ifTrue:[
4fdd00fbdc60 changed:
fm
parents: 4048
diff changeset
  8931
                        lastReplacementInfo lastReplacement isString ifFalse:[
4fdd00fbdc60 changed:
fm
parents: 4048
diff changeset
  8932
                            repl := lastReplacementInfo lastReplacement asString "withoutSpaces"
3816
3915f7b67262 again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents: 3813
diff changeset
  8933
                        ] ifTrue:[
4051
4fdd00fbdc60 changed:
fm
parents: 4048
diff changeset
  8934
                            repl := lastReplacementInfo lastReplacement "withoutSpaces".
3816
3915f7b67262 again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents: 3813
diff changeset
  8935
                        ].
3915f7b67262 again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents: 3813
diff changeset
  8936
                        self insertLines:repl asStringCollection withCR:false.
3915f7b67262 again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents: 3813
diff changeset
  8937
                        self selectFromLine:line col:col toLine:cursorLine col:(cursorCol - 1).
3915f7b67262 again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents: 3813
diff changeset
  8938
                        undoSupport actionInfo:'replace'.
3915f7b67262 again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents: 3813
diff changeset
  8939
                    ].
3915f7b67262 again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents: 3813
diff changeset
  8940
                    selectStyle := savedSelectStyle.
4484
38f88010834c class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4483
diff changeset
  8941
                    typeOfSelection := #paste.
3816
3915f7b67262 again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents: 3813
diff changeset
  8942
                    ^ true
3915f7b67262 again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents: 3813
diff changeset
  8943
                ]
4048
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
  8944
            ifAbsent:
3816
3915f7b67262 again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents: 3813
diff changeset
  8945
                [
3915f7b67262 again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents: 3813
diff changeset
  8946
                    self sensor compressKeyPressEventsWithKey:#Again.
3915f7b67262 again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents: 3813
diff changeset
  8947
                    self showNotFound.
3915f7b67262 again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents: 3813
diff changeset
  8948
                    selectStyle := savedSelectStyle.
3915f7b67262 again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents: 3813
diff changeset
  8949
                    ^ false
3915f7b67262 again, when the next replacement start immediately after the selection fixed
Claus Gittinger <cg@exept.de>
parents: 3813
diff changeset
  8950
                ].
3127
29767bf8a215 better info of replace action (compound-undo-action has info, too)
Claus Gittinger <cg@exept.de>
parents: 3115
diff changeset
  8951
    ].
2730
61a2f1981ac6 Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents: 2725
diff changeset
  8952
61a2f1981ac6 Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents: 2725
diff changeset
  8953
    ^ true.
501
13fc7b9ce5cb fixed (?) again-replace
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  8954
840
b0071cea13fd fixed Again when spaces are replaced
Claus Gittinger <cg@exept.de>
parents: 828
diff changeset
  8955
    "Modified: 9.10.1996 / 16:14:11 / cg"
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  8956
!
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  8957
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  8958
hasRedoAction
2989
5dcc2912bcb6 undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents: 2984
diff changeset
  8959
    ^ undoSupport hasRedoAction.
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  8960
!
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  8961
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  8962
hasUndoAction
2989
5dcc2912bcb6 undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents: 2984
diff changeset
  8963
    ^ undoSupport hasUndoAction.
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  8964
!
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  8965
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8966
multipleAgain
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8967
    "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
  8968
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8969
    [self again] whileTrue:[]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8970
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  8971
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  8972
nonUndoableDo:aBlock
2989
5dcc2912bcb6 undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents: 2984
diff changeset
  8973
    undoSupport nonUndoableDo:aBlock.
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  8974
!
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  8975
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  8976
redo
3780
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  8977
    "undo the last undo"
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  8978
2989
5dcc2912bcb6 undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents: 2984
diff changeset
  8979
    undoSupport hasRedoAction ifFalse:[
3780
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  8980
        self beep
2989
5dcc2912bcb6 undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents: 2984
diff changeset
  8981
    ] ifTrue:[
3780
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  8982
        undoSupport redo.
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  8983
    ]
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  8984
!
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  8985
121
claus
parents: 118
diff changeset
  8986
undo
3780
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  8987
    "undo the last edit operation"
628343522da5 redo key
Claus Gittinger <cg@exept.de>
parents: 3732
diff changeset
  8988
2989
5dcc2912bcb6 undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents: 2984
diff changeset
  8989
    undoSupport hasUndoAction ifFalse:[
5834
60d6d5a839d3 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5833
diff changeset
  8990
        self beep
2989
5dcc2912bcb6 undo/redo extracted to separate component for better reuse
Claus Gittinger <cg@exept.de>
parents: 2984
diff changeset
  8991
    ] ifTrue:[
5834
60d6d5a839d3 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5833
diff changeset
  8992
        undoSupport undo.
60d6d5a839d3 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5833
diff changeset
  8993
        self makeSelectionVisible.
60d6d5a839d3 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5833
diff changeset
  8994
        self makeCursorVisible.
121
claus
parents: 118
diff changeset
  8995
    ]
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  8996
!
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  8997
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  8998
undoableDo:aBlock
3495
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  8999
    self undoableDo:aBlock info:nil.
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  9000
4ff7edbd5942 changed #dropFileObject:
Claus Gittinger <cg@exept.de>
parents: 3483
diff changeset
  9001
    "Modified: / 28-07-2007 / 13:20:14 / cg"
3130
c0f39f9f28d6 undoable keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3127
diff changeset
  9002
!
c0f39f9f28d6 undoable keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3127
diff changeset
  9003
c0f39f9f28d6 undoable keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3127
diff changeset
  9004
undoableDo:aBlock info:aString
5689
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  9005
    |selectionRestore|
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  9006
3154
42bf7ebd54c8 refadctored intention revealing code:
Claus Gittinger <cg@exept.de>
parents: 3150
diff changeset
  9007
    self checkModificationsAllowed ifFalse:[
4823
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  9008
        "/ will trigger an error-dialog there (no need for undo-carekeeping)
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  9009
        aBlock value.
3154
42bf7ebd54c8 refadctored intention revealing code:
Claus Gittinger <cg@exept.de>
parents: 3150
diff changeset
  9010
    ] ifTrue:[
5689
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  9011
        undoSupport isInTransaction ifFalse:[
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  9012
            selectionRestore := RestoreSelectionAndCursor new 
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  9013
                                    cursorLine:cursorLine cursorCol:cursorCol
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  9014
                                    selectionStartLine:selectionStartLine selectionStartCol:selectionStartCol
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  9015
                                    selectionEndLine:selectionEndLine selectionEndCol:selectionEndCol
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  9016
                                    info:nil.
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  9017
        ].
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  9018
        undoSupport 
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  9019
            undoableDo:[
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  9020
                aBlock value.
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  9021
                selectionRestore notNil ifTrue:[
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  9022
                    undoSupport transactionNotEmpty ifTrue:[
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  9023
                        undoSupport addUndoFirst:selectionRestore 
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  9024
                    ].
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  9025
                ].
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  9026
            ]
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  9027
            info:aString.
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  9028
    ].
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  9029
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  9030
    "Modified: / 30-04-2016 / 21:08:30 / cg"
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9031
! !
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9032
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9033
!EditTextView::EditAction class methodsFor:'instance creation'!
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9034
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9035
line1:arg1 col1:arg2 line2:arg3 col2:arg4
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9036
    ^ self new line1:arg1 col1:arg2 line2:arg3 col2:arg4
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9037
!
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9038
3115
b75128334006 info string in undo
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
  9039
line1:arg1 col1:arg2 line2:arg3 col2:arg4 info:info
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  9040
    ^ (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
  9041
!
b75128334006 info string in undo
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
  9042
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9043
line:arg1 col:arg2 character:arg3
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9044
    ^ self new line:arg1 col:arg2 character:arg3
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9045
!
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9046
3115
b75128334006 info string in undo
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
  9047
line:arg1 col:arg2 character:arg3 info:info
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  9048
    ^ (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
  9049
!
b75128334006 info string in undo
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
  9050
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9051
line:arg1 col:arg2 characters:arg3 info:info
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9052
    ^ (self new line:arg1 col:arg2 characters:arg3) info:info
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9053
!
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9054
3156
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  9055
line:arg1 col:arg2 info:arg3
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  9056
    ^ self new line:arg1 col:arg2 info:arg3
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  9057
!
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  9058
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9059
line:arg1 col:arg2 string:arg3
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9060
    ^ self new line:arg1 col:arg2 string:arg3
3115
b75128334006 info string in undo
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
  9061
!
b75128334006 info string in undo
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
  9062
b75128334006 info string in undo
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
  9063
line:arg1 col:arg2 string:arg3 info:info
b75128334006 info string in undo
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
  9064
    ^ (self new line:arg1 col:arg2 string:arg3) info:info
3130
c0f39f9f28d6 undoable keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3127
diff changeset
  9065
!
c0f39f9f28d6 undoable keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3127
diff changeset
  9066
c0f39f9f28d6 undoable keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3127
diff changeset
  9067
line:arg1 string:arg3 info:info
c0f39f9f28d6 undoable keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3127
diff changeset
  9068
    ^ (self new line:arg1 string:arg3) info:info
3131
8f21dba07d24 undoable format
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
  9069
!
8f21dba07d24 undoable format
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
  9070
8f21dba07d24 undoable format
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
  9071
text:arg info:info
8f21dba07d24 undoable format
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
  9072
    ^ (self new text:arg) info:info
3115
b75128334006 info string in undo
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
  9073
! !
b75128334006 info string in undo
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
  9074
b75128334006 info string in undo
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
  9075
!EditTextView::EditAction methodsFor:'accessing'!
b75128334006 info string in undo
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
  9076
b75128334006 info string in undo
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
  9077
info
b75128334006 info string in undo
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
  9078
    ^ userFriendlyInfo
b75128334006 info string in undo
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
  9079
!
b75128334006 info string in undo
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
  9080
b75128334006 info string in undo
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
  9081
info:aString
b75128334006 info string in undo
Claus Gittinger <cg@exept.de>
parents: 3114
diff changeset
  9082
    userFriendlyInfo := aString
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9083
! !
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9084
3400
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9085
!EditTextView::EditAction methodsFor:'combining'!
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9086
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9087
canCombineWithPreviousPasteStringAction: aPasteStringAction
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9088
    ^ false.
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9089
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9090
    "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
  9091
! !
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9092
3156
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  9093
!EditTextView::EditAction methodsFor:'queries'!
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  9094
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  9095
canCombineWithNext:nextAction
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  9096
    ^ false
5710
7757eb8d4d3e #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5689
diff changeset
  9097
!
7757eb8d4d3e #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5689
diff changeset
  9098
7757eb8d4d3e #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5689
diff changeset
  9099
isRestoreSelectionAndCursor
7757eb8d4d3e #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5689
diff changeset
  9100
    ^ false
3156
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  9101
! !
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  9102
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9103
!EditTextView::DeleteRange methodsFor:'accessing'!
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9104
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  9105
line1:line1Arg col1:col1Arg line2:line2Arg col2:col2Arg
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9106
    "set instance variables (automatically generated)"
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9107
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9108
    self assert:(line1Arg notNil).
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9109
    self assert:(col1Arg notNil).
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9110
    self assert:(line2Arg notNil).
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9111
    self assert:(col2Arg notNil).
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9112
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9113
    line1 := line1Arg.
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9114
    col1 := col1Arg.
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9115
    line2 := line2Arg.
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9116
    col2 := col2Arg.
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9117
! !
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9118
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9119
!EditTextView::DeleteRange methodsFor:'execution'!
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9120
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  9121
executeIn:editor
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9122
    editor unselect.
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  9123
    editor
4823
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  9124
        deleteFromLine:line1
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  9125
        col:col1
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  9126
        toLine:line2
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  9127
        col:col2.
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9128
    editor cursorLine:line1 col:col1.
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9129
! !
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9130
3156
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  9131
!EditTextView::DeleteCharacters methodsFor:'accessing'!
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  9132
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  9133
col1
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  9134
    ^ col1
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  9135
!
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  9136
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  9137
col2
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  9138
    ^ col2
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  9139
!
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  9140
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  9141
line
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  9142
    ^ line
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  9143
!
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  9144
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  9145
line:lineArg col1:col1Arg col2:col2Arg
3156
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  9146
    "set instance variables (automatically generated)"
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  9147
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  9148
    self assert:(lineArg notNil).
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  9149
    self assert:(col1Arg notNil).
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  9150
    self assert:(col2Arg notNil).
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  9151
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  9152
    line := lineArg.
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  9153
    col1 := col1Arg.
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  9154
    col2 := col2Arg.
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  9155
!
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  9156
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  9157
line:lineArg col:colArg info:infoArg
3156
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  9158
    self assert:(lineArg notNil).
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  9159
    self assert:(colArg notNil).
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  9160
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  9161
    line := lineArg.
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  9162
    col1 := col2 := colArg.
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  9163
    self info:infoArg.
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  9164
! !
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  9165
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  9166
!EditTextView::DeleteCharacters methodsFor:'combining'!
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  9167
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  9168
canCombineWithNext:anotherAction
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  9169
    ^ anotherAction perform:#canCombineWithPreviousDeleteCharactersAction: with:self ifNotUnderstood:false
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  9170
!
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  9171
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  9172
canCombineWithPreviousDeleteCharactersAction:previousDeleteAction
3156
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  9173
    "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
  9174
     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
  9175
     (i.e. single-character typing)"
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  9176
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  9177
    previousDeleteAction line == line ifTrue:[
4823
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  9178
        previousDeleteAction col2 == (col1-1) ifTrue:[
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  9179
            ^ true
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  9180
        ].
3156
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  9181
    ].
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  9182
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  9183
    ^ false
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  9184
!
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  9185
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  9186
combineWithNext:nextDeleteAction
3156
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  9187
    self assert:(line == nextDeleteAction line).
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  9188
    self assert:(col2 == (nextDeleteAction col1 - 1)).
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  9189
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  9190
    col2 := nextDeleteAction col2.
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  9191
    userFriendlyInfo := 'insert ' , (col2 - col1 + 1) printString
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  9192
! !
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  9193
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  9194
!EditTextView::DeleteCharacters methodsFor:'execution'!
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  9195
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  9196
executeIn:editor
3156
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  9197
    editor unselect.
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  9198
    editor
4823
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  9199
        deleteFromLine:line
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  9200
        col:col1
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  9201
        toLine:line
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  9202
        col:col2.
3156
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  9203
    editor cursorLine:line col:col1.
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  9204
! !
25ef39958fd8 undo - combine multiple-single keystrokes
Claus Gittinger <cg@exept.de>
parents: 3154
diff changeset
  9205
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9206
!EditTextView::EditMode class methodsFor:'constants'!
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9207
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9208
insertAndSelectMode
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9209
    ^ InsertAndSelectMode
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9210
!
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9211
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9212
insertMode
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9213
    ^ InsertMode
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9214
!
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9215
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9216
overwriteMode
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9217
    ^ OverwriteMode
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9218
! !
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9219
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9220
!EditTextView::EditMode class methodsFor:'queries'!
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9221
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9222
isInsertAndSelectMode
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9223
    ^ false
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9224
!
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9225
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9226
isInsertMode
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9227
    ^ false
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9228
!
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9229
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9230
symbolicName
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9231
    self subclassResponsibility
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9232
! !
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9233
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9234
!EditTextView::EditMode::InsertAndSelectMode class methodsFor:'info'!
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9236
infoPrintString
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9237
    ^ 'IS'
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9238
! !
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9239
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9240
!EditTextView::EditMode::InsertAndSelectMode class methodsFor:'queries'!
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9241
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9242
isInsertAndSelectMode
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9243
    ^ true
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9244
!
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9245
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9246
isInsertMode
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9247
    ^ true
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9248
! !
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9249
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9250
!EditTextView::EditMode::InsertMode class methodsFor:'info'!
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9251
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9252
infoPrintString
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9253
    ^ 'I'
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9254
! !
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9255
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9256
!EditTextView::EditMode::InsertMode class methodsFor:'queries'!
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9257
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9258
isInsertMode
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9259
    ^ true
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9260
! !
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9261
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9262
!EditTextView::EditMode::OverwriteMode class methodsFor:'info'!
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9263
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9264
infoPrintString
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9265
    ^ 'O'
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9266
! !
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9267
4048
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
  9268
!EditTextView::LastReplacementInfo methodsFor:'accessing'!
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
  9269
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
  9270
lastReplaceIgnoredCase
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
  9271
    ^ lastReplaceIgnoredCase ? false
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
  9272
!
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
  9273
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
  9274
lastReplaceIgnoredCase:something
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
  9275
    lastReplaceIgnoredCase := something.
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
  9276
!
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
  9277
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
  9278
lastReplaceWasMatch
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
  9279
    ^ lastReplaceWasMatch ? false
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
  9280
!
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
  9281
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
  9282
lastReplaceWasMatch:something
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
  9283
    lastReplaceWasMatch := something.
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
  9284
!
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
  9285
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
  9286
lastReplacement
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
  9287
    ^ lastReplacement
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
  9288
!
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
  9289
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
  9290
lastReplacement:something
4053
31117d801975 added: #setLastStringToReplace:
fm
parents: 4051
diff changeset
  9291
"/Transcript showCR: 'lastReplacement:', something printString.
4048
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
  9292
    lastReplacement := something.
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
  9293
!
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
  9294
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
  9295
lastStringToReplace
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
  9296
    ^ lastStringToReplace
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
  9297
!
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
  9298
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
  9299
lastStringToReplace:something
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
  9300
    lastStringToReplace := something.
4818
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  9301
!
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  9302
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  9303
previousReplacements
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  9304
    ^ previousReplacements ? #()
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  9305
!
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  9306
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  9307
stillCollectingInput
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  9308
    ^ stillCollectingInput
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  9309
!
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  9310
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  9311
stillCollectingInput:aBoolean
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  9312
    stillCollectingInput := aBoolean.
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  9313
! !
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  9314
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  9315
!EditTextView::LastReplacementInfo methodsFor:'history'!
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  9316
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  9317
rememberReplacement
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  9318
    "remember the previous replacement (called when a new one appears).
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  9319
     Mostly for the benefit of the code completion..."
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  9320
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  9321
    |oldString newString|
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  9322
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  9323
    oldString := lastStringToReplace.
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  9324
    newString := lastReplacement.
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  9325
    (oldString notEmptyOrNil and:[newString notEmptyOrNil]) ifTrue:[
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  9326
        previousReplacements isNil ifTrue:[
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  9327
            previousReplacements := OrderedCollection new.
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  9328
        ].
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  9329
        previousReplacements := previousReplacements reject:[:entry | entry key = oldString].
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  9330
        previousReplacements addFirst:(oldString -> newString).
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  9331
        previousReplacements size > 20 ifTrue:[
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  9332
            previousReplacements removeLast.
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  9333
        ]
22857701ea2f class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4816
diff changeset
  9334
    ].
4048
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
  9335
! !
a2ec0cedffc2 LastReplacementInfo
fm
parents: 4042
diff changeset
  9336
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9337
!EditTextView::PasteString methodsFor:'accessing'!
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9338
3400
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9339
col
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9340
    ^ col
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9341
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9342
    "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
  9343
!
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9344
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9345
col2
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9346
    ^ col + string size - 1
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9347
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9348
    "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
  9349
!
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9350
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9351
line
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9352
    ^ line
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9353
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9354
    "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
  9355
!
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9356
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  9357
line:lineArg col:colArg string:stringArg
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9358
    self assert:(lineArg notNil).
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9359
    self assert:(colArg notNil).
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9360
    self assert:(stringArg notNil).
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9361
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9362
    line := lineArg.
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9363
    col := colArg.
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9364
    string := stringArg.
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9365
!
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9366
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9367
line:lineArg col:colArg string:stringArg selected:selectedArg
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9368
    self assert:(lineArg notNil).
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9369
    self assert:(colArg notNil).
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9370
    self assert:(stringArg notNil).
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9371
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9372
    line := lineArg.
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9373
    col := colArg.
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9374
    string := stringArg.
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9375
    selected := selectedArg.
3400
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9376
!
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9377
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9378
string
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9379
    ^ string
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9380
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9381
    "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
  9382
! !
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9383
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9384
!EditTextView::PasteString methodsFor:'combining'!
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9385
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9386
canCombineWithNext:anotherAction
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9387
    ^ anotherAction canCombineWithPreviousPasteStringAction:self
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9388
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9389
    "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
  9390
!
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9391
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9392
canCombineWithPreviousPasteStringAction: previousPasteAction
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9393
    "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
  9394
     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
  9395
     (i.e. single-character deletes)"
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9396
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9397
    previousPasteAction line == line ifTrue:[
4823
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  9398
        previousPasteAction col == (self col2+1) ifTrue:[
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  9399
            ^ true
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  9400
        ].
3400
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9401
    ].
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9402
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9403
    ^ false
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9404
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9405
    "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
  9406
!
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9407
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9408
combineWithNext:nextPasteAction
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9409
    |s1 s2|
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9410
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9411
    self assert:(line == nextPasteAction line).
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9412
    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
  9413
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9414
    s1 := nextPasteAction string.
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9415
    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
  9416
    s2 := string.
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9417
    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
  9418
3683
5891af82a177 middleButtonMenu and keyCommands no longer held in instvars but in moreAttributes.
Claus Gittinger <cg@exept.de>
parents: 3650
diff changeset
  9419
    string := s1, s2.
3400
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9420
    col := nextPasteAction col.
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9421
    userFriendlyInfo := 'delete ' , string size printString
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9422
c3fd4330f9ea undo: join multiple delete-characters into a single undo
Claus Gittinger <cg@exept.de>
parents: 3326
diff changeset
  9423
    "Created: / 25-09-2006 / 12:24:10 / cg"
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9424
! !
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9425
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9426
!EditTextView::PasteString methodsFor:'execution'!
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9427
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  9428
executeIn:editor
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9429
    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
  9430
    editor paste:string.
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9431
    selected ~~ true ifTrue:[
4823
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  9432
        editor unselect
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9433
    ].
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9434
! !
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9435
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9436
!EditTextView::ReplaceCharacter methodsFor:'accessing'!
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9437
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9438
col
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9439
    ^ col
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9440
!
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
col1
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9443
    ^ col
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
col2
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9447
    ^ col
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9448
!
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9449
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9450
line
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9451
    ^ line
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9452
!
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9453
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  9454
line:lineArg col:colArg character:characterArg
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9455
    line := lineArg.
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9456
    col := colArg.
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9457
    character := characterArg.
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9458
! !
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9459
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9460
!EditTextView::ReplaceCharacter methodsFor:'execution'!
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9461
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  9462
executeIn:editor
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  9463
    editor
4823
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  9464
        replace:character
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  9465
        atLine:line
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  9466
        col:col.
2952
08d18f507e05 first attempt for undo
Claus Gittinger <cg@exept.de>
parents: 2951
diff changeset
  9467
    editor cursorLine:line col:col.
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  9468
! !
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  9469
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9470
!EditTextView::ReplaceCharacters methodsFor:'accessing'!
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9471
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9472
characters
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9473
    ^ characters
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9474
!
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9475
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9476
col1
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9477
    ^ col1
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9478
!
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9479
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9480
col2
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9481
    ^ col2
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9482
!
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9483
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9484
line
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9485
    ^ line
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9486
!
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9487
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9488
line:lineArg col:colArg character:characterArg
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9489
    line := lineArg.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9490
    col1 := col2 := colArg.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9491
    characters := characterArg asString.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9492
!
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9493
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9494
line:lineArg col:colArg characters:charactersArg
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9495
    line := lineArg.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9496
    col1 := colArg.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9497
    characters := charactersArg asString.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9498
    col2 := col1 + charactersArg size - 1
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9499
! !
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9500
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9501
!EditTextView::ReplaceCharacters methodsFor:'combining'!
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9502
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9503
canCombineWithNext:anotherAction
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9504
    ^ anotherAction perform:#canCombineWithPreviousReplaceCharactersAction: with:self ifNotUnderstood:false
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9505
!
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9506
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9507
canCombineWithPreviousReplaceCharactersAction:previousReplaceAction
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9508
    "I will combine only if we both are single character deletes,
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9509
     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
  9510
     (i.e. single-character typing)"
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9511
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9512
    previousReplaceAction line == line ifTrue:[
4823
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  9513
        previousReplaceAction col2 == (col1-1) ifTrue:[
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  9514
            ^ true
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  9515
        ].
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9516
    ].
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9517
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9518
    ^ false
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9519
!
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9520
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9521
combineWithNext:nextReplaceAction
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9522
    self assert:(line == nextReplaceAction line).
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9523
    self assert:(self col2 == (nextReplaceAction col1 - 1)).
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9524
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9525
    col2 := nextReplaceAction col2.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9526
    userFriendlyInfo := 'replace ' , (col2 - col1 + 1) printString.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9527
    characters := characters , nextReplaceAction characters.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9528
! !
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9529
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9530
!EditTextView::ReplaceCharacters methodsFor:'execution'!
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9531
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9532
executeIn:editor
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9533
    editor
4823
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  9534
        replaceString:characters
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  9535
        atLine:line
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  9536
        col:col1.
3235
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9537
    editor cursorLine:line col:col1.
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9538
! !
422c2db64114 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3232
diff changeset
  9539
3131
8f21dba07d24 undoable format
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
  9540
!EditTextView::ReplaceContents methodsFor:'accessing'!
8f21dba07d24 undoable format
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
  9541
8f21dba07d24 undoable format
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
  9542
text:something
8f21dba07d24 undoable format
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
  9543
    text := something.
8f21dba07d24 undoable format
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
  9544
! !
8f21dba07d24 undoable format
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
  9545
8f21dba07d24 undoable format
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
  9546
!EditTextView::ReplaceContents methodsFor:'execution'!
8f21dba07d24 undoable format
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
  9547
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  9548
executeIn:editor
3131
8f21dba07d24 undoable format
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
  9549
    editor contents:text
8f21dba07d24 undoable format
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
  9550
! !
8f21dba07d24 undoable format
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
  9551
3130
c0f39f9f28d6 undoable keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3127
diff changeset
  9552
!EditTextView::ReplaceLine methodsFor:'accessing'!
c0f39f9f28d6 undoable keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3127
diff changeset
  9553
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  9554
line:lineArg string:stringArg
3130
c0f39f9f28d6 undoable keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3127
diff changeset
  9555
    line := lineArg.
c0f39f9f28d6 undoable keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3127
diff changeset
  9556
    text := stringArg.
c0f39f9f28d6 undoable keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3127
diff changeset
  9557
! !
c0f39f9f28d6 undoable keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3127
diff changeset
  9558
c0f39f9f28d6 undoable keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3127
diff changeset
  9559
!EditTextView::ReplaceLine methodsFor:'execution'!
c0f39f9f28d6 undoable keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3127
diff changeset
  9560
3160
77096deedd53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3156
diff changeset
  9561
executeIn:editor
3130
c0f39f9f28d6 undoable keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3127
diff changeset
  9562
    editor list at:line put:text.
c0f39f9f28d6 undoable keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3127
diff changeset
  9563
    editor invalidateLine:line
c0f39f9f28d6 undoable keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3127
diff changeset
  9564
! !
c0f39f9f28d6 undoable keyboard macros
Claus Gittinger <cg@exept.de>
parents: 3127
diff changeset
  9565
3402
d6545009a22b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3400
diff changeset
  9566
!EditTextView::ReplaceLines methodsFor:'accessing'!
d6545009a22b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3400
diff changeset
  9567
d6545009a22b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3400
diff changeset
  9568
line:lineArg lines:lineCollectionArg
d6545009a22b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3400
diff changeset
  9569
    line := lineArg.
d6545009a22b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3400
diff changeset
  9570
    text := lineCollectionArg.
d6545009a22b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3400
diff changeset
  9571
d6545009a22b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3400
diff changeset
  9572
    "Created: / 09-10-2006 / 10:35:22 / cg"
d6545009a22b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3400
diff changeset
  9573
! !
d6545009a22b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3400
diff changeset
  9574
d6545009a22b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3400
diff changeset
  9575
!EditTextView::ReplaceLines methodsFor:'execution'!
d6545009a22b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3400
diff changeset
  9576
d6545009a22b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3400
diff changeset
  9577
executeIn:editor
d6545009a22b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3400
diff changeset
  9578
    |lnr|
d6545009a22b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3400
diff changeset
  9579
d6545009a22b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3400
diff changeset
  9580
    lnr := line.
d6545009a22b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3400
diff changeset
  9581
    text do:[:eachLine |
4823
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  9582
        editor list at:lnr put:eachLine.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  9583
        editor invalidateLine:lnr.
0d685a9c7f5a class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 4821
diff changeset
  9584
        lnr := lnr + 1.
3402
d6545009a22b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3400
diff changeset
  9585
    ].
d6545009a22b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3400
diff changeset
  9586
d6545009a22b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3400
diff changeset
  9587
    "Modified: / 09-10-2006 / 10:39:16 / cg"
d6545009a22b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3400
diff changeset
  9588
! !
d6545009a22b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3400
diff changeset
  9589
5689
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  9590
!EditTextView::RestoreSelectionAndCursor methodsFor:'accessing'!
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  9591
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  9592
cursorLine:cursorLineArg cursorCol:cursorColArg selectionStartLine:selectionStartLineArg selectionStartCol:selectionStartColArg selectionEndLine:selectionEndLineArg selectionEndCol:selectionEndColArg 
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  9593
    cursorLine := cursorLineArg.
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  9594
    cursorCol := cursorColArg.
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  9595
    selectionStartLine := selectionStartLineArg.
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  9596
    selectionStartCol := selectionStartColArg.
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  9597
    selectionEndLine := selectionEndLineArg.
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  9598
    selectionEndCol := selectionEndColArg.
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  9599
!
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  9600
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  9601
cursorLine:cursorLineArg cursorCol:cursorColArg 
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  9602
        selectionStartLine:selectionStartLineArg selectionStartCol:selectionStartColArg 
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  9603
        selectionEndLine:selectionEndLineArg selectionEndCol:selectionEndColArg
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  9604
        info:info
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  9605
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  9606
    cursorLine := cursorLineArg.
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  9607
    cursorCol := cursorColArg.
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  9608
    selectionStartLine := selectionStartLineArg.
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  9609
    selectionStartCol := selectionStartColArg.
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  9610
    selectionEndLine := selectionEndLineArg.
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  9611
    selectionEndCol := selectionEndColArg.
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  9612
    userFriendlyInfo := info.
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  9613
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  9614
    "Created: / 30-04-2016 / 20:21:18 / cg"
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  9615
! !
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  9616
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  9617
!EditTextView::RestoreSelectionAndCursor methodsFor:'execution'!
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  9618
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  9619
executeIn:editor
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  9620
    (selectionStartLine notNil and:[selectionEndLine notNil
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  9621
    and:[selectionStartCol notNil and:[selectionEndCol notNil]]]) ifTrue:[
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  9622
        editor setCursorLine:cursorLine col:cursorCol.
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  9623
        editor selectFromLine:selectionStartLine col:selectionStartCol toLine:selectionEndLine col:selectionEndCol
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  9624
    ] ifFalse:[
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  9625
        editor cursorLine:cursorLine col:cursorCol.
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  9626
    ].
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  9627
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  9628
    "Created: / 30-04-2016 / 20:14:55 / cg"
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  9629
! !
05b065914682 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5643
diff changeset
  9630
5710
7757eb8d4d3e #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5689
diff changeset
  9631
!EditTextView::RestoreSelectionAndCursor methodsFor:'queries'!
7757eb8d4d3e #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5689
diff changeset
  9632
7757eb8d4d3e #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5689
diff changeset
  9633
isRestoreSelectionAndCursor
7757eb8d4d3e #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5689
diff changeset
  9634
    ^ true
7757eb8d4d3e #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5689
diff changeset
  9635
! !
7757eb8d4d3e #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5689
diff changeset
  9636
865
d42c7c99e67d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 840
diff changeset
  9637
!EditTextView class methodsFor:'documentation'!
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  9638
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  9639
version
5361
d39070e004c1 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5357
diff changeset
  9640
    ^ '$Header$'
3945
295e4733f3a5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3915
diff changeset
  9641
!
295e4733f3a5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3915
diff changeset
  9642
295e4733f3a5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3915
diff changeset
  9643
version_CVS
5361
d39070e004c1 class: EditTextView
Claus Gittinger <cg@exept.de>
parents: 5357
diff changeset
  9644
    ^ '$Header$'
4843
7cd827899263 Selection refactoring, part 2: update cursor position when selecting by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4841
diff changeset
  9645
!
7cd827899263 Selection refactoring, part 2: update cursor position when selecting by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4841
diff changeset
  9646
7cd827899263 Selection refactoring, part 2: update cursor position when selecting by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4841
diff changeset
  9647
version_HG
7cd827899263 Selection refactoring, part 2: update cursor position when selecting by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4841
diff changeset
  9648
7cd827899263 Selection refactoring, part 2: update cursor position when selecting by mouse.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4841
diff changeset
  9649
    ^ '$Changeset: <not expanded> $'
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  9650
! !
4481
76c592c0ae9c class: EditTextView
Stefan Vogel <sv@exept.de>
parents: 4475
diff changeset
  9651