EditTextView.st
author Claus Gittinger <cg@exept.de>
Sat, 20 Jun 1998 19:42:23 +0200
changeset 1597 5fdcfcedb91c
parent 1596 0bbdb4e9fc43
child 1599 63636b356b1f
permissions -rw-r--r--
fixed cursor positioning after replaceStringAtCursor.
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
59
450ce95a72a4 *** empty log message ***
claus
parents: 46
diff changeset
     3
	      All Rights Reserved
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
     4
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
     5
 This software is furnished under a license and may be used
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
     6
 only in accordance with the terms of that license and with the
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
     8
 be provided or otherwise made available to, or used by, any
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
     9
 other person.  No title to or ownership of the software is
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    10
 hereby transferred.
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    11
"
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    12
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    13
TextView subclass:#EditTextView
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
    14
	instanceVariableNames:'cursorLine cursorVisibleLine cursorCol cursorShown
331
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
    15
		prevCursorState readOnly modifiedChannel fixedSize exceptionBlock
1022
4362861fe15e allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents: 1018
diff changeset
    16
		cursorFgColor cursorBgColor cursorNoFocusFgColor cursorType
1334
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
    17
		cursorTypeNoFocus undoAction typeOfSelection lastString
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
    18
		lastReplacement lastAction replacing showMatchingParenthesis
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
    19
		hasKeyboardFocus acceptAction lockUpdates tabMeansNextField
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
    20
		autoIndent insertMode trimBlankLines wordWrap
1596
0bbdb4e9fc43 made st80Mode also an inst-flag;
Claus Gittinger <cg@exept.de>
parents: 1591
diff changeset
    21
		replacementWordSelectStyle acceptChannel acceptEnabled st80Mode'
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
    22
	classVariableNames:'DefaultCursorForegroundColor DefaultCursorBackgroundColor
1534
bcb211e1b41a read noFocus cursorStyle from styleSheet
Claus Gittinger <cg@exept.de>
parents: 1533
diff changeset
    23
		DefaultCursorType DefaultCursorNoFocusForegroundColor ST80Mode
bcb211e1b41a read noFocus cursorStyle from styleSheet
Claus Gittinger <cg@exept.de>
parents: 1533
diff changeset
    24
		DefaultCursorTypeNoFocus'
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
    25
	poolDictionaries:''
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
    26
	category:'Views-Text'
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    27
!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    28
865
d42c7c99e67d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 840
diff changeset
    29
!EditTextView class methodsFor:'documentation'!
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    30
33
5eeef3ea8ebd added access methods for cursorLine & cursorCol
claus
parents: 25
diff changeset
    31
copyright
5eeef3ea8ebd added access methods for cursorLine & cursorCol
claus
parents: 25
diff changeset
    32
"
5eeef3ea8ebd added access methods for cursorLine & cursorCol
claus
parents: 25
diff changeset
    33
 COPYRIGHT (c) 1989 by Claus Gittinger
59
450ce95a72a4 *** empty log message ***
claus
parents: 46
diff changeset
    34
	      All Rights Reserved
33
5eeef3ea8ebd added access methods for cursorLine & cursorCol
claus
parents: 25
diff changeset
    35
5eeef3ea8ebd added access methods for cursorLine & cursorCol
claus
parents: 25
diff changeset
    36
 This software is furnished under a license and may be used
5eeef3ea8ebd added access methods for cursorLine & cursorCol
claus
parents: 25
diff changeset
    37
 only in accordance with the terms of that license and with the
5eeef3ea8ebd added access methods for cursorLine & cursorCol
claus
parents: 25
diff changeset
    38
 inclusion of the above copyright notice.   This software may not
5eeef3ea8ebd added access methods for cursorLine & cursorCol
claus
parents: 25
diff changeset
    39
 be provided or otherwise made available to, or used by, any
5eeef3ea8ebd added access methods for cursorLine & cursorCol
claus
parents: 25
diff changeset
    40
 other person.  No title to or ownership of the software is
5eeef3ea8ebd added access methods for cursorLine & cursorCol
claus
parents: 25
diff changeset
    41
 hereby transferred.
5eeef3ea8ebd added access methods for cursorLine & cursorCol
claus
parents: 25
diff changeset
    42
"
5eeef3ea8ebd added access methods for cursorLine & cursorCol
claus
parents: 25
diff changeset
    43
!
5eeef3ea8ebd added access methods for cursorLine & cursorCol
claus
parents: 25
diff changeset
    44
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    45
documentation
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    46
"
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    47
    a view for editable text - adds editing functionality to TextView
125
claus
parents: 123
diff changeset
    48
    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
    49
    acceptAction to be performed for accept
125
claus
parents: 123
diff changeset
    50
claus
parents: 123
diff changeset
    51
    If used with a model, this is informed by sending it a changeMsg with
claus
parents: 123
diff changeset
    52
    the current contents as argument.
297
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
    53
    (however, it is possible to define both changeMsg and acceptAction)
125
claus
parents: 123
diff changeset
    54
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
    55
    Please read the historic notice in the ListView class.
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    56
586
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 567
diff changeset
    57
    [Instance variables:]
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
    58
1415
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
    59
	cursorLine              <Number>        line where cursor sits (1..)
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
    60
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
    61
	cursorVisibleLine       <Number>        visible line where cursor sits (1..nLinesShown)
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
    62
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
    63
	cursorCol               <Number>        col where cursor sits (1..)
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
    64
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
    65
	cursorShown             <Boolean>       true, if cursor is currently shown
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
    66
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
    67
	readOnly                <Boolean>       true, if text may not be edited
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
    68
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
    69
	modifiedChannel         <ValueHolder>   holding true, if text has been modified.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
    70
						cleared on accept.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
    71
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
    72
	acceptChannel           <ValueHolder>   holding true, if text has been accepted.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
    73
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
    74
	fixedSize               <Boolean>       true, if no lines may be added/removed
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
    75
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
    76
	exceptionBlock          <Block>         block to be evaluated when readonly text is about to be modified
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
    77
						if it returns true, the modification will be done anyway.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
    78
						if it returns anything else, the modification is not done.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
    79
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
    80
	cursorFgColor           <Color>         color used for cursor drawing
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
    81
	cursorBgColor           <Color>         color used for cursor drawing
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
    82
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
    83
	cursorType              <Symbol>        how the cursor is drawn; currently implemented
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
    84
						are #block (solid-block cursor), #ibeam
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
    85
						(vertical bar at insertion point) 
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
    86
						and #caret (caret below insertion-point)
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
    87
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
    88
	cursorTypeNoFocus       <Symbol>        like above, if view has no focus
1334
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
    89
						nil means: hide the cursor.
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
    90
1415
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
    91
	undoAction              <Block>         block which undoes last cut, paste or replace
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
    92
						(not yet fully implemented)
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
    93
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
    94
	typeOfSelection         <Symbol>        #paste, if selection created by paste, nil otherwise
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
    95
						this affects the next keyPress: if #paste it does not
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
    96
						replace; otherwise it replaces the selection.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
    97
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
    98
	lastCut                 <String>        last cut or replaced string
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
    99
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   100
	lastReplacement         <String>        last replacement
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   101
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   102
	replacing               <Boolean>       true if entered characters replace last selection
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   103
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   104
	showMatchingParenthesis <Boolean>       if true, shows matching parenthesis
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   105
						when entering one; this is the default.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   106
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   107
	hasKeyboardFocus        <Boolean>       true if this view has the focus
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   108
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   109
	acceptAction            <Block>         accept action - evaluated passing the contents as 
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   110
						argument 
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   111
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   112
	tabMeansNextField       <Boolean>       if true, Tab is ignored as input and shifts keyboard
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   113
						focus to the next field. For editTextViews, this is false
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   114
						by default (i.e. tabs can be entered into the text).
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   115
						For some subclasses (inputFields), this may be true.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   116
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   117
	trimBlankLines          <Boolean>       if true, trailing blanks are
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   118
						removed when editing.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   119
						Default is true.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   120
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   121
	wordWrap                <Boolean>       Currently not used.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   122
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   123
	lockUpdates             <Boolean>       internal, private
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   124
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   125
	prevCursorState         <Boolean>       temporary, private
323
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   126
33
5eeef3ea8ebd added access methods for cursorLine & cursorCol
claus
parents: 25
diff changeset
   127
1300
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
   128
    class variables:
1415
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   129
	ST80Mode                <Boolean>       if true, cursor positioning is
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   130
						done as in vi or ST80; i.e.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   131
						wysiwyg mode is somewhat relaxed,
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   132
						in that the cursor cannot be
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   133
						positioned behind a lines end.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   134
						This is not yet completely implemented.
33
5eeef3ea8ebd added access methods for cursorLine & cursorCol
claus
parents: 25
diff changeset
   135
    used globals:
5eeef3ea8ebd added access methods for cursorLine & cursorCol
claus
parents: 25
diff changeset
   136
1415
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   137
	DeleteHistory           <Text>          last 1000 lines of deleted text
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   138
						(but only if this variable exists already)
586
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 567
diff changeset
   139
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 567
diff changeset
   140
    [styleSheet parameters:]
121
claus
parents: 118
diff changeset
   141
1415
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   142
	textCursorForegroundColor <Color>       cursor fg color; default: text background
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   143
	textCursorBackgroundColor <Color>       cursor bg color; default: text foreground
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   144
	textCursorNoFocusForegroundColor 
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   145
				  <Color>       cursor fg color if no focus; default: cursor fg color
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   146
	textCursorType            <Symbol>      cursor type; default:  #block
586
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 567
diff changeset
   147
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 567
diff changeset
   148
    [author:]
1415
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   149
	Claus Gittinger
586
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 567
diff changeset
   150
032b3245e53a documentation
Claus Gittinger <cg@exept.de>
parents: 567
diff changeset
   151
    [see also:]
1415
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   152
	CodeView Workspace TextView ListView
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   153
	EditField
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   154
"
297
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   155
!
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   156
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   157
examples
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   158
"
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   159
  non MVC operation:
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   160
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   161
    basic setup:
1415
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   162
									[exBegin]
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   163
	|top textView|
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   164
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   165
	top := StandardSystemView new.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   166
	top extent:300@200.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   167
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   168
	textView := EditTextView new.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   169
	textView origin:0.0 @ 0.0 corner:1.0 @ 1.0.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   170
	top addSubView:textView.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   171
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   172
	textView contents:('/etc/hosts' asFilename contentsOfEntireFile).
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   173
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   174
	top open.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   175
									[exEnd]
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   176
297
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   177
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   178
    with vertical scrollbar:
1415
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   179
									[exBegin]
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   180
	|top scrollView textView|
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   181
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   182
	top := StandardSystemView new.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   183
	top extent:300@200.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   184
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   185
	scrollView := ScrollableView for:EditTextView.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   186
	textView := scrollView scrolledView.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   187
	scrollView origin:0.0 @ 0.0 corner:1.0 @ 1.0.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   188
	top addSubView:scrollView.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   189
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   190
	textView contents:('/etc/hosts' asFilename contentsOfEntireFile).
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   191
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   192
	top open.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   193
									[exEnd]
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   194
297
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   195
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   196
    with horizontal & vertical scrollbars:
1415
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   197
									[exBegin]
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   198
	|top scrollView textView|
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   199
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   200
	top := StandardSystemView new.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   201
	top extent:300@200.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   202
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   203
	scrollView := HVScrollableView for:EditTextView.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   204
	textView := scrollView scrolledView.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   205
	scrollView origin:0.0 @ 0.0 corner:1.0 @ 1.0.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   206
	top addSubView:scrollView.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   207
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   208
	textView contents:('/etc/hosts' asFilename contentsOfEntireFile).
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   209
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   210
	top open.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   211
									[exEnd]
297
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   212
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   213
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   214
    set the action for accept:
1415
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   215
									[exBegin]
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   216
	|top textView|
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   217
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   218
	top := StandardSystemView new.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   219
	top extent:300@200.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   220
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   221
	textView := EditTextView new.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   222
	textView origin:0.0 @ 0.0 corner:1.0 @ 1.0.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   223
	top addSubView:textView.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   224
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   225
	textView contents:('/etc/hosts' asFilename contentsOfEntireFile).
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   226
	textView acceptAction:[:contents |
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   227
				Transcript showCR:'will not overwrite the file with:'.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   228
				Transcript showCR:contents asString
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   229
			      ].
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   230
	top open.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   231
									[exEnd]
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   232
297
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   233
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   234
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
   235
    non-string (text) items:
1415
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   236
									[exBegin]
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   237
	|top textView list|
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   238
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   239
	list := '/etc/hosts' asFilename contentsOfEntireFile asStringCollection.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   240
	1 to:list size by:2 do:[:nr |
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   241
	    list at:nr put:(Text string:(list at:nr)
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   242
				 emphasis:(Array with:#bold with:(#color->Color red)))
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   243
	].
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   244
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   245
	top := StandardSystemView new.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   246
	top extent:300@200.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   247
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   248
	textView := EditTextView new.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   249
	textView origin:0.0 @ 0.0 corner:1.0 @ 1.0.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   250
	top addSubView:textView.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   251
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   252
	textView contents:list.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   253
	top open.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   254
									[exEnd]
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
   255
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
   256
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
   257
297
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   258
  MVC operation:
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   259
    (the examples model here is a plug simulating a real model;
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   260
     real world applications would not use a plug ..)
1415
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   261
									[exBegin]
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   262
	|top textView model|
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   263
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   264
	model := Plug new.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   265
	model respondTo:#accepted:
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   266
		   with:[:newContents | 
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   267
				Transcript showCR:'will not overwrite the file with:'.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   268
				Transcript showCR:newContents asString
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   269
			].
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   270
	model respondTo:#getList
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   271
		   with:['/etc/hosts' asFilename contentsOfEntireFile].
297
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   272
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   273
        
1415
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   274
	top := StandardSystemView new.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   275
	top extent:300@200.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   276
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   277
	textView := EditTextView new.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   278
	textView origin:0.0 @ 0.0 corner:1.0 @ 1.0.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   279
	top addSubView:textView.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   280
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   281
	textView listMessage:#getList;
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   282
		 model:model;
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   283
		 changeMessage:#accepted:;
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   284
		 aspect:#list.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   285
	top open.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   286
									[exEnd]
594
b9c5a5e5f905 examples
Claus Gittinger <cg@exept.de>
parents: 586
diff changeset
   287
297
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   288
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   289
    two textViews on the same model:
1415
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   290
									[exBegin]
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   291
	|top1 textView1 top2 textView2 model currentContents|
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   292
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   293
	model := Plug new.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   294
	model respondTo:#accepted:
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   295
		   with:[:newContents |
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   296
				Transcript showCR:'accepted:'.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   297
				Transcript showCR:newContents asString.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   298
				currentContents := newContents.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   299
				model changed:#contents
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   300
			].
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   301
	model respondTo:#getList
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   302
		   with:[Transcript showCR:'query'.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   303
			 currentContents].
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   304
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   305
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   306
	top1 := StandardSystemView new.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   307
	top1 extent:300@200.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   308
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   309
	textView1 := EditTextView new.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   310
	textView1 origin:0.0 @ 0.0 corner:1.0 @ 1.0.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   311
	top1 addSubView:textView1.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   312
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   313
	textView1 listMessage:#getList;
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   314
		  model:model;
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   315
		  aspect:#contents;
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   316
		  changeMessage:#accepted:.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   317
	top1 open.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   318
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   319
	top2 := StandardSystemView new.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   320
	top2 extent:300@200.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   321
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   322
	textView2 := EditTextView new.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   323
	textView2 origin:0.0 @ 0.0 corner:1.0 @ 1.0.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   324
	top2 addSubView:textView2.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   325
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   326
	textView2 listMessage:#getList;
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   327
		  model:model;
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   328
		  aspect:#contents;
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   329
		  changeMessage:#accepted:.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   330
	top2 open.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   331
									[exEnd]
297
08eec8838a4c beep if cursor leaves the visible area
Claus Gittinger <cg@exept.de>
parents: 274
diff changeset
   332
"
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   333
! !
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
   334
865
d42c7c99e67d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 840
diff changeset
   335
!EditTextView class methodsFor:'defaults'!
59
450ce95a72a4 *** empty log message ***
claus
parents: 46
diff changeset
   336
1419
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   337
st80Mode
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   338
    "return true, if the st80 editing mode is turned on.
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   339
     This setting affects the behavior of the cursor, when positioned
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   340
     behond the end of a line or the end of the text.
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   341
     The default is initialized from the viewStyle."
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   342
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   343
    ^ ST80Mode
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   344
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   345
   "
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   346
    EditTextView st80Mode:true
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   347
    EditTextView st80Mode:false
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   348
   "
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   349
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   350
    "Modified: / 16.1.1998 / 22:54:57 / cg"
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   351
!
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   352
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   353
st80Mode:aBoolean
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   354
    "turns on/off st80 behavior, where the cursor cannot be positioned
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   355
     behond the end of a line or the last line"
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   356
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   357
    ST80Mode := aBoolean.
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   358
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   359
   "
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   360
    EditTextView st80Mode:true
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   361
    EditTextView st80Mode:false
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   362
   "
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   363
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   364
    "Modified: / 16.1.1998 / 22:55:19 / cg"
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   365
!
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   366
59
450ce95a72a4 *** empty log message ***
claus
parents: 46
diff changeset
   367
updateStyleCache
440
2beb33cb0146 added style resource directive
Claus Gittinger <cg@exept.de>
parents: 428
diff changeset
   368
    "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
   369
1390
99674e1d9c85 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
   370
    <resource: #style (#'textCursor.foregroundColor' #'textCursor.backgroundColor'
1534
bcb211e1b41a read noFocus cursorStyle from styleSheet
Claus Gittinger <cg@exept.de>
parents: 1533
diff changeset
   371
                       #'textCursor.noFocusForegroundColor' 
bcb211e1b41a read noFocus cursorStyle from styleSheet
Claus Gittinger <cg@exept.de>
parents: 1533
diff changeset
   372
                       #'textCursor.type' #'textCursor.typeNoFocus'
bcb211e1b41a read noFocus cursorStyle from styleSheet
Claus Gittinger <cg@exept.de>
parents: 1533
diff changeset
   373
                       #'editText.st80Mode')>
1355
6725ab9cc6f5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
   374
6725ab9cc6f5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
   375
    DefaultCursorForegroundColor := StyleSheet colorAt:'textCursor.foregroundColor'.
6725ab9cc6f5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
   376
    DefaultCursorBackgroundColor := StyleSheet colorAt:'textCursor.backgroundColor'.
6725ab9cc6f5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
   377
    DefaultCursorNoFocusForegroundColor := StyleSheet colorAt:'textCursor.noFocusForegroundColor'.
6725ab9cc6f5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1339
diff changeset
   378
    DefaultCursorType := StyleSheet at:'textCursor.type' default:#block.
1534
bcb211e1b41a read noFocus cursorStyle from styleSheet
Claus Gittinger <cg@exept.de>
parents: 1533
diff changeset
   379
    DefaultCursorTypeNoFocus := StyleSheet at:'textCursor.typeNoFocus'.
bcb211e1b41a read noFocus cursorStyle from styleSheet
Claus Gittinger <cg@exept.de>
parents: 1533
diff changeset
   380
1419
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   381
    ST80Mode := StyleSheet at:'editText.st80Mode' default:false.
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   382
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   383
    "
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   384
     self updateStyleCache
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   385
    "
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   386
1534
bcb211e1b41a read noFocus cursorStyle from styleSheet
Claus Gittinger <cg@exept.de>
parents: 1533
diff changeset
   387
    "Modified: / 20.5.1998 / 04:27:41 / cg"
59
450ce95a72a4 *** empty log message ***
claus
parents: 46
diff changeset
   388
! !
450ce95a72a4 *** empty log message ***
claus
parents: 46
diff changeset
   389
1552
d3d4afaf4c68 dummy ST80 compatibility: #autoAccept:
Claus Gittinger <cg@exept.de>
parents: 1548
diff changeset
   390
!EditTextView methodsFor:'ST-80 compatibility'!
d3d4afaf4c68 dummy ST80 compatibility: #autoAccept:
Claus Gittinger <cg@exept.de>
parents: 1548
diff changeset
   391
d3d4afaf4c68 dummy ST80 compatibility: #autoAccept:
Claus Gittinger <cg@exept.de>
parents: 1548
diff changeset
   392
autoAccept:aBoolean
d3d4afaf4c68 dummy ST80 compatibility: #autoAccept:
Claus Gittinger <cg@exept.de>
parents: 1548
diff changeset
   393
    "ignored for now"
d3d4afaf4c68 dummy ST80 compatibility: #autoAccept:
Claus Gittinger <cg@exept.de>
parents: 1548
diff changeset
   394
d3d4afaf4c68 dummy ST80 compatibility: #autoAccept:
Claus Gittinger <cg@exept.de>
parents: 1548
diff changeset
   395
    "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
   396
!
9bf6cf249376 two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents: 1580
diff changeset
   397
9bf6cf249376 two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents: 1580
diff changeset
   398
continuousAccept:aBoolean
9bf6cf249376 two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents: 1580
diff changeset
   399
    "ignored for now"
9bf6cf249376 two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents: 1580
diff changeset
   400
9bf6cf249376 two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents: 1580
diff changeset
   401
    "Created: / 19.6.1998 / 00:03:49 / cg"
9bf6cf249376 two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents: 1580
diff changeset
   402
!
9bf6cf249376 two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents: 1580
diff changeset
   403
1589
4fc01fd85b65 added #disable (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 1588
diff changeset
   404
disable
4fc01fd85b65 added #disable (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 1588
diff changeset
   405
    self readOnly:true
4fc01fd85b65 added #disable (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 1588
diff changeset
   406
4fc01fd85b65 added #disable (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 1588
diff changeset
   407
    "Created: / 19.6.1998 / 02:34:14 / cg"
4fc01fd85b65 added #disable (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 1588
diff changeset
   408
!
4fc01fd85b65 added #disable (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 1588
diff changeset
   409
1585
9bf6cf249376 two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents: 1580
diff changeset
   410
textHasChanged
9bf6cf249376 two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents: 1580
diff changeset
   411
    ^ self modified
9bf6cf249376 two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents: 1580
diff changeset
   412
9bf6cf249376 two more ST-80 compatibility methods.
Claus Gittinger <cg@exept.de>
parents: 1580
diff changeset
   413
    "Created: / 19.6.1998 / 00:09:43 / cg"
1552
d3d4afaf4c68 dummy ST80 compatibility: #autoAccept:
Claus Gittinger <cg@exept.de>
parents: 1548
diff changeset
   414
! !
d3d4afaf4c68 dummy ST80 compatibility: #autoAccept:
Claus Gittinger <cg@exept.de>
parents: 1548
diff changeset
   415
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   416
!EditTextView methodsFor:'ST-80 compatibility editing'!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   417
1390
99674e1d9c85 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
   418
cutSelection
99674e1d9c85 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
   419
    self cut
99674e1d9c85 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
   420
99674e1d9c85 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
   421
    "Created: / 31.10.1997 / 03:29:50 / cg"
99674e1d9c85 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
   422
!
99674e1d9c85 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
   423
1590
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   424
deselect
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   425
    "remove the selection"
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   426
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   427
    ^ self unselect
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   428
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   429
    "Created: / 19.6.1998 / 02:41:54 / cg"
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   430
!
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   431
1294
dac755d4acd3 added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   432
insert:aString at:aCharacterPosition
dac755d4acd3 added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   433
    "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
   434
dac755d4acd3 added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   435
    |line col|
dac755d4acd3 added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   436
dac755d4acd3 added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   437
    line := self lineOfCharacterPosition:aCharacterPosition.
dac755d4acd3 added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   438
    col := aCharacterPosition - (self characterPositionOfLine:line col:1) + 1.
1480
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
   439
    col < 1 ifTrue:[
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
   440
        col := 1
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
   441
    ].
1294
dac755d4acd3 added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   442
    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
   443
dac755d4acd3 added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   444
    "
dac755d4acd3 added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   445
     |top v|
dac755d4acd3 added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   446
dac755d4acd3 added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   447
     top := StandardSystemView new.
dac755d4acd3 added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   448
     top extent:300@300.
dac755d4acd3 added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   449
     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
   450
     top openAndWait.
dac755d4acd3 added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   451
     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
   452
     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
   453
    "
dac755d4acd3 added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   454
1480
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
   455
    "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
   456
!
dac755d4acd3 added #insert:at: - for inserting at a particular character position.
Claus Gittinger <cg@exept.de>
parents: 1292
diff changeset
   457
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   458
insertAndSelect:aString at:aCharacterPosition
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   459
    "insert a selected string at aCharacterPosition."
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   460
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   461
    |line col|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   462
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   463
    line := self lineOfCharacterPosition:aCharacterPosition.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   464
    col := aCharacterPosition - (self characterPositionOfLine:line col:1) + 1.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   465
    self insertString:aString atLine:line col:col.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   466
    self selectFromLine:line col:col toLine:line col:col + aString size - 1
125
claus
parents: 123
diff changeset
   467
    "
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   468
     |v|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   469
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   470
     v := EditTextView new openAndWait.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   471
     v contents:'1234567890\1234567890\1234567890\' withCRs.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   472
     v insertAndSelect:'<- hello there' at:5.
125
claus
parents: 123
diff changeset
   473
    "
1390
99674e1d9c85 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
   474
!
99674e1d9c85 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
   475
99674e1d9c85 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
   476
pasteSelection
99674e1d9c85 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
   477
    self paste
99674e1d9c85 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
   478
99674e1d9c85 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
   479
    "Created: / 31.10.1997 / 03:28:53 / cg"
1590
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   480
!
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   481
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   482
replaceSelectionWith:aString
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   483
    ^ self replaceSelectionBy:aString
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   484
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   485
    "Created: / 19.6.1998 / 02:42:32 / cg"
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   486
!
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   487
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   488
selectAt:pos
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   489
    "move the cursor before cursorPosition."
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   490
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   491
    self cursorToCharacterPosition:pos
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   492
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   493
    "Modified: / 19.6.1998 / 02:41:28 / cg"
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   494
    "Created: / 19.6.1998 / 02:43:39 / cg"
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   495
!
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   496
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   497
selectFrom:startPos to:endPos
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   498
    "change the selection given two aCharacterPositions."
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   499
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   500
    |line1 col1 line2 col2|
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   501
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   502
    startPos > endPos ifTrue:[
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   503
        ^ self unselect
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   504
    ].
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   505
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   506
    line1 := self lineOfCharacterPosition:startPos.
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   507
    col1 := startPos - (self characterPositionOfLine:line1 col:1) + 1.
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   508
    col1 < 1 ifTrue:[
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   509
        col1 := 1
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   510
    ].
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   511
    line2 := self lineOfCharacterPosition:endPos.
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   512
    col2 := startPos - (self characterPositionOfLine:line2 col:1) + 1.
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   513
    col2 < 1 ifTrue:[
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   514
        col2 := 1
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   515
    ].
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   516
    self selectFromLine:line1 col:col1 toLine:line2 col:col2
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   517
b537d0d4e6d3 more ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents: 1589
diff changeset
   518
    "Modified: / 19.6.1998 / 02:41:28 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   519
! !
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   520
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   521
!EditTextView methodsFor:'accessing-behavior'!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   522
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   523
acceptAction
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   524
    "return the action to be performed on accept (or nil)"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   525
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   526
    ^ acceptAction
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   527
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   528
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   529
acceptAction:aBlock
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   530
    "set the action to be performed on accept"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   531
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   532
    acceptAction := aBlock
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   533
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   534
1108
3d14bb6bceb7 added disableAccept
Claus Gittinger <cg@exept.de>
parents: 1082
diff changeset
   535
acceptEnabled:aBoolean
3d14bb6bceb7 added disableAccept
Claus Gittinger <cg@exept.de>
parents: 1082
diff changeset
   536
    "enable/disable accept. This greys the corresponding item in the menu"
3d14bb6bceb7 added disableAccept
Claus Gittinger <cg@exept.de>
parents: 1082
diff changeset
   537
3d14bb6bceb7 added disableAccept
Claus Gittinger <cg@exept.de>
parents: 1082
diff changeset
   538
    acceptEnabled := aBoolean
3d14bb6bceb7 added disableAccept
Claus Gittinger <cg@exept.de>
parents: 1082
diff changeset
   539
3d14bb6bceb7 added disableAccept
Claus Gittinger <cg@exept.de>
parents: 1082
diff changeset
   540
    "Created: 7.3.1997 / 11:04:34 / cg"
3d14bb6bceb7 added disableAccept
Claus Gittinger <cg@exept.de>
parents: 1082
diff changeset
   541
!
3d14bb6bceb7 added disableAccept
Claus Gittinger <cg@exept.de>
parents: 1082
diff changeset
   542
474
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   543
autoIndent:aBoolean
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   544
    autoIndent := aBoolean
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   545
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   546
    "Created: 5.3.1996 / 14:37:50 / cg"
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   547
!
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   548
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   549
exceptionBlock:aBlock
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   550
    "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
   551
     readonly text"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   552
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   553
    exceptionBlock := aBlock
323
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   554
!
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   555
477
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
   556
insertMode:aBoolean
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
   557
    insertMode := aBoolean
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
   558
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
   559
    "Created: 6.3.1996 / 12:24:05 / cg"
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
   560
!
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
   561
323
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   562
tabMeansNextField:aBoolean
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   563
    "set/clear tabbing to the next field.
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   564
     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
   565
     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
   566
     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
   567
     input fields."
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   568
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
   569
    tabMeansNextField := aBoolean
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   570
! !
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   571
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   572
!EditTextView methodsFor:'accessing-contents'!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   573
1013
391290c747b3 added an acceptChannel
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
   574
acceptChannel
1437
ab84b08a9f9c allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   575
    "return the valueHolder holding true if text was accepted.
ab84b08a9f9c allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   576
     By placing a true into this channel, an accept can also be forced."
1013
391290c747b3 added an acceptChannel
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
   577
391290c747b3 added an acceptChannel
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
   578
    ^ acceptChannel
391290c747b3 added an acceptChannel
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
   579
1437
ab84b08a9f9c allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   580
    "Modified: / 30.1.1998 / 14:17:11 / cg"
ab84b08a9f9c allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   581
!
ab84b08a9f9c allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   582
ab84b08a9f9c allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   583
acceptChannel:aValueHolder
ab84b08a9f9c allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   584
    "set the valueHolder holding true if text was accepted.
ab84b08a9f9c allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   585
     By placing a true into this channel, an accept can also be forced."
ab84b08a9f9c allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   586
ab84b08a9f9c allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   587
    |prev|
ab84b08a9f9c allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   588
ab84b08a9f9c allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   589
    prev := acceptChannel.
ab84b08a9f9c allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   590
    acceptChannel := aValueHolder.
ab84b08a9f9c allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   591
    self setupChannel:aValueHolder for:nil withOld:prev
ab84b08a9f9c allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   592
ab84b08a9f9c allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   593
    "Created: / 30.1.1998 / 14:51:09 / cg"
1013
391290c747b3 added an acceptChannel
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
   594
!
391290c747b3 added an acceptChannel
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
   595
391290c747b3 added an acceptChannel
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
   596
accepted
391290c747b3 added an acceptChannel
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
   597
    "return true if text was accepted"
391290c747b3 added an acceptChannel
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
   598
391290c747b3 added an acceptChannel
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
   599
    ^ acceptChannel value
391290c747b3 added an acceptChannel
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
   600
391290c747b3 added an acceptChannel
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
   601
    "Created: 14.2.1997 / 16:43:46 / cg"
391290c747b3 added an acceptChannel
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
   602
!
391290c747b3 added an acceptChannel
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
   603
391290c747b3 added an acceptChannel
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
   604
accepted:aBoolean
1437
ab84b08a9f9c allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   605
    "set/clear the accepted flag.
ab84b08a9f9c allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   606
     This may force my current contents to be placed into my model."
ab84b08a9f9c allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   607
ab84b08a9f9c allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   608
    acceptChannel value:aBoolean.
ab84b08a9f9c allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   609
ab84b08a9f9c allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   610
    "Created: / 14.2.1997 / 16:44:01 / cg"
ab84b08a9f9c allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   611
    "Modified: / 30.1.1998 / 14:20:15 / cg"
1013
391290c747b3 added an acceptChannel
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
   612
!
391290c747b3 added an acceptChannel
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
   613
522
aa9458e4643e indent/undent did not trigger a modify
ca
parents: 503
diff changeset
   614
at:lineNr put:aLine
aa9458e4643e indent/undent did not trigger a modify
ca
parents: 503
diff changeset
   615
    (self at:lineNr) = aLine ifFalse:[
1415
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   616
	super at:lineNr put:aLine.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   617
	self textChanged
522
aa9458e4643e indent/undent did not trigger a modify
ca
parents: 503
diff changeset
   618
    ].
aa9458e4643e indent/undent did not trigger a modify
ca
parents: 503
diff changeset
   619
!
aa9458e4643e indent/undent did not trigger a modify
ca
parents: 503
diff changeset
   620
1577
4e487247ad33 dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents: 1568
diff changeset
   621
characterBeforeCursor
4e487247ad33 dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents: 1568
diff changeset
   622
    "return the character under the cursor - space if behond line.
4e487247ad33 dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents: 1568
diff changeset
   623
     For non-block cursors, this is the character immediately to the right
4e487247ad33 dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents: 1568
diff changeset
   624
     of the insertion-bar or caret."
4e487247ad33 dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents: 1568
diff changeset
   625
4e487247ad33 dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents: 1568
diff changeset
   626
    cursorCol == 1 ifTrue:[^ nil].
4e487247ad33 dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents: 1568
diff changeset
   627
4e487247ad33 dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents: 1568
diff changeset
   628
    ^ self characterAtLine:cursorLine col:cursorCol-1
4e487247ad33 dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents: 1568
diff changeset
   629
4e487247ad33 dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents: 1568
diff changeset
   630
    "Created: / 17.6.1998 / 15:16:41 / cg"
4e487247ad33 dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents: 1568
diff changeset
   631
!
4e487247ad33 dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents: 1568
diff changeset
   632
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   633
characterUnderCursor
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   634
    "return the character under the cursor - space if behond line.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   635
     For non-block cursors, this is the character immediately to the right
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   636
     of the insertion-bar or caret."
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   637
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   638
    ^ self characterAtLine:cursorLine col:cursorCol
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   639
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   640
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   641
contents
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   642
    "return the contents as a String"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   643
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   644
    list isNil ifTrue:[^ ''].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   645
    self removeTrailingBlankLines.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   646
    ^ list asStringWithCRs
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   647
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   648
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   649
cursorCol
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   650
    "return the cursors col (1..).
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   651
     This is the absolute col; NOT the visible col"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   652
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   653
    ^ cursorCol
125
claus
parents: 123
diff changeset
   654
!
claus
parents: 123
diff changeset
   655
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   656
cursorLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   657
    "return the cursors line (1..). 
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   658
     This is the absolute line; NOT the visible line"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   659
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   660
    ^ cursorLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   661
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   662
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   663
fixedSize
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   664
    "make the texts size fixed (no lines may be added).
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   665
     OBSOLETE: use readOnly"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   666
1018
427190d7026f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1017
diff changeset
   667
    self obsoleteMethodWarning:'use #readOnly:'.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   668
    readOnly ifFalse:[
1415
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   669
	readOnly := true.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   670
	middleButtonMenu notNil ifTrue:[
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   671
	    middleButtonMenu disableAll:#(cut paste replace indent)
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   672
	]
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   673
    ]
1018
427190d7026f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1017
diff changeset
   674
427190d7026f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1017
diff changeset
   675
    "Modified: 14.2.1997 / 17:35:24 / cg"
127
claus
parents: 125
diff changeset
   676
!
claus
parents: 125
diff changeset
   677
1037
2ff1891e1ecb added #isReadOnly
ca
parents: 1025
diff changeset
   678
isReadOnly
2ff1891e1ecb added #isReadOnly
ca
parents: 1025
diff changeset
   679
    "return true, if the text is readonly."
2ff1891e1ecb added #isReadOnly
ca
parents: 1025
diff changeset
   680
2ff1891e1ecb added #isReadOnly
ca
parents: 1025
diff changeset
   681
    ^ readOnly 
2ff1891e1ecb added #isReadOnly
ca
parents: 1025
diff changeset
   682
2ff1891e1ecb added #isReadOnly
ca
parents: 1025
diff changeset
   683
    "Modified: 14.2.1997 / 17:35:56 / cg"
2ff1891e1ecb added #isReadOnly
ca
parents: 1025
diff changeset
   684
!
2ff1891e1ecb added #isReadOnly
ca
parents: 1025
diff changeset
   685
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   686
list:something
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   687
    "position cursor home when setting contents"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   688
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   689
    super list:something.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   690
    self cursorHome
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   691
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   692
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   693
modified
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   694
    "return true if text was modified"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   695
331
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
   696
    ^ modifiedChannel value
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
   697
!
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
   698
362
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
   699
modified:aBoolean
1013
391290c747b3 added an acceptChannel
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
   700
    "set/clear the modified flag"
362
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
   701
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
   702
    modifiedChannel value:aBoolean
1013
391290c747b3 added an acceptChannel
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
   703
391290c747b3 added an acceptChannel
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
   704
    "Modified: 14.2.1997 / 16:44:05 / cg"
362
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
   705
!
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
   706
331
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
   707
modifiedChannel
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
   708
    "return the valueHolder holding true if text was modified"
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
   709
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
   710
    ^ modifiedChannel
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   711
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   712
1437
ab84b08a9f9c allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   713
modifiedChannel:aValueHolder
ab84b08a9f9c allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   714
    "set the valueHolder holding true if text was modified"
ab84b08a9f9c allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   715
ab84b08a9f9c allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   716
    |prev|
ab84b08a9f9c allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   717
ab84b08a9f9c allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   718
    prev := modifiedChannel.
ab84b08a9f9c allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   719
    modifiedChannel := aValueHolder.
ab84b08a9f9c allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   720
    self setupChannel:aValueHolder for:nil withOld:prev
ab84b08a9f9c allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   721
ab84b08a9f9c allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   722
    "Created: / 30.1.1998 / 14:51:32 / cg"
ab84b08a9f9c allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   723
!
ab84b08a9f9c allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   724
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   725
readOnly
1018
427190d7026f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1017
diff changeset
   726
    "make the text readonly.
427190d7026f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1017
diff changeset
   727
     Somewhat obsolete - use #readOnly:"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   728
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   729
    readOnly := true
1018
427190d7026f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1017
diff changeset
   730
427190d7026f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1017
diff changeset
   731
    "Modified: 14.2.1997 / 17:35:56 / cg"
427190d7026f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1017
diff changeset
   732
!
427190d7026f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1017
diff changeset
   733
427190d7026f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1017
diff changeset
   734
readOnly:aBoolean
427190d7026f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1017
diff changeset
   735
    "make the text readonly or writable"
427190d7026f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1017
diff changeset
   736
427190d7026f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1017
diff changeset
   737
    readOnly := aBoolean
427190d7026f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1017
diff changeset
   738
427190d7026f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1017
diff changeset
   739
    "Created: 14.2.1997 / 17:35:39 / cg"
1476
ac38c8af8585 setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents: 1449
diff changeset
   740
!
ac38c8af8585 setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents: 1449
diff changeset
   741
ac38c8af8585 setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents: 1449
diff changeset
   742
setContents:something
ac38c8af8585 setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents: 1449
diff changeset
   743
    |selType|
ac38c8af8585 setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents: 1449
diff changeset
   744
ac38c8af8585 setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents: 1449
diff changeset
   745
    selType := typeOfSelection.
ac38c8af8585 setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents: 1449
diff changeset
   746
    super setContents:something.
ac38c8af8585 setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents: 1449
diff changeset
   747
    typeOfSelection := selType.
ac38c8af8585 setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents: 1449
diff changeset
   748
ac38c8af8585 setContents: - keep selection
Claus Gittinger <cg@exept.de>
parents: 1449
diff changeset
   749
    "Created: / 31.3.1998 / 23:35:06 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   750
! !
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   751
474
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   752
!EditTextView methodsFor:'accessing-look'!
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   753
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   754
cursorForegroundColor:color1 backgroundColor:color2
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   755
    "set both cursor foreground and cursor background colors"
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   756
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   757
    |wasOn|
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   758
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   759
    wasOn := self hideCursor.
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   760
    cursorFgColor := color1 on:device.
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   761
    cursorBgColor := color2 on:device.
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   762
    wasOn ifTrue:[self showCursor]
1333
56af09878b96 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1325
diff changeset
   763
!
56af09878b96 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1325
diff changeset
   764
56af09878b96 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1325
diff changeset
   765
cursorType:aCursorTypeSymbol
56af09878b96 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1325
diff changeset
   766
    "set the style of the text cursor.
56af09878b96 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1325
diff changeset
   767
     Currently, supported are: #block, #frame, #ibeam, #caret, #solidCaret
1415
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   768
			       #bigCaret and #bigSolidCaret"
1333
56af09878b96 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1325
diff changeset
   769
1334
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
   770
    cursorType := aCursorTypeSymbol.
1333
56af09878b96 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1325
diff changeset
   771
56af09878b96 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1325
diff changeset
   772
    "Created: 21.9.1997 / 13:42:23 / cg"
56af09878b96 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1325
diff changeset
   773
    "Modified: 21.9.1997 / 13:43:35 / cg"
1334
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
   774
!
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
   775
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
   776
cursorTypeNoFocus:aCursorTypeSymbol
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
   777
    "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
   778
     If left unspecified, this is the same as the regular cursorType."
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
   779
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
   780
    cursorTypeNoFocus := aCursorTypeSymbol
474
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   781
! !
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
   782
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   783
!EditTextView methodsFor:'change & update '!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   784
125
claus
parents: 123
diff changeset
   785
accept
claus
parents: 123
diff changeset
   786
    "accept the current contents by executing the accept-action and/or
claus
parents: 123
diff changeset
   787
     changeMessage."
claus
parents: 123
diff changeset
   788
1108
3d14bb6bceb7 added disableAccept
Claus Gittinger <cg@exept.de>
parents: 1082
diff changeset
   789
    acceptEnabled == false ifTrue:[
1437
ab84b08a9f9c allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   790
        device beep.
ab84b08a9f9c allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   791
        ^ self
1108
3d14bb6bceb7 added disableAccept
Claus Gittinger <cg@exept.de>
parents: 1082
diff changeset
   792
    ].
3d14bb6bceb7 added disableAccept
Claus Gittinger <cg@exept.de>
parents: 1082
diff changeset
   793
125
claus
parents: 123
diff changeset
   794
    lockUpdates := true.
1013
391290c747b3 added an acceptChannel
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
   795
391290c747b3 added an acceptChannel
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
   796
    "/
391290c747b3 added an acceptChannel
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
   797
    "/ ST-80 way of doing it
391290c747b3 added an acceptChannel
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
   798
    "/
391290c747b3 added an acceptChannel
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
   799
    model notNil ifTrue:[
1437
ab84b08a9f9c allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   800
        self sendChangeMessageWith:self argForChangeMessage.
1013
391290c747b3 added an acceptChannel
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
   801
    ].
391290c747b3 added an acceptChannel
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
   802
757
2cc7e423f0ef only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents: 730
diff changeset
   803
    "/
2cc7e423f0ef only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents: 730
diff changeset
   804
    "/ ST/X way of doing things
2cc7e423f0ef only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents: 730
diff changeset
   805
    "/ as a historic (and temporary) leftover,
2cc7e423f0ef only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents: 730
diff changeset
   806
    "/ 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
   807
    "/ - not with the actual string
2cc7e423f0ef only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents: 730
diff changeset
   808
    "/
2cc7e423f0ef only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents: 730
diff changeset
   809
    acceptAction notNil ifTrue:[
1437
ab84b08a9f9c allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   810
        acceptAction value:self list
757
2cc7e423f0ef only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents: 730
diff changeset
   811
    ].
2cc7e423f0ef only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents: 730
diff changeset
   812
1017
Claus Gittinger <cg@exept.de>
parents: 1015
diff changeset
   813
    self modified:false.
1437
ab84b08a9f9c allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   814
ab84b08a9f9c allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   815
    "/ self accepted:true.
ab84b08a9f9c allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   816
    "/ changed to:
ab84b08a9f9c allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   817
    acceptChannel value:true withoutNotifying:self.
125
claus
parents: 123
diff changeset
   818
claus
parents: 123
diff changeset
   819
    lockUpdates := false.
757
2cc7e423f0ef only try changeMessage, if there is a model
Claus Gittinger <cg@exept.de>
parents: 730
diff changeset
   820
1437
ab84b08a9f9c allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   821
    "Modified: / 30.1.1998 / 14:19:00 / cg"
131
claus
parents: 130
diff changeset
   822
!
claus
parents: 130
diff changeset
   823
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   824
argForChangeMessage
597
fb42c94a042e commentary
Claus Gittinger <cg@exept.de>
parents: 594
diff changeset
   825
    "return the argument to be passed with the change notification.
fb42c94a042e commentary
Claus Gittinger <cg@exept.de>
parents: 594
diff changeset
   826
     Defined as separate method for easier subclassability."
fb42c94a042e commentary
Claus Gittinger <cg@exept.de>
parents: 594
diff changeset
   827
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   828
    ^ self contents
597
fb42c94a042e commentary
Claus Gittinger <cg@exept.de>
parents: 594
diff changeset
   829
fb42c94a042e commentary
Claus Gittinger <cg@exept.de>
parents: 594
diff changeset
   830
    "Modified: 29.4.1996 / 12:42:14 / cg"
121
claus
parents: 118
diff changeset
   831
!
claus
parents: 118
diff changeset
   832
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   833
getListFromModel
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   834
    "get my contents from the model.
597
fb42c94a042e commentary
Claus Gittinger <cg@exept.de>
parents: 594
diff changeset
   835
     Redefined to ignore updates resulting from my own changes
fb42c94a042e commentary
Claus Gittinger <cg@exept.de>
parents: 594
diff changeset
   836
     (i.e. if lockUpdates is true)."
121
claus
parents: 118
diff changeset
   837
claus
parents: 118
diff changeset
   838
    "
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   839
     ignore updates from my own change
121
claus
parents: 118
diff changeset
   840
    "
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   841
    lockUpdates ifTrue:[
1415
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   842
	lockUpdates := false.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   843
	^ self
121
claus
parents: 118
diff changeset
   844
    ].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   845
    ^ super getListFromModel
597
fb42c94a042e commentary
Claus Gittinger <cg@exept.de>
parents: 594
diff changeset
   846
fb42c94a042e commentary
Claus Gittinger <cg@exept.de>
parents: 594
diff changeset
   847
    "Modified: 29.4.1996 / 12:42:33 / cg"
1437
ab84b08a9f9c allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   848
!
ab84b08a9f9c allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   849
ab84b08a9f9c allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   850
update:something with:aParameter from:changedObject
1438
bed1564b0640 fixed update for acceptChannel
Claus Gittinger <cg@exept.de>
parents: 1437
diff changeset
   851
    changedObject == acceptChannel ifTrue:[
1439
d1b3ca91ed8a fixed update for acceptChannel
Claus Gittinger <cg@exept.de>
parents: 1438
diff changeset
   852
        acceptChannel value == true ifTrue:[ 
d1b3ca91ed8a fixed update for acceptChannel
Claus Gittinger <cg@exept.de>
parents: 1438
diff changeset
   853
            self accept.
d1b3ca91ed8a fixed update for acceptChannel
Claus Gittinger <cg@exept.de>
parents: 1438
diff changeset
   854
        ].
1437
ab84b08a9f9c allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   855
        ^ self.
ab84b08a9f9c allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   856
    ].
ab84b08a9f9c allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   857
    super update:something with:aParameter from:changedObject
ab84b08a9f9c allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   858
ab84b08a9f9c allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   859
    "Created: / 30.1.1998 / 14:15:56 / cg"
1439
d1b3ca91ed8a fixed update for acceptChannel
Claus Gittinger <cg@exept.de>
parents: 1438
diff changeset
   860
    "Modified: / 1.2.1998 / 13:15:55 / cg"
121
claus
parents: 118
diff changeset
   861
! !
claus
parents: 118
diff changeset
   862
claus
parents: 118
diff changeset
   863
!EditTextView methodsFor:'cursor handling'!
claus
parents: 118
diff changeset
   864
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   865
cursorBacktab
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   866
    "move cursor to prev tabstop"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   867
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   868
    self cursorCol:(self prevTabBefore:cursorCol).
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   869
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   870
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   871
cursorCol:newCol
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   872
    "move cursor to some column in the current line"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   873
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   874
    |wasOn|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   875
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   876
    wasOn := self hideCursor.
672
065750d02339 added cursorCol-validation
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
   877
    cursorCol := self validateCursorCol:newCol inLine:cursorLine.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   878
    self makeCursorVisibleAndShowCursor:wasOn.
672
065750d02339 added cursorCol-validation
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
   879
065750d02339 added cursorCol-validation
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
   880
    "Modified: 22.5.1996 / 14:25:53 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   881
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   882
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   883
cursorDown
632
5af2c22002e4 dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
   884
    "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
   885
     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
   886
5af2c22002e4 dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
   887
    |wasOn|
5af2c22002e4 dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
   888
5af2c22002e4 dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
   889
    self cursorDown:1.
5af2c22002e4 dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
   890
5af2c22002e4 dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
   891
    "/ cursor behond text ?
5af2c22002e4 dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
   892
    cursorLine > list size ifTrue:[
1561
db5f27354172 make cursor correctly visible if in partial last line.
Claus Gittinger <cg@exept.de>
parents: 1560
diff changeset
   893
        wasOn := self hideCursor.
db5f27354172 make cursor correctly visible if in partial last line.
Claus Gittinger <cg@exept.de>
parents: 1560
diff changeset
   894
        cursorLine := self validateCursorLine:(list size + 1).
db5f27354172 make cursor correctly visible if in partial last line.
Claus Gittinger <cg@exept.de>
parents: 1560
diff changeset
   895
        cursorCol := self validateCursorCol:cursorCol inLine:cursorLine.
db5f27354172 make cursor correctly visible if in partial last line.
Claus Gittinger <cg@exept.de>
parents: 1560
diff changeset
   896
        cursorVisibleLine := self listLineToVisibleLine:cursorLine.
db5f27354172 make cursor correctly visible if in partial last line.
Claus Gittinger <cg@exept.de>
parents: 1560
diff changeset
   897
        "/ wasOn ifTrue:[self showCursor].
db5f27354172 make cursor correctly visible if in partial last line.
Claus Gittinger <cg@exept.de>
parents: 1560
diff changeset
   898
        self makeCursorVisibleAndShowCursor:wasOn.
db5f27354172 make cursor correctly visible if in partial last line.
Claus Gittinger <cg@exept.de>
parents: 1560
diff changeset
   899
        self beep.
632
5af2c22002e4 dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
   900
    ].
5af2c22002e4 dont beep if cursor is moved down programmatically
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
   901
1561
db5f27354172 make cursor correctly visible if in partial last line.
Claus Gittinger <cg@exept.de>
parents: 1560
diff changeset
   902
    "Modified: / 10.6.1998 / 17:00:23 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   903
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   904
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   905
cursorDown:n
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   906
    "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
   907
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   908
    |wasOn nv|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   909
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   910
    cursorVisibleLine notNil ifTrue:[
1561
db5f27354172 make cursor correctly visible if in partial last line.
Claus Gittinger <cg@exept.de>
parents: 1560
diff changeset
   911
        wasOn := self hideCursor.
db5f27354172 make cursor correctly visible if in partial last line.
Claus Gittinger <cg@exept.de>
parents: 1560
diff changeset
   912
        nv := cursorVisibleLine + n - 1.
db5f27354172 make cursor correctly visible if in partial last line.
Claus Gittinger <cg@exept.de>
parents: 1560
diff changeset
   913
        (nv >= nFullLinesShown) ifTrue:[
db5f27354172 make cursor correctly visible if in partial last line.
Claus Gittinger <cg@exept.de>
parents: 1560
diff changeset
   914
            self scrollDown:(nv - nFullLinesShown + 1)
db5f27354172 make cursor correctly visible if in partial last line.
Claus Gittinger <cg@exept.de>
parents: 1560
diff changeset
   915
        ].
db5f27354172 make cursor correctly visible if in partial last line.
Claus Gittinger <cg@exept.de>
parents: 1560
diff changeset
   916
        cursorLine := self validateCursorLine:(cursorLine + n).
db5f27354172 make cursor correctly visible if in partial last line.
Claus Gittinger <cg@exept.de>
parents: 1560
diff changeset
   917
        cursorCol := self validateCursorCol:cursorCol inLine:cursorLine.
db5f27354172 make cursor correctly visible if in partial last line.
Claus Gittinger <cg@exept.de>
parents: 1560
diff changeset
   918
        cursorVisibleLine := self listLineToVisibleLine:cursorLine.
db5f27354172 make cursor correctly visible if in partial last line.
Claus Gittinger <cg@exept.de>
parents: 1560
diff changeset
   919
        "/ wasOn ifTrue:[self showCursor].
db5f27354172 make cursor correctly visible if in partial last line.
Claus Gittinger <cg@exept.de>
parents: 1560
diff changeset
   920
        self makeCursorVisibleAndShowCursor:wasOn.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   921
    ] ifFalse:[
1561
db5f27354172 make cursor correctly visible if in partial last line.
Claus Gittinger <cg@exept.de>
parents: 1560
diff changeset
   922
        cursorLine isNil ifTrue:[
db5f27354172 make cursor correctly visible if in partial last line.
Claus Gittinger <cg@exept.de>
parents: 1560
diff changeset
   923
            cursorLine := firstLineShown
db5f27354172 make cursor correctly visible if in partial last line.
Claus Gittinger <cg@exept.de>
parents: 1560
diff changeset
   924
        ].
db5f27354172 make cursor correctly visible if in partial last line.
Claus Gittinger <cg@exept.de>
parents: 1560
diff changeset
   925
        cursorLine := self validateCursorLine:(cursorLine + n).
db5f27354172 make cursor correctly visible if in partial last line.
Claus Gittinger <cg@exept.de>
parents: 1560
diff changeset
   926
        cursorCol := self validateCursorCol:cursorCol inLine:cursorLine.
db5f27354172 make cursor correctly visible if in partial last line.
Claus Gittinger <cg@exept.de>
parents: 1560
diff changeset
   927
        cursorVisibleLine := self listLineToVisibleLine:cursorLine.
db5f27354172 make cursor correctly visible if in partial last line.
Claus Gittinger <cg@exept.de>
parents: 1560
diff changeset
   928
        self makeCursorVisible.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   929
    ].
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
   930
1561
db5f27354172 make cursor correctly visible if in partial last line.
Claus Gittinger <cg@exept.de>
parents: 1560
diff changeset
   931
    "Modified: / 10.6.1998 / 16:59:17 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   932
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   933
121
claus
parents: 118
diff changeset
   934
cursorHome
597
fb42c94a042e commentary
Claus Gittinger <cg@exept.de>
parents: 594
diff changeset
   935
    "scroll to top AND move cursor to first line of text."
121
claus
parents: 118
diff changeset
   936
674
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
   937
    self cursorLine:1 col:1
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
   938
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
   939
"/    |wasOn|
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
   940
"/
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
   941
"/    wasOn := self hideCursor.
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
   942
"/    self scrollToTop.
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
   943
"/    cursorLine := cursorVisibleLine := 1.
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
   944
"/    cursorCol := self validateCursorCol:1 inLine:cursorLine.
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
   945
"/    self makeCursorVisibleAndShowCursor:wasOn.
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
   946
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
   947
    "Modified: 22.5.1996 / 18:26:42 / cg"
121
claus
parents: 118
diff changeset
   948
!
claus
parents: 118
diff changeset
   949
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   950
cursorLeft
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   951
    "move cursor to left"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   952
1300
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
   953
    (cursorCol ~~ 1) ifTrue:[
1426
de76570ba19e crsrLeft/crsrRight does not wrap to prev/next line in st80 mode
Claus Gittinger <cg@exept.de>
parents: 1419
diff changeset
   954
        self cursorCol:(cursorCol - 1)
1300
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
   955
    ] ifFalse:[
1426
de76570ba19e crsrLeft/crsrRight does not wrap to prev/next line in st80 mode
Claus Gittinger <cg@exept.de>
parents: 1419
diff changeset
   956
"/ no, do not wrap back to previous line
de76570ba19e crsrLeft/crsrRight does not wrap to prev/next line in st80 mode
Claus Gittinger <cg@exept.de>
parents: 1419
diff changeset
   957
"/        cursorLine ~~ 1 ifTrue:[
de76570ba19e crsrLeft/crsrRight does not wrap to prev/next line in st80 mode
Claus Gittinger <cg@exept.de>
parents: 1419
diff changeset
   958
"/            ST80Mode == true ifTrue:[
de76570ba19e crsrLeft/crsrRight does not wrap to prev/next line in st80 mode
Claus Gittinger <cg@exept.de>
parents: 1419
diff changeset
   959
"/                self cursorUp.
de76570ba19e crsrLeft/crsrRight does not wrap to prev/next line in st80 mode
Claus Gittinger <cg@exept.de>
parents: 1419
diff changeset
   960
"/                self cursorToEndOfLine.
de76570ba19e crsrLeft/crsrRight does not wrap to prev/next line in st80 mode
Claus Gittinger <cg@exept.de>
parents: 1419
diff changeset
   961
"/           ]
de76570ba19e crsrLeft/crsrRight does not wrap to prev/next line in st80 mode
Claus Gittinger <cg@exept.de>
parents: 1419
diff changeset
   962
"/        ]
1300
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
   963
    ]
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
   964
1426
de76570ba19e crsrLeft/crsrRight does not wrap to prev/next line in st80 mode
Claus Gittinger <cg@exept.de>
parents: 1419
diff changeset
   965
    "Modified: / 23.1.1998 / 12:37:13 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   966
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   967
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   968
cursorLine:line col:col
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   969
    "this positions onto physical - not visible - line"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   970
676
b65b82a1ffcb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   971
    |wasOn newCol|
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   972
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   973
    wasOn := self hideCursor.
674
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
   974
    cursorLine := self validateCursorLine:line.
1419
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   975
    cursorVisibleLine := self listLineToVisibleLine:cursorLine.
672
065750d02339 added cursorCol-validation
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
   976
    (col < 1) ifTrue:[
1596
0bbdb4e9fc43 made st80Mode also an inst-flag;
Claus Gittinger <cg@exept.de>
parents: 1591
diff changeset
   977
        newCol := 1
672
065750d02339 added cursorCol-validation
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
   978
    ] ifFalse:[
1596
0bbdb4e9fc43 made st80Mode also an inst-flag;
Claus Gittinger <cg@exept.de>
parents: 1591
diff changeset
   979
        newCol := col.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   980
    ].
1596
0bbdb4e9fc43 made st80Mode also an inst-flag;
Claus Gittinger <cg@exept.de>
parents: 1591
diff changeset
   981
    st80Mode ifTrue:[
0bbdb4e9fc43 made st80Mode also an inst-flag;
Claus Gittinger <cg@exept.de>
parents: 1591
diff changeset
   982
        (cursorLine == list size
0bbdb4e9fc43 made st80Mode also an inst-flag;
Claus Gittinger <cg@exept.de>
parents: 1591
diff changeset
   983
        and:[cursorLine ~~ line]) ifTrue:[
0bbdb4e9fc43 made st80Mode also an inst-flag;
Claus Gittinger <cg@exept.de>
parents: 1591
diff changeset
   984
            newCol := (self listAt:(list size)) size + 1.
0bbdb4e9fc43 made st80Mode also an inst-flag;
Claus Gittinger <cg@exept.de>
parents: 1591
diff changeset
   985
        ]
1419
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
   986
    ].
676
b65b82a1ffcb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   987
    cursorCol := self validateCursorCol:newCol inLine:cursorLine.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   988
    self makeCursorVisibleAndShowCursor:wasOn.
672
065750d02339 added cursorCol-validation
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
   989
1596
0bbdb4e9fc43 made st80Mode also an inst-flag;
Claus Gittinger <cg@exept.de>
parents: 1591
diff changeset
   990
    "Modified: / 20.6.1998 / 18:19:06 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   991
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
   992
1580
d30e562bea15 allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
   993
cursorMovementAllowed
d30e562bea15 allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
   994
    "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
   995
     (via button-click, or cursor-key with selection).
d30e562bea15 allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
   996
     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
   997
     in special subclasses (such as a terminal view), where
d30e562bea15 allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
   998
     this is not wanted"
d30e562bea15 allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
   999
d30e562bea15 allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
  1000
    ^ true
d30e562bea15 allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
  1001
d30e562bea15 allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
  1002
    "Created: / 18.6.1998 / 14:11:16 / cg"
d30e562bea15 allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
  1003
!
d30e562bea15 allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
  1004
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1005
cursorReturn
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1006
    "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
  1007
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1008
    |wasOn|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1009
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1010
    self checkForExistingLine:(cursorLine + 1).
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1011
    cursorVisibleLine notNil ifTrue:[
1415
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1012
	nFullLinesShown notNil ifTrue:[
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1013
	    (cursorVisibleLine >= nFullLinesShown) ifTrue:[self scrollDown]
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1014
	]
259
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
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1017
    wasOn := self hideCursor.
674
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  1018
    cursorLine := self validateCursorLine:cursorLine + 1.
672
065750d02339 added cursorCol-validation
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  1019
    cursorCol := self validateCursorCol:1 inLine:cursorLine.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1020
    cursorVisibleLine := self listLineToVisibleLine:cursorLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1021
    self makeCursorVisibleAndShowCursor:wasOn.
672
065750d02339 added cursorCol-validation
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  1022
674
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  1023
    "Modified: 22.5.1996 / 18:27:34 / cg"
259
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
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1026
cursorRight
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1027
    "move cursor to right"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1028
1300
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  1029
    |l|
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  1030
1596
0bbdb4e9fc43 made st80Mode also an inst-flag;
Claus Gittinger <cg@exept.de>
parents: 1591
diff changeset
  1031
    st80Mode == true ifTrue:[
1426
de76570ba19e crsrLeft/crsrRight does not wrap to prev/next line in st80 mode
Claus Gittinger <cg@exept.de>
parents: 1419
diff changeset
  1032
        l := (self listAt:cursorLine).
de76570ba19e crsrLeft/crsrRight does not wrap to prev/next line in st80 mode
Claus Gittinger <cg@exept.de>
parents: 1419
diff changeset
  1033
        cursorCol >= (l size + 1) ifTrue:[
de76570ba19e crsrLeft/crsrRight does not wrap to prev/next line in st80 mode
Claus Gittinger <cg@exept.de>
parents: 1419
diff changeset
  1034
"/ no, do not wrap to next line
de76570ba19e crsrLeft/crsrRight does not wrap to prev/next line in st80 mode
Claus Gittinger <cg@exept.de>
parents: 1419
diff changeset
  1035
"/            cursorLine < list size ifTrue:[
de76570ba19e crsrLeft/crsrRight does not wrap to prev/next line in st80 mode
Claus Gittinger <cg@exept.de>
parents: 1419
diff changeset
  1036
"/                self cursorReturn.
de76570ba19e crsrLeft/crsrRight does not wrap to prev/next line in st80 mode
Claus Gittinger <cg@exept.de>
parents: 1419
diff changeset
  1037
"/            ].
de76570ba19e crsrLeft/crsrRight does not wrap to prev/next line in st80 mode
Claus Gittinger <cg@exept.de>
parents: 1419
diff changeset
  1038
            ^ self    
de76570ba19e crsrLeft/crsrRight does not wrap to prev/next line in st80 mode
Claus Gittinger <cg@exept.de>
parents: 1419
diff changeset
  1039
        ]
1300
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  1040
    ].    
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1041
    self cursorCol:(cursorCol + 1)
1300
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  1042
1596
0bbdb4e9fc43 made st80Mode also an inst-flag;
Claus Gittinger <cg@exept.de>
parents: 1591
diff changeset
  1043
    "Modified: / 20.6.1998 / 18:19:07 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1044
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1045
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1046
cursorTab
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1047
    "move cursor to next tabstop"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1048
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1049
    self cursorCol:(self nextTabAfter:cursorCol).
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1050
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1051
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1052
cursorToBeginOfLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1053
    "move cursor to start of current line"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1054
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1055
    self cursorCol:1
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1056
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1057
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1058
cursorToBottom
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1059
    "move cursor to last line of text"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1060
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1061
    |wasOn newTop|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1062
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1063
    wasOn := self hideCursor.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1064
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1065
    newTop := list size - nFullLinesShown.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1066
    (newTop < 1) ifTrue:[
1415
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1067
	newTop := 1
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1068
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1069
    self scrollToLine:newTop.
674
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  1070
    cursorLine := self validateCursorLine:list size.
672
065750d02339 added cursorCol-validation
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  1071
    cursorCol := self validateCursorCol:1 inLine:cursorLine.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1072
    cursorVisibleLine := self listLineToVisibleLine:cursorLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1073
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1074
    self makeCursorVisibleAndShowCursor:wasOn.
672
065750d02339 added cursorCol-validation
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  1075
674
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  1076
    "Modified: 22.5.1996 / 18:27:45 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1077
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1078
1415
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1079
cursorToCharacterPosition:pos
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1080
    "compute line/col from character position (1..)
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1081
     and move the cursor onto that char"
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1082
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1083
    |line col|
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1084
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1085
    line := self lineOfCharacterPosition:pos.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1086
    col := pos - (self characterPositionOfLine:line col:1) + 1.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1087
    self cursorLine:line col:col
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1088
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1089
    "Created: / 15.1.1998 / 21:55:33 / cg"
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1090
!
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1091
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1092
cursorToEnd
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1093
    "move cursor down below last line of text"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1094
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1095
    |wasOn newTop l line|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1096
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1097
    l := list size.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1098
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1099
    cursorLine >= l ifTrue:[
1415
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1100
	line := self listAt:cursorLine.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1101
	(line isNil or:[line isEmpty]) ifTrue:[
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1102
	    ^ self
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1103
	]
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1104
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1105
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1106
    wasOn := self hideCursor.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1107
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1108
    l := l + 1.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1109
    newTop :=  l - nFullLinesShown.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1110
    (newTop < 1) ifTrue:[
1415
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1111
	newTop := 1
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1112
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1113
    self scrollToLine:newTop.
674
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  1114
    cursorLine := self validateCursorLine:l.
672
065750d02339 added cursorCol-validation
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  1115
    cursorCol := self validateCursorCol:1 inLine:1.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1116
    cursorVisibleLine := self listLineToVisibleLine:cursorLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1117
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1118
    self makeCursorVisibleAndShowCursor:wasOn.
672
065750d02339 added cursorCol-validation
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  1119
674
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  1120
    "Modified: 22.5.1996 / 18:27:53 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1121
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1122
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1123
cursorToEndOfLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1124
    "move cursor to end of current line"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1125
1300
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  1126
    |line|
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  1127
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  1128
    line := (self listAt:cursorLine).
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  1129
    self cursorCol:(line size + 1)
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  1130
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  1131
    "Modified: 13.8.1997 / 15:34:02 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1132
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1133
131
claus
parents: 130
diff changeset
  1134
cursorToFirstVisibleLine
claus
parents: 130
diff changeset
  1135
    "place cursor into the first visible line; do not scroll."
claus
parents: 130
diff changeset
  1136
claus
parents: 130
diff changeset
  1137
    self cursorLine:(self visibleLineToAbsoluteLine:1) col:1
claus
parents: 130
diff changeset
  1138
!
claus
parents: 130
diff changeset
  1139
claus
parents: 130
diff changeset
  1140
cursorToLastVisibleLine
claus
parents: 130
diff changeset
  1141
    "place cursor into the first visible line; do not scroll."
claus
parents: 130
diff changeset
  1142
claus
parents: 130
diff changeset
  1143
    self cursorLine:(self visibleLineToAbsoluteLine:nFullLinesShown) col:1
claus
parents: 130
diff changeset
  1144
!
claus
parents: 130
diff changeset
  1145
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1146
cursorToNextWord
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1147
    "move the cursor to the beginning of the next word"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1148
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1149
    |col line searching|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1150
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1151
    (cursorLine > list size) ifTrue:[^ self].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1152
    self wordAtLine:cursorLine col:cursorCol do:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1153
	:beginLine :beginCol :endLine :endCol :style | 
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1154
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1155
	line := endLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1156
	col := endCol + 1.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1157
	searching := true.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1158
	[searching 
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1159
	 and:[(self characterAtLine:line col:col) isSeparator]] whileTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1160
	    self wordAtLine:line col:col do:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1161
		:beginLine :beginCol :endLine :endCol :style |
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
		(line > list size) ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1164
		    "break out"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1165
		    searching := false
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1166
		] ifFalse:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1167
		    line := endLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1168
		    col := endCol + 1.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1169
		]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1170
	    ]
121
claus
parents: 118
diff changeset
  1171
	].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1172
	self cursorLine:line col:col
121
claus
parents: 118
diff changeset
  1173
    ]
claus
parents: 118
diff changeset
  1174
!
claus
parents: 118
diff changeset
  1175
499
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
  1176
cursorToPreviousWord
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
  1177
    "move the cursor to the beginning of this or the previous word"
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
  1178
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
  1179
    |col line searching l|
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
  1180
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
  1181
    (cursorLine > list size) ifTrue:[^ self].
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
  1182
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
  1183
    self wordAtLine:cursorLine col:cursorCol do:[
1415
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1184
	:beginLine :beginCol :endLine :endCol :style | 
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1185
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1186
	line := beginLine.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1187
	col := beginCol.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1188
	style == #wordLeft ifTrue:[
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1189
	    col := col + 1
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1190
	].
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1191
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1192
	(cursorLine == line
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1193
	and:[cursorCol == col]) ifTrue:[
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1194
	    searching := true.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1195
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1196
	    col > 1 ifTrue:[
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1197
		col := col - 1.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1198
	    ].
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1199
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1200
	    [searching] whileTrue:[
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1201
		(col == 1) ifTrue:[    
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1202
		    line == 1 ifTrue:[
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1203
			searching := false
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1204
		    ] ifFalse:[
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1205
			line := line - 1.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1206
			l := list at:line.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1207
			col := l size + 1.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1208
		    ]
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1209
		] ifFalse:[
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1210
		    (self characterAtLine:line col:col) isSeparator ifFalse:[
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1211
			self wordAtLine:line col:col do:[
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1212
			    :beginLine :beginCol :endLine :endCol :style |
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1213
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1214
			    line := beginLine.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1215
			    col := beginCol.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1216
			    style == #wordLeft ifTrue:[
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1217
				col := col + 1
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1218
			    ].
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1219
			    searching := false.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1220
			]
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1221
		    ] ifTrue:[
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1222
			col := col - 1
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1223
		    ]
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1224
		]
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1225
	    ]
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1226
	].
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1227
	self cursorLine:line col:col
499
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
  1228
    ]
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
  1229
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
  1230
    "Created: 8.3.1996 / 21:52:48 / cg"
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
  1231
    "Modified: 8.3.1996 / 22:12:45 / cg"
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
  1232
!
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
  1233
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1234
cursorToTop
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1235
    "move cursor to absolute home"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1236
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1237
    self cursorLine:1 col:1
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1238
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1239
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1240
cursorUp
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1241
    "move cursor up; scroll if at start of visible text"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1242
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1243
    self cursorUp:1
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1244
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1245
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1246
cursorUp:n
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1247
    "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
  1248
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1249
    |wasOn nv nl|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1250
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1251
    cursorLine isNil ifTrue:[
1415
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1252
	cursorLine := firstLineShown + nFullLinesShown - 1.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1253
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1254
    nl := cursorLine - n.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1255
    nl < 1 ifTrue:[nl := 1].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1256
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1257
    (nl ~~ cursorLine) ifTrue: [
1415
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1258
	wasOn := self hideCursor.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1259
	cursorVisibleLine notNil ifTrue:[
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1260
	    nv := cursorVisibleLine - n.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1261
	    nv < 1 ifTrue:[
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1262
		self scrollUp:(nv negated + 1)
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1263
	    ].
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1264
	].
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1265
	cursorLine := self validateCursorLine:nl.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1266
	cursorVisibleLine := self listLineToVisibleLine:cursorLine.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1267
	cursorCol := self validateCursorCol:cursorCol inLine:cursorLine.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1268
	wasOn ifTrue:[self showCursor].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1269
"/
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1270
"/ to make cursor visible (even if below visible end):
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1271
"/
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1272
"/      self makeCursorVisibleAndShowCursor:wasOn.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1273
    ]
672
065750d02339 added cursorCol-validation
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  1274
674
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  1275
    "Modified: 22.5.1996 / 18:28:11 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1276
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1277
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1278
cursorVisibleLine:visibleLineNr col:colNr
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1279
    "put cursor to visibleline/col"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1280
676
b65b82a1ffcb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
  1281
    |wasOn newCol|
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1282
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1283
    wasOn := self hideCursor.
674
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  1284
    cursorLine := self validateCursorLine:(self visibleLineToAbsoluteLine:visibleLineNr).
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1285
    cursorVisibleLine := visibleLineNr.
676
b65b82a1ffcb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
  1286
    newCol := colNr.
b65b82a1ffcb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
  1287
    (newCol < 1) ifTrue:[
1597
5fdcfcedb91c fixed cursor positioning after replaceStringAtCursor.
Claus Gittinger <cg@exept.de>
parents: 1596
diff changeset
  1288
        newCol := 1
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1289
    ].
676
b65b82a1ffcb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
  1290
    cursorCol := self validateCursorCol:newCol inLine:cursorLine.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1291
    self makeCursorVisibleAndShowCursor:wasOn.
672
065750d02339 added cursorCol-validation
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  1292
1597
5fdcfcedb91c fixed cursor positioning after replaceStringAtCursor.
Claus Gittinger <cg@exept.de>
parents: 1596
diff changeset
  1293
    "Modified: / 20.6.1998 / 18:40:28 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1294
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1295
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1296
cursorX:x y:y
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1297
    "put cursor to position next to x/y coordinate in view"
121
claus
parents: 118
diff changeset
  1298
claus
parents: 118
diff changeset
  1299
    |line col|
claus
parents: 118
diff changeset
  1300
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1301
    line := self visibleLineOfY:y.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1302
    col := self colOfX:x inVisibleLine:line.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1303
    self cursorVisibleLine:line col:col.
121
claus
parents: 118
diff changeset
  1304
!
claus
parents: 118
diff changeset
  1305
claus
parents: 118
diff changeset
  1306
drawCursor
claus
parents: 118
diff changeset
  1307
    "draw the cursor if shown and cursor is visible.
claus
parents: 118
diff changeset
  1308
     (but not, if there is a selection - to avoid confusion)"
claus
parents: 118
diff changeset
  1309
claus
parents: 118
diff changeset
  1310
    shown ifTrue:[
claus
parents: 118
diff changeset
  1311
	cursorVisibleLine notNil ifTrue:[
claus
parents: 118
diff changeset
  1312
	    self hasSelection ifFalse:[
claus
parents: 118
diff changeset
  1313
		self drawCursorCharacter
claus
parents: 118
diff changeset
  1314
	    ]
claus
parents: 118
diff changeset
  1315
	]
claus
parents: 118
diff changeset
  1316
    ]
claus
parents: 118
diff changeset
  1317
!
claus
parents: 118
diff changeset
  1318
claus
parents: 118
diff changeset
  1319
drawCursor:cursorType with:fgColor and:bgColor
claus
parents: 118
diff changeset
  1320
    "draw a cursor; the argument cursorType specifies what type
125
claus
parents: 123
diff changeset
  1321
     of cursor should be drawn.
728
3ef81000ee8c new cursorTypes: #bigCaret and #bigSolidCaret
Claus Gittinger <cg@exept.de>
parents: 698
diff changeset
  1322
     Currently, supported are: #block, #frame, #ibeam, #caret, #solidCaret
1449
2a54bdfff203 eliminated direct refs to paint instvar
Claus Gittinger <cg@exept.de>
parents: 1446
diff changeset
  1323
                               #bigCaret and #bigSolidCaret"
121
claus
parents: 118
diff changeset
  1324
666
9ac9adb80415 clip at margin when drawing a caret cursor
Claus Gittinger <cg@exept.de>
parents: 662
diff changeset
  1325
    |x y w char y2 x1 x2 oldPaint oldClip|
121
claus
parents: 118
diff changeset
  1326
claus
parents: 118
diff changeset
  1327
    self hasSelection ifTrue:[
1449
2a54bdfff203 eliminated direct refs to paint instvar
Claus Gittinger <cg@exept.de>
parents: 1446
diff changeset
  1328
        "
2a54bdfff203 eliminated direct refs to paint instvar
Claus Gittinger <cg@exept.de>
parents: 1446
diff changeset
  1329
         hide cursor, if there is a selection
2a54bdfff203 eliminated direct refs to paint instvar
Claus Gittinger <cg@exept.de>
parents: 1446
diff changeset
  1330
        "
2a54bdfff203 eliminated direct refs to paint instvar
Claus Gittinger <cg@exept.de>
parents: 1446
diff changeset
  1331
        ^ super redrawVisibleLine:cursorVisibleLine col:cursorCol.
121
claus
parents: 118
diff changeset
  1332
    ].
claus
parents: 118
diff changeset
  1333
1334
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  1334
    cursorType == #none ifTrue:[
1449
2a54bdfff203 eliminated direct refs to paint instvar
Claus Gittinger <cg@exept.de>
parents: 1446
diff changeset
  1335
        ^ self
1334
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  1336
    ].
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  1337
121
claus
parents: 118
diff changeset
  1338
    cursorType == #block ifTrue:[
1449
2a54bdfff203 eliminated direct refs to paint instvar
Claus Gittinger <cg@exept.de>
parents: 1446
diff changeset
  1339
        super drawVisibleLine:cursorVisibleLine 
2a54bdfff203 eliminated direct refs to paint instvar
Claus Gittinger <cg@exept.de>
parents: 1446
diff changeset
  1340
                          col:cursorCol 
2a54bdfff203 eliminated direct refs to paint instvar
Claus Gittinger <cg@exept.de>
parents: 1446
diff changeset
  1341
                         with:fgColor
2a54bdfff203 eliminated direct refs to paint instvar
Claus Gittinger <cg@exept.de>
parents: 1446
diff changeset
  1342
                          and:bgColor.
2a54bdfff203 eliminated direct refs to paint instvar
Claus Gittinger <cg@exept.de>
parents: 1446
diff changeset
  1343
        ^ self
121
claus
parents: 118
diff changeset
  1344
    ].
claus
parents: 118
diff changeset
  1345
    x := (self xOfCol:cursorCol inVisibleLine:cursorVisibleLine) - leftOffset.
claus
parents: 118
diff changeset
  1346
    y := self yOfVisibleLine:cursorVisibleLine.
claus
parents: 118
diff changeset
  1347
1449
2a54bdfff203 eliminated direct refs to paint instvar
Claus Gittinger <cg@exept.de>
parents: 1446
diff changeset
  1348
    oldPaint := self paint. "/ do not clobber GC
121
claus
parents: 118
diff changeset
  1349
    cursorType == #frame ifTrue:[
1449
2a54bdfff203 eliminated direct refs to paint instvar
Claus Gittinger <cg@exept.de>
parents: 1446
diff changeset
  1350
        super redrawVisibleLine:cursorVisibleLine col:cursorCol.
2a54bdfff203 eliminated direct refs to paint instvar
Claus Gittinger <cg@exept.de>
parents: 1446
diff changeset
  1351
2a54bdfff203 eliminated direct refs to paint instvar
Claus Gittinger <cg@exept.de>
parents: 1446
diff changeset
  1352
        char := self characterUnderCursor asString.
2a54bdfff203 eliminated direct refs to paint instvar
Claus Gittinger <cg@exept.de>
parents: 1446
diff changeset
  1353
        self paint:bgColor.
2a54bdfff203 eliminated direct refs to paint instvar
Claus Gittinger <cg@exept.de>
parents: 1446
diff changeset
  1354
        self displayRectangleX:x y:y 
2a54bdfff203 eliminated direct refs to paint instvar
Claus Gittinger <cg@exept.de>
parents: 1446
diff changeset
  1355
                         width:(font widthOf:char) height:fontHeight.
133
claus
parents: 132
diff changeset
  1356
    ] ifFalse:[
1449
2a54bdfff203 eliminated direct refs to paint instvar
Claus Gittinger <cg@exept.de>
parents: 1446
diff changeset
  1357
        self paint:bgColor.
2a54bdfff203 eliminated direct refs to paint instvar
Claus Gittinger <cg@exept.de>
parents: 1446
diff changeset
  1358
        cursorType == #ibeam ifTrue:[
2a54bdfff203 eliminated direct refs to paint instvar
Claus Gittinger <cg@exept.de>
parents: 1446
diff changeset
  1359
            x1 := x - 1.
2a54bdfff203 eliminated direct refs to paint instvar
Claus Gittinger <cg@exept.de>
parents: 1446
diff changeset
  1360
            y2 := y + fontHeight - 1.
2a54bdfff203 eliminated direct refs to paint instvar
Claus Gittinger <cg@exept.de>
parents: 1446
diff changeset
  1361
            self displayLineFromX:x1 y:y toX:x1 y:y2. 
2a54bdfff203 eliminated direct refs to paint instvar
Claus Gittinger <cg@exept.de>
parents: 1446
diff changeset
  1362
            self displayLineFromX:x y:y toX:x y:y2. 
2a54bdfff203 eliminated direct refs to paint instvar
Claus Gittinger <cg@exept.de>
parents: 1446
diff changeset
  1363
            ^ self
2a54bdfff203 eliminated direct refs to paint instvar
Claus Gittinger <cg@exept.de>
parents: 1446
diff changeset
  1364
        ] ifFalse:[
2a54bdfff203 eliminated direct refs to paint instvar
Claus Gittinger <cg@exept.de>
parents: 1446
diff changeset
  1365
            y := y + fontHeight - 3.
2a54bdfff203 eliminated direct refs to paint instvar
Claus Gittinger <cg@exept.de>
parents: 1446
diff changeset
  1366
            ((cursorType == #bigCaret) or:[cursorType == #bigSolidCaret]) ifTrue:[
2a54bdfff203 eliminated direct refs to paint instvar
Claus Gittinger <cg@exept.de>
parents: 1446
diff changeset
  1367
                w := (fontWidth * 2 // 3) max:4.
2a54bdfff203 eliminated direct refs to paint instvar
Claus Gittinger <cg@exept.de>
parents: 1446
diff changeset
  1368
                y2 := y + w + (w//2).
2a54bdfff203 eliminated direct refs to paint instvar
Claus Gittinger <cg@exept.de>
parents: 1446
diff changeset
  1369
            ] ifFalse:[
2a54bdfff203 eliminated direct refs to paint instvar
Claus Gittinger <cg@exept.de>
parents: 1446
diff changeset
  1370
                w := (fontWidth // 2) max:4.
2a54bdfff203 eliminated direct refs to paint instvar
Claus Gittinger <cg@exept.de>
parents: 1446
diff changeset
  1371
                y2 := y + w.
2a54bdfff203 eliminated direct refs to paint instvar
Claus Gittinger <cg@exept.de>
parents: 1446
diff changeset
  1372
            ].
2a54bdfff203 eliminated direct refs to paint instvar
Claus Gittinger <cg@exept.de>
parents: 1446
diff changeset
  1373
            x1 := x - w.
2a54bdfff203 eliminated direct refs to paint instvar
Claus Gittinger <cg@exept.de>
parents: 1446
diff changeset
  1374
            x2 := x + w.
2a54bdfff203 eliminated direct refs to paint instvar
Claus Gittinger <cg@exept.de>
parents: 1446
diff changeset
  1375
2a54bdfff203 eliminated direct refs to paint instvar
Claus Gittinger <cg@exept.de>
parents: 1446
diff changeset
  1376
            oldClip := self clippingRectangleOrNil.
2a54bdfff203 eliminated direct refs to paint instvar
Claus Gittinger <cg@exept.de>
parents: 1446
diff changeset
  1377
            self clippingRectangle:(margin@margin extent:(width-margin) @ (height-margin)).
2a54bdfff203 eliminated direct refs to paint instvar
Claus Gittinger <cg@exept.de>
parents: 1446
diff changeset
  1378
2a54bdfff203 eliminated direct refs to paint instvar
Claus Gittinger <cg@exept.de>
parents: 1446
diff changeset
  1379
            cursorType == #caret ifTrue:[
2a54bdfff203 eliminated direct refs to paint instvar
Claus Gittinger <cg@exept.de>
parents: 1446
diff changeset
  1380
                self lineWidth:2.
2a54bdfff203 eliminated direct refs to paint instvar
Claus Gittinger <cg@exept.de>
parents: 1446
diff changeset
  1381
                self displayLineFromX:x1 y:y2 toX:x y:y. 
2a54bdfff203 eliminated direct refs to paint instvar
Claus Gittinger <cg@exept.de>
parents: 1446
diff changeset
  1382
                self displayLineFromX:x y:y toX:x2 y:y2. 
2a54bdfff203 eliminated direct refs to paint instvar
Claus Gittinger <cg@exept.de>
parents: 1446
diff changeset
  1383
            ] ifFalse:[
2a54bdfff203 eliminated direct refs to paint instvar
Claus Gittinger <cg@exept.de>
parents: 1446
diff changeset
  1384
                "anything else: solidCaret"
2a54bdfff203 eliminated direct refs to paint instvar
Claus Gittinger <cg@exept.de>
parents: 1446
diff changeset
  1385
2a54bdfff203 eliminated direct refs to paint instvar
Claus Gittinger <cg@exept.de>
parents: 1446
diff changeset
  1386
                self fillPolygon:(Array with:(x1 @ y2)
2a54bdfff203 eliminated direct refs to paint instvar
Claus Gittinger <cg@exept.de>
parents: 1446
diff changeset
  1387
                                        with:(x @ y)
2a54bdfff203 eliminated direct refs to paint instvar
Claus Gittinger <cg@exept.de>
parents: 1446
diff changeset
  1388
                                        with:(x2 @ y2))
2a54bdfff203 eliminated direct refs to paint instvar
Claus Gittinger <cg@exept.de>
parents: 1446
diff changeset
  1389
            ].
2a54bdfff203 eliminated direct refs to paint instvar
Claus Gittinger <cg@exept.de>
parents: 1446
diff changeset
  1390
2a54bdfff203 eliminated direct refs to paint instvar
Claus Gittinger <cg@exept.de>
parents: 1446
diff changeset
  1391
            self clippingRectangle:oldClip
2a54bdfff203 eliminated direct refs to paint instvar
Claus Gittinger <cg@exept.de>
parents: 1446
diff changeset
  1392
        ]
121
claus
parents: 118
diff changeset
  1393
    ].
133
claus
parents: 132
diff changeset
  1394
    self paint:oldPaint.
662
4bcdf0cce3a7 dont let caret cursor become too small (with small fonts)
Claus Gittinger <cg@exept.de>
parents: 655
diff changeset
  1395
1022
4362861fe15e allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents: 1018
diff changeset
  1396
    "Modified: 18.2.1997 / 15:19:03 / cg"
121
claus
parents: 118
diff changeset
  1397
!
claus
parents: 118
diff changeset
  1398
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1399
drawCursorCharacter
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1400
    "draw the cursor. 
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1401
     (i.e. the cursor if no selection)
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1402
     - helper for many cursor methods"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1403
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1404
    hasKeyboardFocus ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1405
	self drawFocusCursor
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1406
    ] ifFalse:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1407
	self drawNoFocusCursor
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1408
    ]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1409
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1410
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1411
drawFocusCursor
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1412
    "draw the cursor when the focus is in the view."
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1413
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1414
    self hasSelection ifTrue:[
1415
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1415
	^ super redrawVisibleLine:cursorVisibleLine col:cursorCol.
1334
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  1416
    ].
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  1417
    cursorType == #none ifTrue:[
1415
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1418
	^ self undrawCursor
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1419
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1420
    self drawCursor:cursorType with:cursorFgColor and:cursorBgColor.
1334
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  1421
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  1422
    "Modified: 22.9.1997 / 00:16:38 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1423
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1424
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1425
drawNoFocusCursor
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1426
    "draw the cursor for the case when the view has no keyboard focus" 
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1427
1334
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  1428
    |cType|
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  1429
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1430
    self hasSelection ifTrue:[
1415
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1431
	^ super redrawVisibleLine:cursorVisibleLine col:cursorCol.
121
claus
parents: 118
diff changeset
  1432
    ].
1022
4362861fe15e allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents: 1018
diff changeset
  1433
1334
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  1434
    cType := cursorTypeNoFocus ? cursorType.
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  1435
    cType == #none ifTrue:[
1415
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1436
	^ self undrawCursor
1334
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  1437
    ].
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  1438
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  1439
    cType == #block ifTrue:[
1415
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1440
	^ self drawCursor:#frame with:cursorNoFocusFgColor and:cursorBgColor
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1441
    ].
1022
4362861fe15e allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents: 1018
diff changeset
  1442
1334
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  1443
    ^ self drawCursor:cType with:cursorNoFocusFgColor and:cursorNoFocusFgColor.
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  1444
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  1445
    "Modified: 22.9.1997 / 00:16:13 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1446
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1447
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1448
gotoLine:aLineNumber
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1449
    "position cursor onto line, aLineNumber.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1450
     Make certain that this line is visible"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1451
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1452
    self makeLineVisible:aLineNumber.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1453
    self cursorLine:aLineNumber col:1
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1454
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1455
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1456
hideCursor
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1457
    "make cursor invisible if currently visible; 
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1458
     return true if cursor was visible before."
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1459
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1460
    cursorShown ifTrue: [
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1461
	shown ifTrue: [
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1462
	    self undrawCursor.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1463
	].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1464
	cursorShown := false.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1465
	^ true
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1466
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1467
    ^ false
121
claus
parents: 118
diff changeset
  1468
!
claus
parents: 118
diff changeset
  1469
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1470
makeCursorVisible
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1471
    "scroll text to make cursorline visible 
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1472
     (i.e. to have cursorLine in visible area)"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1473
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1474
    |line col|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1475
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1476
    cursorLine notNil ifTrue:[
1415
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1477
	line := cursorLine.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1478
	col := cursorCol.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1479
	"
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1480
	 if there is a selection, its better to
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1481
	 have its start being visible, instead of the end
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1482
	"
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1483
	(selectionStartLine notNil 
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1484
	and:[selectionEndLine notNil]) ifTrue:[
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1485
	    expandingTop ~~ false ifTrue:[
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1486
		line := selectionStartLine.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1487
		col := selectionStartCol.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1488
	    ] ifFalse:[
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1489
		line := selectionEndLine.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1490
		col := selectionEndCol
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1491
	    ]
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1492
	].
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1493
	self makeLineVisible:line.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1494
	self makeColVisible:col inLine:line 
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1495
    ]
479
fae6d1251888 fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 477
diff changeset
  1496
fae6d1251888 fixed Shift-Cursor selection & show another cursor when matching parents
Claus Gittinger <cg@exept.de>
parents: 477
diff changeset
  1497
    "Modified: 6.3.1996 / 13:46:46 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1498
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1499
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1500
makeCursorVisibleAndShowCursor:flag
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1501
    "scroll to make cursorLine visible;
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1502
     if flag is true, draw the cursor"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1503
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1504
    self makeCursorVisible.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1505
    flag ifTrue:[self showCursor]
121
claus
parents: 118
diff changeset
  1506
!
claus
parents: 118
diff changeset
  1507
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1508
showCursor
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1509
    "make cursor visible if currently invisible"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1510
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1511
    cursorShown ifFalse: [
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1512
	self drawCursor.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1513
	cursorShown := true
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1514
    ]
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
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1517
undrawCursor
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1518
    "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
  1519
1495
3b79070e35e4 fixed drawing of italics under cursor
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1520
    |prevCol line oldClip x y|
1022
4362861fe15e allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents: 1018
diff changeset
  1521
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1522
    cursorVisibleLine notNil ifTrue:[
1495
3b79070e35e4 fixed drawing of italics under cursor
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1523
        prevCol := cursorCol - 1.
3b79070e35e4 fixed drawing of italics under cursor
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1524
3b79070e35e4 fixed drawing of italics under cursor
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1525
        ((cursorType == #caret)
3b79070e35e4 fixed drawing of italics under cursor
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1526
         or:[cursorType == #solidCaret
3b79070e35e4 fixed drawing of italics under cursor
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1527
         or:[cursorType == #bigSolidCaret
3b79070e35e4 fixed drawing of italics under cursor
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1528
         or:[cursorType == #bigCaret]]]) ifTrue:[
3b79070e35e4 fixed drawing of italics under cursor
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1529
            "caret-cursor touches 4 characters"
3b79070e35e4 fixed drawing of italics under cursor
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1530
            ((cursorCol > 1) and:[fontIsFixedWidth]) ifTrue:[
3b79070e35e4 fixed drawing of italics under cursor
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1531
                super redrawVisibleLine:cursorVisibleLine from:prevCol to:cursorCol.
3b79070e35e4 fixed drawing of italics under cursor
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1532
                super redrawVisibleLine:cursorVisibleLine+1 from:prevCol to:cursorCol.
3b79070e35e4 fixed drawing of italics under cursor
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1533
            ] ifFalse:[
3b79070e35e4 fixed drawing of italics under cursor
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1534
                "care for left margin"
3b79070e35e4 fixed drawing of italics under cursor
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1535
                super redrawVisibleLine:cursorVisibleLine; redrawVisibleLine:cursorVisibleLine+1.
3b79070e35e4 fixed drawing of italics under cursor
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1536
            ].
3b79070e35e4 fixed drawing of italics under cursor
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1537
            ^ self
3b79070e35e4 fixed drawing of italics under cursor
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1538
        ].
3b79070e35e4 fixed drawing of italics under cursor
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1539
3b79070e35e4 fixed drawing of italics under cursor
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1540
        cursorType == #ibeam ifTrue:[
3b79070e35e4 fixed drawing of italics under cursor
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1541
            "ibeam-cursor touches 2 characters"
3b79070e35e4 fixed drawing of italics under cursor
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1542
            cursorCol > 1 ifTrue:[
3b79070e35e4 fixed drawing of italics under cursor
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1543
                super redrawVisibleLine:cursorVisibleLine from:prevCol to:cursorCol.
3b79070e35e4 fixed drawing of italics under cursor
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1544
            ] ifFalse:[
3b79070e35e4 fixed drawing of italics under cursor
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1545
                "care for left margin"
3b79070e35e4 fixed drawing of italics under cursor
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1546
                super redrawVisibleLine:cursorVisibleLine.
3b79070e35e4 fixed drawing of italics under cursor
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1547
            ].
3b79070e35e4 fixed drawing of italics under cursor
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1548
            ^ self
3b79070e35e4 fixed drawing of italics under cursor
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1549
        ].
3b79070e35e4 fixed drawing of italics under cursor
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1550
3b79070e35e4 fixed drawing of italics under cursor
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1551
        "block cursor is simple - just one character under cursor"
3b79070e35e4 fixed drawing of italics under cursor
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1552
3b79070e35e4 fixed drawing of italics under cursor
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1553
        "/ however, if italic characters are involved, we must care
3b79070e35e4 fixed drawing of italics under cursor
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1554
        "/ for the chars before/after the cursor.
3b79070e35e4 fixed drawing of italics under cursor
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1555
        "/ We redraw the part of the previous character which got
3b79070e35e4 fixed drawing of italics under cursor
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1556
        "/ detroyed by the block cursor.
3b79070e35e4 fixed drawing of italics under cursor
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1557
        "/ (must change the clip, to avoid destroying the prev-prev character) 
3b79070e35e4 fixed drawing of italics under cursor
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1558
3b79070e35e4 fixed drawing of italics under cursor
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1559
        line := self visibleAt:cursorVisibleLine.
3b79070e35e4 fixed drawing of italics under cursor
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1560
        (line notNil and:[line isText]) ifTrue:[
3b79070e35e4 fixed drawing of italics under cursor
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1561
            cursorCol > 1 ifTrue:[
3b79070e35e4 fixed drawing of italics under cursor
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1562
                oldClip := self clippingRectangleOrNil.
3b79070e35e4 fixed drawing of italics under cursor
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1563
                x := (self xOfCol:cursorCol inVisibleLine:cursorVisibleLine) - leftOffset.
3b79070e35e4 fixed drawing of italics under cursor
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1564
                y := self yOfVisibleLine:cursorVisibleLine.
3b79070e35e4 fixed drawing of italics under cursor
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1565
                self clippingRectangle:(x@y extent:((font width) @ fontHeight)).
3b79070e35e4 fixed drawing of italics under cursor
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1566
                super redrawVisibleLine:cursorVisibleLine from:cursorCol-1 to:cursorCol.
3b79070e35e4 fixed drawing of italics under cursor
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1567
                self clippingRectangle:oldClip.
3b79070e35e4 fixed drawing of italics under cursor
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1568
                ^ self.
3b79070e35e4 fixed drawing of italics under cursor
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1569
            ].
3b79070e35e4 fixed drawing of italics under cursor
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1570
        ].
3b79070e35e4 fixed drawing of italics under cursor
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1571
        super redrawVisibleLine:cursorVisibleLine col:cursorCol
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1572
    ]
728
3ef81000ee8c new cursorTypes: #bigCaret and #bigSolidCaret
Claus Gittinger <cg@exept.de>
parents: 698
diff changeset
  1573
1495
3b79070e35e4 fixed drawing of italics under cursor
Claus Gittinger <cg@exept.de>
parents: 1480
diff changeset
  1574
    "Modified: / 22.4.1998 / 09:13:07 / cg"
121
claus
parents: 118
diff changeset
  1575
!
claus
parents: 118
diff changeset
  1576
672
065750d02339 added cursorCol-validation
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  1577
validateCursorCol:col inLine:line
674
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  1578
    "check of col is a valid cursor position; return a new col-nr if not.
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  1579
     Here, no limits are enforced (and col is returned), 
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  1580
     but it may be redefined in EditFields or views which dont like the 
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  1581
     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
  1582
1300
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  1583
    |l max|
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  1584
1419
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
  1585
    "/ in ST80 mode,
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
  1586
    "/ the cursor may not be positioned behond the
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
  1587
    "/ end of a line or behond the last line of the text
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
  1588
    "/
1596
0bbdb4e9fc43 made st80Mode also an inst-flag;
Claus Gittinger <cg@exept.de>
parents: 1591
diff changeset
  1589
    st80Mode == true ifTrue:[
0bbdb4e9fc43 made st80Mode also an inst-flag;
Claus Gittinger <cg@exept.de>
parents: 1591
diff changeset
  1590
        l := (self listAt:line).
0bbdb4e9fc43 made st80Mode also an inst-flag;
Claus Gittinger <cg@exept.de>
parents: 1591
diff changeset
  1591
        max := l size + 1.
0bbdb4e9fc43 made st80Mode also an inst-flag;
Claus Gittinger <cg@exept.de>
parents: 1591
diff changeset
  1592
        col > max ifTrue:[
0bbdb4e9fc43 made st80Mode also an inst-flag;
Claus Gittinger <cg@exept.de>
parents: 1591
diff changeset
  1593
            ^ max
0bbdb4e9fc43 made st80Mode also an inst-flag;
Claus Gittinger <cg@exept.de>
parents: 1591
diff changeset
  1594
        ]
1300
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  1595
    ].
672
065750d02339 added cursorCol-validation
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  1596
    ^ col
065750d02339 added cursorCol-validation
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  1597
1419
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
  1598
    "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
  1599
    "Modified: / 20.6.1998 / 18:19:24 / cg"
674
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  1600
!
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  1601
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  1602
validateCursorLine:line
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  1603
    "check of line is a valid cursor line; return a fixed line-nr if not.
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  1604
     Here, no limits are enforced (and line is returned), but it may be 
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  1605
     redefined in views which dont like the cursor to be positioned
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  1606
     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
  1607
     skip reserved regions"
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  1608
1419
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
  1609
    "/
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
  1610
    "/ in st80Mode, the cursor may not be positioned
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
  1611
    "/ behond the last line
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
  1612
    "/
1596
0bbdb4e9fc43 made st80Mode also an inst-flag;
Claus Gittinger <cg@exept.de>
parents: 1591
diff changeset
  1613
    st80Mode == true ifTrue:[
0bbdb4e9fc43 made st80Mode also an inst-flag;
Claus Gittinger <cg@exept.de>
parents: 1591
diff changeset
  1614
        ^ (line min:(list size)) max:1
1419
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
  1615
    ].
674
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  1616
    ^ line
247db5b61407 added cursor-line validation
Claus Gittinger <cg@exept.de>
parents: 672
diff changeset
  1617
1419
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
  1618
    "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
  1619
    "Modified: / 20.6.1998 / 18:19:26 / cg"
672
065750d02339 added cursorCol-validation
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  1620
!
065750d02339 added cursorCol-validation
Claus Gittinger <cg@exept.de>
parents: 671
diff changeset
  1621
121
claus
parents: 118
diff changeset
  1622
withCursorOffDo:aBlock
claus
parents: 118
diff changeset
  1623
    "evaluate aBlock with cursor off; turn it on afterwards."
claus
parents: 118
diff changeset
  1624
claus
parents: 118
diff changeset
  1625
    (shown not or:[cursorShown not]) ifTrue:[
claus
parents: 118
diff changeset
  1626
	^ aBlock value
claus
parents: 118
diff changeset
  1627
    ].
claus
parents: 118
diff changeset
  1628
    self hideCursor.
claus
parents: 118
diff changeset
  1629
    aBlock valueNowOrOnUnwindDo:[
claus
parents: 118
diff changeset
  1630
	self showCursor
claus
parents: 118
diff changeset
  1631
    ]
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1632
! !
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1633
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1634
!EditTextView methodsFor:'editing'!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1635
313
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  1636
copyAndDeleteSelection
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  1637
    "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
  1638
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  1639
    selectionStartLine notNil ifTrue:[
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  1640
	self setTextSelection:(self selection).
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  1641
	self deleteSelection.
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  1642
    ].
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  1643
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  1644
    "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
  1645
!
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  1646
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1647
deleteCharAtCursor
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1648
    "delete single character under cursor; does not merge lines"
121
claus
parents: 118
diff changeset
  1649
claus
parents: 118
diff changeset
  1650
    |wasOn|
claus
parents: 118
diff changeset
  1651
claus
parents: 118
diff changeset
  1652
    wasOn := self hideCursor.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1653
    self deleteCharAtLine:cursorLine col:cursorCol.
121
claus
parents: 118
diff changeset
  1654
    wasOn ifTrue:[self showCursor]
claus
parents: 118
diff changeset
  1655
!
claus
parents: 118
diff changeset
  1656
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1657
deleteCharAtLine:lineNr col:colNr
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1658
    "delete a single character at colNr in line lineNr"
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1659
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1660
    self deleteCharsAtLine:lineNr fromCol:colNr toCol:colNr
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1661
!
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1662
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1663
deleteCharBeforeCursor
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1664
    "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
  1665
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1666
    |soCol wasOn lineNrAboveCursor ln|
121
claus
parents: 118
diff changeset
  1667
claus
parents: 118
diff changeset
  1668
    wasOn := self hideCursor.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1669
1415
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1670
	(autoIndent
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1671
    and:[cursorCol  ~~ 1
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1672
    and:[cursorLine <= (list size)]]) 
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1673
     ifTrue:[
1415
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1674
	soCol := (self leftIndentForLine:cursorLine) + 1.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1675
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1676
	(cursorCol == soCol and:[soCol > 1]) ifTrue:[
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1677
	    ln := list at:cursorLine.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1678
	    (ln notNil and:[(ln indexOfNonSeparatorStartingAt:1) < soCol]) ifTrue:[
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1679
		soCol := 1
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1680
	    ]
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1681
	]
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1682
    ] ifFalse:[
1415
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1683
	soCol := 1
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1684
    ].
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1685
1419
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
  1686
    (cursorCol ~~ soCol and:[cursorCol ~~ 1]) ifTrue:[
1415
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1687
	"
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1688
	 somewhere in the middle of a line
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1689
	"
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1690
	self cursorLeft.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1691
	self deleteCharAtLine:cursorLine col:cursorCol.
1419
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
  1692
    ] ifFalse:[
1415
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1693
	"
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1694
	 at begin of line - merge with previous line;
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1695
	 except for the very first line.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1696
	"
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1697
	(cursorLine == 1) ifFalse:[
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1698
	    lineNrAboveCursor := self validateCursorLine:(cursorLine - 1).
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1699
	    lineNrAboveCursor < cursorLine ifTrue:[
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1700
		self mergeLine:lineNrAboveCursor removeBlanks:false.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1701
	    ]
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1702
	]
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1703
    ].
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1704
    wasOn ifTrue:[ self showCursor ]
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1705
1419
3aec8008e0a6 more for st80Mode
Claus Gittinger <cg@exept.de>
parents: 1415
diff changeset
  1706
    "Modified: / 16.1.1998 / 22:33:04 / cg"
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1707
!
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1708
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1709
deleteCharsAtLine:lineNr fromCol:colNr
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1710
    "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
  1711
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1712
    |line|
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1713
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1714
    (line := self listAt:lineNr) notNil ifTrue:[
1415
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1715
	self deleteCharsAtLine:lineNr fromCol:colNr toCol:(line size)
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1716
    ]
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1717
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1718
!
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1719
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1720
deleteCharsAtLine:lineNr toCol:colNr
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1721
    "delete characters from start up to colNr in line lineNr"
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1722
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1723
    self deleteCharsAtLine:lineNr fromCol:1 toCol:colNr
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1724
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1725
121
claus
parents: 118
diff changeset
  1726
!
claus
parents: 118
diff changeset
  1727
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1728
deleteCursorLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1729
    "delete the line where the cursor sits"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1730
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1731
    self deleteLine:cursorLine
121
claus
parents: 118
diff changeset
  1732
!
claus
parents: 118
diff changeset
  1733
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1734
deleteLine:lineNr
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1735
    "delete line"
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1736
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1737
    self deleteFromLine:lineNr toLine:lineNr
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1738
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1739
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1740
!
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  1741
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1742
deleteLinesWithoutRedrawFrom:startLine to:endLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1743
    "delete lines - no redraw;
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1744
     return true, if something was really deleted"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1745
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1746
    |lastLine|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1747
331
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
  1748
    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
  1749
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1750
    (list isNil or:[startLine > list size]) ifTrue:[^ false].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1751
    (endLine > list size) ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1752
	lastLine := list size
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1753
    ] ifFalse:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1754
	lastLine := endLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1755
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1756
    list removeFromIndex:startLine toIndex:lastLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1757
    widthOfWidestLine := nil. "/ i.e. unknown
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1758
    self textChanged.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1759
    ^ true
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1760
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1761
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1762
deleteSelection
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1763
    "delete the selection"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1764
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1765
    |wasOn startLine startCol endLine endCol|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1766
331
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
  1767
    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
  1768
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1769
    selectionStartLine notNil ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1770
	wasOn := self hideCursor.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1771
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1772
	startLine := selectionStartLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1773
	startCol := selectionStartCol.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1774
	endLine := selectionEndLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1775
	endCol := selectionEndCol.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1776
	self unselectWithoutRedraw.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1777
	self deleteFromLine:startLine col:startCol 
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1778
		     toLine:endLine col:endCol.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1779
	cursorCol := startCol.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1780
	cursorLine := startLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1781
	cursorVisibleLine := self listLineToVisibleLine:cursorLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1782
	self makeCursorVisibleAndShowCursor:wasOn
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1783
    ]
121
claus
parents: 118
diff changeset
  1784
!
claus
parents: 118
diff changeset
  1785
claus
parents: 118
diff changeset
  1786
insertCharAtCursor:aCharacter
1566
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  1787
    "insert a single character at cursor-position - advance cursor."
121
claus
parents: 118
diff changeset
  1788
claus
parents: 118
diff changeset
  1789
    |wasOn|
claus
parents: 118
diff changeset
  1790
claus
parents: 118
diff changeset
  1791
    wasOn := self hideCursor.
1566
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  1792
    aCharacter == Character tab ifTrue:[
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  1793
        "/ needs special care to advance cursor correctly
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  1794
        self insertTabAtCursor
121
claus
parents: 118
diff changeset
  1795
    ] ifFalse:[
1566
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  1796
        self insert:aCharacter atLine:cursorLine col:cursorCol.
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  1797
        aCharacter == (Character cr) ifTrue:[
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  1798
            self cursorReturn
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  1799
        ] ifFalse:[
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  1800
            self cursorRight.
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  1801
        ].
121
claus
parents: 118
diff changeset
  1802
    ].
claus
parents: 118
diff changeset
  1803
    self makeCursorVisibleAndShowCursor:wasOn.
1566
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  1804
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  1805
    "Modified: / 12.6.1998 / 21:50:20 / cg"
121
claus
parents: 118
diff changeset
  1806
!
claus
parents: 118
diff changeset
  1807
641
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  1808
insertLine:aString before:lineNr
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  1809
    "insert the line aString before line lineNr"
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  1810
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  1811
    ^ self insertLines:(Array with:aString) from:1 to:1  before:lineNr.
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  1812
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  1813
    "Modified: 14.5.1996 / 13:42:54 / cg"
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  1814
!
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  1815
155
claus
parents: 133
diff changeset
  1816
insertLines:aStringCollection before:lineNr
claus
parents: 133
diff changeset
  1817
    "insert a bunch before line lineNr"
claus
parents: 133
diff changeset
  1818
claus
parents: 133
diff changeset
  1819
    self insertLines:aStringCollection from:1 to:aStringCollection size before:lineNr
claus
parents: 133
diff changeset
  1820
claus
parents: 133
diff changeset
  1821
    "Modified: 6.9.1995 / 20:51:03 / claus"
claus
parents: 133
diff changeset
  1822
!
claus
parents: 133
diff changeset
  1823
654
d621e63baaa5 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 641
diff changeset
  1824
insertLines:lines withCR:withCr
1566
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  1825
    "insert a bunch of lines at cursor position. 
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  1826
     Cursor is moved behind insertion.
641
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  1827
     If withCr is true, append cr after last line"
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  1828
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  1829
    |start end nLines wasOn|
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  1830
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  1831
    lines notNil ifTrue:[
1566
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  1832
        nLines := lines size.
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  1833
        (nLines == 1) ifTrue:[
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  1834
            self insertStringAtCursor:(lines at:1).
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  1835
            withCr ifTrue:[
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  1836
                self insertCharAtCursor:(Character cr)
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  1837
            ] 
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  1838
        ] ifFalse:[
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  1839
            (cursorCol ~~ 1) ifTrue:[
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  1840
                self insertStringAtCursor:(lines at:1).
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  1841
                self insertCharAtCursor:(Character cr).
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  1842
                start := 2
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  1843
            ] ifFalse:[
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  1844
                start := 1
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  1845
            ].
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  1846
            withCr ifTrue:[
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  1847
                end := nLines
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  1848
            ] ifFalse:[
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  1849
                end := nLines - 1
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  1850
            ].
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  1851
            (start < nLines) ifTrue:[
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  1852
                (end >= start) ifTrue:[
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  1853
                    wasOn := self hideCursor.
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  1854
                    self insertLines:lines from:start to:end before:cursorLine.
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  1855
                    cursorLine := cursorLine + (end - start + 1).
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  1856
                    cursorVisibleLine := self absoluteLineToVisibleLine:cursorLine.
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  1857
                    wasOn ifTrue:[self showCursor].
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  1858
                ]
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  1859
            ].
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  1860
            withCr ifFalse:[
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  1861
                "last line without cr"
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  1862
                self insertStringAtCursor:(lines at:nLines)
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  1863
            ]
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  1864
        ]
641
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  1865
    ]
654
d621e63baaa5 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 641
diff changeset
  1866
1566
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  1867
    "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
  1868
    "Modified: / 12.6.1998 / 21:51:16 / cg"
654
d621e63baaa5 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 641
diff changeset
  1869
!
d621e63baaa5 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 641
diff changeset
  1870
d621e63baaa5 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 641
diff changeset
  1871
insertLines:lines withCr:withCr
d621e63baaa5 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 641
diff changeset
  1872
    "insert a bunch of lines at cursor position. Cursor
d621e63baaa5 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 641
diff changeset
  1873
     is moved behind insertion.
d621e63baaa5 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 641
diff changeset
  1874
     If withCr is true, append cr after last line"
d621e63baaa5 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 641
diff changeset
  1875
1292
ca4c9a957a32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1290
diff changeset
  1876
    self obsoleteMethodWarning:'use #insertLines:withCR:'.
ca4c9a957a32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1290
diff changeset
  1877
    self insertLines:lines withCR:withCr.
ca4c9a957a32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1290
diff changeset
  1878
ca4c9a957a32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1290
diff changeset
  1879
    "Modified: 31.7.1997 / 23:07:22 / cg"
641
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  1880
!
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  1881
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1882
insertSelectedStringAtCursor:aString
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1883
    "insert the argument, aString at cursor position and select it"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1884
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1885
    |startLine startCol|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1886
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1887
    startLine := cursorLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1888
    startCol := cursorCol.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1889
    self insertStringAtCursor:aString.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1890
    self selectFromLine:startLine col:startCol
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1891
		 toLine:cursorLine col:(cursorCol - 1)
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1892
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1893
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1894
insertString:aString atLine:lineNr col:colNr
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1895
    "insert the string, aString at line/col;
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1896
     handle cr's correctly"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1897
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1898
    |start           "{ Class: SmallInteger }"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1899
     stop            "{ Class: SmallInteger }"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1900
     end             "{ Class: SmallInteger }"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1901
     subString c
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1902
     l               "{ Class: SmallInteger }" |
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1903
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1904
    aString isNil ifTrue:[^ self].
1560
43d0f7c2143f use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents: 1559
diff changeset
  1905
    (aString includes:(Character cr)) ifFalse:[
1480
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  1906
        ^ self insertStringWithoutCRs:aString atLine:lineNr col:colNr
121
claus
parents: 118
diff changeset
  1907
    ].
1560
43d0f7c2143f use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents: 1559
diff changeset
  1908
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1909
    l := lineNr.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1910
    c := colNr.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1911
    start := 1.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1912
    end := aString size.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1913
    [start <= end] whileTrue:[
1480
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  1914
        stop := aString indexOf:(Character cr) startingAt:start.
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  1915
        stop == 0 ifTrue:[
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  1916
            stop := end + 1
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  1917
        ].
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  1918
        subString := aString copyFrom:start to:(stop - 1).
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  1919
        self insertStringWithoutCRs:subString atLine:l col:c.
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  1920
        (stop <= end) ifTrue:[
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  1921
            c := c + subString size.
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  1922
            self insert:(Character cr) atLine:l col:c.
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  1923
            l := l + 1.
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  1924
            c := 1
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  1925
        ].
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  1926
        start := stop + 1
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1927
    ]
1480
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  1928
1560
43d0f7c2143f use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents: 1559
diff changeset
  1929
    "Modified: / 10.6.1998 / 19:03:59 / cg"
121
claus
parents: 118
diff changeset
  1930
!
claus
parents: 118
diff changeset
  1931
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1932
insertStringAtCursor:aString
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1933
    "insert the argument, aString at cursor position
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1934
     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
  1935
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1936
    aString isNil ifTrue:[
1560
43d0f7c2143f use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents: 1559
diff changeset
  1937
        "new:"
43d0f7c2143f use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents: 1559
diff changeset
  1938
        self insertCharAtCursor:(Character cr).
43d0f7c2143f use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents: 1559
diff changeset
  1939
        ^ self
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1940
    ].
1560
43d0f7c2143f use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents: 1559
diff changeset
  1941
    (aString includes:(Character cr)) ifFalse:[
43d0f7c2143f use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents: 1559
diff changeset
  1942
        ^ self insertStringWithoutCRsAtCursor:aString
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1943
    ].
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1944
654
d621e63baaa5 showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 641
diff changeset
  1945
    self insertLines:aString asStringCollection withCR:false.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1946
1560
43d0f7c2143f use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents: 1559
diff changeset
  1947
    "Modified: / 10.6.1998 / 19:03:21 / cg"
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1948
!
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1949
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1950
insertStringWithoutCRs:aString atLine:lineNr col:colNr
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1951
    "insert aString (which has no crs) at lineNr/colNr"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1952
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1953
    self withoutRedrawInsertStringWithoutCRs:aString atLine:lineNr col:colNr.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1954
    shown ifTrue:[self redrawLine:lineNr from:colNr]
1480
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  1955
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  1956
    "Modified: / 5.4.1998 / 16:51:14 / cg"
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1957
!
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1958
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1959
insertStringWithoutCRsAtCursor:aString
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1960
    "insert a string (which has no crs) at cursor position
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1961
     - advance cursor"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1962
1563
b4eb49efdfcd fixed cursor positioning if inserting a string with tabs.
Claus Gittinger <cg@exept.de>
parents: 1561
diff changeset
  1963
    |wasOn oldLen newLen|
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1964
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1965
    aString notNil ifTrue:[
1563
b4eb49efdfcd fixed cursor positioning if inserting a string with tabs.
Claus Gittinger <cg@exept.de>
parents: 1561
diff changeset
  1966
        wasOn := self hideCursor.
b4eb49efdfcd fixed cursor positioning if inserting a string with tabs.
Claus Gittinger <cg@exept.de>
parents: 1561
diff changeset
  1967
        (aString includes:Character tab) ifTrue:[
b4eb49efdfcd fixed cursor positioning if inserting a string with tabs.
Claus Gittinger <cg@exept.de>
parents: 1561
diff changeset
  1968
            self checkForExistingLine:cursorLine.
b4eb49efdfcd fixed cursor positioning if inserting a string with tabs.
Claus Gittinger <cg@exept.de>
parents: 1561
diff changeset
  1969
            oldLen := (list at:cursorLine) size.
b4eb49efdfcd fixed cursor positioning if inserting a string with tabs.
Claus Gittinger <cg@exept.de>
parents: 1561
diff changeset
  1970
            self insertString:aString atLine:cursorLine col:cursorCol.
b4eb49efdfcd fixed cursor positioning if inserting a string with tabs.
Claus Gittinger <cg@exept.de>
parents: 1561
diff changeset
  1971
            newLen := (list at:cursorLine) size.
b4eb49efdfcd fixed cursor positioning if inserting a string with tabs.
Claus Gittinger <cg@exept.de>
parents: 1561
diff changeset
  1972
            cursorCol := cursorCol + (newLen - oldLen).
b4eb49efdfcd fixed cursor positioning if inserting a string with tabs.
Claus Gittinger <cg@exept.de>
parents: 1561
diff changeset
  1973
        ] ifFalse:[
b4eb49efdfcd fixed cursor positioning if inserting a string with tabs.
Claus Gittinger <cg@exept.de>
parents: 1561
diff changeset
  1974
            self insertString:aString atLine:cursorLine col:cursorCol.
b4eb49efdfcd fixed cursor positioning if inserting a string with tabs.
Claus Gittinger <cg@exept.de>
parents: 1561
diff changeset
  1975
            cursorCol := cursorCol + aString size.
b4eb49efdfcd fixed cursor positioning if inserting a string with tabs.
Claus Gittinger <cg@exept.de>
parents: 1561
diff changeset
  1976
        ].
b4eb49efdfcd fixed cursor positioning if inserting a string with tabs.
Claus Gittinger <cg@exept.de>
parents: 1561
diff changeset
  1977
        wasOn ifTrue:[self showCursor]
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1978
    ]
1563
b4eb49efdfcd fixed cursor positioning if inserting a string with tabs.
Claus Gittinger <cg@exept.de>
parents: 1561
diff changeset
  1979
b4eb49efdfcd fixed cursor positioning if inserting a string with tabs.
Claus Gittinger <cg@exept.de>
parents: 1561
diff changeset
  1980
    "Modified: / 10.6.1998 / 20:43:52 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1981
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1982
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1983
insertTabAtCursor
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1984
    "insert spaces to next tab"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1985
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1986
    |wasOn nextTab|
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1987
121
claus
parents: 118
diff changeset
  1988
    wasOn := self hideCursor.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1989
    nextTab := self nextTabAfter:cursorCol.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1990
    self insertStringAtCursor:(String new:(nextTab - cursorCol)).
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1991
    self makeCursorVisibleAndShowCursor:wasOn.
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1992
!
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  1993
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1994
removeTrailingBlankLines
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1995
    "remove all blank lines at end of text"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1996
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1997
    |lastLine "{ Class: SmallInteger }"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1998
     line finished|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  1999
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2000
    lastLine := list size.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2001
    finished := false.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2002
    [finished] whileFalse:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2003
	(lastLine <= 1) ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2004
	    finished := true
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2005
	] ifFalse:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2006
	    line := list at:lastLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2007
	    line notNil ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2008
		line isBlank ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2009
		    list at:lastLine put:nil.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2010
		    line := nil
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
	    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2013
	    line notNil ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2014
		finished := true
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2015
	    ] ifFalse:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2016
		lastLine := lastLine - 1
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2017
	    ]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2018
	]
118
claus
parents: 105
diff changeset
  2019
    ].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2020
    (lastLine ~~ list size) ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2021
	list grow:lastLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2022
"/        self textChanged
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2023
    ]
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
477
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  2026
replaceCharAtCursor:aCharacter
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  2027
    "replace a single character at cursor-position - advance cursor"
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  2028
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  2029
    |wasOn|
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  2030
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  2031
    wasOn := self hideCursor.
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  2032
    aCharacter == (Character cr) ifTrue:[
1415
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2033
	self cursorReturn
477
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  2034
    ] ifFalse:[
1415
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2035
	self replace:aCharacter atLine:cursorLine col:cursorCol.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2036
	self cursorRight.
477
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  2037
    ].
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  2038
    self makeCursorVisibleAndShowCursor:wasOn.
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  2039
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  2040
    "Created: 6.3.1996 / 12:27:42 / cg"
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  2041
!
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  2042
1564
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  2043
replaceLines:lines withCR:withCr
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  2044
    "replace a bunch of lines at cursor position. Cursor
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  2045
     is moved behind replacement.
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  2046
     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
  2047
     after the last line"
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  2048
1567
0eff7ca88e89 much faster multi-line replace (avoid scroll)
Claus Gittinger <cg@exept.de>
parents: 1566
diff changeset
  2049
    |line col end nLines wasOn|
1564
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  2050
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  2051
    lines notNil ifTrue:[
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  2052
        wasOn := self hideCursor.
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  2053
        nLines := lines size.
1567
0eff7ca88e89 much faster multi-line replace (avoid scroll)
Claus Gittinger <cg@exept.de>
parents: 1566
diff changeset
  2054
        line := cursorLine.
0eff7ca88e89 much faster multi-line replace (avoid scroll)
Claus Gittinger <cg@exept.de>
parents: 1566
diff changeset
  2055
        col := cursorCol.
1564
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  2056
        lines keysAndValuesDo:[:i :l |
1567
0eff7ca88e89 much faster multi-line replace (avoid scroll)
Claus Gittinger <cg@exept.de>
parents: 1566
diff changeset
  2057
            self replaceString:l atLine:line col:col.
1564
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  2058
            (i ~~ nLines or:[withCr]) ifTrue:[
1567
0eff7ca88e89 much faster multi-line replace (avoid scroll)
Claus Gittinger <cg@exept.de>
parents: 1566
diff changeset
  2059
                line := line + 1.
0eff7ca88e89 much faster multi-line replace (avoid scroll)
Claus Gittinger <cg@exept.de>
parents: 1566
diff changeset
  2060
                col := 1.
0eff7ca88e89 much faster multi-line replace (avoid scroll)
Claus Gittinger <cg@exept.de>
parents: 1566
diff changeset
  2061
            ] ifFalse:[
0eff7ca88e89 much faster multi-line replace (avoid scroll)
Claus Gittinger <cg@exept.de>
parents: 1566
diff changeset
  2062
                col := col + (l size).
1564
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  2063
            ]
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  2064
        ].
1567
0eff7ca88e89 much faster multi-line replace (avoid scroll)
Claus Gittinger <cg@exept.de>
parents: 1566
diff changeset
  2065
        self cursorLine:line col:col.
0eff7ca88e89 much faster multi-line replace (avoid scroll)
Claus Gittinger <cg@exept.de>
parents: 1566
diff changeset
  2066
        self makeCursorVisibleAndShowCursor:wasOn.
0eff7ca88e89 much faster multi-line replace (avoid scroll)
Claus Gittinger <cg@exept.de>
parents: 1566
diff changeset
  2067
        "/ wasOn ifTrue:[self showCursor].
1564
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  2068
    ]
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  2069
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  2070
    "Created: / 18.5.1996 / 15:32:06 / cg"
1567
0eff7ca88e89 much faster multi-line replace (avoid scroll)
Claus Gittinger <cg@exept.de>
parents: 1566
diff changeset
  2071
    "Modified: / 12.6.1998 / 22:05:51 / cg"
1564
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  2072
!
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  2073
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2074
replaceSelectionBy:something
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2075
    "delete the selection (if any) and insert something, a character or string;
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2076
     leave cursor after insertion"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2077
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2078
    self replaceSelectionBy:something keepCursor:false
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  2079
!
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  2080
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  2081
replaceSelectionBy:something keepCursor:keep
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  2082
    "delete the selection (if any) and insert something, a character or string;
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  2083
     leave cursor after insertion or leave it, depending on keep"
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  2084
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  2085
    |sel l c|
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  2086
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  2087
    l := cursorLine.
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  2088
    c := cursorCol.
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  2089
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  2090
    sel := self selection.
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  2091
    sel notNil ifTrue:[
1415
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2092
	lastString := sel.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2093
	self deleteSelection.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2094
	replacing := true.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2095
	lastReplacement := ''
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  2096
    ].
840
b0071cea13fd fixed Again when spaces are replaced
Claus Gittinger <cg@exept.de>
parents: 828
diff changeset
  2097
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  2098
    (something isMemberOf:Character) ifTrue:[
1415
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2099
	lastReplacement notNil ifTrue:[
840
b0071cea13fd fixed Again when spaces are replaced
Claus Gittinger <cg@exept.de>
parents: 828
diff changeset
  2100
"/ "XXX - replacing text with spaces ..."
b0071cea13fd fixed Again when spaces are replaced
Claus Gittinger <cg@exept.de>
parents: 828
diff changeset
  2101
"/            (lastReplacement endsWith:Character space) ifTrue:[
b0071cea13fd fixed Again when spaces are replaced
Claus Gittinger <cg@exept.de>
parents: 828
diff changeset
  2102
"/                lastReplacement := lastReplacement copyWithoutLast:1 "copyTo:(lastReplacement size - 1)".
b0071cea13fd fixed Again when spaces are replaced
Claus Gittinger <cg@exept.de>
parents: 828
diff changeset
  2103
"/                lastReplacement := lastReplacement copyWith:something.
b0071cea13fd fixed Again when spaces are replaced
Claus Gittinger <cg@exept.de>
parents: 828
diff changeset
  2104
"/                lastReplacement := lastReplacement copyWith:Character space
b0071cea13fd fixed Again when spaces are replaced
Claus Gittinger <cg@exept.de>
parents: 828
diff changeset
  2105
"/            ] ifFalse:[
1415
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2106
		lastReplacement := lastReplacement copyWith:something.
840
b0071cea13fd fixed Again when spaces are replaced
Claus Gittinger <cg@exept.de>
parents: 828
diff changeset
  2107
"/            ]
1415
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2108
	].
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2109
	insertMode ifTrue:[
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2110
	    self insertCharAtCursor:something
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2111
	] ifFalse:[
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2112
	    self replaceCharAtCursor:something
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2113
	]
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  2114
    ] ifFalse:[
1415
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2115
	lastReplacement := something.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2116
	insertMode ifTrue:[
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2117
	    self insertStringAtCursor:something
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2118
	] ifFalse:[
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2119
	    self replaceStringAtCursor
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2120
	]
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  2121
    ].
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  2122
    keep ifTrue:[
1415
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2123
	self cursorLine:l col:c
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  2124
    ]
477
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  2125
840
b0071cea13fd fixed Again when spaces are replaced
Claus Gittinger <cg@exept.de>
parents: 828
diff changeset
  2126
    "Modified: 9.10.1996 / 16:14:35 / cg"
1564
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  2127
!
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  2128
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  2129
replaceStringAtCursor:aString
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  2130
    "replace multiple characters at cursor-position - advance cursor"
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  2131
1566
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  2132
    |wasOn i1 i2|
1564
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  2133
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  2134
    wasOn := self hideCursor.
1566
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  2135
    (aString includes:Character tab) ifTrue:[
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  2136
        "/ need special care for TAB (to move cursor correctly)
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  2137
        i1 := 1.
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  2138
        [i1 ~~ 0] whileTrue:[
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  2139
            i2 := aString indexOf:Character tab startingAt:i1.
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  2140
            i2 ~~ 0 ifTrue:[
1597
5fdcfcedb91c fixed cursor positioning after replaceStringAtCursor.
Claus Gittinger <cg@exept.de>
parents: 1596
diff changeset
  2141
                i1 ~~ i2 ifTrue:[
5fdcfcedb91c fixed cursor positioning after replaceStringAtCursor.
Claus Gittinger <cg@exept.de>
parents: 1596
diff changeset
  2142
                    self replaceString:(aString copyFrom:i1 to:i2-1) atLine:cursorLine col:cursorCol.
5fdcfcedb91c fixed cursor positioning after replaceStringAtCursor.
Claus Gittinger <cg@exept.de>
parents: 1596
diff changeset
  2143
                    self cursorCol:(cursorCol + (i2 - i1)).
5fdcfcedb91c fixed cursor positioning after replaceStringAtCursor.
Claus Gittinger <cg@exept.de>
parents: 1596
diff changeset
  2144
                ].
1566
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  2145
                self replaceTABAtCursor.
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  2146
                i2 := i2 + 1.
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  2147
            ] ifFalse:[
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  2148
                self replaceString:(aString copyFrom:i1) atLine:cursorLine col:cursorCol.
1597
5fdcfcedb91c fixed cursor positioning after replaceStringAtCursor.
Claus Gittinger <cg@exept.de>
parents: 1596
diff changeset
  2149
                self cursorCol:(cursorCol + (aString size - i1 + 1)).
1566
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  2150
            ].
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  2151
            i1 := i2.
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  2152
        ]
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  2153
    ] ifFalse:[
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  2154
        self replaceString:aString atLine:cursorLine col:cursorCol.
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  2155
        self cursorCol:(cursorCol + aString size).
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  2156
    ].
1564
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  2157
    self makeCursorVisibleAndShowCursor:wasOn.
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  2158
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  2159
    "Created: / 9.6.1998 / 20:33:20 / cg"
1597
5fdcfcedb91c fixed cursor positioning after replaceStringAtCursor.
Claus Gittinger <cg@exept.de>
parents: 1596
diff changeset
  2160
    "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
  2161
!
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  2162
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  2163
replaceTABAtCursor
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  2164
    "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
  2165
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  2166
    |wasOn nextTab|
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  2167
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  2168
    wasOn := self hideCursor.
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  2169
    nextTab := self nextTabAfter:cursorCol.
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  2170
    self replaceStringAtCursor:(String new:(nextTab - cursorCol)).
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  2171
    self makeCursorVisibleAndShowCursor:wasOn.
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  2172
4e37a55bd140 care for TAB chars in new replace functions.
Claus Gittinger <cg@exept.de>
parents: 1564
diff changeset
  2173
    "Created: / 12.6.1998 / 21:53:23 / cg"
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2174
! !
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2175
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2176
!EditTextView methodsFor:'editing - basic'!
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2177
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2178
deleteCharsAtLine:lineNr fromCol:startCol toCol:endCol
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2179
    "delete characters from startCol to endCol in line lineNr
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2180
    "
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2181
    |line lineSize newLine start stop|
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2182
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2183
    line := self listAt:lineNr.
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2184
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2185
    (self checkModificationsAllowed and:[line notNil]) ifTrue:[ 
1415
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2186
	lineSize := line size.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2187
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2188
	startCol == 0     ifFalse:[ start := startCol ]
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2189
			   ifTrue:[ start := 1 ]. 
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2190
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2191
	endCol > lineSize ifFalse:[ stop  := endCol ]
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2192
			   ifTrue:[ stop  := lineSize ].
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2193
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2194
	stop >= start ifTrue:[
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2195
	    start ~~ 1 ifTrue:[ newLine := line copyFrom:1 to:(start-1) ]
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2196
		      ifFalse:[ newLine := '' ].
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2197
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2198
	    stop == lineSize ifFalse:[
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2199
		line bitsPerCharacter > newLine bitsPerCharacter ifTrue:[
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2200
		    newLine := line string species fromString:newLine.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2201
		].
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2202
		newLine := newLine, (line copyFrom:(stop + 1) to:lineSize)
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2203
	    ].
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2204
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2205
	    (trimBlankLines and:[newLine isBlank]) ifTrue:[
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2206
		newLine := nil
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2207
	    ].
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2208
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2209
	    list at:lineNr put:newLine.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2210
	    widthOfWidestLine := nil.   "i.e. unknown"
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2211
	    self textChanged.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2212
	    self redrawLine:lineNr from:start.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2213
	]
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2214
    ]
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2215
879
5bb93a1651cd cutting in a 16-bit text fixed
Claus Gittinger <cg@exept.de>
parents: 870
diff changeset
  2216
    "Modified: 11.11.1996 / 11:24:48 / cg"
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2217
!
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2218
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2219
deleteFromLine:startLine col:startCol toLine:endLine col:endCol
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2220
    "delete all text from startLine/startCol to endLine/endCol -
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2221
     joining lines if nescessary"
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2222
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2223
    |line lineSize|
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2224
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2225
    self checkModificationsAllowed ifFalse:[ ^ self].
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2226
    list isNil ifTrue:[^ self].
960
29a592101ad4 care for deleting a selection behond the texts end
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  2227
    startLine > list size ifTrue:[ ^ self]. "/ deleted space below text
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2228
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2229
    (startLine == endLine) ifTrue:[
1415
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2230
	"/ delete chars within a line
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2231
	self deleteCharsAtLine:startLine fromCol:startCol toCol:endCol.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2232
	^ self
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2233
    ].
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2234
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2235
    ((startCol == 1) and:[endCol == 0]) ifTrue:[
1415
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2236
	"/ delete full lines only
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2237
	endLine > startLine ifTrue:[
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2238
	    self deleteFromLine:startLine toLine:(endLine - 1)
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2239
	].
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2240
	^ self
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2241
    ].
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2242
641
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  2243
    "/ delete right rest of 1st line
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2244
    self deleteCharsAtLine:startLine fromCol:startCol.
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2245
641
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  2246
    "/ delete the inner lines ...
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2247
    endLine > (startLine + 1) ifTrue:[
1415
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2248
	self deleteFromLine:(startLine + 1) toLine:(endLine - 1)
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2249
    ].
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2250
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2251
    (endCol ~~ 0) ifTrue:[
1415
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2252
	"/ delete the left rest of the last line
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2253
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2254
	self deleteCharsAtLine:(startLine + 1) toCol:endCol.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2255
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2256
	"/ must add blanks, if startCol lies behond end of startLine
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2257
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2258
	line := list at:startLine.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2259
	lineSize := line size.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2260
	(startCol > lineSize) ifTrue:[
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2261
	    line isNil ifTrue:[
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2262
		line := String new:(startCol - 1)
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2263
	    ] ifFalse:[
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2264
		line := line , (line species new:(startCol - 1 - lineSize))
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2265
	    ].
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2266
	    list at:startLine put:line.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2267
	    widthOfWidestLine := nil. "/ i.e. unknown
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2268
	    self textChanged.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2269
	]
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2270
    ].
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2271
641
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  2272
    "/ merge the left rest of 1st line with right rest of last line into one
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2273
    self mergeLine:startLine
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2274
960
29a592101ad4 care for deleting a selection behond the texts end
Claus Gittinger <cg@exept.de>
parents: 947
diff changeset
  2275
    "Modified: 18.1.1997 / 14:31:55 / cg"
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2276
!
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2277
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2278
deleteFromLine:startLineNr toLine:endLineNr
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2279
    "delete some lines"
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2280
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2281
    |wasOn nLines|
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2282
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2283
    self checkModificationsAllowed ifFalse:[ ^ self].
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2284
    list isNil ifTrue:[^ self].
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2285
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2286
    wasOn := self hideCursor.
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2287
    list removeFromIndex:startLineNr toIndex:(endLineNr min:list size).
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2288
    widthOfWidestLine := nil. "/ i.e. unknown
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2289
    self textChanged.
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2290
    self redrawFromLine:startLineNr.
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2291
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2292
    nLines := list size.
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2293
    (firstLineShown >= nLines) ifTrue:[
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2294
	self makeLineVisible:nLines
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2295
    ].
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2296
    wasOn ifTrue:[self showCursor].
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2297
!
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2298
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2299
deleteLineWithoutRedraw:lineNr
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2300
    "delete line - no redraw;
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2301
     return true, if something was really deleted"
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2302
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2303
    self checkModificationsAllowed ifFalse:[ ^ self].
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2304
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2305
    (list isNil or:[lineNr > list size]) ifTrue:[^ false].
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2306
    list removeIndex:lineNr.
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2307
    widthOfWidestLine := nil. "/ i.e. unknown
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2308
    self textChanged.
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2309
    ^ true
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2310
!
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2311
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2312
insert:aCharacter atLine:lineNr col:colNr
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2313
    "insert a single character at lineNr/colNr; 
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2314
     set emphasis to character at current position"
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2315
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2316
    |line lineSize newLine drawCharacterOnly attribute|
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2317
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2318
    self checkModificationsAllowed ifFalse:[ ^ self].
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2319
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2320
    aCharacter == (Character cr) ifTrue:[
1596
0bbdb4e9fc43 made st80Mode also an inst-flag;
Claus Gittinger <cg@exept.de>
parents: 1591
diff changeset
  2321
        self splitLine:lineNr before:colNr.
0bbdb4e9fc43 made st80Mode also an inst-flag;
Claus Gittinger <cg@exept.de>
parents: 1591
diff changeset
  2322
        ^ self
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2323
    ].
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2324
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2325
    drawCharacterOnly := false.
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2326
    self checkForExistingLine:lineNr.
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2327
    line := list at:lineNr.
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2328
    lineSize := line size.
671
f3fe0d8c604d added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents: 666
diff changeset
  2329
1596
0bbdb4e9fc43 made st80Mode also an inst-flag;
Claus Gittinger <cg@exept.de>
parents: 1591
diff changeset
  2330
    st80Mode ~~ true ifTrue:[
0bbdb4e9fc43 made st80Mode also an inst-flag;
Claus Gittinger <cg@exept.de>
parents: 1591
diff changeset
  2331
        (trimBlankLines 
0bbdb4e9fc43 made st80Mode also an inst-flag;
Claus Gittinger <cg@exept.de>
parents: 1591
diff changeset
  2332
        and:[colNr > lineSize
0bbdb4e9fc43 made st80Mode also an inst-flag;
Claus Gittinger <cg@exept.de>
parents: 1591
diff changeset
  2333
        and:[aCharacter == Character space]]) ifTrue:[
0bbdb4e9fc43 made st80Mode also an inst-flag;
Claus Gittinger <cg@exept.de>
parents: 1591
diff changeset
  2334
            ^ self
0bbdb4e9fc43 made st80Mode also an inst-flag;
Claus Gittinger <cg@exept.de>
parents: 1591
diff changeset
  2335
        ]
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2336
    ].
671
f3fe0d8c604d added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents: 666
diff changeset
  2337
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2338
    (lineSize == 0) ifTrue:[
1596
0bbdb4e9fc43 made st80Mode also an inst-flag;
Claus Gittinger <cg@exept.de>
parents: 1591
diff changeset
  2339
        newLine := aCharacter asString species new:colNr.
0bbdb4e9fc43 made st80Mode also an inst-flag;
Claus Gittinger <cg@exept.de>
parents: 1591
diff changeset
  2340
        drawCharacterOnly := true
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2341
    ] ifFalse: [
1596
0bbdb4e9fc43 made st80Mode also an inst-flag;
Claus Gittinger <cg@exept.de>
parents: 1591
diff changeset
  2342
        (colNr > lineSize) ifTrue: [
0bbdb4e9fc43 made st80Mode also an inst-flag;
Claus Gittinger <cg@exept.de>
parents: 1591
diff changeset
  2343
            colNr == (lineSize +1) ifTrue:[
0bbdb4e9fc43 made st80Mode also an inst-flag;
Claus Gittinger <cg@exept.de>
parents: 1591
diff changeset
  2344
                attribute := line emphasisAt:lineSize
0bbdb4e9fc43 made st80Mode also an inst-flag;
Claus Gittinger <cg@exept.de>
parents: 1591
diff changeset
  2345
            ].
0bbdb4e9fc43 made st80Mode also an inst-flag;
Claus Gittinger <cg@exept.de>
parents: 1591
diff changeset
  2346
            newLine := line species new:colNr.
0bbdb4e9fc43 made st80Mode also an inst-flag;
Claus Gittinger <cg@exept.de>
parents: 1591
diff changeset
  2347
            newLine replaceFrom:1 to:lineSize
0bbdb4e9fc43 made st80Mode also an inst-flag;
Claus Gittinger <cg@exept.de>
parents: 1591
diff changeset
  2348
                           with:line startingAt:1.
0bbdb4e9fc43 made st80Mode also an inst-flag;
Claus Gittinger <cg@exept.de>
parents: 1591
diff changeset
  2349
            drawCharacterOnly := true
0bbdb4e9fc43 made st80Mode also an inst-flag;
Claus Gittinger <cg@exept.de>
parents: 1591
diff changeset
  2350
        ] ifFalse: [
0bbdb4e9fc43 made st80Mode also an inst-flag;
Claus Gittinger <cg@exept.de>
parents: 1591
diff changeset
  2351
            attribute := line emphasisAt:colNr.
0bbdb4e9fc43 made st80Mode also an inst-flag;
Claus Gittinger <cg@exept.de>
parents: 1591
diff changeset
  2352
            newLine   := line species new:(lineSize + 1).
0bbdb4e9fc43 made st80Mode also an inst-flag;
Claus Gittinger <cg@exept.de>
parents: 1591
diff changeset
  2353
0bbdb4e9fc43 made st80Mode also an inst-flag;
Claus Gittinger <cg@exept.de>
parents: 1591
diff changeset
  2354
            newLine replaceFrom:1 to:(colNr - 1)
0bbdb4e9fc43 made st80Mode also an inst-flag;
Claus Gittinger <cg@exept.de>
parents: 1591
diff changeset
  2355
                           with:line startingAt:1.
0bbdb4e9fc43 made st80Mode also an inst-flag;
Claus Gittinger <cg@exept.de>
parents: 1591
diff changeset
  2356
            newLine replaceFrom:(colNr + 1) to:(lineSize + 1)
0bbdb4e9fc43 made st80Mode also an inst-flag;
Claus Gittinger <cg@exept.de>
parents: 1591
diff changeset
  2357
                           with:line startingAt:colNr
0bbdb4e9fc43 made st80Mode also an inst-flag;
Claus Gittinger <cg@exept.de>
parents: 1591
diff changeset
  2358
        ]
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2359
    ].
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2360
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2361
    newLine at:colNr put:aCharacter.
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2362
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2363
    attribute notNil ifTrue:[
1596
0bbdb4e9fc43 made st80Mode also an inst-flag;
Claus Gittinger <cg@exept.de>
parents: 1591
diff changeset
  2364
        newLine emphasisAt:colNr put:attribute
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2365
    ].
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2366
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2367
    aCharacter == (Character tab) ifTrue:[
1596
0bbdb4e9fc43 made st80Mode also an inst-flag;
Claus Gittinger <cg@exept.de>
parents: 1591
diff changeset
  2368
        newLine := self withTabsExpanded:newLine.
0bbdb4e9fc43 made st80Mode also an inst-flag;
Claus Gittinger <cg@exept.de>
parents: 1591
diff changeset
  2369
        drawCharacterOnly := false
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2370
    ].
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2371
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2372
    list at:lineNr put:newLine.
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2373
    widthOfWidestLine notNil ifTrue:[
1596
0bbdb4e9fc43 made st80Mode also an inst-flag;
Claus Gittinger <cg@exept.de>
parents: 1591
diff changeset
  2374
        widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:line).
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2375
    ].
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2376
    self textChanged.
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2377
    shown ifTrue:[
1596
0bbdb4e9fc43 made st80Mode also an inst-flag;
Claus Gittinger <cg@exept.de>
parents: 1591
diff changeset
  2378
        drawCharacterOnly ifTrue:[
0bbdb4e9fc43 made st80Mode also an inst-flag;
Claus Gittinger <cg@exept.de>
parents: 1591
diff changeset
  2379
            self redrawLine:lineNr col:colNr
0bbdb4e9fc43 made st80Mode also an inst-flag;
Claus Gittinger <cg@exept.de>
parents: 1591
diff changeset
  2380
        ] ifFalse:[
0bbdb4e9fc43 made st80Mode also an inst-flag;
Claus Gittinger <cg@exept.de>
parents: 1591
diff changeset
  2381
            self redrawLine:lineNr from:colNr
0bbdb4e9fc43 made st80Mode also an inst-flag;
Claus Gittinger <cg@exept.de>
parents: 1591
diff changeset
  2382
        ]
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2383
    ]
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2384
1596
0bbdb4e9fc43 made st80Mode also an inst-flag;
Claus Gittinger <cg@exept.de>
parents: 1591
diff changeset
  2385
    "Modified: / 20.6.1998 / 18:19:22 / cg"
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2386
!
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2387
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2388
insertLines:someText from:start to:end before:lineNr
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2389
    "insert a bunch of lines before line lineNr"
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2390
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2391
    |text indent visLine w nLines "{ Class: SmallInteger }"
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2392
     srcY "{ Class: SmallInteger }"
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2393
     dstY "{ Class: SmallInteger }" |
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2394
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2395
    readOnly ifTrue:[
1415
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2396
	^ self
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2397
    ].
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2398
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2399
    autoIndent ifTrue:[
1415
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2400
	indent := self leftIndentForLine:lineNr.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2401
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2402
	text := someText collect:[:ln||line|
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2403
	    ln notNil ifTrue:[
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2404
		line := ln withoutLeadingSeparators.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2405
		(line isEmpty or:[indent == 0]) ifFalse:[
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2406
		    line := (String new:indent), line
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2407
		].
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2408
		line
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2409
	    ] ifFalse:[
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2410
		nil
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2411
	    ]
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2412
	].
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2413
    ] ifFalse:[
1415
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2414
	text := someText
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2415
    ].
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2416
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2417
    visLine := self listLineToVisibleLine:lineNr.
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2418
    (shown not or:[visLine isNil]) ifTrue:[
1415
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2419
	self withoutRedrawInsertLines:text
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2420
				 from:start to:end
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2421
			       before:lineNr.
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2422
    ] ifFalse:[
1415
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2423
	nLines := end - start + 1.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2424
	((visLine + nLines) >= nLinesShown) ifTrue:[
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2425
	    self withoutRedrawInsertLines:text
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2426
				     from:start to:end
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2427
				   before:lineNr.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2428
	    self redrawFromVisibleLine:visLine to:nLinesShown
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2429
	] ifFalse:[
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2430
	    w := self widthForScrollBetween:(lineNr + nLines)
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2431
					and:(firstLineShown + nLines + nLinesShown).
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2432
	    srcY := topMargin + ((visLine - 1) * fontHeight).
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2433
	    dstY := srcY + (nLines * fontHeight).
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2434
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2435
	    "/
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2436
	    "/ scroll ...
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2437
	    "/
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2438
	    "
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2439
	     stupid: must catchExpose before inserting new
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2440
	     stuff - since catchExpose may perform redraws
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2441
	    "
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2442
	    self catchExpose.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2443
	    self withoutRedrawInsertLines:text
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2444
				     from:start to:end
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2445
				   before:lineNr.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2446
	    self 
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2447
		copyFrom:self 
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2448
		x:textStartLeft y:srcY
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2449
		toX:textStartLeft y:dstY
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2450
		width:w
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2451
		height:(height - dstY)
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2452
		async:true.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2453
	    self redrawFromVisibleLine:visLine to:(visLine + nLines - 1).
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2454
	    self waitForExpose
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2455
	].
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2456
    ].
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2457
    widthOfWidestLine notNil ifTrue:[
1415
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2458
	text do:[:line |
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2459
	    widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:line).
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2460
	]
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2461
    ].
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2462
    self textChanged.
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2463
984
dbd60475b3f5 explicit async bitBlt
Claus Gittinger <cg@exept.de>
parents: 981
diff changeset
  2464
    "Modified: 29.1.1997 / 13:02:39 / cg"
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2465
!
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2466
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2467
mergeLine:lineNr
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2468
    "merge line lineNr with line lineNr+1"
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2469
1319
2739903e7a80 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  2470
    self mergeLine:lineNr removeBlanks:true
2739903e7a80 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  2471
2739903e7a80 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  2472
    "Modified: 9.9.1997 / 09:28:03 / cg"
2739903e7a80 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  2473
!
2739903e7a80 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  2474
2739903e7a80 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  2475
mergeLine:lineNr removeBlanks:removeBlanks
2739903e7a80 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  2476
    "merge line lineNr with line lineNr+1"
2739903e7a80 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  2477
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2478
    |leftPart rightPart bothParts nextLineNr i|
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2479
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2480
    (list notNil and:[(list size) > lineNr]) ifFalse:[
1415
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2481
	^ self
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2482
    ].
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2483
    leftPart := self listAt:lineNr.
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2484
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2485
    leftPart isNil ifTrue:[
1415
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2486
	leftPart := ''.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2487
	autoIndent ifTrue:[
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2488
	    (i := self leftIndentForLine:cursorLine) == 0 ifFalse:[
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2489
		leftPart := String new:i
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2490
	    ]
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2491
	]
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2492
    ].
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2493
    self cursorLine:lineNr col:((leftPart size) + 1).
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2494
    nextLineNr := self validateCursorLine:(lineNr + 1).
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2495
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2496
    nextLineNr > (list size) ifFalse:[
1415
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2497
	(rightPart := self listAt:nextLineNr) isNil ifTrue:[
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2498
	    rightPart := ''
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2499
	] ifFalse:[
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2500
	    removeBlanks ifTrue:[
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2501
		rightPart := rightPart withoutLeadingSeparators.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2502
	    ]
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2503
	].
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2504
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2505
	bothParts := leftPart , rightPart.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2506
	(trimBlankLines and:[bothParts isBlank]) ifTrue:[bothParts := nil].
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2507
	list at:lineNr put:bothParts.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2508
	self redrawLine:lineNr.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2509
	self deleteLine:nextLineNr
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2510
    ]
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2511
1319
2739903e7a80 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  2512
    "Created: 9.9.1997 / 09:27:38 / cg"
2739903e7a80 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1308
diff changeset
  2513
    "Modified: 9.9.1997 / 09:28:27 / cg"
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2514
!
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2515
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2516
replace:aCharacter atLine:lineNr col:colNr
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2517
    "replace a single character at lineNr/colNr"
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2518
1558
abf35cc39757 minimize redraw in overwrite-replace;
Claus Gittinger <cg@exept.de>
parents: 1557
diff changeset
  2519
    |line lineSize newLine drawCharacterOnly|
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2520
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2521
    self checkModificationsAllowed ifFalse:[ ^ self].
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2522
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2523
    aCharacter == (Character cr) ifTrue:[
1558
abf35cc39757 minimize redraw in overwrite-replace;
Claus Gittinger <cg@exept.de>
parents: 1557
diff changeset
  2524
        ^ self
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2525
    ].
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2526
1558
abf35cc39757 minimize redraw in overwrite-replace;
Claus Gittinger <cg@exept.de>
parents: 1557
diff changeset
  2527
    drawCharacterOnly := true.
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2528
    self checkForExistingLine:lineNr.
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2529
    line := list at:lineNr.
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2530
    lineSize := line size.
671
f3fe0d8c604d added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents: 666
diff changeset
  2531
f3fe0d8c604d added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents: 666
diff changeset
  2532
    (trimBlankLines
f3fe0d8c604d added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents: 666
diff changeset
  2533
    and:[colNr > lineSize
f3fe0d8c604d added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents: 666
diff changeset
  2534
    and:[aCharacter == Character space]]) ifTrue:[
1558
abf35cc39757 minimize redraw in overwrite-replace;
Claus Gittinger <cg@exept.de>
parents: 1557
diff changeset
  2535
        ^ self
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2536
    ].
671
f3fe0d8c604d added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents: 666
diff changeset
  2537
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2538
    (lineSize == 0) ifTrue:[
1558
abf35cc39757 minimize redraw in overwrite-replace;
Claus Gittinger <cg@exept.de>
parents: 1557
diff changeset
  2539
        newLine := aCharacter asString species new:colNr.
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2540
    ] ifFalse: [
1558
abf35cc39757 minimize redraw in overwrite-replace;
Claus Gittinger <cg@exept.de>
parents: 1557
diff changeset
  2541
        (colNr > lineSize) ifTrue: [
abf35cc39757 minimize redraw in overwrite-replace;
Claus Gittinger <cg@exept.de>
parents: 1557
diff changeset
  2542
            newLine := line species new:colNr.
abf35cc39757 minimize redraw in overwrite-replace;
Claus Gittinger <cg@exept.de>
parents: 1557
diff changeset
  2543
            newLine replaceFrom:1 to:lineSize with:line startingAt:1.
abf35cc39757 minimize redraw in overwrite-replace;
Claus Gittinger <cg@exept.de>
parents: 1557
diff changeset
  2544
        ] ifFalse: [
1559
cecf77805bff expand tabs in #replaceAll:...
Claus Gittinger <cg@exept.de>
parents: 1558
diff changeset
  2545
            newLine := line copy.
1558
abf35cc39757 minimize redraw in overwrite-replace;
Claus Gittinger <cg@exept.de>
parents: 1557
diff changeset
  2546
        ]
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2547
    ].
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2548
    newLine at:colNr put:aCharacter.
1558
abf35cc39757 minimize redraw in overwrite-replace;
Claus Gittinger <cg@exept.de>
parents: 1557
diff changeset
  2549
    aCharacter == (Character tab) ifTrue:[
abf35cc39757 minimize redraw in overwrite-replace;
Claus Gittinger <cg@exept.de>
parents: 1557
diff changeset
  2550
        newLine := self withTabsExpanded:newLine.
abf35cc39757 minimize redraw in overwrite-replace;
Claus Gittinger <cg@exept.de>
parents: 1557
diff changeset
  2551
        drawCharacterOnly := false
abf35cc39757 minimize redraw in overwrite-replace;
Claus Gittinger <cg@exept.de>
parents: 1557
diff changeset
  2552
    ].
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2553
    list at:lineNr put:newLine.
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2554
    widthOfWidestLine notNil ifTrue:[
1558
abf35cc39757 minimize redraw in overwrite-replace;
Claus Gittinger <cg@exept.de>
parents: 1557
diff changeset
  2555
        widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:line).
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2556
    ].
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2557
    self textChanged.
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2558
    shown ifTrue:[
1558
abf35cc39757 minimize redraw in overwrite-replace;
Claus Gittinger <cg@exept.de>
parents: 1557
diff changeset
  2559
        drawCharacterOnly ifTrue:[
abf35cc39757 minimize redraw in overwrite-replace;
Claus Gittinger <cg@exept.de>
parents: 1557
diff changeset
  2560
            self redrawLine:lineNr col:colNr
abf35cc39757 minimize redraw in overwrite-replace;
Claus Gittinger <cg@exept.de>
parents: 1557
diff changeset
  2561
        ] ifFalse:[
abf35cc39757 minimize redraw in overwrite-replace;
Claus Gittinger <cg@exept.de>
parents: 1557
diff changeset
  2562
            self redrawLine:lineNr from:colNr
abf35cc39757 minimize redraw in overwrite-replace;
Claus Gittinger <cg@exept.de>
parents: 1557
diff changeset
  2563
        ]
629
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2564
    ]
cf0a3ab9b9f1 Text fixes & category changes
Claus Gittinger <cg@exept.de>
parents: 606
diff changeset
  2565
1558
abf35cc39757 minimize redraw in overwrite-replace;
Claus Gittinger <cg@exept.de>
parents: 1557
diff changeset
  2566
    "Created: / 6.3.1996 / 12:29:20 / cg"
1559
cecf77805bff expand tabs in #replaceAll:...
Claus Gittinger <cg@exept.de>
parents: 1558
diff changeset
  2567
    "Modified: / 10.6.1998 / 18:50:18 / cg"
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  2568
!
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  2569
1564
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  2570
replaceString:aString atLine:lineNr col:colNr
1557
b88c7410311f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1552
diff changeset
  2571
    "replace multiple characters starting at lineNr/colNr.
1567
0eff7ca88e89 much faster multi-line replace (avoid scroll)
Claus Gittinger <cg@exept.de>
parents: 1566
diff changeset
  2572
     This is not prepared to encounter special chars (except TAB)
0eff7ca88e89 much faster multi-line replace (avoid scroll)
Claus Gittinger <cg@exept.de>
parents: 1566
diff changeset
  2573
     in the string."
1557
b88c7410311f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1552
diff changeset
  2574
b88c7410311f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1552
diff changeset
  2575
    |line lineSize newLine endCol|
b88c7410311f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1552
diff changeset
  2576
b88c7410311f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1552
diff changeset
  2577
    self checkModificationsAllowed ifFalse:[ ^ self].
b88c7410311f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1552
diff changeset
  2578
b88c7410311f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1552
diff changeset
  2579
    self checkForExistingLine:lineNr.
b88c7410311f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1552
diff changeset
  2580
    line := list at:lineNr.
b88c7410311f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1552
diff changeset
  2581
    lineSize := line size.
b88c7410311f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1552
diff changeset
  2582
b88c7410311f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1552
diff changeset
  2583
    endCol := colNr + aString size - 1.
b88c7410311f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1552
diff changeset
  2584
    (lineSize == 0) ifTrue:[
b88c7410311f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1552
diff changeset
  2585
        newLine := aString species new:endCol.
b88c7410311f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1552
diff changeset
  2586
    ] ifFalse: [
b88c7410311f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1552
diff changeset
  2587
        (endCol > lineSize) ifTrue: [
b88c7410311f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1552
diff changeset
  2588
            newLine := line species new:endCol.
b88c7410311f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1552
diff changeset
  2589
            newLine replaceFrom:1 to:lineSize with:line startingAt:1.
b88c7410311f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1552
diff changeset
  2590
        ] ifFalse: [
b88c7410311f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1552
diff changeset
  2591
            newLine := line copy.
b88c7410311f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1552
diff changeset
  2592
        ]
b88c7410311f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1552
diff changeset
  2593
    ].
b88c7410311f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1552
diff changeset
  2594
    newLine replaceFrom:colNr with:aString.
1559
cecf77805bff expand tabs in #replaceAll:...
Claus Gittinger <cg@exept.de>
parents: 1558
diff changeset
  2595
    (aString includes:(Character tab)) ifTrue:[
cecf77805bff expand tabs in #replaceAll:...
Claus Gittinger <cg@exept.de>
parents: 1558
diff changeset
  2596
        newLine := self withTabsExpanded:newLine.
cecf77805bff expand tabs in #replaceAll:...
Claus Gittinger <cg@exept.de>
parents: 1558
diff changeset
  2597
    ].
1557
b88c7410311f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1552
diff changeset
  2598
    list at:lineNr put:newLine.
b88c7410311f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1552
diff changeset
  2599
    widthOfWidestLine notNil ifTrue:[
b88c7410311f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1552
diff changeset
  2600
        widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:line).
b88c7410311f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1552
diff changeset
  2601
    ].
b88c7410311f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1552
diff changeset
  2602
    self textChanged.
b88c7410311f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1552
diff changeset
  2603
    shown ifTrue:[
1564
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  2604
        self redrawLine:lineNr from:colNr
1557
b88c7410311f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1552
diff changeset
  2605
    ]
b88c7410311f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1552
diff changeset
  2606
1564
04c13358013e renamed replaceAll:* to replaceString:*;
Claus Gittinger <cg@exept.de>
parents: 1563
diff changeset
  2607
    "Created: / 11.6.1998 / 10:38:32 / cg"
1567
0eff7ca88e89 much faster multi-line replace (avoid scroll)
Claus Gittinger <cg@exept.de>
parents: 1566
diff changeset
  2608
    "Modified: / 12.6.1998 / 22:06:11 / cg"
1557
b88c7410311f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1552
diff changeset
  2609
!
b88c7410311f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1552
diff changeset
  2610
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2611
splitLine:lineNr before:colNr
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2612
    "split the line linNr before colNr; the right part (from colNr)
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2613
     is cut off and inserted after lineNr; the view is redrawn"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2614
981
6e52d3876ea7 dont catchExpose, if copy is empty
Claus Gittinger <cg@exept.de>
parents: 960
diff changeset
  2615
    |line lineSize leftRest rightRest visLine w h mustWait    
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2616
     srcY    "{ Class: SmallInteger }" |
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2617
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2618
    list isNil ifFalse:[
1415
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2619
	lineNr > (list size) ifFalse:[
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2620
	    (colNr == 1) ifTrue:[
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2621
		self insertLine:nil before:lineNr.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2622
		^ self
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2623
	    ].
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2624
	    line := list at:lineNr.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2625
	    line isNil ifFalse:[
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2626
		lineSize := line size.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2627
		(colNr <= lineSize) ifTrue:[
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2628
		    rightRest := line copyFrom:colNr to:lineSize.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2629
		    (colNr > 1) ifTrue:[
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2630
			leftRest := line copyTo:(colNr - 1)
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2631
		    ]
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2632
		] ifFalse:[
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2633
		    leftRest := line
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2634
		]
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2635
	    ].
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2636
	    leftRest notNil ifTrue:[
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2637
		(trimBlankLines and:[leftRest isBlank]) ifTrue:[leftRest := nil]
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2638
	    ].
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2639
	    list at:lineNr put:leftRest.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2640
	    self withoutRedrawInsertLine:rightRest before:(lineNr + 1).
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2641
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2642
	    visLine := self listLineToVisibleLine:(lineNr).
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2643
	    visLine notNil ifTrue:[
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2644
		w := self widthForScrollBetween:lineNr
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2645
					    and:(firstLineShown + nLinesShown).
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2646
		srcY := topMargin + (visLine * fontHeight).
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2647
		h := ((nLinesShown - visLine - 1) * fontHeight).
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2648
		(mustWait := (w > 0 and:[h > 0])) ifTrue:[
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2649
		    self catchExpose.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2650
		    self 
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2651
			copyFrom:self 
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2652
			x:textStartLeft y:srcY
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2653
			toX:textStartLeft y:(srcY + fontHeight)
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2654
			width:w
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2655
			height:((nLinesShown - visLine - 1) * fontHeight)
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2656
			async:true.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2657
		].
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2658
		self redrawLine:lineNr.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2659
		self redrawLine:(lineNr + 1).
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2660
		mustWait ifTrue:[self waitForExpose]
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2661
	    ].
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2662
	    widthOfWidestLine := nil. "/ unknown
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2663
	    self textChanged.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  2664
	]
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2665
    ]
671
f3fe0d8c604d added trimBlankLines flag & handling
Claus Gittinger <cg@exept.de>
parents: 666
diff changeset
  2666
984
dbd60475b3f5 explicit async bitBlt
Claus Gittinger <cg@exept.de>
parents: 981
diff changeset
  2667
    "Modified: 29.1.1997 / 13:03:22 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2668
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2669
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2670
withoutRedrawInsertLine:aString before:lineNr
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2671
    "insert the argument, aString before line lineNr; the string
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2672
     becomes line nileNr; everything else is moved down; the view
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2673
     is not redrawn"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2674
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2675
    |line|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2676
331
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
  2677
    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
  2678
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2679
    line := aString.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2680
    line notNil ifTrue:[
1560
43d0f7c2143f use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents: 1559
diff changeset
  2681
        line isString ifTrue:[
43d0f7c2143f use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents: 1559
diff changeset
  2682
            line isBlank ifTrue:[
43d0f7c2143f use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents: 1559
diff changeset
  2683
                line := nil
43d0f7c2143f use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents: 1559
diff changeset
  2684
            ] ifFalse:[
43d0f7c2143f use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents: 1559
diff changeset
  2685
                (line includes:(Character tab)) ifTrue:[
43d0f7c2143f use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents: 1559
diff changeset
  2686
                    line := self withTabsExpanded:line
43d0f7c2143f use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents: 1559
diff changeset
  2687
                ]
43d0f7c2143f use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents: 1559
diff changeset
  2688
            ]
43d0f7c2143f use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents: 1559
diff changeset
  2689
        ]
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2690
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2691
    list isNil ifTrue: [
1560
43d0f7c2143f use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents: 1559
diff changeset
  2692
        list := StringCollection new:lineNr
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2693
    ] ifFalse: [
1560
43d0f7c2143f use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents: 1559
diff changeset
  2694
        list grow:((list size + 1) max:lineNr)
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2695
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2696
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2697
    "I have changed 'replaceFrom:to:with:startingAt:' to correctly handle 
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2698
     overlapping copy - if it didn't, we had to use:"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2699
"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2700
    index := list size.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2701
    [index > lineNr] whileTrue: [
1560
43d0f7c2143f use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents: 1559
diff changeset
  2702
        pIndex := index - 1.
43d0f7c2143f use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents: 1559
diff changeset
  2703
        list at:index put:(list at:pIndex).
43d0f7c2143f use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents: 1559
diff changeset
  2704
        index := pIndex
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2705
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2706
"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2707
    list replaceFrom:(lineNr + 1) to:(list size) with:list startingAt:lineNr.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2708
    list at:lineNr put:line.
991
2d97ed971ce4 need a self>>contentsChanged when inserting lines.
Claus Gittinger <cg@exept.de>
parents: 984
diff changeset
  2709
    self contentsChanged
2d97ed971ce4 need a self>>contentsChanged when inserting lines.
Claus Gittinger <cg@exept.de>
parents: 984
diff changeset
  2710
1560
43d0f7c2143f use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents: 1559
diff changeset
  2711
    "Modified: / 10.6.1998 / 19:00:56 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2712
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2713
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2714
withoutRedrawInsertLines:lines from:start to:end before:lineNr
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2715
    "insert a bunch of lines before line lineNr; the view is not redrawn"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2716
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2717
    |newLine newLines nLines|
121
claus
parents: 118
diff changeset
  2718
331
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
  2719
    self checkModificationsAllowed ifFalse:[ ^ self].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2720
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2721
    nLines := end - start + 1.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2722
    newLines := Array new:(lines size).
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2723
    start to:end do:[:index |
1560
43d0f7c2143f use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents: 1559
diff changeset
  2724
        newLine := lines at:index.
43d0f7c2143f use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents: 1559
diff changeset
  2725
        newLine notNil ifTrue:[
43d0f7c2143f use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents: 1559
diff changeset
  2726
            newLine isString ifTrue:[
43d0f7c2143f use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents: 1559
diff changeset
  2727
                newLine isBlank ifTrue:[
43d0f7c2143f use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents: 1559
diff changeset
  2728
                    newLine := nil
43d0f7c2143f use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents: 1559
diff changeset
  2729
                ] ifFalse:[
43d0f7c2143f use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents: 1559
diff changeset
  2730
                    (newLine includes:(Character tab)) ifTrue:[
43d0f7c2143f use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents: 1559
diff changeset
  2731
                        newLine := self withTabsExpanded:newLine
43d0f7c2143f use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents: 1559
diff changeset
  2732
                    ]
43d0f7c2143f use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents: 1559
diff changeset
  2733
                ]
43d0f7c2143f use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents: 1559
diff changeset
  2734
            ]
43d0f7c2143f use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents: 1559
diff changeset
  2735
        ].
43d0f7c2143f use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents: 1559
diff changeset
  2736
        newLines at:index put:newLine
121
claus
parents: 118
diff changeset
  2737
    ].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2738
    list isNil ifTrue: [
1560
43d0f7c2143f use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents: 1559
diff changeset
  2739
        list := StringCollection new:(lineNr + nLines + 1)
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2740
    ] ifFalse: [
1560
43d0f7c2143f use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents: 1559
diff changeset
  2741
        list grow:((list size + nLines) max:(lineNr + nLines - 1))
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2742
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2743
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2744
    "I have changed 'replaceFrom:to:with:startingAt:' to correctly handle 
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2745
     overlapping copy - if it didn't, we had to use:"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2746
"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2747
    index := list size.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2748
    [index > lineNr] whileTrue: [
1560
43d0f7c2143f use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents: 1559
diff changeset
  2749
        pIndex := index - 1.
43d0f7c2143f use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents: 1559
diff changeset
  2750
        list at:index put:(list at:pIndex).
43d0f7c2143f use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents: 1559
diff changeset
  2751
        index := pIndex
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2752
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2753
"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2754
    list replaceFrom:(lineNr + nLines) to:(list size) with:list startingAt:lineNr.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2755
    list replaceFrom:lineNr to:(lineNr + nLines - 1) with:newLines startingAt:start.
991
2d97ed971ce4 need a self>>contentsChanged when inserting lines.
Claus Gittinger <cg@exept.de>
parents: 984
diff changeset
  2756
    self contentsChanged
2d97ed971ce4 need a self>>contentsChanged when inserting lines.
Claus Gittinger <cg@exept.de>
parents: 984
diff changeset
  2757
1560
43d0f7c2143f use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents: 1559
diff changeset
  2758
    "Modified: / 10.6.1998 / 19:01:16 / cg"
121
claus
parents: 118
diff changeset
  2759
!
claus
parents: 118
diff changeset
  2760
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2761
withoutRedrawInsertStringWithoutCRs:aString atLine:lineNr col:colNr
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2762
    "insert aString (which has no crs) at lineNr/colNr"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2763
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2764
    |isText strLen line lineSize newLine stringType sz|
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2765
1480
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  2766
    (aString notNil) ifFalse:[ ^ self].
331
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
  2767
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2768
    strLen := aString size.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2769
    self checkForExistingLine:lineNr.
400
70fb3a81922f better create a 16bit string when pasting one into an 8bit string
Claus Gittinger <cg@exept.de>
parents: 387
diff changeset
  2770
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2771
    stringType := aString string species.
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2772
    isText     := aString isText.
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2773
    line       := list at:lineNr.
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2774
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2775
    line notNil ifTrue:[
1480
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  2776
        lineSize := line size.
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  2777
        line bitsPerCharacter > aString bitsPerCharacter ifTrue:[
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  2778
            stringType := line string species
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  2779
        ].
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  2780
        line isText ifTrue:[ isText := true ]
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2781
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2782
    ] ifFalse:[
1480
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  2783
        lineSize := 0
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2784
    ].
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  2785
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2786
    ((colNr == 1) and:[lineSize == 0]) ifTrue: [
1480
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  2787
        newLine := aString
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2788
    ] ifFalse:[
1480
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  2789
        (lineSize == 0 or:[colNr > lineSize]) ifTrue: [
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  2790
            sz := colNr + strLen - 1
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  2791
        ] ifFalse:[
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  2792
            sz := lineSize + strLen
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  2793
        ].
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  2794
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  2795
        isText ifFalse:[
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  2796
            newLine := stringType new:sz
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  2797
        ] ifTrue:[
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  2798
            newLine := Text string:(stringType new:sz)
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  2799
        ].
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  2800
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  2801
        (lineSize ~~ 0) ifTrue: [
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  2802
            (colNr > lineSize) ifTrue: [
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  2803
                newLine replaceFrom:1 to:lineSize
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  2804
                               with:line startingAt:1
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  2805
            ] ifFalse: [
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  2806
                newLine replaceFrom:1 to:(colNr - 1)
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  2807
                               with:line startingAt:1.
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  2808
                newLine replaceFrom:(colNr + strLen) to:(lineSize + strLen)
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  2809
                               with:line startingAt:colNr
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  2810
            ]
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  2811
        ].
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  2812
        newLine replaceFrom:colNr to:(colNr + strLen - 1)
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  2813
                       with:aString startingAt:1
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2814
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2815
1560
43d0f7c2143f use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents: 1559
diff changeset
  2816
    (aString includes:(Character tab)) ifTrue:[
1480
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  2817
        newLine := self withTabsExpanded:newLine
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2818
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2819
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2820
    list at:lineNr put:newLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2821
    widthOfWidestLine notNil ifTrue:[
1480
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  2822
        widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:newLine).
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2823
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2824
    self textChanged.
385
a373f2dd9c60 care when editing 16bit text (dont hardcode String into the edit methods)
Claus Gittinger <cg@exept.de>
parents: 362
diff changeset
  2825
1560
43d0f7c2143f use includes: instead of occurrencesOf:.
Claus Gittinger <cg@exept.de>
parents: 1559
diff changeset
  2826
    "Modified: / 10.6.1998 / 19:01:52 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2827
! !
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2828
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2829
!EditTextView methodsFor:'event processing'!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2830
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2831
buttonPress:button x:x y:y
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2832
    "hide the cursor when button is activated"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2833
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2834
    hasKeyboardFocus := true.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2835
    cursorShown ifTrue: [self drawCursor].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2836
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2837
    ((button == 1) or:[button == #select]) ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2838
	self hideCursor
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2839
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2840
    (button == #paste) ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2841
	self pasteOrReplace.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2842
	^ self
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2843
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2844
    super buttonPress:button x:x y:y
121
claus
parents: 118
diff changeset
  2845
!
claus
parents: 118
diff changeset
  2846
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2847
buttonRelease:button x:x y:y
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2848
    "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
  2849
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2850
    ((button == 1) or:[button == #select]) ifTrue:[
1580
d30e562bea15 allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
  2851
        typeOfSelection := nil. 
d30e562bea15 allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
  2852
        selectionStartLine isNil ifTrue:[
d30e562bea15 allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
  2853
            clickCol notNil ifTrue:[
d30e562bea15 allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
  2854
                self cursorMovementAllowed ifTrue:[
d30e562bea15 allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
  2855
                    self cursorLine:clickLine col:clickCol
d30e562bea15 allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
  2856
                ]
d30e562bea15 allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
  2857
            ]
d30e562bea15 allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
  2858
        ] ifFalse:[
d30e562bea15 allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
  2859
            lastString := nil. "new selection invalidates remembered string"
d30e562bea15 allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
  2860
        ].
d30e562bea15 allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
  2861
        self showCursor
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2862
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2863
    super buttonRelease:button x:x y:y
1580
d30e562bea15 allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
  2864
d30e562bea15 allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
  2865
    "Modified: / 18.6.1998 / 14:14:05 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2866
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2867
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2868
hasKeyboardFocus:aBoolean
893
33d35adb2702 share code of #hasKeyboardFocus:.
Claus Gittinger <cg@exept.de>
parents: 879
diff changeset
  2869
    "sent by a delegate or myself to make me show a block cursor
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2870
     (otherwise, I would not know about this)"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2871
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2872
    hasKeyboardFocus := aBoolean.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2873
    cursorShown ifTrue: [self drawCursor].
893
33d35adb2702 share code of #hasKeyboardFocus:.
Claus Gittinger <cg@exept.de>
parents: 879
diff changeset
  2874
33d35adb2702 share code of #hasKeyboardFocus:.
Claus Gittinger <cg@exept.de>
parents: 879
diff changeset
  2875
    "Modified: 11.12.1996 / 16:56:12 / cg"
121
claus
parents: 118
diff changeset
  2876
!
claus
parents: 118
diff changeset
  2877
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2878
keyPress:key x:x y:y
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2879
    "handle keyboard input"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2880
922
e6a5e1cf9565 resource spec updated
Claus Gittinger <cg@exept.de>
parents: 915
diff changeset
  2881
    <resource: #keyboard (#Paste #Insert #Cut #Again #Replace #Accept
1446
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  2882
                          #Delete #BasicDelete #BackSpace #BasicBackspace
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  2883
                          #SelectWord
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  2884
                          #SearchMatchingParent #SelectMatchingParents 
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  2885
                          #SelectToEnd #SelectFromBeginning
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  2886
                          #BeginOfLine #EndOfLine #NextWord #PreviousWord
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  2887
                          #CursorRight #CursorDown #CursorLeft #CursorUp
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  2888
                          #Return #Tab #Escape
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  2889
                          #GotoLine #Delete #BeginOfText #EndOfText
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  2890
                          #SelectLine #ExpandSelectionByLine #DeleteLine
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  2891
                          #InsertLine
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  2892
                          #SelectLineFromBeginning
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  2893
                          #'F*' #'f*')>
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2894
474
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  2895
    |sensor n fKeyMacros shifted i|
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2896
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2897
    sensor := self sensor.
1287
cdda8de0af0c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1275
diff changeset
  2898
    sensor notNil ifTrue:[
1446
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  2899
        shifted := sensor shiftDown.
1287
cdda8de0af0c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1275
diff changeset
  2900
    ] ifFalse:[
1446
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  2901
        shifted := device shiftDown
1287
cdda8de0af0c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1275
diff changeset
  2902
    ].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2903
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2904
    (key isMemberOf:Character) ifTrue:[
1548
d4a3d61388dc flash view in readonly mode, when modification is attempted.
Claus Gittinger <cg@exept.de>
parents: 1546
diff changeset
  2905
        readOnly ifTrue:[
d4a3d61388dc flash view in readonly mode, when modification is attempted.
Claus Gittinger <cg@exept.de>
parents: 1546
diff changeset
  2906
            self flash
d4a3d61388dc flash view in readonly mode, when modification is attempted.
Claus Gittinger <cg@exept.de>
parents: 1546
diff changeset
  2907
        ] ifFalse:[
1446
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  2908
            typeOfSelection == #paste ifTrue:[
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  2909
                "pasted selection will NOT be replaced by keystroke"
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  2910
                self unselect
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  2911
            ].
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  2912
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  2913
            "replace selection by what is typed in -
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  2914
             if word was selected with a space, keep it"
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  2915
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  2916
            (selectStyle == #wordLeft) ifTrue:[
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  2917
                self replaceSelectionBy:(' ' copyWith:key)
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  2918
            ] ifFalse:[
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  2919
                (selectStyle == #wordRight) ifTrue:[
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  2920
                    self replaceSelectionBy:(key asString , ' ').
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  2921
                    self cursorLeft
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  2922
                ] ifFalse:[
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  2923
                    self replaceSelectionBy:key
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  2924
                ]
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  2925
            ].
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  2926
            selectStyle := nil.
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  2927
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  2928
            showMatchingParenthesis ifTrue:[
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  2929
                "emacs style parenthesis shower"
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  2930
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  2931
                "claus: only do it for closing parenthesis -
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  2932
                        otherwise its too anoying.
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  2933
                "
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2934
"
1446
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  2935
                (#( $( $) $[ $] ${ $} ) includes:key) ifTrue:[
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2936
"
1446
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  2937
                (#( $) $] $} ) includes:key) ifTrue:[
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  2938
                self searchForMatchingParenthesisFromLine:cursorLine col:(cursorCol - 1)
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  2939
                                   ifFound:[:line :col |
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  2940
                                                |savLine savCol|
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  2941
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  2942
                                                self withCursor:Cursor eye do:[
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  2943
                                                    savLine := cursorLine.
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  2944
                                                    savCol := cursorCol.
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  2945
                                                    self cursorLine:line col:col.
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  2946
                                                    device flush.
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  2947
                                                    Processor activeProcess millisecondDelay:200.
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  2948
                                                    self cursorLine:savLine col:savCol
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  2949
                                                ]
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  2950
                                           ]
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  2951
                                ifNotFound:[self showNotFound]
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  2952
                                   onError:[self beep]
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  2953
                ].
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  2954
            ].
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  2955
        ].
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  2956
        ^ self
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2957
    ].                         
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2958
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2959
    replacing := false.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2960
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2961
    "
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2962
     Fn      pastes a key-sequence (but only if not overlayed with
1446
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  2963
             another function in the keyboard map)
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2964
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2965
     see TextView>>:x:y
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2966
    "
1177
9d23e1241404 avoid match: if possible (to not clobber the previous matchString)
Claus Gittinger <cg@exept.de>
parents: 1108
diff changeset
  2967
    (key at:1) asLowercase == $f ifTrue:[
1446
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  2968
        (('[fF][0-9]' match:key)
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  2969
        or:['[fF][0-9][0-9]' match:key]) ifTrue:[
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  2970
            shifted ifFalse:[
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  2971
                fKeyMacros := Smalltalk at:#FunctionKeySequences.
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  2972
                fKeyMacros notNil ifTrue:[
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  2973
                    (fKeyMacros includesKey:key) ifTrue:[
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  2974
                        self pasteOrReplace:(fKeyMacros at:key) asStringCollection.
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  2975
                        ^ self
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  2976
                    ]
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  2977
                ]
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  2978
            ]
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  2979
        ].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2980
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2981
274
6df4bb990f04 handle accept where acceptAction is define (this was a historic leftover)
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
  2982
    (key == #Accept)  ifTrue:[^ self accept].
6df4bb990f04 handle accept where acceptAction is define (this was a historic leftover)
Claus Gittinger <cg@exept.de>
parents: 259
diff changeset
  2983
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2984
    ((key == #Paste) or:[key == #Insert]) ifTrue:[self pasteOrReplace. ^self].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2985
    (key == #Cut) ifTrue:[self cut. ^self].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2986
    (key == #Again) ifTrue:[self again. ^self].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2987
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2988
    (key == #Replace) ifTrue:[self replace. ^self].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2989
    (key == #SelectWord) ifTrue:[
1446
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  2990
        self makeCursorVisible.
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  2991
        ^ self selectWordUnderCursor. 
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2992
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2993
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2994
    (key == #SearchMatchingParent) ifTrue:[^ self searchForMatchingParenthesis.].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2995
    (key == #SelectMatchingParents) ifTrue:[^ self searchForAndSelectMatchingParenthesis.].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2996
    (key == #SelectToEnd) ifTrue:[^ self selectUpToEnd.].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2997
    (key == #SelectFromBeginning) ifTrue:[^ self selectFromBeginning.].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2998
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  2999
" disabled - nobody liked it ...
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3000
  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
  3001
1304
173d00c195f9 flush pending keyboard events in cursor-up/down
Claus Gittinger <cg@exept.de>
parents: 1300
diff changeset
  3002
    (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
  3003
    (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
  3004
    (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
  3005
    (key == #Ctrlp) ifTrue:[self unselect. self cursorUp. ^ self].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3006
"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3007
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3008
    (key == #BeginOfLine) ifTrue:[self cursorToBeginOfLine. ^self].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3009
    (key == #EndOfLine) ifTrue:[self cursorToEndOfLine. ^self].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3010
    (key == #NextWord) ifTrue:[self cursorToNextWord. ^self].
499
939f39bd545f added previousWord
Claus Gittinger <cg@exept.de>
parents: 488
diff changeset
  3011
    (key == #PreviousWord) ifTrue:[self cursorToPreviousWord. ^self].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3012
    (key == #GotoLine) ifTrue:[self gotoLine. ^self].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3013
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3014
    (key == #CursorRight) ifTrue:[
1446
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3015
        (shifted and:[selectionStartLine isNil]) ifTrue:[
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3016
            selectionStartLine := selectionEndLine := clickStartLine := cursorLine.
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3017
            selectionStartCol := selectionEndCol := clickStartCol := cursorCol.
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3018
            expandingTop := false.
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3019
            ^ self redrawLine:selectionStartLine. 
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3020
        ].
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3021
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3022
        selectionStartLine notNil ifTrue:[
1580
d30e562bea15 allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
  3023
            self cursorMovementAllowed ifTrue:[
d30e562bea15 allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
  3024
                "/
d30e562bea15 allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
  3025
                "/ treat the whole selection as cursor
d30e562bea15 allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
  3026
                "/
d30e562bea15 allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
  3027
                cursorLine := selectionEndLine.
d30e562bea15 allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
  3028
                cursorVisibleLine := self listLineToVisibleLine:cursorLine.
d30e562bea15 allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
  3029
                selectionEndCol == 0 ifTrue:[
d30e562bea15 allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
  3030
                    selectionEndCol := 1.
d30e562bea15 allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
  3031
                ].
d30e562bea15 allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
  3032
                cursorCol := selectionEndCol.
d30e562bea15 allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
  3033
                shifted ifTrue:[
d30e562bea15 allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
  3034
                    self expandSelectionRight.
d30e562bea15 allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
  3035
                    ^ self
d30e562bea15 allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
  3036
                ].
d30e562bea15 allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
  3037
                self unselect; makeCursorVisible.
d30e562bea15 allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
  3038
                cursorCol == 1 ifTrue:[^ self].
1446
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3039
            ].
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3040
        ].
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3041
        self cursorRight. ^self
121
claus
parents: 118
diff changeset
  3042
    ].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3043
    (key == #CursorDown) ifTrue:[
1446
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3044
        (shifted and:[selectionStartLine isNil]) ifTrue:[
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3045
            selectionStartLine := clickStartLine := cursorLine. selectionEndLine := cursorLine + 1.
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3046
            selectionStartCol := clickStartCol := selectionEndCol := cursorCol.
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3047
            self redrawLine:selectionStartLine. 
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3048
            expandingTop := false.
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3049
            ^ self redrawLine:selectionEndLine. 
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3050
        ].
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3051
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3052
        selectionStartLine notNil ifTrue:[
1580
d30e562bea15 allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
  3053
            self cursorMovementAllowed ifTrue:[
d30e562bea15 allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
  3054
                "/
d30e562bea15 allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
  3055
                "/ treat the whole selection as cursor
d30e562bea15 allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
  3056
                "/
d30e562bea15 allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
  3057
                cursorLine := selectionEndLine.
1446
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3058
                cursorVisibleLine := self listLineToVisibleLine:cursorLine.
1580
d30e562bea15 allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
  3059
                cursorCol := selectionStartCol.
d30e562bea15 allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
  3060
                cursorCol == 0 ifTrue:[
d30e562bea15 allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
  3061
                    cursorCol := 1.
d30e562bea15 allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
  3062
                    cursorLine := cursorLine - 1.
d30e562bea15 allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
  3063
                    cursorVisibleLine := self listLineToVisibleLine:cursorLine.
d30e562bea15 allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
  3064
                ].
d30e562bea15 allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
  3065
                self makeCursorVisible.
d30e562bea15 allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
  3066
d30e562bea15 allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
  3067
                shifted ifTrue:[
d30e562bea15 allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
  3068
                    clickLine := cursorLine.
d30e562bea15 allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
  3069
                    clickCol := cursorCol.
d30e562bea15 allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
  3070
                    self expandSelectionDown.
d30e562bea15 allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
  3071
                    ^ self
d30e562bea15 allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
  3072
                ].
d30e562bea15 allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
  3073
                self unselect. 
1446
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3074
            ].
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3075
        ].
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3076
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3077
        sensor isNil ifTrue:[
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3078
            n := 1
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3079
        ] ifFalse:[
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3080
            n := 1 + (sensor compressKeyPressEventsWithKey:#CursorDown).
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3081
        ].
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3082
        self cursorDown:n. 
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3083
        "/
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3084
        "/ flush keyboard to avoid runaway cursor
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3085
        "/
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3086
        sensor notNil ifTrue:[self sensor flushKeyboardFor:self].
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3087
        ^ self
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3088
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3089
    (key == #CursorLeft or:[key == #CursorUp]) ifTrue:[
1446
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3090
        (shifted and:[selectionStartLine isNil]) ifTrue:[
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3091
            expandingTop := true.
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3092
            key == #CursorLeft ifTrue:[
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3093
                cursorCol > 1 ifTrue:[
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3094
                    selectionStartLine := selectionEndLine := clickStartLine := cursorLine.
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3095
                    selectionEndCol := clickStartCol := cursorCol-1.
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3096
                    selectionStartCol := cursorCol-1.
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3097
                    ^ self redrawLine:selectionStartLine. 
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3098
                ]
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3099
            ] ifFalse:[
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3100
                cursorLine > 1 ifTrue:[
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3101
                    selectionEndLine := clickStartLine := cursorLine.
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3102
                    selectionEndCol := selectionStartCol := clickStartCol := cursorCol.
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3103
                    selectionStartLine := cursorLine - 1.
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3104
                    ^ self redrawFromLine:selectionStartLine to:cursorLine. 
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3105
                ]
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3106
            ]
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3107
        ].
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3108
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3109
        selectionStartLine notNil ifTrue:[
1580
d30e562bea15 allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
  3110
            self cursorMovementAllowed ifTrue:[
d30e562bea15 allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
  3111
                "/
d30e562bea15 allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
  3112
                "/ treat the whole selection as cursor
d30e562bea15 allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
  3113
                "/
d30e562bea15 allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
  3114
                cursorLine := selectionStartLine.
d30e562bea15 allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
  3115
                cursorVisibleLine := self listLineToVisibleLine:cursorLine.
d30e562bea15 allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
  3116
                cursorCol := selectionStartCol.
d30e562bea15 allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
  3117
                (key == #CursorLeft) ifTrue:[    
d30e562bea15 allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
  3118
                    cursorCol := cursorCol+1.  "/ compensate for followup crsr-left
d30e562bea15 allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
  3119
                ].
d30e562bea15 allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
  3120
                self makeCursorVisible.
d30e562bea15 allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
  3121
d30e562bea15 allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
  3122
                shifted ifTrue:[
d30e562bea15 allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
  3123
                    (key == #CursorUp) ifTrue:[
d30e562bea15 allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
  3124
                        clickLine := cursorLine.
d30e562bea15 allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
  3125
                        ^ self expandSelectionUp.
d30e562bea15 allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
  3126
                    ].
d30e562bea15 allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
  3127
                    ^ self expandSelectionLeft.
d30e562bea15 allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
  3128
                ].
d30e562bea15 allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
  3129
                self unselect. 
1446
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3130
            ].
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3131
        ].
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3132
        (key == #CursorLeft) ifTrue:[
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3133
            self cursorLeft. ^self
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3134
        ].
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3135
        (key == #CursorUp)        ifTrue:[
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3136
            sensor isNil ifTrue:[
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3137
                n := 1
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3138
            ] ifFalse:[
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3139
                n := 1 + (sensor compressKeyPressEventsWithKey:#CursorUp).
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3140
            ].
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3141
            self cursorUp:n. 
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3142
            "/
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3143
            "/ flush keyboard to avoid runaway cursor
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3144
            "/
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3145
            sensor notNil ifTrue:[sensor flushKeyboardFor:self].
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3146
            ^ self
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3147
        ].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3148
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3149
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3150
    (key == #Return)    ifTrue:[
1446
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3151
        shifted ifTrue:[
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3152
            self unselect. self cursorReturn. ^self
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3153
        ].
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3154
        readOnly ifTrue:[
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3155
            self unselect; makeCursorVisible.
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3156
            self cursorReturn
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3157
        ] ifFalse:[
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3158
            insertMode ifFalse:[
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3159
                self cursorReturn.
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3160
                autoIndent == true ifTrue:[
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3161
                    i := self leftIndentForLine:(cursorLine + 1).
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3162
                    self cursorCol:(i+1 max:1)
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3163
                ]
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3164
            ] ifTrue:[
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3165
                "/ old version just unselected ...
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3166
                "/ self unselect; makeCursorVisible.
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3167
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3168
                "/ new version deletes ...
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3169
                typeOfSelection == #paste ifTrue:[
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3170
                    self unselect; makeCursorVisible.
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3171
                ] ifFalse:[
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3172
                    self copyAndDeleteSelection.            
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3173
                ].
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3174
                self insertCharAtCursor:(Character cr). 
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3175
                autoIndent == true ifTrue:[
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3176
                    i := self leftIndentForLine:cursorLine.
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3177
                    self indentFromLine:cursorLine toLine:cursorLine.
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3178
                    self cursorCol:(i+1 max:1)
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3179
                ].
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3180
            ].
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3181
        ].
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3182
        ^self
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3183
    ].
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
  3184
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3185
    (key == #Tab) ifTrue:[
1446
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3186
        self tabMeansNextField ifTrue:[^ super keyPress:key x:x y:y].
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3187
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3188
        shifted ifTrue:[
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3189
            "
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3190
             the old version used shift-tab as backtab,
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3191
             however, backtab was seldom used.
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3192
             An alternative is to make it a non-inserting tab ...
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3193
            "
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3194
            "/ self unselect. self cursorBacktab.
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3195
            self unselect. self cursorTab. 
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3196
            ^self
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3197
        ].
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3198
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3199
        "
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3200
         uncomment line below, if you like RAND/INed/MAXed editor behavior
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3201
         (where tab-key is only cursor positioning)
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3202
         this was the original behavior of the TAB key, but many people
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3203
         complained ....
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3204
        "
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3205
        insertMode ifFalse:[
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3206
            self unselect. self cursorTab. ^self
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3207
        ].
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3208
        self unselect. self insertTabAtCursor. 
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3209
        ^self
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3210
    ].
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
  3211
870
c606f29db5d7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 865
diff changeset
  3212
    (key == #BackSpace
c606f29db5d7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 865
diff changeset
  3213
     or:[key == #BasicBackspace]) ifTrue:[
1446
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3214
        selectionStartLine notNil ifTrue:[
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3215
            (key == #BasicBackspace) ifTrue:[
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3216
                ^ self deleteSelection.
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3217
            ] ifFalse:[
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3218
                ^ self copyAndDeleteSelection.
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3219
            ].
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3220
        ].
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3221
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3222
        self makeCursorVisible.
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3223
        self deleteCharBeforeCursor. ^self
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3224
    ].
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
  3225
870
c606f29db5d7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 865
diff changeset
  3226
    (key == #Delete
c606f29db5d7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 865
diff changeset
  3227
     or:[key == #BasicDelete]) ifTrue:[
1446
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3228
        selectionStartLine notNil ifTrue:[
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3229
            (key == #BasicDelete) ifTrue:[
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3230
                ^ self deleteSelection.
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3231
            ] ifFalse:[
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3232
                ^ self copyAndDeleteSelection.
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3233
            ].
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3234
        ].
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3235
        self makeCursorVisible.
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3236
        self deleteCharAtCursor. ^self
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3237
    ].
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
  3238
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3239
    (key == #BeginOfText) ifTrue:[     "i.e. HOME"
1446
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3240
        self unselect. 
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3241
        cursorVisibleLine == 1 ifTrue:[
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3242
            self cursorHome.
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3243
        ] ifFalse:[
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3244
            self cursorToFirstVisibleLine
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3245
        ].
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3246
        ^ self
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3247
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3248
    (key == #EndOfText) ifTrue:[       "i.e. END"
1446
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3249
        self unselect.
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3250
        cursorVisibleLine == nFullLinesShown ifTrue:[
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3251
            self cursorToBottom.
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3252
        ] ifFalse:[
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3253
            self cursorToLastVisibleLine
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3254
        ].
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3255
        ^self
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3256
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3257
    ((key == #Escape)
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3258
    or:[key == #SelectLineFromBeginning])    ifTrue:[
1446
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3259
        self makeCursorVisible.
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3260
        self unselect. self selectCursorLineFromBeginning. ^ self
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3261
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3262
    (key == #SelectLine)    ifTrue:[
1446
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3263
        self makeCursorVisible.
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3264
        self unselect. self selectCursorLine. ^ self
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3265
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3266
    (key == #ExpandSelectionByLine)    ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3267
"/        self makeCursorVisible.
1446
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3268
        self selectExpandCursorLine. ^ self
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3269
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3270
    (key == #DeleteLine)    ifTrue:[
1446
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3271
        self makeCursorVisible.
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3272
        self unselect. self deleteCursorLine. ^self
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3273
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3274
    (key == #InsertLine)    ifTrue:[
1446
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3275
        self makeCursorVisible.
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3276
        self unselect. self insertLine:nil before:cursorLine. ^self
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3277
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3278
    super keyPress:key x:x y:y
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3279
1446
609e20a4a234 Fix selections with ShiftCursorKeys.
Stefan Vogel <sv@exept.de>
parents: 1439
diff changeset
  3280
    "Modified: / 6.2.1998 / 11:59:59 / stefan"
1580
d30e562bea15 allow cursorMovement with button-press
Claus Gittinger <cg@exept.de>
parents: 1577
diff changeset
  3281
    "Modified: / 18.6.1998 / 14:13:41 / cg"
121
claus
parents: 118
diff changeset
  3282
!
claus
parents: 118
diff changeset
  3283
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3284
mapped
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3285
    "view was made visible"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3286
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3287
    super mapped.
915
5147640d0cf7 do not make cursor visible when mapped, but instead
Claus Gittinger <cg@exept.de>
parents: 905
diff changeset
  3288
"/    self makeCursorVisible.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3289
    cursorVisibleLine := self listLineToVisibleLine:cursorLine.
915
5147640d0cf7 do not make cursor visible when mapped, but instead
Claus Gittinger <cg@exept.de>
parents: 905
diff changeset
  3290
5147640d0cf7 do not make cursor visible when mapped, but instead
Claus Gittinger <cg@exept.de>
parents: 905
diff changeset
  3291
    "Modified: 20.12.1996 / 14:15:56 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3292
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3293
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3294
pointerEnter:state x:x y:y
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3295
    (windowGroup isNil or:[windowGroup focusView isNil]) ifTrue:[
1415
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  3296
	self hasKeyboardFocus:true
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3297
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3298
    super pointerEnter:state x:x y:y
893
33d35adb2702 share code of #hasKeyboardFocus:.
Claus Gittinger <cg@exept.de>
parents: 879
diff changeset
  3299
33d35adb2702 share code of #hasKeyboardFocus:.
Claus Gittinger <cg@exept.de>
parents: 879
diff changeset
  3300
    "Modified: 11.12.1996 / 16:56:30 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3301
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3302
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3303
pointerLeave:state
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3304
    (windowGroup isNil or:[windowGroup focusView isNil]) ifTrue:[
1415
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  3305
	self hasKeyboardFocus:false
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3306
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3307
    super pointerLeave:state
893
33d35adb2702 share code of #hasKeyboardFocus:.
Claus Gittinger <cg@exept.de>
parents: 879
diff changeset
  3308
33d35adb2702 share code of #hasKeyboardFocus:.
Claus Gittinger <cg@exept.de>
parents: 879
diff changeset
  3309
    "Modified: 11.12.1996 / 16:56:43 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3310
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3311
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
  3312
showFocus:explicit
893
33d35adb2702 share code of #hasKeyboardFocus:.
Claus Gittinger <cg@exept.de>
parents: 879
diff changeset
  3313
    self hasKeyboardFocus:true.
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
  3314
    super showFocus:explicit
893
33d35adb2702 share code of #hasKeyboardFocus:.
Claus Gittinger <cg@exept.de>
parents: 879
diff changeset
  3315
33d35adb2702 share code of #hasKeyboardFocus:.
Claus Gittinger <cg@exept.de>
parents: 879
diff changeset
  3316
    "Modified: 11.12.1996 / 16:56:54 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3317
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3318
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
  3319
showNoFocus:explicit
893
33d35adb2702 share code of #hasKeyboardFocus:.
Claus Gittinger <cg@exept.de>
parents: 879
diff changeset
  3320
    self hasKeyboardFocus:false.
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
  3321
    super showNoFocus:explicit
893
33d35adb2702 share code of #hasKeyboardFocus:.
Claus Gittinger <cg@exept.de>
parents: 879
diff changeset
  3322
33d35adb2702 share code of #hasKeyboardFocus:.
Claus Gittinger <cg@exept.de>
parents: 879
diff changeset
  3323
    "Modified: 11.12.1996 / 16:57:03 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3324
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3325
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3326
sizeChanged:how
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3327
    "make certain, cursor is visible after the sizechange"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3328
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3329
    |cv|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3330
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3331
    cv := cursorVisibleLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3332
    super sizeChanged:how.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3333
    cv notNil ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3334
	self makeLineVisible:cursorLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3335
    ]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3336
! !
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3337
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3338
!EditTextView methodsFor:'formatting'!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3339
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3340
indent
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3341
    "indent selected line-range"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3342
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3343
    |start end|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3344
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3345
    selectionStartLine isNil ifTrue:[^ self].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3346
    start := selectionStartLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3347
    end := selectionEndLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3348
    (selectionEndCol == 0) ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3349
	end := end - 1
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3350
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3351
    self unselect.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3352
    self indentFromLine:start toLine:end
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3353
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3354
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3355
indentFromLine:start toLine:end
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3356
    "indent a line-range - this is don by searching for the 
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3357
     last non-empty line before start, and change the indent
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3358
     of the line based on that indent."
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3359
474
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  3360
    |leftStart delta d line spaces|
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  3361
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  3362
    leftStart := self leftIndentForLine:start.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3363
    (leftStart == 0) ifTrue:[^ self].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3364
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3365
    delta := leftStart - (self leftIndentOfLine:start).
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3366
    (delta == 0) ifTrue:[^ self].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3367
    (delta > 0) ifTrue:[
1415
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  3368
	spaces := String new:delta
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3369
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3370
    start to:end do:[:lineNr |
1415
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  3371
	line := self listAt:lineNr.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  3372
	line notNil ifTrue:[
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  3373
	    line isBlank ifTrue:[
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  3374
		list at:lineNr put:nil
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  3375
	    ] ifFalse:[
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  3376
		(delta > 0) ifTrue:[
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  3377
		    line := spaces , line.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  3378
		    widthOfWidestLine notNil ifTrue:[
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  3379
			widthOfWidestLine := widthOfWidestLine max:(self widthOfLineString:line).
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  3380
		    ]
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  3381
		] ifFalse:[
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  3382
		    "check if deletion is ok"
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  3383
		    d := delta negated + 1.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  3384
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  3385
		    line size > d ifTrue:[
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  3386
			(line copyTo:(d - 1)) withoutSeparators isEmpty ifTrue:[
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  3387
			    line := line copyFrom:d
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  3388
			]
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  3389
		    ].
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  3390
		    widthOfWidestLine := nil
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  3391
		].
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  3392
		list at:lineNr put:line.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  3393
		self textChanged.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  3394
	    ]
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  3395
	]
121
claus
parents: 118
diff changeset
  3396
    ].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3397
    self redrawFromLine:start to:end
474
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  3398
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  3399
    "Modified: 5.3.1996 / 14:59:18 / cg"
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  3400
!
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  3401
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  3402
leftIndentForLine:lineNr
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  3403
    "find an appropriate indent for a line.
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  3404
     this is done by searching for the last non-empty line before it
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  3405
     and returning its indent."
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  3406
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3407
    "SHOULD GO TO ListView"
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3408
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3409
    |line lnr indent|
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3410
474
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  3411
    lnr := lineNr.
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3412
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3413
    [lnr ~~ 1] whileTrue:[
1415
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  3414
	lnr  := lnr - 1.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  3415
	line := self listAt:lnr.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  3416
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  3417
	line notNil ifTrue:[
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  3418
	    indent := line indexOfNonSeparatorStartingAt:1.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  3419
	    indent ~~ 0 ifTrue:[
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  3420
		^ indent - 1
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  3421
	    ]
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  3422
	]
474
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  3423
    ].
827
6b42229252b9 reuse of basic editing functionality and thus change
ca
parents: 823
diff changeset
  3424
    ^ 0
474
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  3425
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  3426
    "Created: 5.3.1996 / 14:58:53 / cg"
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  3427
! !
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  3428
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  3429
!EditTextView methodsFor:'initialization'!
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  3430
941
f06fa4d47f26 fetch device resources early
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  3431
fetchDeviceResources
f06fa4d47f26 fetch device resources early
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  3432
    "fetch device colors, to avoid reallocation at redraw time"
f06fa4d47f26 fetch device resources early
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  3433
f06fa4d47f26 fetch device resources early
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  3434
    super fetchDeviceResources.
f06fa4d47f26 fetch device resources early
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  3435
f06fa4d47f26 fetch device resources early
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  3436
    cursorFgColor notNil ifTrue:[cursorFgColor := cursorFgColor on:device].
f06fa4d47f26 fetch device resources early
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  3437
    cursorBgColor notNil ifTrue:[cursorBgColor := cursorBgColor on:device].
1022
4362861fe15e allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents: 1018
diff changeset
  3438
    cursorNoFocusFgColor notNil ifTrue:[cursorNoFocusFgColor := cursorNoFocusFgColor on:device].
941
f06fa4d47f26 fetch device resources early
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  3439
f06fa4d47f26 fetch device resources early
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  3440
    "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
  3441
    "Modified: 18.2.1997 / 15:02:46 / cg"
941
f06fa4d47f26 fetch device resources early
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  3442
!
f06fa4d47f26 fetch device resources early
Claus Gittinger <cg@exept.de>
parents: 922
diff changeset
  3443
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3444
initEvents
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3445
    "enable enter/leave events in addition"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3446
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3447
    super initEvents.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3448
    self enableEnterLeaveEvents
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3449
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3450
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3451
initStyle
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3452
    "initialize style specific stuff"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3453
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3454
    super initStyle.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3455
    lockUpdates := false.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3456
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3457
    cursorFgColor := DefaultCursorForegroundColor.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3458
    cursorFgColor isNil ifTrue:[cursorFgColor := bgColor].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3459
    cursorBgColor := DefaultCursorBackgroundColor.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3460
    cursorBgColor isNil ifTrue:[cursorBgColor := fgColor].
1334
84e43257565b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1333
diff changeset
  3461
    cursorType := cursorTypeNoFocus := DefaultCursorType.
1534
bcb211e1b41a read noFocus cursorStyle from styleSheet
Claus Gittinger <cg@exept.de>
parents: 1533
diff changeset
  3462
    DefaultCursorTypeNoFocus notNil ifTrue:[
bcb211e1b41a read noFocus cursorStyle from styleSheet
Claus Gittinger <cg@exept.de>
parents: 1533
diff changeset
  3463
        cursorTypeNoFocus := DefaultCursorTypeNoFocus.
bcb211e1b41a read noFocus cursorStyle from styleSheet
Claus Gittinger <cg@exept.de>
parents: 1533
diff changeset
  3464
    ].
1022
4362861fe15e allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents: 1018
diff changeset
  3465
    cursorNoFocusFgColor := DefaultCursorNoFocusForegroundColor.
4362861fe15e allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents: 1018
diff changeset
  3466
    cursorNoFocusFgColor isNil ifTrue:[
1534
bcb211e1b41a read noFocus cursorStyle from styleSheet
Claus Gittinger <cg@exept.de>
parents: 1533
diff changeset
  3467
        cursorType ~~ #block ifTrue:[
bcb211e1b41a read noFocus cursorStyle from styleSheet
Claus Gittinger <cg@exept.de>
parents: 1533
diff changeset
  3468
            cursorNoFocusFgColor := cursorBgColor
bcb211e1b41a read noFocus cursorStyle from styleSheet
Claus Gittinger <cg@exept.de>
parents: 1533
diff changeset
  3469
        ] ifFalse:[
bcb211e1b41a read noFocus cursorStyle from styleSheet
Claus Gittinger <cg@exept.de>
parents: 1533
diff changeset
  3470
            cursorNoFocusFgColor := cursorFgColor
bcb211e1b41a read noFocus cursorStyle from styleSheet
Claus Gittinger <cg@exept.de>
parents: 1533
diff changeset
  3471
        ]
1022
4362861fe15e allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents: 1018
diff changeset
  3472
    ].
4362861fe15e allow specification of noFocusCursor color in styleSheet.
Claus Gittinger <cg@exept.de>
parents: 1018
diff changeset
  3473
1534
bcb211e1b41a read noFocus cursorStyle from styleSheet
Claus Gittinger <cg@exept.de>
parents: 1533
diff changeset
  3474
    "Modified: / 20.5.1998 / 04:26:31 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3475
!
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
initialize
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3478
    "initialize a new EditTextView;
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3479
     setup some instance variables"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3480
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3481
    super initialize.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3482
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3483
    self level:-1.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3484
    readOnly := false.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3485
    fixedSize := false.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3486
    exceptionBlock := [:errorText | ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3487
    cursorShown := prevCursorState := true.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3488
    cursorLine := 1.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3489
    cursorVisibleLine := 1.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3490
    cursorCol := 1.
947
007a374d834c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 941
diff changeset
  3491
    modifiedChannel := ValueHolder newBoolean.
1013
391290c747b3 added an acceptChannel
Claus Gittinger <cg@exept.de>
parents: 997
diff changeset
  3492
    acceptChannel := ValueHolder newBoolean.
1437
ab84b08a9f9c allow modified- and acceptChannels to be set.
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
  3493
    acceptChannel addDependent:self.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3494
    showMatchingParenthesis := false.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3495
    hasKeyboardFocus := false. "/ true.
323
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
  3496
    tabMeansNextField := false.
474
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  3497
    autoIndent := false.
477
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  3498
    insertMode := true.
1596
0bbdb4e9fc43 made st80Mode also an inst-flag;
Claus Gittinger <cg@exept.de>
parents: 1591
diff changeset
  3499
    st80Mode := ST80Mode.
0bbdb4e9fc43 made st80Mode also an inst-flag;
Claus Gittinger <cg@exept.de>
parents: 1591
diff changeset
  3500
    trimBlankLines := st80Mode not. "true."
0bbdb4e9fc43 made st80Mode also an inst-flag;
Claus Gittinger <cg@exept.de>
parents: 1591
diff changeset
  3501
0bbdb4e9fc43 made st80Mode also an inst-flag;
Claus Gittinger <cg@exept.de>
parents: 1591
diff changeset
  3502
    "Modified: / 20.6.1998 / 18:19:17 / cg"
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  3503
! !
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  3504
121
claus
parents: 118
diff changeset
  3505
!EditTextView methodsFor:'menu actions'!
claus
parents: 118
diff changeset
  3506
claus
parents: 118
diff changeset
  3507
cut
claus
parents: 118
diff changeset
  3508
    "cut selection into copybuffer"
claus
parents: 118
diff changeset
  3509
claus
parents: 118
diff changeset
  3510
    |line col history sel|
claus
parents: 118
diff changeset
  3511
1548
d4a3d61388dc flash view in readonly mode, when modification is attempted.
Claus Gittinger <cg@exept.de>
parents: 1546
diff changeset
  3512
    (self checkModificationsAllowed) ifFalse:[
d4a3d61388dc flash view in readonly mode, when modification is attempted.
Claus Gittinger <cg@exept.de>
parents: 1546
diff changeset
  3513
        self flash.
d4a3d61388dc flash view in readonly mode, when modification is attempted.
Claus Gittinger <cg@exept.de>
parents: 1546
diff changeset
  3514
        ^ self
d4a3d61388dc flash view in readonly mode, when modification is attempted.
Claus Gittinger <cg@exept.de>
parents: 1546
diff changeset
  3515
    ].
1480
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  3516
121
claus
parents: 118
diff changeset
  3517
    sel := self selection.
claus
parents: 118
diff changeset
  3518
    sel notNil ifTrue:[
1480
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  3519
        lastString := sel asStringWithCRs.
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  3520
        line := selectionStartLine.
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  3521
        col := selectionStartCol.
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  3522
        undoAction := [self insertString:lastString atLine:line col:col].
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  3523
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  3524
        "
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  3525
         remember in CopyBuffer
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  3526
        "
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  3527
        self setTextSelection:lastString.
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  3528
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  3529
        "
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  3530
         append to DeleteHistory (if there is one)
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  3531
        "
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  3532
        history := Smalltalk at:#DeleteHistory.
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  3533
        history notNil ifTrue:[
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  3534
            history addAll:(lastString asStringCollection).
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  3535
            history size > 1000 ifTrue:[
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  3536
                history := history copyFrom:(history size - 1000)
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  3537
            ].
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  3538
        ].
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  3539
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  3540
        "
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  3541
         now, delete it
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  3542
        "
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  3543
        self deleteSelection.
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  3544
        lastReplacement := nil
121
claus
parents: 118
diff changeset
  3545
    ] ifFalse:[
1480
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  3546
        "
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  3547
         a cut without selection will search&cut again
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  3548
        "
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  3549
        self again
121
claus
parents: 118
diff changeset
  3550
    ]
1290
d87b6c35c3ae checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1289
diff changeset
  3551
1480
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  3552
    "Modified: / 5.4.1998 / 16:51:53 / cg"
121
claus
parents: 118
diff changeset
  3553
!
claus
parents: 118
diff changeset
  3554
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3555
defaultForGotoLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3556
    "return a default value to show in the gotoLine box"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3557
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3558
    cursorLine notNil ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3559
	^ cursorLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3560
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3561
    ^ super defaultForGotoLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3562
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3563
428
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  3564
editMenu
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  3565
    "return the views middleButtonMenu"
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  3566
488
d10fe3a5f0cf resources
Claus Gittinger <cg@exept.de>
parents: 479
diff changeset
  3567
    <resource: #keyboard (#Again #Copy #Cut #Paste #Accept #Find #GotoLine #SaveAs #Print)>
1261
bdb18f73205c resource flag: #menu -> #programMenu
Claus Gittinger <cg@exept.de>
parents: 1198
diff changeset
  3568
    <resource: #programMenu>
1054
d699ecd13e60 menu resource
Claus Gittinger <cg@exept.de>
parents: 1049
diff changeset
  3569
1546
f17fa0744663 use new menu-creation message
Claus Gittinger <cg@exept.de>
parents: 1534
diff changeset
  3570
    |items m sub shortKeys sensor|
1515
9e9b65bd6efb care for nil sensor
Claus Gittinger <cg@exept.de>
parents: 1495
diff changeset
  3571
9e9b65bd6efb care for nil sensor
Claus Gittinger <cg@exept.de>
parents: 1495
diff changeset
  3572
    ((sensor := self sensor) notNil and:[sensor ctrlDown]) ifTrue:[
1546
f17fa0744663 use new menu-creation message
Claus Gittinger <cg@exept.de>
parents: 1534
diff changeset
  3573
        items := #(
f17fa0744663 use new menu-creation message
Claus Gittinger <cg@exept.de>
parents: 1534
diff changeset
  3574
                        ('again (for all)'      multipleAgain)  
f17fa0744663 use new menu-creation message
Claus Gittinger <cg@exept.de>
parents: 1534
diff changeset
  3575
                  ).
428
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  3576
    ] ifFalse:[
1546
f17fa0744663 use new menu-creation message
Claus Gittinger <cg@exept.de>
parents: 1534
diff changeset
  3577
        items := #(
f17fa0744663 use new menu-creation message
Claus Gittinger <cg@exept.de>
parents: 1534
diff changeset
  3578
"/                       ('undo'     undo                   )
f17fa0744663 use new menu-creation message
Claus Gittinger <cg@exept.de>
parents: 1534
diff changeset
  3579
                        ('again'   again            Again  )
f17fa0744663 use new menu-creation message
Claus Gittinger <cg@exept.de>
parents: 1534
diff changeset
  3580
                        ('-'                               )
f17fa0744663 use new menu-creation message
Claus Gittinger <cg@exept.de>
parents: 1534
diff changeset
  3581
                        ('copy'    copySelection    Copy   )
f17fa0744663 use new menu-creation message
Claus Gittinger <cg@exept.de>
parents: 1534
diff changeset
  3582
                        ('cut'     cut              Cut    )
f17fa0744663 use new menu-creation message
Claus Gittinger <cg@exept.de>
parents: 1534
diff changeset
  3583
                        ('paste'   pasteOrReplace   Paste  )
f17fa0744663 use new menu-creation message
Claus Gittinger <cg@exept.de>
parents: 1534
diff changeset
  3584
                        ('-'                               )
f17fa0744663 use new menu-creation message
Claus Gittinger <cg@exept.de>
parents: 1534
diff changeset
  3585
                        ('accept'  accept           Accept )
f17fa0744663 use new menu-creation message
Claus Gittinger <cg@exept.de>
parents: 1534
diff changeset
  3586
                        ('='                               )
f17fa0744663 use new menu-creation message
Claus Gittinger <cg@exept.de>
parents: 1534
diff changeset
  3587
                        ('others'  others                  )
f17fa0744663 use new menu-creation message
Claus Gittinger <cg@exept.de>
parents: 1534
diff changeset
  3588
                  ).
428
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  3589
    ].
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  3590
1546
f17fa0744663 use new menu-creation message
Claus Gittinger <cg@exept.de>
parents: 1534
diff changeset
  3591
    m := PopUpMenu itemList:items resources:resources.
f17fa0744663 use new menu-creation message
Claus Gittinger <cg@exept.de>
parents: 1534
diff changeset
  3592
f17fa0744663 use new menu-creation message
Claus Gittinger <cg@exept.de>
parents: 1534
diff changeset
  3593
    items := #(
f17fa0744663 use new menu-creation message
Claus Gittinger <cg@exept.de>
parents: 1534
diff changeset
  3594
                    ('search ...'    search         Find         )
f17fa0744663 use new menu-creation message
Claus Gittinger <cg@exept.de>
parents: 1534
diff changeset
  3595
                    ('goto ...'      gotoLine       GotoLine     )
f17fa0744663 use new menu-creation message
Claus Gittinger <cg@exept.de>
parents: 1534
diff changeset
  3596
                    ('-'                                         )
f17fa0744663 use new menu-creation message
Claus Gittinger <cg@exept.de>
parents: 1534
diff changeset
  3597
                    ('font ...'      changeFont                  )
f17fa0744663 use new menu-creation message
Claus Gittinger <cg@exept.de>
parents: 1534
diff changeset
  3598
                    ('-'                                         )
f17fa0744663 use new menu-creation message
Claus Gittinger <cg@exept.de>
parents: 1534
diff changeset
  3599
                    ('indent'        indent                      )
f17fa0744663 use new menu-creation message
Claus Gittinger <cg@exept.de>
parents: 1534
diff changeset
  3600
                    ('autoIndent \c' autoIndent:                 )
f17fa0744663 use new menu-creation message
Claus Gittinger <cg@exept.de>
parents: 1534
diff changeset
  3601
                    ('insertMode \c' insertMode:                 )
f17fa0744663 use new menu-creation message
Claus Gittinger <cg@exept.de>
parents: 1534
diff changeset
  3602
                    ('-'                                         )
f17fa0744663 use new menu-creation message
Claus Gittinger <cg@exept.de>
parents: 1534
diff changeset
  3603
                    ('save as ...'   save           SaveAs       )
f17fa0744663 use new menu-creation message
Claus Gittinger <cg@exept.de>
parents: 1534
diff changeset
  3604
                    ('print'         doPrint        Print        )
f17fa0744663 use new menu-creation message
Claus Gittinger <cg@exept.de>
parents: 1534
diff changeset
  3605
              ).
f17fa0744663 use new menu-creation message
Claus Gittinger <cg@exept.de>
parents: 1534
diff changeset
  3606
f17fa0744663 use new menu-creation message
Claus Gittinger <cg@exept.de>
parents: 1534
diff changeset
  3607
    sub := PopUpMenu itemList:items resources:resources performer:model.
428
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  3608
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  3609
    m subMenuAt:#others put:sub.
474
f73ed1f5cb75 added autoIndent functionality
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
  3610
    sub checkToggleAt:#autoIndent: put:autoIndent.
477
e7c29649e8ae fixed autoIndent & added insert vs. overwriteMode
Claus Gittinger <cg@exept.de>
parents: 474
diff changeset
  3611
    sub checkToggleAt:#insertMode: put:insertMode.
428
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  3612
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  3613
    readOnly ifTrue:[
1548
d4a3d61388dc flash view in readonly mode, when modification is attempted.
Claus Gittinger <cg@exept.de>
parents: 1546
diff changeset
  3614
        m disableAll:#(paste pasteOrReplace cut indent autoIndent: insertMode:)
428
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  3615
    ].
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  3616
    self hasSelection not ifTrue:[
1515
9e9b65bd6efb care for nil sensor
Claus Gittinger <cg@exept.de>
parents: 1495
diff changeset
  3617
        m disable:#copySelection.
428
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  3618
    ].
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  3619
    (self hasSelection not or:[readOnly]) ifTrue:[
1515
9e9b65bd6efb care for nil sensor
Claus Gittinger <cg@exept.de>
parents: 1495
diff changeset
  3620
        m disable:#cut.
428
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  3621
    ].
1108
3d14bb6bceb7 added disableAccept
Claus Gittinger <cg@exept.de>
parents: 1082
diff changeset
  3622
    acceptEnabled == false ifTrue:[
1515
9e9b65bd6efb care for nil sensor
Claus Gittinger <cg@exept.de>
parents: 1495
diff changeset
  3623
        m disable:#accept
1108
3d14bb6bceb7 added disableAccept
Claus Gittinger <cg@exept.de>
parents: 1082
diff changeset
  3624
    ].
428
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  3625
    ^ m.
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  3626
1546
f17fa0744663 use new menu-creation message
Claus Gittinger <cg@exept.de>
parents: 1534
diff changeset
  3627
    "Modified: / 21.5.1998 / 15:52:38 / cg"
428
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  3628
!
6b0881b0bce1 changes for accelerator-display
Claus Gittinger <cg@exept.de>
parents: 400
diff changeset
  3629
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3630
paste
1289
e2dcc5fe612c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1287
diff changeset
  3631
    "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
  3632
     Then paste at cursor position."
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3633
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3634
    |sel|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3635
1548
d4a3d61388dc flash view in readonly mode, when modification is attempted.
Claus Gittinger <cg@exept.de>
parents: 1546
diff changeset
  3636
    self checkModificationsAllowed ifFalse:[
d4a3d61388dc flash view in readonly mode, when modification is attempted.
Claus Gittinger <cg@exept.de>
parents: 1546
diff changeset
  3637
        self flash.
d4a3d61388dc flash view in readonly mode, when modification is attempted.
Claus Gittinger <cg@exept.de>
parents: 1546
diff changeset
  3638
        ^ self
d4a3d61388dc flash view in readonly mode, when modification is attempted.
Claus Gittinger <cg@exept.de>
parents: 1546
diff changeset
  3639
    ].
1480
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  3640
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3641
    sel := self getTextSelection.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3642
    self unselect.  
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3643
    sel notNil ifTrue:[
1480
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  3644
        self paste:sel.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3645
    ]
1289
e2dcc5fe612c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1287
diff changeset
  3646
1480
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  3647
    "Modified: / 5.4.1998 / 16:55:02 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3648
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3649
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3650
paste:someText
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3651
    "paste someText at cursor"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3652
1568
e80a52b5aca1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1567
diff changeset
  3653
    |s nLines startLine startCol|
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3654
1480
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  3655
    self checkModificationsAllowed ifFalse:[^ self].
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  3656
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3657
    someText notNil ifTrue:[
1480
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  3658
        s := someText.
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  3659
        s isString ifTrue:[
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  3660
            s := s asStringCollection
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  3661
        ] ifFalse:[
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  3662
            (s isKindOf:StringCollection) ifFalse:[
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  3663
                self warn:'selection (' , s class name , ') is not convertable to Text'.
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  3664
                ^ self
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  3665
            ]
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  3666
        ].
1568
e80a52b5aca1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1567
diff changeset
  3667
        (nLines := s size) == 0 ifTrue:[^ self].
e80a52b5aca1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1567
diff changeset
  3668
        (nLines == 1 and:[(s at:1) size == 0]) ifTrue:[^ self].
1480
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  3669
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  3670
        startLine := cursorLine.
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  3671
        startCol := cursorCol.
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  3672
        self insertLines:(s withTabsExpanded) withCR:false.
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  3673
        self selectFromLine:startLine col:startCol
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  3674
                     toLine:cursorLine col:(cursorCol - 1).
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  3675
        typeOfSelection := #paste.
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  3676
        undoAction := [self cut].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3677
    ]
362
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  3678
1480
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  3679
    "Modified: / 14.2.1996 / 11:14:14 / stefan"
1568
e80a52b5aca1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1567
diff changeset
  3680
    "Modified: / 12.6.1998 / 22:12:00 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3681
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3682
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3683
pasteOrReplace
1289
e2dcc5fe612c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1287
diff changeset
  3684
    "paste the copybuffer; if there is a selection, replace it.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3685
     otherwise paste at cursor position. Replace is not done
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3686
     for originating by a paste, to allow multiple
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3687
     paste."
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3688
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3689
    |sel|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3690
1548
d4a3d61388dc flash view in readonly mode, when modification is attempted.
Claus Gittinger <cg@exept.de>
parents: 1546
diff changeset
  3691
    self checkModificationsAllowed ifFalse:[
d4a3d61388dc flash view in readonly mode, when modification is attempted.
Claus Gittinger <cg@exept.de>
parents: 1546
diff changeset
  3692
        self flash.
d4a3d61388dc flash view in readonly mode, when modification is attempted.
Claus Gittinger <cg@exept.de>
parents: 1546
diff changeset
  3693
        ^ self
d4a3d61388dc flash view in readonly mode, when modification is attempted.
Claus Gittinger <cg@exept.de>
parents: 1546
diff changeset
  3694
    ].
1480
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  3695
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3696
    sel := self getTextSelection.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3697
    self pasteOrReplace:sel.
1289
e2dcc5fe612c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1287
diff changeset
  3698
1480
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  3699
    "Modified: / 5.4.1998 / 16:55:16 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3700
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3701
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3702
pasteOrReplace:someText
1289
e2dcc5fe612c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1287
diff changeset
  3703
    "paste someText; if there is a selection, replace it.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3704
     otherwise paste at cursor position. Replace is not done
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3705
     for originating by a paste, to allow multiple
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3706
     paste."
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3707
1480
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  3708
    self checkModificationsAllowed ifFalse:[^ self].
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  3709
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3710
    ((self hasSelection == true) and:[typeOfSelection ~~ #paste]) ifTrue:[
1480
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  3711
        ^ self replace:someText
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3712
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3713
    self paste:someText.
1289
e2dcc5fe612c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1287
diff changeset
  3714
1480
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  3715
    "Modified: / 5.4.1998 / 16:55:21 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3716
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3717
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3718
replace
1289
e2dcc5fe612c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1287
diff changeset
  3719
    "replace the selection by the contents of the copybuffer"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3720
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3721
    |sel|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3722
1480
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  3723
    self checkModificationsAllowed ifFalse:[^ self].
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  3724
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3725
    sel := self getTextSelection.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3726
    sel notNil ifTrue:[
1480
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  3727
        self replace:sel
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3728
    ]
1289
e2dcc5fe612c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1287
diff changeset
  3729
1480
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  3730
    "Modified: / 5.4.1998 / 16:55:24 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3731
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3732
121
claus
parents: 118
diff changeset
  3733
replace:someText
1289
e2dcc5fe612c checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1287
diff changeset
  3734
    "replace the selection by someText"
121
claus
parents: 118
diff changeset
  3735
362
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  3736
    |selected selectedString| 
121
claus
parents: 118
diff changeset
  3737
1480
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  3738
    self checkModificationsAllowed ifFalse:[^ self].
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  3739
121
claus
parents: 118
diff changeset
  3740
    selected := self selection.
claus
parents: 118
diff changeset
  3741
    selected isNil ifTrue:[
1480
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  3742
        ^ self paste:someText
121
claus
parents: 118
diff changeset
  3743
    ].
claus
parents: 118
diff changeset
  3744
    self deleteSelection.
claus
parents: 118
diff changeset
  3745
claus
parents: 118
diff changeset
  3746
    "take care, if we replace a selection without space by a word selected
claus
parents: 118
diff changeset
  3747
     with one - in this case we usually do not want the space.
claus
parents: 118
diff changeset
  3748
     But, if we replace a word-selected selection by something without a
claus
parents: 118
diff changeset
  3749
     space, we DO want the space added."
claus
parents: 118
diff changeset
  3750
claus
parents: 118
diff changeset
  3751
    selected size == 1 ifTrue:[
1480
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  3752
        selectedString := selected at:1.
7
15a9291b9bd0 *** empty log message ***
claus
parents: 5
diff changeset
  3753
    ].
15a9291b9bd0 *** empty log message ***
claus
parents: 5
diff changeset
  3754
362
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  3755
    someText size == 1 ifTrue:[
1480
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  3756
        |cutOffSpace addSpace replacement replacementString|
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  3757
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  3758
        cutOffSpace := false.
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  3759
        addSpace := false.
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  3760
        replacement := someText copy.
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  3761
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  3762
        selectedString notNil ifTrue:[
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  3763
            ((selectedString startsWith:' ') or:[selectedString endsWith:' ']) ifFalse:[
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  3764
               "selection has no space"
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  3765
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  3766
                ((selectStyle == #wordleft) or:[selectStyle == #wordRight]) ifTrue:[
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  3767
                    cutOffSpace := true
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  3768
                ]
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  3769
            ] ifTrue:[
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  3770
                addSpace := true
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  3771
            ]
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  3772
        ].
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  3773
        replacementString := replacement at:1.
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  3774
        cutOffSpace ifTrue:[
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  3775
            (replacementString startsWith:' ') ifTrue:[
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  3776
                replacementString := replacementString withoutSpaces
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  3777
            ].
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  3778
        ] ifFalse:[
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  3779
            selectStyle == #wordLeft ifTrue:[
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  3780
                "want a space at left"
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  3781
                (replacementString startsWith:' ') ifFalse:[
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  3782
                    replacementString := replacementString withoutSpaces.
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  3783
                    replacementString := ' ' , replacementString
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  3784
                ]
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  3785
            ].
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  3786
            selectStyle == #wordRight ifTrue:[
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  3787
                "want a space at right"
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  3788
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  3789
                (replacementString endsWith:' ') ifFalse:[
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  3790
                    replacementString := replacementString withoutSpaces.
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  3791
                    replacementString := replacementString , ' '
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  3792
                ]
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  3793
            ].
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  3794
        ].
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  3795
        replacement at:1 put: replacementString.
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  3796
        self paste:replacement.
121
claus
parents: 118
diff changeset
  3797
    ] ifFalse:[
1480
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  3798
        self paste:someText
7
15a9291b9bd0 *** empty log message ***
claus
parents: 5
diff changeset
  3799
    ].
121
claus
parents: 118
diff changeset
  3800
    lastString := selectedString.
claus
parents: 118
diff changeset
  3801
    lastReplacement := someText
362
3993ba6c31a0 Expand tabs before pasting a string.
Stefan Vogel <sv@exept.de>
parents: 331
diff changeset
  3802
1480
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  3803
    "Modified: / 14.2.1996 / 10:37:02 / stefan"
eabb1848e2fa fixed insert at character position.
Claus Gittinger <cg@exept.de>
parents: 1476
diff changeset
  3804
    "Modified: / 5.4.1998 / 16:55:28 / cg"
121
claus
parents: 118
diff changeset
  3805
!
claus
parents: 118
diff changeset
  3806
claus
parents: 118
diff changeset
  3807
showDeleted
claus
parents: 118
diff changeset
  3808
    "open a readonly editor on all deleted text"
claus
parents: 118
diff changeset
  3809
claus
parents: 118
diff changeset
  3810
    |v|
claus
parents: 118
diff changeset
  3811
claus
parents: 118
diff changeset
  3812
    v := EditTextView openWith:(Smalltalk at:#DeleteHistory).
claus
parents: 118
diff changeset
  3813
    v readOnly.
claus
parents: 118
diff changeset
  3814
    v topView label:'deleted text'.
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  3815
! !
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  3816
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3817
!EditTextView methodsFor:'private'!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3818
331
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
  3819
checkModificationsAllowed
1300
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  3820
    "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
  3821
     evaluate the exceptionBlock if not.
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  3822
     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
  3823
     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
  3824
331
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
  3825
    readOnly ifTrue: [
1577
4e487247ad33 dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents: 1568
diff changeset
  3826
        exceptionBlock isNil ifTrue:[
4e487247ad33 dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents: 1568
diff changeset
  3827
            ^ false
4e487247ad33 dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents: 1568
diff changeset
  3828
        ].
4e487247ad33 dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents: 1568
diff changeset
  3829
4e487247ad33 dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents: 1568
diff changeset
  3830
        (exceptionBlock value:'Text may not be modified') ~~ true ifTrue:[
4e487247ad33 dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents: 1568
diff changeset
  3831
            ^ false
4e487247ad33 dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents: 1568
diff changeset
  3832
        ]
331
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
  3833
    ].
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
  3834
    ^ true
1300
be8b356b2e59 first attempt in providing an ST80 (or vi)
Claus Gittinger <cg@exept.de>
parents: 1296
diff changeset
  3835
1577
4e487247ad33 dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents: 1568
diff changeset
  3836
    "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
  3837
!
c58f0c52d2d7 made modifiedFlag a channels value (allows change notifications to be sent);
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
  3838
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3839
textChanged
522
aa9458e4643e indent/undent did not trigger a modify
ca
parents: 503
diff changeset
  3840
    "my text was modified (internally).
aa9458e4643e indent/undent did not trigger a modify
ca
parents: 503
diff changeset
  3841
     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
  3842
     contentsChanged, which is triggered when the size has changed, and
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3843
     is used to notify scrollers, other views etc.)"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3844
641
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  3845
    self contentsChanged.
1015
caf7265128b9 clear modified on accept.
Claus Gittinger <cg@exept.de>
parents: 1013
diff changeset
  3846
    self modified:true.
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3847
    contentsWasSaved := false
641
a8bd4e31c060 minor cleanups
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
  3848
1015
caf7265128b9 clear modified on accept.
Claus Gittinger <cg@exept.de>
parents: 1013
diff changeset
  3849
    "Modified: 14.2.1997 / 16:58:38 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3850
! !
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3851
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3852
!EditTextView methodsFor:'queries'!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3853
1526
7676f301bb8f added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents: 1515
diff changeset
  3854
currentLine
7676f301bb8f added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents: 1515
diff changeset
  3855
    "the current line (for relative gotos)"
7676f301bb8f added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents: 1515
diff changeset
  3856
7676f301bb8f added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents: 1515
diff changeset
  3857
    ^ cursorLine
7676f301bb8f added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents: 1515
diff changeset
  3858
7676f301bb8f added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents: 1515
diff changeset
  3859
    "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
  3860
!
7676f301bb8f added #currentLine (req'd for relative gotos)
Claus Gittinger <cg@exept.de>
parents: 1515
diff changeset
  3861
997
615a5a19c5bf specClass
ca
parents: 991
diff changeset
  3862
specClass
1390
99674e1d9c85 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
  3863
    "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
  3864
997
615a5a19c5bf specClass
ca
parents: 991
diff changeset
  3865
    self class == EditTextView ifTrue:[^ TextEditorSpec].
1049
24360c8891d6 specClass query
Claus Gittinger <cg@exept.de>
parents: 1037
diff changeset
  3866
    ^ super specClass
24360c8891d6 specClass query
Claus Gittinger <cg@exept.de>
parents: 1037
diff changeset
  3867
1390
99674e1d9c85 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
  3868
    "Modified: / 31.10.1997 / 19:48:19 / cg"
997
615a5a19c5bf specClass
ca
parents: 991
diff changeset
  3869
!
615a5a19c5bf specClass
ca
parents: 991
diff changeset
  3870
324
9eec6d69e155 better Tab key handling
Claus Gittinger <cg@exept.de>
parents: 323
diff changeset
  3871
tabMeansNextField
323
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
  3872
    "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
  3873
313
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  3874
    "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
  3875
323
58102e6bc087 added tabMeansNextField instVar & method (ST-80 compatibility)
Claus Gittinger <cg@exept.de>
parents: 313
diff changeset
  3876
    ^ readOnly or:[tabMeansNextField]
324
9eec6d69e155 better Tab key handling
Claus Gittinger <cg@exept.de>
parents: 323
diff changeset
  3877
9eec6d69e155 better Tab key handling
Claus Gittinger <cg@exept.de>
parents: 323
diff changeset
  3878
    "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
  3879
!
7c799cd68343 only replace selection by return, if it was not created by a paste
Claus Gittinger <cg@exept.de>
parents: 309
diff changeset
  3880
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3881
widthOfContents
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3882
    "return the width of the contents in pixels
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3883
     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
  3884
     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
  3885
     line (and possibly see the cursor behind the line)"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3886
697
0f258f02e8ea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 693
diff changeset
  3887
    |w dev|
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3888
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3889
    w := super widthOfContents.
697
0f258f02e8ea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 693
diff changeset
  3890
    (dev := device) isNil ifTrue:[
1415
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  3891
	"/ really dont know ...
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  3892
	dev := Screen current
606
682579fa3b62 fixed #widthOfContents if no device is known
Claus Gittinger <cg@exept.de>
parents: 597
diff changeset
  3893
    ].
697
0f258f02e8ea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 693
diff changeset
  3894
    ^ w + (font widthOn:dev)
0f258f02e8ea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 693
diff changeset
  3895
0f258f02e8ea checkin from browser
Claus Gittinger <cg@exept.de>
parents: 693
diff changeset
  3896
    "Modified: 28.5.1996 / 19:32:25 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3897
! !
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3898
1588
e2e4ceeed3da category change
Claus Gittinger <cg@exept.de>
parents: 1585
diff changeset
  3899
!EditTextView methodsFor:'realization'!
e2e4ceeed3da category change
Claus Gittinger <cg@exept.de>
parents: 1585
diff changeset
  3900
e2e4ceeed3da category change
Claus Gittinger <cg@exept.de>
parents: 1585
diff changeset
  3901
realize
e2e4ceeed3da category change
Claus Gittinger <cg@exept.de>
parents: 1585
diff changeset
  3902
    "make the view visible - scroll to make the cursor visible."
e2e4ceeed3da category change
Claus Gittinger <cg@exept.de>
parents: 1585
diff changeset
  3903
e2e4ceeed3da category change
Claus Gittinger <cg@exept.de>
parents: 1585
diff changeset
  3904
    super realize.
e2e4ceeed3da category change
Claus Gittinger <cg@exept.de>
parents: 1585
diff changeset
  3905
e2e4ceeed3da category change
Claus Gittinger <cg@exept.de>
parents: 1585
diff changeset
  3906
    self makeCursorVisible.
e2e4ceeed3da category change
Claus Gittinger <cg@exept.de>
parents: 1585
diff changeset
  3907
    cursorFgColor := cursorFgColor on:device.
e2e4ceeed3da category change
Claus Gittinger <cg@exept.de>
parents: 1585
diff changeset
  3908
    cursorBgColor := cursorBgColor on:device.
e2e4ceeed3da category change
Claus Gittinger <cg@exept.de>
parents: 1585
diff changeset
  3909
e2e4ceeed3da category change
Claus Gittinger <cg@exept.de>
parents: 1585
diff changeset
  3910
    "Modified: 20.12.1996 / 14:16:05 / cg"
e2e4ceeed3da category change
Claus Gittinger <cg@exept.de>
parents: 1585
diff changeset
  3911
    "Created: 24.7.1997 / 18:24:12 / cg"
e2e4ceeed3da category change
Claus Gittinger <cg@exept.de>
parents: 1585
diff changeset
  3912
! !
e2e4ceeed3da category change
Claus Gittinger <cg@exept.de>
parents: 1585
diff changeset
  3913
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3914
!EditTextView methodsFor:'redrawing'!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3915
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3916
redrawCursorIfBetweenVisibleLine:startVisLine and:endVisLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3917
    "redraw the cursor, if it sits in a line range"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3918
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3919
    cursorShown ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3920
	cursorVisibleLine notNil ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3921
	    (cursorVisibleLine between:startVisLine and:endVisLine) ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3922
		self drawCursorCharacter
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3923
	    ]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3924
	]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3925
    ]
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  3926
!
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  3927
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3928
redrawCursorIfInVisibleLine:visLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3929
    "redraw the cursor, if it sits in visible line"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3930
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3931
    cursorShown ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3932
	(visLine == cursorVisibleLine) ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3933
	    self drawCursorCharacter
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3934
	]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3935
    ]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3936
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3937
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3938
redrawFromVisibleLine:startVisLine to:endVisLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3939
    "redraw a visible line range"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3940
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3941
    super redrawFromVisibleLine:startVisLine to:endVisLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3942
    self redrawCursorIfBetweenVisibleLine:startVisLine and:endVisLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3943
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3944
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3945
redrawVisibleLine:visLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3946
    "redraw a visible line"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3947
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3948
    super redrawVisibleLine:visLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3949
    self redrawCursorIfInVisibleLine:visLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3950
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3951
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3952
redrawVisibleLine:visLine col:colNr
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3953
    "redraw the single character in visibleline at colNr"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3954
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3955
    cursorShown ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3956
	(visLine == cursorVisibleLine) ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3957
	    (colNr == cursorCol) ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3958
		self drawCursorCharacter.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3959
		^ self
118
claus
parents: 105
diff changeset
  3960
	    ]
claus
parents: 105
diff changeset
  3961
	]
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  3962
    ].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3963
    super redrawVisibleLine:visLine col:colNr
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3964
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3965
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3966
redrawVisibleLine:visLine from:startCol
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3967
    "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
  3968
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3969
    super redrawVisibleLine:visLine from:startCol.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3970
    self redrawCursorIfInVisibleLine:visLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3971
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3972
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3973
redrawVisibleLine:visLine from:startCol to:endCol
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3974
    "redraw a visible line from startCol to endCol"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3975
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3976
    super redrawVisibleLine:visLine from:startCol to:endCol.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3977
    self redrawCursorIfInVisibleLine:visLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3978
! !
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3979
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3980
!EditTextView methodsFor:'scrolling'!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3981
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3982
halfPageDown
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3983
    "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
  3984
     within the real text  "
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3985
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3986
    |prevCursorLine|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3987
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3988
    prevCursorLine := cursorVisibleLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3989
    super halfPageDown.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3990
    self cursorVisibleLine:prevCursorLine col:cursorCol
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3991
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3992
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3993
halfPageUp
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3994
    "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
  3995
     within the real text  "
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3996
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  3997
    |prevCursorLine|
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
    prevCursorLine := cursorVisibleLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4000
    super halfPageUp.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4001
    self cursorVisibleLine:prevCursorLine col:cursorCol
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4002
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4003
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4004
originChanged:delta
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4005
    "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
  4006
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4007
    super originChanged:delta.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4008
    "
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4009
     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
  4010
    "
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4011
    cursorVisibleLine := self listLineToVisibleLine:cursorLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4012
    prevCursorState ifTrue:[
1577
4e487247ad33 dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents: 1568
diff changeset
  4013
        self showCursor
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4014
    ]
1577
4e487247ad33 dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents: 1568
diff changeset
  4015
4e487247ad33 dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents: 1568
diff changeset
  4016
    "Modified: / 17.6.1998 / 16:13:24 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4017
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4018
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4019
originWillChange
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4020
    "sent before scrolling - have to hide the cursor"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4021
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4022
    prevCursorState := cursorShown.
1577
4e487247ad33 dont care for cursor when scrolling
Claus Gittinger <cg@exept.de>
parents: 1568
diff changeset
  4023
    cursorShown := false.
1591
d84c117e71cc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1590
diff changeset
  4024
    cursorShown ifTrue:[
d84c117e71cc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1590
diff changeset
  4025
        self hideCursor
d84c117e71cc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1590
diff changeset
  4026
    ]
d84c117e71cc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1590
diff changeset
  4027
d84c117e71cc checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1590
diff changeset
  4028
    "Modified: / 20.6.1998 / 10:36:10 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4029
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4030
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4031
pageDown
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4032
    "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
  4033
     within the real text  "
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4034
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4035
    |prevCursorLine|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4036
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4037
    prevCursorLine := cursorVisibleLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4038
    super pageDown.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4039
    self cursorVisibleLine:prevCursorLine col:cursorCol
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4040
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4041
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4042
pageUp
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4043
    "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
  4044
     within the real text  "
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4045
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4046
    |prevCursorLine|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4047
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4048
    prevCursorLine := cursorVisibleLine.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4049
    super pageUp.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4050
    self cursorVisibleLine:prevCursorLine col:cursorCol
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4051
! !
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4052
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4053
!EditTextView methodsFor:'searching'!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4054
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4055
searchBwd:pattern ifAbsent:aBlock
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4056
    "do a backward search"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4057
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4058
    |startLine startCol|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4059
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4060
    cursorLine isNil ifTrue:[^ self].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4061
    selectionStartLine notNil ifTrue:[
1415
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  4062
	startLine := selectionStartLine.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  4063
	startCol := selectionStartCol
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4064
    ] ifFalse:[
1415
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  4065
	startLine := cursorLine min:list size.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  4066
	startCol := cursorCol
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4067
    ].
1339
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  4068
    self 
1415
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  4069
	searchBackwardFor:pattern 
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  4070
	startingAtLine:startLine col:startCol
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  4071
	ifFound:[:line :col |
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  4072
	    self cursorLine:line col:col.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  4073
	    self showMatch:pattern atLine:line col:col.
1339
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  4074
"/            self makeLineVisible:cursorLine
1415
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  4075
	    typeOfSelection := #search] 
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  4076
	ifAbsent:aBlock
1339
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  4077
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  4078
    "Modified: 9.10.1997 / 13:02:04 / cg"
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  4079
!
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  4080
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  4081
searchBwd:pattern ignoreCase:ign ifAbsent:aBlock
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  4082
    "do a backward search"
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  4083
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  4084
    |startLine startCol|
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  4085
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  4086
    cursorLine isNil ifTrue:[^ self].
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  4087
    selectionStartLine notNil ifTrue:[
1415
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  4088
	startLine := selectionStartLine.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  4089
	startCol := selectionStartCol
1339
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  4090
    ] ifFalse:[
1415
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  4091
	startLine := cursorLine min:list size.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  4092
	startCol := cursorCol
1339
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  4093
    ].
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  4094
    self 
1415
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  4095
	searchBackwardFor:pattern
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  4096
	ignoreCase:ign
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  4097
	startingAtLine:startLine col:startCol
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  4098
	ifFound:[:line :col |
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  4099
	    self cursorLine:line col:col.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  4100
	    self showMatch:pattern atLine:line col:col.
1339
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  4101
"/            self makeLineVisible:cursorLine
1415
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  4102
	    typeOfSelection := #search] 
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  4103
	ifAbsent:aBlock
1339
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  4104
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  4105
    "Modified: 9.10.1997 / 13:02:13 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4106
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4107
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4108
searchForAndSelectMatchingParenthesis
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4109
    "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
  4110
1339
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  4111
    self 
1415
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  4112
	searchForMatchingParenthesisFromLine:cursorLine col:cursorCol
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  4113
	ifFound:[:line :col | 
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  4114
		  self selectFromLine:cursorLine col:cursorCol
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  4115
			       toLine:line col:col]
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  4116
	ifNotFound:[self showNotFound]
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  4117
	onError:[self beep]
1339
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  4118
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  4119
    "Modified: 9.10.1997 / 12:57:34 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4120
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4121
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4122
searchForMatchingParenthesis
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4123
    "search for a matching parenthesis starting at cursor position. 
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4124
     Search for the corresponding character is done forward if its an opening, 
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4125
     backwards if its a closing parenthesis.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4126
     Positions the cursor if found, peeps if not"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4127
1339
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  4128
     self 
1415
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  4129
	searchForMatchingParenthesisFromLine:cursorLine col:cursorCol
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  4130
	ifFound:[:line :col | self cursorLine:line col:col]
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  4131
	ifNotFound:[self showNotFound]
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  4132
	onError:[self beep]
1339
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  4133
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  4134
    "Modified: 9.10.1997 / 12:56:30 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4135
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4136
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4137
searchFwd:pattern ifAbsent:aBlock
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4138
    "do a forward search"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4139
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4140
    |startCol|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4141
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4142
    "/ if there is no selection and the cursor is at the origin, 
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4143
    "/ assume its the first search and do not skip the very first match
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4144
    startCol := cursorCol.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4145
    self hasSelection ifFalse:[
1415
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  4146
	(cursorLine == 1 and:[cursorCol == 1]) ifTrue:[
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  4147
	    startCol := 0
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  4148
	]
1339
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  4149
    ].
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  4150
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  4151
    self 
1415
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  4152
	searchFwd:pattern 
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  4153
	startingAtLine:cursorLine col:startCol 
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  4154
	ifAbsent:aBlock
1339
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  4155
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  4156
    "Modified: 9.10.1997 / 12:58:59 / cg"
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  4157
!
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  4158
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  4159
searchFwd:pattern ignoreCase:ign ifAbsent:aBlock
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  4160
    "do a forward search"
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  4161
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  4162
    |startCol|
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  4163
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  4164
    "/ if there is no selection and the cursor is at the origin, 
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  4165
    "/ assume its the first search and do not skip the very first match
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  4166
    startCol := cursorCol.
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  4167
    self hasSelection ifFalse:[
1415
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  4168
	(cursorLine == 1 and:[cursorCol == 1]) ifTrue:[
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  4169
	    startCol := 0
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  4170
	]
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4171
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4172
1339
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  4173
    self 
1415
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  4174
	searchFwd:pattern
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  4175
	ignoreCase:ign
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  4176
	startingAtLine:cursorLine col:startCol 
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  4177
	ifAbsent:aBlock
1339
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  4178
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  4179
    "Modified: 9.10.1997 / 12:58:59 / cg"
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  4180
    "Created: 9.10.1997 / 13:04:10 / cg"
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  4181
!
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  4182
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  4183
searchFwd:pattern ignoreCase:ign startingAtLine:startLine col:startCol ifAbsent:aBlock
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  4184
    "do a forward search"
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  4185
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  4186
    cursorLine isNil ifTrue:[^ self].
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  4187
    self 
1415
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  4188
	searchForwardFor:pattern 
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  4189
	ignoreCase:ign
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  4190
	startingAtLine:startLine col:startCol
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  4191
	ifFound:[:line :col |
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  4192
	    self cursorLine:line col:col.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  4193
	    self showMatch:pattern atLine:line col:col.
1339
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  4194
"/            self makeLineVisible:cursorLine
1415
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  4195
	    typeOfSelection := #search]
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  4196
	ifAbsent:aBlock
1339
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  4197
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  4198
    "Modified: 9.10.1997 / 12:57:47 / cg"
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  4199
    "Created: 9.10.1997 / 13:01:12 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4200
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4201
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4202
searchFwd:pattern startingAtLine:startLine col:startCol ifAbsent:aBlock
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4203
    "do a forward search"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4204
1339
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  4205
    self 
1415
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  4206
	searchForwardFor:pattern 
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  4207
	startingAtLine:startLine col:startCol
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  4208
	ifFound:[:line :col |
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  4209
	    self cursorLine:line col:col.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  4210
	    self showMatch:pattern atLine:line col:col.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  4211
	    typeOfSelection := #search]
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  4212
	ifAbsent:aBlock
1339
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  4213
41b5e743d78a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
  4214
    "Modified: 9.10.1997 / 13:07:52 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4215
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4216
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4217
setSearchPattern
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4218
    "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
  4219
     cursor to start of pattern"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4220
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4221
    |sel|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4222
559
3ff87e9447c6 keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents: 522
diff changeset
  4223
    "/
3ff87e9447c6 keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents: 522
diff changeset
  4224
    "/ if the last operation was a replcae, set pattern to last
3ff87e9447c6 keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents: 522
diff changeset
  4225
    "/ original string (for search after again)
3ff87e9447c6 keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents: 522
diff changeset
  4226
    "/
565
f2a0499ba3d0 preserve search pattern
Claus Gittinger <cg@exept.de>
parents: 559
diff changeset
  4227
    (lastString notNil 
f2a0499ba3d0 preserve search pattern
Claus Gittinger <cg@exept.de>
parents: 559
diff changeset
  4228
     and:[lastReplacement notNil
f2a0499ba3d0 preserve search pattern
Claus Gittinger <cg@exept.de>
parents: 559
diff changeset
  4229
     and:[typeOfSelection ~~ #search]]) ifTrue:[
1415
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  4230
	lastSearchPattern := lastString asString withoutSeparators.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  4231
	^ self
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4232
    ].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4233
559
3ff87e9447c6 keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents: 522
diff changeset
  4234
    "/
3ff87e9447c6 keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents: 522
diff changeset
  4235
    "/ if there is a selection:
3ff87e9447c6 keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents: 522
diff changeset
  4236
    "/    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
  4237
    "/    if there was a previous search, only take the selection if
3ff87e9447c6 keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents: 522
diff changeset
  4238
    "/    it did not result from a paste.
3ff87e9447c6 keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents: 522
diff changeset
  4239
    "/    (to allow search-paste to be repeated)
3ff87e9447c6 keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents: 522
diff changeset
  4240
    "/
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4241
    sel := self selection.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4242
    sel notNil ifTrue:[
1415
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  4243
	(lastSearchPattern isNil
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  4244
	or:[typeOfSelection ~~ #paste]) ifTrue:[
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  4245
	    self cursorLine:selectionStartLine col:selectionStartCol.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  4246
	    lastSearchPattern := sel asString withoutSeparators
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  4247
	]
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4248
    ]
559
3ff87e9447c6 keep searchPattern after a paste
Claus Gittinger <cg@exept.de>
parents: 522
diff changeset
  4249
565
f2a0499ba3d0 preserve search pattern
Claus Gittinger <cg@exept.de>
parents: 559
diff changeset
  4250
    "Modified: 20.4.1996 / 12:50:13 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4251
! !
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4252
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4253
!EditTextView methodsFor:'selections'!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4254
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4255
selectAll
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4256
    "select the whole text.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4257
     redefined to send super selectFrom... since we dont want the
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4258
     cursor to be moved in this case."
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4260
    list isNil ifTrue:[
1415
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  4261
	self unselect
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4262
    ] ifFalse:[
1415
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  4263
	super selectFromLine:1 col:1 toLine:(list size + 1) col:0.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  4264
	typeOfSelection := nil
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4265
    ]
1082
ccc3aa4268c1 better #selectAll
Claus Gittinger <cg@exept.de>
parents: 1054
diff changeset
  4266
ccc3aa4268c1 better #selectAll
Claus Gittinger <cg@exept.de>
parents: 1054
diff changeset
  4267
    "Modified: 28.2.1997 / 19:14:54 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4268
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4269
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4270
selectCursorLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4271
    "select cursorline"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4272
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4273
    self selectFromLine:cursorLine col:1 toLine:cursorLine+1 col:0 
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4274
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4275
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4276
selectCursorLineFromBeginning
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4277
    "select cursorline up to cursor position"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4278
823
fc61564f7832 escape selects up to previous character
Claus Gittinger <cg@exept.de>
parents: 785
diff changeset
  4279
    cursorCol > 1 ifTrue:[
1415
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  4280
	self selectFromLine:cursorLine col:1
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  4281
		     toLine:cursorLine col:(cursorCol-1)
823
fc61564f7832 escape selects up to previous character
Claus Gittinger <cg@exept.de>
parents: 785
diff changeset
  4282
    ]
fc61564f7832 escape selects up to previous character
Claus Gittinger <cg@exept.de>
parents: 785
diff changeset
  4283
fc61564f7832 escape selects up to previous character
Claus Gittinger <cg@exept.de>
parents: 785
diff changeset
  4284
    "Modified: 16.8.1996 / 19:14:14 / cg"
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4285
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4286
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4287
selectExpandCursorLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4288
    "expand selection by one line or select cursorline"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4289
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4290
    selectionStartLine isNil ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4291
	self selectCursorLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4292
    ] ifFalse:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4293
	self selectFromLine:selectionStartLine col:selectionStartCol
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4294
		     toLine:cursorLine+1 col:0.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4295
	self makeLineVisible:selectionEndLine
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4296
    ]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4297
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4298
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4299
selectFromBeginning
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4300
    "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
  4301
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4302
    |col|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4303
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4304
    list isNil ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4305
	self unselect
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4306
    ] ifFalse:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4307
	cursorCol == 0 ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4308
	    col := 0
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4309
	] ifFalse:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4310
	    col := cursorCol - 1
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4311
	].
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4312
	super selectFromLine:1 col:1 toLine:cursorLine col:col.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4313
	typeOfSelection := nil
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4314
    ]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4315
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4316
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4317
selectFromLine:startLine col:startCol toLine:endLine col:endCol
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4318
    "when a range is selected, position the cursor behind the selection
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4319
     for easier editing. Also typeOfSelection is nilled here."
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4320
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4321
    super selectFromLine:startLine col:startCol toLine:endLine col:endCol.
1198
1c5390d2d3fb care for failed selection when positioning cursor.
ca
parents: 1177
diff changeset
  4322
    selectionEndLine notNil ifTrue:[
1415
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  4323
	self cursorLine:selectionEndLine col:(selectionEndCol + 1).
1198
1c5390d2d3fb care for failed selection when positioning cursor.
ca
parents: 1177
diff changeset
  4324
    ].
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4325
    typeOfSelection := nil
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4326
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4327
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4328
selectUpToEnd
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4329
    "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
  4330
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4331
    list isNil ifTrue:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4332
	self unselect
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4333
    ] ifFalse:[
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4334
	super selectFromLine:cursorLine col:cursorCol toLine:(list size + 1) col:0.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4335
	typeOfSelection := nil
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4336
    ]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4337
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4338
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4339
selectWordUnderCursor
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4340
    "select the word under the cursor"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4341
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4342
    self selectWordAtLine:cursorLine col:cursorCol
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4343
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4344
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4345
unselect
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4346
    "forget and unhilight selection - must take care of cursor here"
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4347
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4348
    |wasOn|
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4349
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4350
    wasOn := self hideCursor.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4351
    super unselect.
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4352
    wasOn ifTrue:[self showCursor]
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  4353
! !
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  4354
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  4355
!EditTextView methodsFor:'undo & again'!
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  4356
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  4357
again
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  4358
    "repeat the last action (which was a cut or replace).
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  4359
     If current selection is not last string, search forward to
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  4360
     next occurence of it before repeating the last operation."
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  4361
501
13fc7b9ce5cb fixed (?) again-replace
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  4362
    |s l c sel savedSelectStyle|
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  4363
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  4364
    lastString notNil ifTrue:[
1415
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  4365
	s := lastString asString.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  4366
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  4367
	"remove final cr"
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  4368
	s := s copyWithoutLast:1.
840
b0071cea13fd fixed Again when spaces are replaced
Claus Gittinger <cg@exept.de>
parents: 828
diff changeset
  4369
"/        s := s withoutSpaces.        "XXX - replacing text with spaces ..."
1415
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  4370
	savedSelectStyle := selectStyle.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  4371
	selectStyle := nil.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  4372
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  4373
	sel := self selection.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  4374
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  4375
	"if we are already there (after a find), ommit search"
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  4376
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  4377
	(sel notNil and:[sel asString withoutSeparators = s]) ifTrue:[
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  4378
	    undoAction := [self insertLines:lastString atLine:cursorLine col:cursorCol].
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  4379
	    l := selectionStartLine "cursorLine". 
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  4380
	    c := selectionStartCol "cursorCol".
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  4381
	    self deleteSelection.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  4382
	    lastReplacement notNil ifTrue:[
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  4383
		self insertLines:lastReplacement asStringCollection withCR:false.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  4384
		self selectFromLine:l col:c toLine:cursorLine col:(cursorCol - 1).
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  4385
	    ].
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  4386
	    selectStyle := savedSelectStyle.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  4387
	    ^ true
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  4388
	].
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  4389
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  4390
	self searchForwardFor:s startingAtLine:cursorLine col:cursorCol 
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  4391
	    ifFound:
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  4392
		[
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  4393
		    :line :col |
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  4394
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  4395
		    |repl|
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  4396
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  4397
		    self selectFromLine:line col:col
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  4398
				 toLine:line col:(col + s size - 1).
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  4399
		    self makeLineVisible:line.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  4400
		    undoAction := [self insertLines:lastString atLine:line col:col].
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  4401
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  4402
		    self deleteSelection.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  4403
		    lastReplacement notNil ifTrue:[
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  4404
			lastReplacement isString ifFalse:[
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  4405
			    repl := lastReplacement asString withoutSpaces
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  4406
			] ifTrue:[
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  4407
			    repl := lastReplacement withoutSpaces.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  4408
			].
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  4409
			self insertLines:repl asStringCollection withCR:false.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  4410
			self selectFromLine:line col:col toLine:cursorLine col:(cursorCol - 1).
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  4411
		    ].
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  4412
		    selectStyle := savedSelectStyle.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  4413
		    ^ true
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  4414
		] 
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  4415
	   ifAbsent:
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  4416
		[
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  4417
		    self showNotFound.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  4418
		    selectStyle := savedSelectStyle.
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  4419
		    ^ false
f75eeebc0d1d added #cursorToCharacterPosition:
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  4420
		]
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  4421
    ]
501
13fc7b9ce5cb fixed (?) again-replace
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  4422
840
b0071cea13fd fixed Again when spaces are replaced
Claus Gittinger <cg@exept.de>
parents: 828
diff changeset
  4423
    "Modified: 9.10.1996 / 16:14:11 / cg"
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  4424
!
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  4425
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4426
multipleAgain
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4427
    "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
  4428
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4429
    [self again] whileTrue:[]
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4430
!
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4431
121
claus
parents: 118
diff changeset
  4432
undo
claus
parents: 118
diff changeset
  4433
    "currently not implemented"
claus
parents: 118
diff changeset
  4434
claus
parents: 118
diff changeset
  4435
    undoAction notNil ifTrue:[
claus
parents: 118
diff changeset
  4436
	undoAction value
claus
parents: 118
diff changeset
  4437
    ]
105
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  4438
! !
3d064ba4a0cc *** empty log message ***
claus
parents: 97
diff changeset
  4439
865
d42c7c99e67d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 840
diff changeset
  4440
!EditTextView class methodsFor:'documentation'!
259
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4441
837ccdc138ea use non-blocking millisecondDelay
Claus Gittinger <cg@exept.de>
parents: 214
diff changeset
  4442
version
1597
5fdcfcedb91c fixed cursor positioning after replaceStringAtCursor.
Claus Gittinger <cg@exept.de>
parents: 1596
diff changeset
  4443
    ^ '$Header: /cvs/stx/stx/libwidg/EditTextView.st,v 1.177 1998-06-20 17:42:23 cg Exp $'
0
e6a541c1c0eb Initial revision
claus
parents:
diff changeset
  4444
! !